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

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

            using (CSDLContext db = new CSDLContext())
            {
                list = db.AdminAccount.ToList();
            }
            return(list);
        }
Example #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);
 }
Example #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); }
 }
Example #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); }
 }
Example #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);
     }
 }