2020-11-28 07:03:28 +00:00
|
|
|
|
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;
|
|
|
|
|
|
2021-07-04 01:41:15 +00:00
|
|
|
|
namespace Itrycn_Project2.DbOp
|
2020-11-28 07:03:28 +00:00
|
|
|
|
{
|
2021-06-12 14:09:28 +00:00
|
|
|
|
public partial class FrmAdd : RySkins.SKinForm
|
2020-11-28 07:03:28 +00:00
|
|
|
|
{
|
|
|
|
|
public ModalForm mr = null;
|
|
|
|
|
public string tableName = "MainTable1";
|
|
|
|
|
public int isAdd = 1;
|
|
|
|
|
public string selectId = "-1";
|
|
|
|
|
public FrmAdd()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
#region 需要修改
|
|
|
|
|
public void GetInfo(string id)
|
|
|
|
|
{
|
|
|
|
|
selectId = id;
|
|
|
|
|
DataProvider mydb = new DataProvider();
|
|
|
|
|
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
|
|
|
|
if (db.ConnDb(Itrycn_Db.SQLConnStr) == 1)
|
|
|
|
|
{
|
|
|
|
|
DataSet ds = db.ReadData(tableName, id);
|
|
|
|
|
if (mydb.HaveData(ds))
|
|
|
|
|
{
|
|
|
|
|
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 == "")
|
|
|
|
|
{
|
2021-06-12 14:09:28 +00:00
|
|
|
|
RySkins.Msg.ShowMsg("名称不能为空。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
2020-11-28 07:03:28 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
RyQuickSQL mySQL = new RyQuickSQL(tableName);
|
|
|
|
|
mySQL.AddField("name", txtName.Text);
|
|
|
|
|
DataProvider mydb = new DataProvider();
|
|
|
|
|
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
|
|
|
|
if (db.ConnDb(Itrycn_Db.SQLConnStr) == 1)
|
|
|
|
|
{
|
|
|
|
|
if (isAdd >= 1)
|
|
|
|
|
{
|
|
|
|
|
mySQL.AddField("addTime",DateTime.Now);
|
|
|
|
|
mySQL.AddField("editTime", DateTime.Now);
|
|
|
|
|
db.ExecuteNonQuery(mySQL.GetInsertSQL(), db.GetParameter(mySQL));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
mySQL.AddField("editTime", DateTime.Now);
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|