private void button3_Click(object sender, EventArgs e) { string sql = ""; if (txtEmp.Text != "") { sql = @"update nhanvien set manhanvien = N'" + txtEmp.Text + "' ,tennhanvien = N'" + txtEmp_nm.Text + "' ,diachi = N'" + txtEmp_add.Text + "' ,phone = N'" + txtEmp_ctc.Text + "' ,chucvu = N'" + txtEmp_pos.Text + "'where manhanvien = N'" + txtEmp.Text + "'"; } else { if (txtEmp_new.Text == "") { MessageBox.Show("Nhận mã nhân viên mới!"); } else { sql = @"insert into nhanvien (manhanvien,tennhanvien,diachi,phone,chucvu) values (N'" + txtEmp_new.Text + "',N'" + txtEmp_nm.Text + "',N'" + txtEmp_add.Text + "',N'" + txtEmp_ctc.Text + "',N'" + txtEmp_pos.Text + "')"; } } try { kn.ExcuteNonQuery(sql); MessageBox.Show("Save successful"); } catch (SqlException ex) { MessageBox.Show(ex.Message); } }
public void xoaNv(string id) { try { kn.ExcuteNonQuery(@"delete from nhanvien where manhanvien ='" + id + "'"); } catch { } }