예제 #1
0
        public static bool CapNhat(BizThietBi bizThietBi)
        {
            db = new QuanTriThietBiEntities();
            ThietBi thietBi = db.ThietBis.SingleOrDefault(n => n.MaTB == bizThietBi.MaTB);
            if(thietBi != null)
            {
                thietBi.NamSD = thietBi.NamSD;
                thietBi.TiLeKhauHao = thietBi.TiLeKhauHao;
                thietBi.GiaTriSuDung = thietBi.GiaTriSuDung;
                thietBi.TinhTrang = thietBi.TinhTrang;
                thietBi.MaNhomTB = thietBi.MaNhomTB;
                thietBi.MaDV = thietBi.MaDV;

                try
                {
                    db.SaveChanges();
                    return true;
                }
                catch (Exception)
                {
                    return false;
                }
            }
            else
            {
                return false;
            }
        }
예제 #2
0
 public ActionResult CreateThietBi(BizThietBi thietbi, int MaNhom, int MaDonVi)
 {
     ViewBag.MaNhom = new SelectList(db.NhomThietBis.ToList(), "MaNhomTB", "TenNhomTB");
     ViewBag.MaDonVi = new SelectList(db.DonVis.ToList(), "MaDV", "TenDonVi");
     thietbi.MaNhomTB = MaNhom;
     thietbi.MaDV = MaDonVi;
     if (ModelState.IsValid)
     {
         if (thietbi.Them())
         {
             ViewBag.ThongBao = "Đăng ký thành công!";
             return View();
         }
         else
         {
             ViewBag.ThongBao = "Đăng ký không thành công!";
             return View();
         }
     }
     return View();
 }
예제 #3
0
        public static List<BizThietBi> LayDanhSachThietBi()
        {
            db = new QuanTriThietBiEntities();
            List<ThietBi> lstThietBis = db.ThietBis.ToList();
            List<BizThietBi> lstBizThietBis = new List<BizThietBi>();

            foreach (var thietBi in lstThietBis)
            {
                BizThietBi bizThietBi = new BizThietBi(
                        thietBi.MaTB,
                        (DateTime)thietBi.NamSD,
                        (double)thietBi.TiLeKhauHao,
                        (int)thietBi.GiaTriSuDung,
                        (int)thietBi.TinhTrang,
                        (int)thietBi.MaNhomTB,
                        (int)thietBi.MaDV
                    );
                lstBizThietBis.Add(bizThietBi);
            }
            return lstBizThietBis;
        }
예제 #4
0
        public static bool ThemThietBi(BizThietBi thietBi)
        {
            db = new QuanTriThietBiEntities();

            ThietBi newThietBi = new ThietBi();
            newThietBi.MaNhomTB = thietBi.MaNhomTB;
            newThietBi.NamSD = thietBi.NamSD;
            newThietBi.MaDV = thietBi.MaDV;
            newThietBi.TiLeKhauHao = thietBi.TiLeKhauHao;
            newThietBi.GiaTriSuDung = thietBi.GiaTriSuDung;
            newThietBi.TinhTrang = thietBi.TinhTrang;

            try
            {
                db.ThietBis.Add(newThietBi);
                db.SaveChanges();
            }
            catch (Exception)
            {
                return false;
            }
            return true;
        }
예제 #5
0
 public ActionResult Delete(int id, BizThietBi thietbi)
 {
     thietbi.MaTB = id;
     thietbi.Xoa();
     return Content("<script language='javascript' type='text/javascript'>alert('XóaThành Công!'); window.location.href = '../Home/Index';</script>");
 }
예제 #6
0
 public static bool XoaThietBi(BizThietBi bizThietBi)
 {
     db = new QuanTriThietBiEntities();
     ThietBi thietBi = db.ThietBis.SingleOrDefault(n => n.MaTB == bizThietBi.MaTB);
     if(thietBi == null)
     {
         return false;
     }
     try
     {
         db.ThietBis.Remove(thietBi);
         db.SaveChanges();
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }