示例#1
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);
 }
示例#2
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); }
 }
示例#3
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); }
 }
示例#4
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);
     }
 }