Exemplo n.º 1
0
        private void btnCapNhat_Click(object sender, EventArgs e)
        {
            KhachHangThanThiet khtt = new KhachHangThanThiet();

            khtt.MaKhachHang = txtMaKhachHangThanThiet.Text.Trim();
            khtt.HoTen       = txtTenKhachHangThanThiet.Text.Trim();
            khtt.DiaChi      = txtDiaChi.Text.Trim();
            khtt.CMND        = txtCMND.Text.Trim();
            khtt.DiemThuong  = Convert.ToInt32(txtDiemTichLuy.Text);
            khtt.NgayCapThe  = deNgayCapThe.DateTime;
            try
            {
                if (KhachHangThanThietService.Update(khtt))
                {
                    XtraMessageBox.Show("Cập nhật thành công");
                    grcKHTT.DataSource = KhachHangThanThietService.LoadDataTable();
                }
                else
                {
                    XtraMessageBox.Show("Cập nhật thất bại!");
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("Cập nhật thất bại");
            }
        }
Exemplo n.º 2
0
        private void gridView1_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
        {
            btnThem.Enabled    = false;
            btnCapNhat.Enabled = true;
            int currentID = e.RowHandle;

            string             maKH = gridView1.GetRowCellValue(currentID, MaKhachHang).ToString();
            KhachHangThanThiet khtt = new KhachHangThanThiet();

            khtt = KhachHangThanThietService.GetDataFromRowSelected(maKH);
            txtMaKhachHangThanThiet.Text  = khtt.MaKhachHang;
            txtTenKhachHangThanThiet.Text = khtt.HoTen;
            txtDiaChi.Text        = khtt.DiaChi;
            txtCMND.Text          = khtt.CMND;
            deNgayCapThe.DateTime = khtt.NgayCapThe.Value;
            txtDiemTichLuy.Text   = khtt.DiemThuong.ToString();
        }
        public KhachHangThanThiet GetDataFromRowSelected(string ID)
        {
            _connect.open();
            KhachHangThanThiet khtt = new KhachHangThanThiet();
            string             sql;

            sql = string.Format("SELECT * FROM KHACHHANGTHANTHIET WHERE MaKhachHang =  '{0}'", ID);
            SqlDataReader reader = _connect.GetDataFromRowSelected(sql);

            while (reader.Read())
            {
                khtt.MaKhachHang = reader[0].ToString();
                khtt.HoTen       = reader[1].ToString();
                khtt.DiaChi      = reader[2].ToString();
                khtt.CMND        = reader[3].ToString();
                khtt.NgayCapThe  = Convert.ToDateTime(reader[4].ToString());
                khtt.DiemThuong  = Convert.ToInt32(reader[5].ToString());
            }
            _connect.close();
            return(khtt);
        }
Exemplo n.º 4
0
 private void btnThem_Click(object sender, EventArgs e)
 {
     if (validateForm())
     {
         KhachHangThanThiet khtt = new KhachHangThanThiet();
         khtt.MaKhachHang = txtMaKhachHangThanThiet.Text.Trim();
         khtt.HoTen       = txtTenKhachHangThanThiet.Text.Trim();
         khtt.DiaChi      = txtDiaChi.Text.Trim();
         khtt.CMND        = txtCMND.Text.Trim();
         try
         {
             khtt.DiemThuong = Convert.ToInt32(txtDiemTichLuy.Text);
         }
         catch (Exception ex1)
         {
             XtraMessageBox.Show("Vui lòng nhập đúng kiểu dữ liệu");
         }
         khtt.NgayCapThe = deNgayCapThe.DateTime;
         try
         {
             if (KhachHangThanThietService.Insert(khtt))
             {
                 XtraMessageBox.Show("Thêm thành công");
                 grcKHTT.DataSource = KhachHangThanThietService.LoadDataTable();
             }
             else
             {
                 XtraMessageBox.Show("Thêm thất bại!");
             }
         }
         catch (Exception ex)
         {
             XtraMessageBox.Show("Thêm thất bại");
         }
     }
 }
Exemplo n.º 5
0
 public static bool Update(KhachHangThanThiet khtt)
 {
     return(Controller.Update(khtt));
 }
Exemplo n.º 6
0
 public static bool Insert(KhachHangThanThiet khtt)
 {
     return(Controller.Insert(khtt));
 }
 public bool Update(KhachHangThanThiet khtt)
 {
     return(_connect.Update("SP_KHACHHANGTHANTHIET_UPD", khtt));
 }
 public bool Insert(KhachHangThanThiet khtt)
 {
     return(_connect.Update(khtt));
 }