Esempio n. 1
0
        public Boolean themKhachHang(eKhachHang eKhach)
        {
            tbKhachHang tbKhach = new tbKhachHang();

            tbKhach.MaKhachHang = eKhach.MaKhachHang;
            tbKhach.TenKH       = eKhach.TenKH;
            tbKhach.DiaChi      = eKhach.DiaChi;
            tbKhach.SoDienThoai = eKhach.SoDienThoai;
            tbKhach.PhiPhat     = eKhach.PhiPhat;
            db.tbKhachHangs.InsertOnSubmit(tbKhach);
            db.SubmitChanges();
            return(true);
        }
Esempio n. 2
0
        public Boolean xoaKhachHang(String ma)
        {
            tbKhachHang tbKhach = (from x in db.tbKhachHangs
                                   where x.MaKhachHang.Equals(ma)
                                   select x).FirstOrDefault();

            if (tbKhach != null)
            {
                db.tbKhachHangs.DeleteOnSubmit(tbKhach);
                db.SubmitChanges();
                return(true);
            }
            return(false);
        }
Esempio n. 3
0
        public Boolean suaKhachHang(eKhachHang kh)
        {
            tbKhachHang khachHang = (from n in db.tbKhachHangs
                                     where n.MaKhachHang.Equals(kh.MaKhachHang)
                                     select n).FirstOrDefault();

            if (khachHang != null)
            {
                khachHang.TenKH       = kh.TenKH;
                khachHang.DiaChi      = kh.DiaChi;
                khachHang.SoDienThoai = kh.SoDienThoai;
                db.SubmitChanges();
                return(true);
            }
            return(false);
        }
Esempio n. 4
0
 private void gridView1_RowUpdated(object sender, DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e)
 {
     for (int i = 0; i <= gridView1.RowCount - 1; i++)
     {
         var dr = gridView1.GetDataRow(i);
         if (dr.RowState == DataRowState.Modified)
         {
             if (XtraMessageBox.Show("Bạn có muốn cập nhật không", "Cảnh báo", MessageBoxButtons.YesNo,
                                     MessageBoxIcon.Question) == DialogResult.Yes)
             {
                 var db = new MyDBContextDataContext();
                 var tb = db.tbKhachHangs.Single(s => s.MaKhachHang == (int)dr["MaKhachHang"]);
                 tb.TenKhachHang = dr["TenKhachHang"].ToString();
                 tb.DiaChi       = dr["DiaChi"].ToString();
                 tb.MaSoThue     = dr["MaSoThue"].ToString();
                 tb.NguoiLienHe  = dr["NguoiLienHe"].ToString();
                 tb.Email        = dr["Email"].ToString();
                 tb.DienThoai    = dr["DienThoai"].ToString();
                 tb.GhiChu       = dr["GhiChu"].ToString();
                 tb.TinhTrang    = dr["TinhTrang"].ToString();
                 db.SubmitChanges();
                 MessageBox.Show(PrintRibbon.capnhat);
             }
         }
         else if (dr.RowState == DataRowState.Added)
         {
             if (XtraMessageBox.Show("Bạn có muốn thêm không", "Cảnh báo", MessageBoxButtons.YesNo,
                                     MessageBoxIcon.Question) == DialogResult.Yes)
             {
                 var db = new MyDBContextDataContext();
                 var tb = new tbKhachHang();
                 tb.TenKhachHang = dr["TenKhachHang"].ToString();
                 tb.DiaChi       = dr["DiaChi"].ToString();
                 tb.MaSoThue     = dr["MaSoThue"].ToString();
                 tb.NguoiLienHe  = dr["NguoiLienHe"].ToString();
                 tb.Email        = dr["Email"].ToString();
                 tb.DienThoai    = dr["DienThoai"].ToString();
                 tb.GhiChu       = dr["GhiChu"].ToString();
                 tb.TinhTrang    = dr["TinhTrang"].ToString();
                 db.tbKhachHangs.InsertOnSubmit(tb);
                 db.SubmitChanges();
                 MessageBox.Show(PrintRibbon.themthanhcong);
             }
         }
     }
     //frmKhachHang_Load(sender, e);
 }