コード例 #1
0
 public ActionResult editThuoc(Models.THUOC thuoc)
 {
     Models.THUOC a = db.THUOCs.Find(thuoc.mathuoc);
     a.tenthuoc  = thuoc.tenthuoc;
     a.mancc     = thuoc.mancc;
     a.mota      = thuoc.mota;
     a.hansd     = thuoc.hansd;
     a.dongia    = thuoc.dongia;
     a.donvitinh = thuoc.donvitinh;
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
コード例 #2
0
 public ActionResult delThuoc(string mathuoc)
 {
     Models.THUOC a = db.THUOCs.Find(mathuoc);
     if (a != null)
     {
         List <Models.CHITIETHOADON> lstCTHD = db.CHITIETHOADONs.Where(x => x.mathuoc == mathuoc).ToList();
         foreach (var item in lstCTHD)
         {
             Models.HOADON hd = db.HOADONs.Find(item.sohd);
             db.CHITIETHOADONs.Remove(item);
             hd.thanhtien = hd.CHITIETHOADONs.Sum(x => x.soluong * x.dongia);
         }
         db.THUOCs.Remove(a);
         db.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
コード例 #3
0
 public ActionResult addThuoc(Models.THUOC thuoc)
 {
     if (ModelState.IsValid)
     {
         if (db.THUOCs.Find(thuoc.mathuoc) == null)
         {
             db.THUOCs.Add(thuoc);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         else
         {
             ModelState.AddModelError("mathuoc", "Thuốc đã có dữ liệu!");
             ViewBag.DSNCC = db.NHACUNGCAPs.ToList();
             return(View("FormAddThuoc"));
         }
     }
     ViewBag.DSNCC = db.NHACUNGCAPs.ToList();
     return(View("FormAddThuoc"));
 }