public static void LoadSwitch(int 模块地址) { string sql = string.Format(@" select * from 开关信息 where 模块地址 = '{0}' ", 模块地址.ToString()); 调试模块 tmp = ModelsOperate.GetModel(模块地址); //if (tmp.开关列表 == null) // tmp.开关列表 = new List<开关模块>(); DataTable dt = AccessLib.GetData(sql); foreach (DataRow v in dt.Rows) { 开关模块 swit = new 开关模块() { 模块编号 = 模块地址.ToString(), 开关编号 = Convert.ToString(v["开关编号"]), 开关名称 = Convert.ToString(v["开关名称"]), 开关位置 = Convert.ToString(v["开关位置"]) }; //int index = -1; //if ((index = tmp.开关列表.FindIndex(t => t.开关编号 == swit.开关编号)) != -1) //{ // //tmp.开关列表[index] = swit; // tmp.开关列表[index].开关位置 = swit.开关位置; // tmp.开关列表[index].开关名称 = swit.开关名称; //} //else //{ // tmp.开关列表.Add(swit); //} } }
public static void SaveModel(开关模块 v) { string sql1 = string.Format("select count(*) from 开关信息 where 模块地址 = '{0}' and 开关编号 = '{1}' ", v.模块编号, v.开关编号); if ((int)AccessLib.GetFirstCell(sql1) == 0) { string s = string.Format("Insert into 开关信息(模块地址,开关编号, 开关名称, 开关位置) values('{0}', '{1}', '{2}','{3}')", v.模块编号, v.开关编号, v.开关名称, v.开关位置); AccessLib.Execute(s); } else { string s = string.Format("update 开关信息 set 开关名称 = '{0}',开关位置 = '{1}',State = '2' where 模块地址 = '{2}' and 开关编号 = '{3}'", v.开关名称, v.开关位置, v.模块编号, v.开关编号); AccessLib.Execute(s); } }
private void btn_查询_Click(object sender, EventArgs e) { dataGridView1.Rows.Clear(); DataTable dt = AccessLib.GetError(dateTimePicker1.Value.Date.ToString("yyyy-MM-dd"), dateTimePicker2.Value.Date.AddDays(1).ToString("yyyy-MM-dd")); int j = 0; if (dt != null) { foreach (DataRow row in dt.Rows) { int index = dataGridView1.Rows.Add(new string[] { Convert.ToString(row[1]), Convert.ToString(row[2]), Convert.ToString(row[3]), Convert.ToString(row[4]), Convert.ToString(row[5]), Convert.ToString(row[6]) }); dataGridView1.Rows[index].HeaderCell.Value = Convert.ToString(j + 1); j++; } } }
private void btn_Login_Click(object sender, EventArgs e) { try { if (AccessLib.CheckPassword(comboBox1.Text, txt_Password.Text) > 0) { MainForm.UserName = comboBox1.Text; DialogResult = DialogResult.OK; } else { MessageBox.Show("密码不正确!"); } } catch (Exception ex) { MessageBox.Show("登录异常!"); } }
private void btn_Clear_Click(object sender, EventArgs e) { AccessLib.DeleteError(dateTimePicker1.Value.Date.ToString("yyyy-MM-dd"), dateTimePicker1.Value.Date.AddDays(1).ToString("yyyy-MM-dd")); btn_查询.PerformClick(); }