private void simpleButton2_Click(object sender, EventArgs e) { try { if (txtSDT.Text == "" || txtCMND.Text == "" || txtDiaChi.Text == "" || txtGioiTinh.Text == "" || txtMaNT.Text == "" || txtNgaySinh.Text == "" || cboMaKH.Text == "" || txtTenNT.Text == "") { MessageBox.Show("Mời Nhập Đủ Thông Tin"); } else { if (cboMaKH.Text == txtMaKHRieng.Text) { MessageBox.Show("Nhập Lỗi Hai Mã Khách Hàng"); } else { NguoiThanDao ng = new NguoiThanDao(); ng.ThemNT(txtMaNT.Text, cboMaKH.Text, txtTenNT.Text, txtNgaySinh.DateTime, txtGioiTinh.Text, txtDiaChi.Text, txtCMND.Text, txtMaKHRieng.Text, txtSDT.Text); MessageBox.Show("Thêm Thành Công"); this.Close(); } } f.refresh(); } catch (Exception ex) { MessageBox.Show("Đã có lỗi xảy ra"); } }
public ucNguoiThanKhachHang() { InitializeComponent(); NguoiThanDao ng = new NguoiThanDao(); nguoiThansBindingSource.DataSource = ng.Load(); }
private void simpleButton2_Click(object sender, EventArgs e) { try { if (txtMaNT.Text == "" || txtMaKHNT.Text == "" || cboGioitinh.Text == "" || txtDiaChi.Text == "" || txtCMND.Text == "" || txtNgaySinh.Text == "" || txtTenKH.Text == "" || txtTenNTKH.Text == "") { MessageBox.Show("Chọn Thông Tin Cần Sửa"); } else { var s = ""; s = cboGioitinh.Text; NguoiThanDao ng = new NguoiThanDao(); ng.suakhachhang(txtMaNT.Text, txtMaKHNT.Text, txtTenNTKH.Text, txtNgaySinh.DateTime, s, txtDiaChi.Text, txtCMND.Text, txtMaKH.Text, txtSDT.Text); MessageBox.Show("Sửa Thành Công"); this.refresh(); } //KhachHangDao kh = new KhachHangDao(); //SuaKH f = new SuaKH(txtMaNT.Text, txtMaKH.Text, kh.GetCapDo(txtMaNT.Text), txtNgaySinh.Text, txtGioiTinh.Text, txtCMND.Text, txtDiaChi.Text, txtSdt.Text); //f.Show(); } catch (Exception ex) { MessageBox.Show("Chọn Khách Hàng Cần Sửa"); } }
private void txtMaKHNT_Properties_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { KhachHangDao kh = new KhachHangDao(); var result = kh.getKH(txtMaKHNT.Text); if (result == null) { XtraMessageBox.Show("Mã Khách Hàng Không Tồn Tại", "Thông Báo"); NguoiThanDao ng = new NguoiThanDao(); var model = ng.getNT(txtMaNT.Text); txtMaKHNT.Text = model.MaKH; txtTenKHNT.Text = kh.TenKH(model.MaKH); txtMaKH.Text = model.MaKHRieng; txtTenKH.Text = model.TenNT; txtCMND.Text = model.CMND; if (model.GioiTinh == true) { cboGioitinh.Text = "Nam"; } else { cboGioitinh.Text = "Nữ"; } txtDiaChi.Text = model.DiaChi; txtSDT.Text = model.SDT; txtNgaySinh.DateTime = Convert.ToDateTime(model.NgaySinh); } else { popup(result.TenKH); } } }
private void simpleButton2_Click(object sender, EventArgs e) { try { if (txtSDT.Text == "" || txtCMND.Text == "" || txtDiaChi.Text == "" || txtGioiTinh.Text == "" || txtMaNT.Text == "" || txtNgaySinh.Text == "" || cboMaKH.Text == "" || txtTenNT.Text == "") { XtraMessageBox.Show("Mời Nhập Đủ Thông Tin", "Thông Báo"); } else { if (cboMaKH.Text == txtMaKHRieng.Text) { MessageBox.Show("Nhập Lỗi Hai Mã Khách Hàng", "Thông Báo"); } else { if (txtMaKHRieng.Text == "") { NguoiThanDao ng = new NguoiThanDao(); ng.ThemNT(txtMaNT.Text, cboMaKH.Text, txtTenNT.Text, txtNgaySinh.DateTime, txtGioiTinh.Text, txtDiaChi.Text, txtCMND.Text, txtMaKHRieng.Text, txtSDT.Text); XtraMessageBox.Show("Thêm Thành Công", "Thông Báo"); this.Close(); } else { KhachHangDao kh = new KhachHangDao(); var model = kh.getKH(txtMaKHRieng.Text); string gioitinh; if (model.GioiTinh == true) { gioitinh = "Nam"; } else { gioitinh = "Nữ"; } DateTime dateTime = Convert.ToDateTime(model.NgaySinh); if (model.TenKH != txtTenNT.Text || dateTime != txtNgaySinh.DateTime || model.Sdt != txtSDT.Text || model.DiaChi != txtDiaChi.Text || gioitinh != txtGioiTinh.Text || model.CMND != txtCMND.Text) { XtraMessageBox.Show("Thông Tin Người Thân Bị Sai", "Thông Báo"); laythongtin(); } else { NguoiThanDao ng = new NguoiThanDao(); ng.ThemNT(txtMaNT.Text, cboMaKH.Text, txtTenNT.Text, txtNgaySinh.DateTime, txtGioiTinh.Text, txtDiaChi.Text, txtCMND.Text, txtMaKHRieng.Text, txtSDT.Text); XtraMessageBox.Show("Thêm Thành Công", "Thông Báo"); this.Close(); } } } } f.refresh(); } catch (Exception ex) { XtraMessageBox.Show("Đã có lỗi xảy ra!!"); } }
public ThemNT(ucNguoiThanKhachHang ff) { InitializeComponent(); f = ff; NguoiThanDao ng = new NguoiThanDao(); txtMaNT.Text = ng.getlastnguoithan(); }
private void simpleButton2_Click(object sender, EventArgs e) { try { if (txtMaNT.Text == "" || txtMaKHNT.Text == "" || cboGioitinh.Text == "" || txtDiaChi.Text == "" || txtCMND.Text == "" || txtNgaySinh.Text == "" || txtTenKHNT.Text == "" || txtTenKH.Text == "") { MessageBox.Show("Chọn Thông Tin Cần Sửa"); } else { var s = ""; s = cboGioitinh.Text; NguoiThanDao ng = new NguoiThanDao(); if (txtMaKH.Text != " ") { KhachHangDao kh = new KhachHangDao(); var model = kh.getKH(txtMaKH.Text); Boolean gioitinh; if (cboGioitinh.Text == "Nam") { gioitinh = true; } else { gioitinh = false; } if (model.TenKH != txtTenKH.Text || model.CMND != txtCMND.Text || model.DiaChi != txtDiaChi.Text || model.GioiTinh != gioitinh || model.NgaySinh != txtNgaySinh.DateTime || model.Sdt != txtSDT.Text) { XtraMessageBox.Show("Thông tin người thân tồn tại khác với khách hàng đã có", "Thông Báo"); } else { ng.suakhachhang(txtMaNT.Text, txtMaKHNT.Text, txtTenKH.Text, txtNgaySinh.DateTime, s, txtDiaChi.Text, txtCMND.Text, txtMaKH.Text, txtSDT.Text); XtraMessageBox.Show("Sửa Thành Công", "Thông Báo"); this.refresh(); } } else { ng.suakhachhang(txtMaNT.Text, txtMaKHNT.Text, txtTenKH.Text, txtNgaySinh.DateTime, s, txtDiaChi.Text, txtCMND.Text, txtMaKH.Text, txtSDT.Text); MessageBox.Show("Sửa Thành Công"); this.refresh(); } } //KhachHangDao kh = new KhachHangDao(); //SuaKH f = new SuaKH(txtMaNT.Text, txtMaKH.Text, kh.GetCapDo(txtMaNT.Text), txtNgaySinh.Text, txtGioiTinh.Text, txtCMND.Text, txtDiaChi.Text, txtSdt.Text); //f.Show(); } catch (Exception ex) { MessageBox.Show("Chọn Khách Hàng Cần Sửa"); } }
private void simpleButton3_Click(object sender, EventArgs e) { if (txtMaNT.Text == "") { XtraMessageBox.Show("Bạn chưa chọn dòng!!"); } else { DialogResult dialogResult = XtraMessageBox.Show("Xác nhận", "Bạn thực sự muốn xóa?", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { NguoiThanDao ng = new NguoiThanDao(); ng.xoanguothan(txtMaNT.Text); XtraMessageBox.Show("Đã xóa thành công!!"); this.refresh(); resettext(); } } }
public void refresh() { NguoiThanDao ng = new NguoiThanDao(); nguoiThansBindingSource.DataSource = ng.Load(); }
private void btnLuu_Click(object sender, EventArgs e) { try { if (txtSDT.Text == "" || txtMaNT.Text == "" || txtMaKHNT.Text == "" || cboGioitinh.Text == "" || txtDiaChi.Text == "" || txtCMND.Text == "" || txtNgaySinh.Text == "" || txtTenKHNT.Text == "" || txtTenKH.Text == "") { XtraMessageBox.Show("Chọn Thông Tin Cần Sửa", "Thông Báo"); } else { var s = ""; s = cboGioitinh.Text; NguoiThanDao ng = new NguoiThanDao(); if (txtMaKH.Text != "") { KhachHangDao kh = new KhachHangDao(); var model = kh.getKH(txtMaKH.Text); Boolean gioitinh; if (cboGioitinh.Text == "Nam") { gioitinh = true; } else { gioitinh = false; } if (model != null) { DateTime dateTime = Convert.ToDateTime(model.NgaySinh); if (model.TenKH != txtTenKH.Text || model.CMND != txtCMND.Text || model.DiaChi != txtDiaChi.Text || model.GioiTinh != gioitinh || dateTime != txtNgaySinh.DateTime || model.Sdt != txtSDT.Text) { XtraMessageBox.Show("Thông tin người thân tồn tại khác với khách hàng đã có", "Thông Báo"); } else { ng.suakhachhang(txtMaNT.Text, txtMaKHNT.Text, txtTenKH.Text, txtNgaySinh.DateTime, s, txtDiaChi.Text, txtCMND.Text, txtMaKH.Text, txtSDT.Text); XtraMessageBox.Show("Sửa Thành Công", "Thông Báo"); this.refresh(); } } else { XtraMessageBox.Show("Khách Hàng Không Tồn Tại", "Thông Báo"); var model2 = ng.getNT(txtMaNT.Text); txtMaKHNT.Text = model2.MaKH; txtTenKHNT.Text = kh.TenKH(model2.MaKH); txtMaKH.Text = model2.MaKHRieng; txtTenKH.Text = model2.TenNT; txtCMND.Text = model2.CMND; if (model2.GioiTinh == true) { cboGioitinh.Text = "Nam"; } else { cboGioitinh.Text = "Nữ"; } txtDiaChi.Text = model2.DiaChi; txtSDT.Text = model2.SDT; txtNgaySinh.DateTime = Convert.ToDateTime(model2.NgaySinh); } } else { ng.suakhachhang(txtMaNT.Text, txtMaKHNT.Text, txtTenKH.Text, txtNgaySinh.DateTime, s, txtDiaChi.Text, txtCMND.Text, txtMaKH.Text, txtSDT.Text); XtraMessageBox.Show("Sửa Thành Công", "Thông Báo"); this.refresh(); } } //KhachHangDao kh = new KhachHangDao(); //SuaKH f = new SuaKH(txtMaNT.Text, txtMaKH.Text, kh.GetCapDo(txtMaNT.Text), txtNgaySinh.Text, txtGioiTinh.Text, txtCMND.Text, txtDiaChi.Text, txtSdt.Text); //f.Show(); } catch (Exception ex) { XtraMessageBox.Show("Chọn Khách Hàng Cần Sửa", "Thông Báo"); } }