private void btnDelete_Click(object sender, EventArgs e) { string delete = "delete from tblNhanVien where MaNV=N'" + txtMaNV.Text + "'"; if (MessageBox.Show("Bạn có muốn xóa không", "Xóa dữ liệu", MessageBoxButtons.YesNo) == DialogResult.Yes) { mydt.runQuery(delete); } gridViewHSNV.Refresh(); mydt.loaddata(gridViewHSNV, "select * from tblNhanVien"); }
private void btnXoa_Click(object sender, EventArgs e) { string delete = "delete from tblChiTietChamCong where NgayCong ='" + dateCong.Text + "'"; if (MessageBox.Show("Bạn có muốn xóa không", "Xóa dữ liệu", MessageBoxButtons.YesNo) == DialogResult.Yes) { mydt.runQuery(delete); } loaddt(); }
private void btnHoanTat_Click(object sender, EventArgs e) { int a = 0, b = 0; dr = DemMa(txtMaNV.Text); while (dr.Read()) { a += dr.GetInt32(0); } dr = DemTen(txtĐN.Text); while (dr.Read()) { b = dr.GetInt32(0); } String query = "insert into tblTaiKhoan( MaNV, TenNhanVien, TenTaiKhoan, MatKhau) values('" + txtMaNV.Text + "',N'" + txtTenNV.Text + "',N'" + txtĐN.Text + "','" + txtMK.Text + "')"; if (a > 0) { MessageBox.Show("Nhân viên đã có tài khoản đăng nhập"); txtMaNV.Clear(); } else { if (b > 0) { MessageBox.Show("Tên đăng nhập này đã tồn tại"); txtĐN.Clear(); } else { mydt.runQuery(query); MessageBox.Show("Chúc mừng bạn đã đăng kí thành công"); this.Close(); } } }
private void btnCapNhat_Click(object sender, EventArgs e) { string query = string.Format("update tblLuong set LuongCoBan = '" + txtLuongCB.Text + "' where HeSoLuong = '" + comboHSL.Text + "'"); mydt.runQuery(query); }