private void btnThem_Click(object sender, EventArgs e) { if (txtHoTen.Text != "" && txtEmail.Text != "" && txtSDT.Text != "" && txtGioiTinh.Text != "" && txtBirth.Text != "" && txtEmail.Text != "" && txtSDT.Text != "") { DialogResult dialog = MessageBox.Show("Bạn có muốn thêm khách hàng " + txtHoTen.Text + " không?", "Xác nhận thêm", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialog == DialogResult.Yes) { if (!DKH.check_KH(txtMaKhachHang.Text)) { if (DKH.Add_KH(txtHoTen.Text, txtGioiTinh.Text, txtBirth.Value, txtEmail.Text, txtSDT.Text)) { MessageBox.Show("Thêm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); DKH = new Data_KH(); Load_KH(DKH.Inf_KH()); openButton(true); } else { MessageBox.Show("Thêm thất bại, vui lòng kiểm tra lại", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Error); DKH = new Data_KH(); Load_KH(DKH.Inf_KH()); } } } } else { MessageBox.Show("Vui lòng điền đầy đủ thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void Btn_ReFresh_Click(object sender, EventArgs e) { Data_KH DKH = new Data_KH(); Load_KH(DKH.Inf_KH()); Clear(); loi = false; }
private void btnDelete_Click(object sender, EventArgs e) { if (txtHoTen.Text != "" && txtEmail.Text != "" && txtSDT.Text != "" && txtGioiTinh.Text != "" && txtBirth.Text != "" && txtEmail.Text != "" && txtSDT.Text != "") { DialogResult dialog = MessageBox.Show("Bạn có chắn chắn muốn xóa khách hàng " + txtHoTen.Text + " không?", "Xác nhận xóa", MessageBoxButtons.YesNo, MessageBoxIcon.Error); if (dialog == DialogResult.Yes) { if (DKH.Delete_KH(txtMaKhachHang.Text)) { MessageBox.Show("Xóa thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); DKH = new Data_KH(); Load_KH(DKH.Inf_KH()); openButton(true); } else { MessageBox.Show("Xóa thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void ThongTinKhachHang_Activated(object sender, EventArgs e) { DKH = new Data_KH(); Load_KH(DKH.Inf_KH()); }