Beispiel #1
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (lsvDanhSach.SelectedIndices.Count == 0)
     {
         MessageBox.Show("Vui lòng chọn Shop");
         return;
     }
     else
     {
         KT      = true;
         ThayDoi = false;
         int         index   = lsvDanhSach.SelectedIndices[0];
         int         ma      = int.Parse(lsvDanhSach.Items[index].SubItems[0].Text);
         KhachHang   kh      = context.KhachHangs.FirstOrDefault(x => x.MaKH == ma);
         frmThemShop frmThem = new frmThemShop();
         frmThem.txtMa.ReadOnly = true;
         frmThem.txtTen.Focus();
         frmThem.txtMa.Text     = kh.MaKH + "";
         frmThem.txtTen.Text    = kh.TenKH;
         frmThem.txtDiaChi.Text = kh.DiaChi;
         frmThem.txtMail.Text   = kh.Email;
         frmThem.txtSDT.Text    = kh.SoDienThoai;
         frmThem.ShowDialog();
         if (ThayDoi == true)
         {
             kh.MaKH        = int.Parse(frmThem.txtMa.Text);
             kh.TenKH       = frmThem.txtTen.Text;
             kh.DiaChi      = frmThem.txtDiaChi.Text;
             kh.Email       = frmThem.txtMail.Text;
             kh.SoDienThoai = frmThem.txtSDT.Text;
             context.SubmitChanges();
             HienThiDanhSach();
         }
     }
 }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            frmThemShop frmThem = new frmThemShop();

            frmThem.ShowDialog();
            if (ThayDoi == true)
            {
                KhachHang kh = new KhachHang();
                kh.MaKH        = int.Parse(frmThem.txtMa.Text);
                kh.TenKH       = frmThem.txtTen.Text;
                kh.DiaChi      = frmThem.txtDiaChi.Text;
                kh.Email       = frmThem.txtMail.Text;
                kh.SoDienThoai = frmThem.txtSDT.Text;
                context.KhachHangs.InsertOnSubmit(kh);
                context.SubmitChanges();
                HienThiDanhSach();
            }
        }