コード例 #1
0
 public List <Laptop> timgandung(string tensp)
 {
     using (CSDLContext db = new CSDLContext())
     {
         return(db.Laptop.Where(s => s.TenLaptop.Contains(tensp)).ToList());
     }
 }
コード例 #2
0
 public List <Laptop> timtheoten(string tensp)
 {
     using (CSDLContext db = new CSDLContext())
     {
         return(db.Laptop.Where(p => p.TenLaptop.Equals(tensp)).ToList());
     }
 }
コード例 #3
0
 public Laptop tim(int id)
 {
     using (CSDLContext db = new CSDLContext())
     {
         return(db.Laptop.Find(id));
     }
 }
コード例 #4
0
 public List <Laptop> SXGiaTienGiam()
 {
     using (CSDLContext db = new CSDLContext())
     {
         return(db.Laptop.OrderByDescending(s => s.Giatien).ToList());
     }
 }
コード例 #5
0
 public List <Laptop> SXTen()
 {
     using (CSDLContext db = new CSDLContext())
     {
         return(db.Laptop.OrderBy(s => s.TenLaptop).ToList());
     }
 }
コード例 #6
0
 public AdminAccount Tim(int id)
 {
     using (CSDLContext db = new CSDLContext())
     {
         return(db.AdminAccount.Find(id));
     }
 }
コード例 #7
0
        public List <Laptop> DSLT()
        {
            List <Laptop> list = new List <Laptop>();

            using (CSDLContext db = new CSDLContext())
            {
                list = db.Laptop.ToList();
            }
            return(list);
        }
コード例 #8
0
        public List <AdminAccount> DSAdmin()
        {
            List <AdminAccount> list = new List <AdminAccount>();

            using (CSDLContext db = new CSDLContext())
            {
                list = db.AdminAccount.ToList();
            }
            return(list);
        }
コード例 #9
0
 public int DoiMatKhau(int id, string matkhau)
 {
     using (CSDLContext db = new CSDLContext())
     {
         AdminAccount admin = db.AdminAccount.Find(id);
         admin.Password        = matkhau;
         db.Entry(admin).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
     return(1);
 }
コード例 #10
0
 public int xoa(int id)
 {
     try
     {
         using (CSDLContext db = new CSDLContext())
         {
             Laptop laptop = db.Laptop.Find(id);
             db.Entry(laptop).State = EntityState.Deleted;
             db.SaveChanges();
         }
         return(1);
     }
     catch (Exception e)
     { return(0); }
 }
コード例 #11
0
 public int sua(int id, string tensp, int giatien, string thongso, int MaTH)
 {
     try
     {
         using (CSDLContext db = new CSDLContext())
         {
             Laptop laptop = db.Laptop.Find(id);
             laptop.TenLaptop       = tensp;
             laptop.Giatien         = giatien;
             laptop.ThongSo         = thongso;
             laptop.MaTH            = MaTH;
             db.Entry(laptop).State = EntityState.Modified;
             db.SaveChanges();
         }
         return(1);
     }
     catch (Exception e)
     { return(0); }
 }
コード例 #12
0
 public int themsp(string tensp, int giatien, string thongso, int MaTH, string picture)
 {
     try
     {
         using (CSDLContext db = new CSDLContext())
         {
             db.Laptop.Add(new Laptop
             {
                 TenLaptop = tensp,
                 Giatien   = giatien,
                 ThongSo   = thongso,
                 MaTH      = MaTH,
                 Image     = picture,
             });
             db.SaveChanges();
         }
         return(1);
     }
     catch (Exception e)
     {
         return(0);
     }
 }