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 AGVSystem { public partial class InputSet : Form { private string strsql; private ClsDBConn_sql db = new ClsDBConn_sql(); private DataSet ds = new DataSet(); private int flag = 0; public InputSet() { InitializeComponent(); } private void comboBox8_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox8.SelectedIndex == 1) { label7.Visible = false; numericUpDown2.Visible = false; label9.Visible = false; numericUpDown3.Visible = false; numericUpDown2.Value = 0; numericUpDown3.Value = 0; } else { label7.Visible = true; numericUpDown2.Visible = true; label9.Visible = true; numericUpDown3.Visible = true; } } private void toolStripButton1_Click(object sender, EventArgs e) { flag = 0; groupBox1.Enabled = true; comboBox1.SelectedIndex = 0; comboBox2.SelectedIndex = 0; comboBox3.SelectedIndex = 0; comboBox4.SelectedIndex = 0; comboBox5.SelectedIndex = 0; comboBox6.SelectedIndex = 0; comboBox7.SelectedIndex = 0; comboBox8.SelectedIndex = 0; comboBox9.SelectedIndex = 0; textBox1.Text = ""; numericUpDown1.Value = 0; numericUpDown2.Value = 0; numericUpDown3.Value = 0; } private void InputSet_Load(object sender, EventArgs e) { strsql = "SELECT [Card_ID] as 板卡编号 ,[Port] as 端口号 ,[Bit] as 端口位 ,[Value] as 输入值,[Class] as 区分 ,[Loc1] as 起始位ID ,[Loc2] as 中转位ID ,[Loc3] as 最终位ID ,[Remark] as 备注 FROM [IO_Accept]"; ds.Tables.Clear(); ds = db.connDt(strsql); dataGridView1.DataSource = ds.Tables[0]; } private void toolStripButton3_Click(object sender, EventArgs e) { if (Cls.Param.UserName_temp == "") { MessageBox.Show("请登录管理员权限!", "AGV调度管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } flag = 0; strsql = "INSERT INTO [IO_Accept] ([Card_ID] ,[Port] ,[Bit] ,[Value] ,[Class] ,[Loc1] ,[Loc2] ,[Loc3] ,[Remark]) VALUES "+ "("+comboBox1.SelectedIndex+","+comboBox2.SelectedIndex+ ","+comboBox3.SelectedIndex+","+comboBox4.SelectedIndex+","+comboBox8.SelectedIndex+","+numericUpDown1.Value+","+numericUpDown2.Value+","+numericUpDown3.Value+",'"+textBox1.Text +"')"; if (db.Command(strsql) == "1") { MessageBox.Show("添加成功!"); InputSet_Load(null, null); toolStripButton1_Click(null, null); } } private void dataGridView1_DoubleClick(object sender, EventArgs e) { if (dataGridView1.RowCount > 0) { flag = 0; comboBox1.SelectedIndex = Convert.ToInt16(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["板卡编号"].Value); comboBox5.SelectedIndex = Convert.ToInt16(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["板卡编号"].Value); comboBox2.SelectedIndex = Convert.ToInt16(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["端口号"].Value); comboBox6.SelectedIndex = Convert.ToInt16(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["端口号"].Value); comboBox3.SelectedIndex = Convert.ToInt16(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["端口位"].Value); comboBox7.SelectedIndex = Convert.ToInt16(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["端口位"].Value); comboBox4.SelectedIndex = Convert.ToInt16(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["输入值"].Value); comboBox9.SelectedIndex = Convert.ToInt16(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["输入值"].Value); comboBox8.SelectedIndex = Convert.ToInt16(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["区分"].Value); numericUpDown1.Value = Convert.ToDecimal(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["起始位ID"].Value); numericUpDown2.Value = Convert.ToDecimal(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["中转位ID"].Value); numericUpDown3.Value = Convert.ToDecimal(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["最终位ID"].Value); textBox1.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["备注"].Value.ToString(); groupBox1.Enabled = false; } } private void toolStripButton5_Click(object sender, EventArgs e) { groupBox1.Enabled = true; flag = 1; } private void toolStripButton6_Click(object sender, EventArgs e) { if (Cls.Param.UserName_temp == "") { MessageBox.Show("请登录管理员权限!", "AGV调度管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (flag == 1) { strsql = "UPDATE [IO_Accept] SET [Card_ID] = "+comboBox1.SelectedIndex+ ",[Port] = "+comboBox2.SelectedIndex+ ",[Bit] = "+comboBox3.SelectedIndex+ ",[Value] = "+comboBox4.SelectedIndex+ ",[Class] = "+comboBox8.SelectedIndex+ ",[Loc1] = "+numericUpDown1.Value+ ",[Loc2] = "+numericUpDown2.Value+ ",[Loc3] = "+numericUpDown3.Value+ ",[Remark] = '"+textBox1.Text+"'"+ " WHERE [Card_ID] = "+comboBox5.SelectedIndex+" and "+ " [Port] = "+comboBox6.SelectedIndex +" and "+ " [Bit] = "+comboBox7.SelectedIndex+" and "+ " [Value] = "+comboBox9.SelectedIndex; if (db.Command(strsql) == "1") { MessageBox.Show("更新成功!"); InputSet_Load(null, null); toolStripButton1_Click(null, null); flag = 0; } } } private void toolStripButton4_Click(object sender, EventArgs e) { if (Cls.Param.UserName_temp == "") { MessageBox.Show("请登录管理员权限!", "AGV调度管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } flag = 0; strsql = " DELETE FROM [IO_Accept] WHERE [Card_ID] = " + comboBox5.SelectedIndex + " and [Port] =" + comboBox6.SelectedIndex + " and [Bit] = " + comboBox7.SelectedIndex + " and Value = "+comboBox9.SelectedIndex; if (db.Command(strsql) == "1") { MessageBox.Show("删除成功!"); InputSet_Load(null, null); toolStripButton1_Click(null, null); flag = 0; } } } }