private void btnDangKy_Click(object sender, EventArgs e) { if (txtUsername.Text == "") { MessageBox.Show("Vui lòng nhập Username!"); txtUsername.Focus(); return; } if (txtMatKhau.Text == "") { MessageBox.Show("Vui lòng nhập mật khẩu!"); txtMatKhau.Focus(); return; } if (txtMatKhau.Text != txtNhapLaiMK.Text) { MessageBox.Show("Mật khẩu và nhập lại mật khẩu phải trùng khớp nhau!"); } else { NV.EndCurrentEdit(); tblNHANVIEN.ghi(); MessageBox.Show("Đăng ký tài khoản thành công!"); } }
private void btnXoa_Click(object sender, EventArgs e) { if (MessageBox.Show("Bạn có muốn xóa nhân viên " + txtTen.Text + " không?", "DELETE", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { DataTable kttt = new DataTable(); // kttt kiểm tra thông tin có trong bảng khác không??? string sql = "select * from HOADON where MaNV= '" + txtMaNV.Text + "'"; kttt = new XLHOADON(sql); int i = kttt.Rows.Count; if (i > 0) { MessageBox.Show("Nhân viên " + txtTen.Text + " có trong bảng Hóa đơn!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { NHANVIEN.RemoveAt(NHANVIEN.Position); tblNHANVIEN.ghi(); MessageBox.Show("Xóa thành công!"); } } }