------ #### RaUIV4 V4.0.2311.0701 - *.[全新]整合了MyDb、ryControls、MyDb_MySQL等dll文件到RaUI一个项目。 - *.[新增]新增ApkOp类,可以轻松获取APK信息。 - *.[新增]新增JsonExt扩展类,让Json操作更简单。 - *.[新增]新增WebP类,可以支持webp格式的图片。 - *.[改进]ryQuickSQL中的AddField方法改为自动替换已存在的同名值。 - *.[修复]ryQuickSQL中的AddFieldCalc方法无法正常计算的BUG。
79 lines
2.6 KiB
C#
79 lines
2.6 KiB
C#
using ryCommon;
|
|
using ryCommonDb;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Itrycn_Project2.DbOp
|
|
{
|
|
public partial class FrmAdd : RySkins.SKinForm
|
|
{
|
|
public ModalForm mr = null;
|
|
public string tableName = "MainTable1";
|
|
public int isAdd = 1;
|
|
public string selectId = "-1";
|
|
public DataProvider.DataProviderType dataType = DataProvider.DataProviderType.SQLiteDataProvider;
|
|
public string SQLConnStr = Itrycn_Db.SQLConnStr;
|
|
public FrmAdd()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
#region 需要修改
|
|
public void GetInfo(string id)
|
|
{
|
|
selectId = id;
|
|
IDbInterface db = DataProvider.CreateDataProvider(dataType);
|
|
if (db.ConnDb(SQLConnStr) == 1)
|
|
{
|
|
DataSet ds = db.ReadData(tableName, id);
|
|
if (ds.HaveData()){
|
|
DataRow reader = ds.Tables[0].Rows[0];
|
|
#region 读取信息
|
|
txtName.Text = reader["Name"].ToString();
|
|
#endregion
|
|
}
|
|
}
|
|
db.Free();
|
|
}
|
|
|
|
private void BtnOK_Click(object sender, EventArgs e)
|
|
{
|
|
if (txtName.Text == "")
|
|
{
|
|
RySkins.Msg.ShowMsg("名称不能为空。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
return;
|
|
}
|
|
RyQuickSQL mySQL = new RyQuickSQL(tableName);
|
|
mySQL.AddField("name", txtName.Text);
|
|
IDbInterface db = DataProvider.CreateDataProvider(dataType);
|
|
if (db.ConnDb(SQLConnStr) == 1)
|
|
{
|
|
if (isAdd >= 1)
|
|
{
|
|
mySQL.AddField("addTime",DateTime.Now.ToInt64());
|
|
mySQL.AddField("editTime", DateTime.Now.ToInt64());
|
|
db.ExecuteNonQuery(mySQL.GetInsertSQL(), db.GetParameter(mySQL));
|
|
}
|
|
else
|
|
{
|
|
mySQL.AddField("editTime", DateTime.Now.ToInt64());
|
|
db.ExecuteNonQuery(mySQL.GetUpdateSQL() + " where id=" + selectId, db.GetParameter(mySQL));
|
|
}
|
|
}
|
|
db.Free();
|
|
ModalForm.SetDialogResult(this, mr, DialogResult.OK);
|
|
}
|
|
#endregion
|
|
|
|
private void BtnCancel_Click(object sender, EventArgs e)
|
|
{
|
|
ModalForm.SetDialogResult(this, mr, DialogResult.Cancel);
|
|
}
|
|
}
|
|
}
|