using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using DBFactory; using Microsoft.VisualBasic; namespace SystemConfig { public partial class FrmItemTaskTypeEdit : Form { private static FrmItemTaskTypeEdit _formInstance; bool IfUpdate = false; DBOperator dbo = CStaticClass.dbo; public static FrmItemTaskTypeEdit FormInstance { get { if (_formInstance==null) { _formInstance = new FrmItemTaskTypeEdit(); } return _formInstance; } set { _formInstance = value; } } public FrmItemTaskTypeEdit() { InitializeComponent(); } private void btQuery_Click(object sender, EventArgs e) { try { string df, sql; if (this.tbContent.Text.Trim() == "") return; if (this.cbField.Text == "管理程序的出入库类型的编码") { df = "FCODE"; } else//搬运路径类型 { df = "FINTERCODE"; } sql = "SELECT FCODE AS 管理程序的出入库类型的编码,FINTERCODE AS 搬运路径类型,FNAME AS " + " 出入库类型名称,FSOFTCONFIRM AS 需要软确认 FROM T_ITEMTASKTYPE where " + df + "= " + Convert.ToInt32(this.tbContent.Text); DataSet ds = dbo.ExceSQL(sql); this.dataGridView1.DataSource = ds.Tables[0].DefaultView; } catch (Exception ex) { throw ex; } } private void btNullQuery_Click(object sender, EventArgs e) { this.cbField.Text = ""; this.tbContent.Text = ""; } private void btSave_Click(object sender, EventArgs e) { if (MessageBox.Show("您确认要保存出入库类型的命令信息吗?", "操作提示:", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK) { return; } string sql = ""; string strsql; if (Information.IsNumeric(this.textBox4.Text) == false) { MessageBox.Show("管理程序的出入库类型的编码只能是数字类型!", "误操作提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (this.comboBox1.Text.Trim().Length == 0) { MessageBox.Show("搬运路径类型不允许是空值!", "误操作提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (this.textBox1.Text.Trim().Length == 0) { MessageBox.Show("出入库类型名称不允许是空值!", "误操作提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string fc, fi, fn; char fs; char[] cc = new char[1] {':' }; fc = this.textBox4.Text; string[] sp = this.comboBox1.Text.Split(cc); fi = sp[0]; fn = textBox1.Text; if (checkBox1.Checked == true) { fs = '1'; } else { fs = '0'; } DataSet ds; strsql = "SELECT FCODE, FINTERCODE, FNAME, FSOFTCONFIRM FROM T_ITEMTASKTYPE WHERE FCODE = '" + this.textBox4.Text.Trim() + "'"; if (dbo.Exists(strsql) == false) { IfUpdate = false; } if (IfUpdate == true) { sql = "update T_ITEMTASKTYPE set FNAME='" + fn + "',FSOFTCONFIRM='" + fs + "', FINTERCODE= '" + fi + "' where FCODE='" + fc + "'"; ds = dbo.ExceSQL(sql); MessageBox.Show("出入库类型信息修改成功!", "操作提示:", MessageBoxButtons.OK, MessageBoxIcon.Information); IfUpdate = false; } else { strsql = "SELECT FCODE, FINTERCODE, FNAME, FSOFTCONFIRM FROM T_ITEMTASKTYPE WHERE FCODE = '" + fc + "'"; if (dbo.Exists(strsql) == true) { MessageBox.Show("管理程序的出入库类型的编码不允许输入重复的值!", "误操作提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } sql = "INSERT INTO T_ITEMTASKTYPE (FCODE, FINTERCODE,FNAME,FSOFTCONFIRM)VALUES ('" + fc + "','" + fi + "','" + fn + "','" + fs + "')"; ds = dbo.ExceSQL(sql); MessageBox.Show("设备类型信息录入成功!", "操作提示:", MessageBoxButtons.OK, MessageBoxIcon.Information); } ds.Clear(); strsql = "SELECT FCODE AS 管理程序的出入库类型的编码,FINTERCODE AS 搬运路径类型,FNAME AS " + " 出入库类型名称,FSOFTCONFIRM AS 需要软确认 FROM T_ITEMTASKTYPE where " + " FCODE='"+fc+"'"; ds = dbo.ExceSQL(strsql); this.dataGridView1.DataSource = ds.Tables[0].DefaultView; } private void btNull_Click(object sender, EventArgs e) { this.textBox1.Text = ""; this.textBox4.Text = ""; this.comboBox1.Text = ""; this.checkBox1.Checked = false; } private void button1_Click(object sender, EventArgs e) { IfUpdate = false; } private void FrmItemTaskTypeEdit_Load(object sender, EventArgs e) { } private void tsmEdit_Click(object sender, EventArgs e) { string strname = ""; if (dataGridView1.RowCount <= 0) { return; } this.tabControl1.SelectTab("tabPage1"); this.textBox4.Text = this.dataGridView1.CurrentRow.Cells[0].Value.ToString() + ""; //1:入库;2:出库;3:倒库;9:搬运货物;91:码盘入库;92:码盘出库 switch (this.dataGridView1.CurrentRow.Cells[1].Value.ToString()) { case "1" : strname = ":入库"; break; case "2": strname = ":出库"; break; case "3": strname = ":倒库"; break; case "9": strname = ":搬运货物"; break; case "91": strname = ":码盘入库"; break; case "92": strname = "::码盘出库"; break; default: break; } this.comboBox1.Text = this.dataGridView1.CurrentRow.Cells[1].Value.ToString() + strname ; this.textBox1.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString() + ""; if (this.dataGridView1.CurrentRow.Cells[3].Value.ToString()=="1") this.checkBox1.Checked = true; else this.checkBox1.Checked = false; IfUpdate = true; } private void tsmDel_Click(object sender, EventArgs e) { if (dataGridView1.RowCount <= 0) { return; } if (MessageBox.Show("您确认要删除选中行的“管理程序出入库类型:" + this.dataGridView1.CurrentRow.Cells[0].Value.ToString() + "信息吗?", "操作提示:", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK) { return; } dbo.ExceSQL("delete from T_ITEMTASKTYPE where FCODE ='" + this.dataGridView1.CurrentRow.Cells[0].Value+"'" ); button2_Click(sender, e); } private void button2_Click(object sender, EventArgs e) { string sql = "SELECT FCODE AS 管理程序的出入库类型的编码,FINTERCODE AS 搬运路径类型,FNAME AS " + " 出入库类型名称,FSOFTCONFIRM AS 需要软确认 FROM T_ITEMTASKTYPE"; DataSet ds = dbo.ExceSQL(sql); this.dataGridView1.DataSource = ds.Tables[0].DefaultView; } } }