private void button1_Click(object sender, EventArgs e) { string deptid, deptname; deptid = textBox1.Text; deptname = textBox2.Text; int res = NonQuery("insert into departmentInfo values('" + deptid + "','" + deptname + "')"); MessageBox.Show("保存成功!"); UC.FreshTreeview(); }
private void button1_Click(object sender, EventArgs e) { if (UC.modifyFlag == 0)//添加 { DataTable dt0 = new DataTable(); if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "" || comboBox1.Text == "") { MessageBox.Show("请完整填入信息!"); } else { dname = textBox1.Text; dsex = textBox2.Text; did = textBox3.Text; deptid = textBox4.Text; account = textBox6.Text; if (comboBox1.Text.Equals("医生") == true) { is_Director = 0.ToString(); } else { is_Director = 1.ToString(); } if (comboBox2.Text.Equals("在岗") == true) { status = 1; } else { status = 0; } dt = Fill("select * from doctorinfo where did='" + did + "'"); dt0 = Fill("select * from doctorinfo where account='" + account + "'"); if (dt.Rows.Count == 0 || dt0.Rows.Count == 0) { int res = NonQuery("insert into doctorinfo values('" + did + "','" + dname + "','" + dsex + "','" + deptid + "','" + account + "','" + is_Director + "'," + status + ")"); string password = Encrypt.MD5Encrypt32("303303"); int res0 = NonQuery("insert into doctoraccount values('" + account + "','" + password + "','" + did + "')"); MessageBox.Show("保存成功"); UC.FreshTreeview(); } else { MessageBox.Show("医生编号或帐号重复!"); } } } else//修改 { DataTable dt0 = new DataTable(); if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "" || comboBox1.Text == "") { MessageBox.Show("请完整填入信息!"); } else { dname = textBox1.Text; dsex = textBox2.Text; did = textBox3.Text; deptid = textBox4.Text; account = textBox6.Text; if (comboBox1.Text.Equals("医生") == true) { is_Director = 0.ToString(); } else { is_Director = 1.ToString(); } if (comboBox2.Text.Equals("在岗") == true) { status = 1; } else { status = 0; } int res0 = NonQuery("delete doctorinfo where did='" + did + "'"); int res = NonQuery("insert into doctorinfo values('" + did + "','" + dname + "','" + dsex + "','" + deptid + "','" + account + "','" + is_Director + "'," + status + ")"); string password = Encrypt.MD5Encrypt32("303303"); int res1 = NonQuery("insert into doctoraccount values('" + account + "','" + password + "','" + did + "')"); MessageBox.Show("保存成功"); } } }