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 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 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"); } }