98 lines
3.4 KiB
C#
98 lines
3.4 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;
|
|
using 开发辅助工具.Manager;
|
|
|
|
namespace SuperDesign.Manager
|
|
{
|
|
public partial class FrmAddVar : Form
|
|
{
|
|
public int isAdd = 1;
|
|
public string selectId = "-1";
|
|
|
|
public FrmAddVar()
|
|
{
|
|
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.User_SQLConn) == 1)
|
|
{
|
|
DataSet ds = db.ReadData("VarInfo", id);
|
|
if (mydb.HaveData(ds))
|
|
{
|
|
DataRow reader = ds.Tables[0].Rows[0];
|
|
#region 读取信息
|
|
TxtVar.Text = reader["VarName"].ToString();
|
|
TxtVarValue.Text = reader["VarValue"].ToString();
|
|
TxtDes.Text = reader["Des"].ToString();
|
|
#endregion
|
|
}
|
|
}
|
|
db.Free();
|
|
}
|
|
|
|
private void BtnOK_Click(object sender, EventArgs e)
|
|
{
|
|
if (TxtVar.Text.Length==0)
|
|
{
|
|
MessageBox.Show("变量名不能为空。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
return;
|
|
}
|
|
if (!TxtVar.Text.Length.IsInRange(2,10))
|
|
{
|
|
MessageBox.Show("变量名太短或太长。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
return;
|
|
}
|
|
if (!TxtVar.Text.IsEng())
|
|
{
|
|
MessageBox.Show("变量名必须为英文。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
return;
|
|
}
|
|
if (TxtVarValue.Text.Contains("|"))
|
|
{
|
|
MessageBox.Show("变量值不得包含|", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
return;
|
|
}
|
|
RyQuickSQL mySQL = new RyQuickSQL("VarInfo");
|
|
mySQL.AddField("VarName", TxtVar.Text);
|
|
mySQL.AddField("VarValue", TxtVarValue.Text);
|
|
mySQL.AddField("Des", TxtDes.Text);
|
|
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
|
if (db.ConnDb(Itrycn_Db.User_SQLConn) == 1)
|
|
{
|
|
if (isAdd >= 1)
|
|
{
|
|
mySQL.AddField("addTime", DateTime.Now);
|
|
mySQL.AddField("editTime", DateTime.Now);
|
|
db.ExecuteNonQuery(mySQL.GetInsertSQL(),mySQL);
|
|
}
|
|
else
|
|
{
|
|
mySQL.AddField("editTime", DateTime.Now);
|
|
db.ExecuteNonQuery(mySQL.GetUpdateSQL() + " where id=" + selectId, mySQL);
|
|
}
|
|
}
|
|
db.Free();
|
|
DialogResult = DialogResult.OK;
|
|
}
|
|
#endregion
|
|
|
|
private void BtnCancel_Click(object sender, EventArgs e)
|
|
{
|
|
DialogResult = DialogResult.Cancel;
|
|
}
|
|
}
|
|
}
|