Example #1
0
 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);
         }
     }
 }
Example #2
0
 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");
     }
 }