public ActionResult Create([Bind(Include = "ItemID,ItemName,ItemQuantity,ItemType")] Item item) { if (ModelState.IsValid) { db.Items.Add(item); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(item)); }
public ActionResult Create([Bind(Include = "TypeID,TypeName,deleted")] PatientType patientType) { if (ModelState.IsValid) { patientType.deleted = "0"; db.PatientTypes.Add(patientType); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(patientType)); }
public ActionResult Create([Bind(Include = "PatientID,PatientLast,PatientFirst,PatientMid,PatientGender,PatientBDate,PatientAddrss,PatientType,PatientClass,CollegeID")] Patient patient) { if (ModelState.IsValid) { db.Patients.Add(patient); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CollegeID = new SelectList(db.PColleges, "CollegeID", "CollegeCode", patient.CollegeID); return(View(patient)); }
public ActionResult Create([Bind(Include = "CollegeID,CollegeCode,CollegeName,deleted")] PCollege pCollege) { if (ModelState.IsValid) { pCollege.deleted = "0"; db.PColleges.Add(pCollege); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(pCollege)); }
public ActionResult Create([Bind(Include = "StaffID,StaffLast,StaffFirst,StaffMid,StaffGender,StaffPassword,StaffJoinedDate,UserTypeID")] Staff staff) { if (ModelState.IsValid) { staff.deleted = "0"; db.Staffs.Add(staff); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UserTypeID = new SelectList(db.UserTypes, "UserTypeID", "TypeDesc", staff.UserTypeID); return(View(staff)); }
// GET: Items public ActionResult Index() { //Get the critical stock string filePath = System.AppDomain.CurrentDomain.BaseDirectory + "/config.conf"; FileStream reader = new FileStream(filePath, FileMode.Open, FileAccess.Read); var critical_stock_value = 0; using (StreamReader sr = new StreamReader(reader)) { critical_stock_value = int.Parse(sr.ReadToEnd()); } reader.Close(); System.Diagnostics.Debug.WriteLine(critical_stock_value); var supply = db.Supplies.Where(s => s.ExpirationDate <= DateTime.Now).Where(s => s.removed == 0).GroupBy(s => s.ItemID).Select(g => new { ItemID = g.Key, SupplyQuantity = g.Sum(ss => ss.SupplyQuantity) }).ToList(); foreach (var s in supply) { var supplies = db.Supplies.Where(sp => sp.ItemID == s.ItemID).Where(sp => sp.ExpirationDate <= DateTime.Now).ToList(); if (supplies != null) { foreach (var x in supplies) { x.removed = 1; db.SaveChanges(); } } System.Diagnostics.Debug.WriteLine(s.ItemID + ' ' + s.SupplyQuantity); var item = db.Items.SingleOrDefault(i => i.ItemID == s.ItemID); if (item != null) { item.ItemQuantity -= (Int16)(s.SupplyQuantity); db.SaveChanges(); } } ModelContainer modelcontainer = new ModelContainer(); modelcontainer.Medicine = db.Items.Where(i => i.ItemType == "Medicine").Where(i => i.deleted == "0").ToList(); modelcontainer.Utensil = db.Items.Where(i => i.ItemType == "Utensil").Where(i => i.deleted == "0").ToList(); ViewBag.CriticalStock = db.Items.Where(i => i.ItemQuantity <= critical_stock_value).Where(i => i.ItemQuantity > 0).Where(i => i.deleted == "0").Count(); ViewBag.OutOfStock = db.Items.Where(i => i.ItemQuantity == 0).Where(i => i.deleted == "0").Count(); ViewBag.ItemsUsed = db.MedCheckItems.Where(s => s.Item.ItemType == "Utensil").GroupBy(s => s.ItemID).Select(g => new { ItemID = g.Key, QuantityUsed = g.Sum(ss => ss.Quantity) }).Count(); ViewBag.ExpiredStocks = db.Supplies.Where(s => s.ExpirationDate <= DateTime.Now).Count(); modelcontainer.CriticalStock = db.Items.Where(i => i.ItemQuantity <= critical_stock_value).Where(i => i.ItemQuantity > 0).Where(i => i.deleted == "0").ToList(); modelcontainer.OutOfStock = db.Items.Where(i => i.ItemQuantity == 0).Where(i => i.deleted == "0").ToList(); modelcontainer.MedCheckItem = db.MedCheckItems.SqlQuery("SELECT MedCheckItems.* FROM dbo.MedCheckItems, dbo.MedChecks WHERE ItemID LIKE 'UT%' AND MedCheckItems.MedCheckID = MedChecks.MedCheckID AND MedChecks.Time_out BETWEEN DATEADD(DAY, -7, GETDATE()) AND GETDATE()").ToList(); modelcontainer.SupplyList = db.Supplies.Where(s => s.ExpirationDate <= DateTime.Now).ToList(); if (TempData.ContainsKey("isUtensil")) { if (TempData["isUtensil"].ToString() == "T") { ViewBag.isUtensil = true; } else { ViewBag.isUtensil = false; } } return(View(modelcontainer)); }