Exemplo n.º 1
0
        public bool InsertPBH(DTO_PhieuBanHang obj)
        {
            using (CellphoneComponentEntities db = new CellphoneComponentEntities())
            {
                var result = db.Database
                             .SqlQuery <String>("select MaNhanVien from dbo.NhanVien where TenNhanVien = N'" + obj.TenNhanVien + "'")
                             .FirstOrDefault();
                PhieuBanHang phieuBanHang = new PhieuBanHang();
                phieuBanHang.MaPhieuBanHang = obj.MaPhieuBanHang;
                phieuBanHang.NgayBan        = obj.NgayBan;
                phieuBanHang.MaNhanVien     = result;
                phieuBanHang.TenKhachHang   = obj.TenKhachHang;
                phieuBanHang.SoDienThoai    = obj.SoDienThoai;
                phieuBanHang.TongTien       = obj.TongTien;
                phieuBanHang.GhiChu         = obj.GhiChu;
                phieuBanHang.NgayChinhSua   = obj.NgayChinhSua;

                db.PhieuBanHangs.Add(phieuBanHang);
                if (db.SaveChanges() > 0)
                {
                    return(true);
                }
                return(false);
            }
        }
Exemplo n.º 2
0
 public bool DeletePBH(String id)
 {
     using (CellphoneComponentEntities db = new CellphoneComponentEntities())
     {
         PhieuBanHang phieuBanHang = (from item in db.PhieuBanHangs
                                      where item.MaPhieuBanHang == id
                                      select item).SingleOrDefault();
         db.PhieuBanHangs.Remove(phieuBanHang);
         if (db.SaveChanges() > 0)
         {
             return(true);
         }
         return(false);
     }
 }