private void simpleButtonOK_Click(object sender, EventArgs e) { ConnDB conn = new ConnDB(); string strsql, strsql2, log_name, dept1, dept2, dept3; int rows; log_name = textEditLogName.Text.ToString().Trim(); dept1 = comboBoxDept1.Text.ToString(); dept2 = comboBoxDept2.Text.ToString(); dept3 = comboBoxDept3.Text.ToString(); if (dept1 == "请选择") { dept1 = ""; } if (dept2 == "请选择") { dept2 = ""; } if (dept3 == "请选择") { dept3 = ""; } strsql = "insert into cost_check_dept(log_name,DEPT1,DEPT2,DEPT3) values('" + log_name + "','" + dept1 + "','" + dept2 + "','" + dept3 + "')"; strsql2 = "select * from cost_check_dept where log_name = '" + log_name + "' and dept1 = '" + dept1 + "' and dept2 = '" + dept2 + "' and dept3 ='" + dept3 + "'"; if (log_name != "") { rows = conn.ReturnRecordCount(strsql2); if (rows > 0) { MessageBox.Show("该记录已经存在!"); } else { bool isok = conn.EditDatabase(strsql); if (isok) { MessageBox.Show("添加成功!"); UserDeptCheckQuery.RefreshEX(); this.Close(); } else { MessageBox.Show("失败!"); } } } else { MessageBox.Show("不能为空!"); } conn.Close(); }
private void simpleButtonOK_Click(object sender, EventArgs e) { ConnDB conn = new ConnDB(); string dept11, dept22, dept33; dept11 = comboBoxDept1.Text; dept22 = comboBoxDept2.Text; dept33 = comboBoxDept3.Text; if (dept11 == "请选择") { dept11 = ""; } if (dept22 == "请选择") { dept22 = ""; } if (dept33 == "请选择") { dept33 = ""; } string sql = "update cost_check_dept set dept1 ='" + dept11 + "',dept2 ='" + dept22 + "',dept3 ='" + dept33; sql = sql + "' where log_name = '" + logname + "' and dept1 = '" + dept1 + "' and dept2 = '" + dept2 + "' and dept3 = '" + dept3 + "'"; // string sql2 = "select cname from cost_user where cname = '" + textEditLogName.Text.ToString().Trim() + "' and password ='******'"; if (textEditLogName.Text.ToString().Trim() != "") { bool isok = conn.EditDatabase(sql); if (isok) { MessageBox.Show("修改成功!"); UserDeptCheckQuery.RefreshEX(); this.Close(); } else { MessageBox.Show("失败!"); } } else { MessageBox.Show("登录名不能为空值!"); } conn.Close(); }
private void barButtonItem刷新_ItemClick(object sender, ItemClickEventArgs e) { UserDeptCheckQuery.RefreshEX(); }