public ActionResult AddModify(MedicineMaster mm) { using (HISDBEntities db = new HISDBEntities()) { if (mm.MMID == 0) { //AddSupplierCategories(mm); db.MedicineMasters.Add(mm); MedicineInventory mi = new MedicineInventory(); mi.MedicineID = mm.MMID; mi.AvailableQty = 0; db.MedicineInventories.Add(mi); db.SaveChanges(); return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet)); } else { //AddSupplierCategories(mm); var mi = db.MedicineInventories.Where(m => m.MedicineID == mm.MMID).FirstOrDefault(); if (mi != null) { mi.PricePerItem = mm.ItemPrice; mi.AvailableQty = mm.AvailableQuantity; } db.Entry(mi).State = EntityState.Modified; db.Entry(mm).State = EntityState.Modified; db.SaveChanges(); return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet)); } } }
public ActionResult EditPO(List <PurchaseOrder> items) { using (HISDBEntities db = new HISDBEntities()) { if (items != null && items.Count() > 0) { foreach (PurchaseOrder po in items) { if (po.OrderID == 0) { db.PurchaseOrders.Add(po); } else { db.Entry(po).State = EntityState.Modified; } db.SaveChanges(); } DeletePurchaseOrderItems(items); return(Json(new { success = true, message = string.Format("PO# - {0} adjusted Successfully", items[0].PONumber) }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, message = "Error occured" }, JsonRequestBehavior.AllowGet)); } } }
private void UpdateMedicineInventory(List <PurchaseOrder> poItems) { using (HISDBEntities hs = new HISDBEntities()) { foreach (PurchaseOrder po in poItems) { var minventory = hs.MedicineInventories.Where(mi => mi.MedicineID == po.MedicineID).ToList(); if (minventory != null && minventory.Count() > 0) { var m = minventory[0]; m.AvailableQty = m.AvailableQty + po.OrderedQty; m.PricePerItem = po.PricePerItem; hs.Entry(m).State = EntityState.Modified; } else { MedicineInventory newM = new MedicineInventory(); newM.MedicineID = po.MedicineID; newM.AvailableQty = po.OrderedQty; hs.MedicineInventories.Add(newM); } } hs.SaveChanges(); } }
public ActionResult AddModify(Bed b) { using (HISDBEntities db = new HISDBEntities()) { if (b.BedNo == 0) { db.Beds.Add(b); db.SaveChanges(); return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet)); } else { try { db.Entry(b).State = EntityState.Modified; db.SaveChanges(); return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet)); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } } } }
public JsonResult SaveKitItems(List <LabKitViewModel> kitItems) { using (HISDBEntities db = new HISDBEntities()) { if (kitItems != null && kitItems.Count() > 0) { var kitID = kitItems[0].LKitID; var items = db.LabKitItems.Where(x => x.LKitID == kitID).ToList(); if (items.Count() == 0) { foreach (var kit in kitItems) { var labKitItem = new LabKitItem { LKitID = kitID, TestID = kit.TestID }; db.LabKitItems.Add(labKitItem); } db.SaveChanges(); return(Json(new { success = true, message = "Lab Package created Successfully" }, JsonRequestBehavior.AllowGet)); } else { db.LabKitItems.RemoveRange(items); foreach (var kit in kitItems) { var labKitItem = new LabKitItem { LKitID = kitID, TestID = kit.TestID }; db.LabKitItems.Add(labKitItem); } TestType type = (from x in db.TestTypes where x.TestID == kitID select x).First(); type.TestCost = kitItems[0].LKitCost; db.Entry(type).State = EntityState.Modified; db.SaveChanges(); return(Json(new { success = true, message = "Lab Package Updated Successfully" }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, message = "Error Found!!" }, JsonRequestBehavior.AllowGet)); } } }
public ActionResult Approve_Post(string poNumber) { using (HISDBEntities hs = new HISDBEntities()) { var poItems = hs.PurchaseOrders.Where(i => i.PONumber.Equals(poNumber)).ToList(); foreach (PurchaseOrder po in poItems) { po.ApprovedStatus = true; po.MedicineWithDose = "text"; hs.Entry(po).State = EntityState.Modified; } hs.SaveChanges(); UpdateMedicineInventory(poItems); return(Json(new { success = true, message = string.Format("PO - {0} approved successfully!!", poNumber) }, JsonRequestBehavior.AllowGet)); } }
public ActionResult SaveGrid(string[] chkboxes) { using (HISDBEntities db = new HISDBEntities()) { //db.Database.ExecuteSqlCommand("TRUNCATE TABLE UserPermission"); //db.SaveChanges(); string chk = "'"; foreach (var i in chkboxes) { chk += i + "','"; string pd, ttooltip = ""; if (i.Contains('_')) { string[] data = i.Split('_'); pd = data[0]; ttooltip = data[1]; } else { pd = i; } Permission p = db.Permissions.Where(x => x.PermissionDescription == pd).FirstOrDefault <Permission>(); if (p != null) { p.PermissionStatus = true; p.Toottip = ttooltip; db.Entry(p).State = EntityState.Modified; db.SaveChanges(); } else { Permission pa = new Permission(); pa.PermissionDescription = pd; pa.Toottip = ttooltip; pa.PermissionStatus = true; db.Permissions.Add(pa); db.SaveChanges(); } } db.Database.ExecuteSqlCommand("update Permissions set PermissionStatus=0 where PermissionDescription not in (" + chk.Substring(0, chk.Length - 2) + ")"); db.SaveChanges(); return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult AddModify(Purpose p) { using (HISDBEntities db = new HISDBEntities()) { if (p.PurposeID == 0) { db.Purposes.Add(p); db.SaveChanges(); return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet)); } else { db.Entry(p).State = EntityState.Modified; db.SaveChanges(); return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet)); } } }
public ActionResult AddModify(ScanCategory scg) { using (HISDBEntities db = new HISDBEntities()) { if (scg.SCID == 0) { db.ScanCategories.Add(scg); db.SaveChanges(); return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet)); } else { db.Entry(scg).State = EntityState.Modified; db.SaveChanges(); return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet)); } } }
public ActionResult AddModify(IntakeFrequency ifs) { using (HISDBEntities db = new HISDBEntities()) { if (ifs.FrequencyID == 0) { db.IntakeFrequencies.Add(ifs); db.SaveChanges(); return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet)); } else { db.Entry(ifs).State = EntityState.Modified; db.SaveChanges(); return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet)); } } }
public ActionResult AddModify(ConsultationType ct) { using (HISDBEntities db = new HISDBEntities()) { if (ct.ConsultTypeID == 0) { db.ConsultationTypes.Add(ct); db.SaveChanges(); return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet)); } else { db.Entry(ct).State = EntityState.Modified; db.SaveChanges(); return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet)); } } }
public ActionResult AddModify(InsuranceProvider ip) { using (HISDBEntities db = new HISDBEntities()) { if (ip.ProviderID == 0) { db.InsuranceProviders.Add(ip); db.SaveChanges(); return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet)); } else { db.Entry(ip).State = EntityState.Modified; db.SaveChanges(); return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet)); } } }
public ActionResult ConsultantPaymentSave(ConsultantVisit consultant) { using (HISDBEntities db = new HISDBEntities()) { if (consultant.ConsultantID == 0) { db.ConsultantVisits.Add(consultant); db.SaveChanges(); return(Json(new { success = true, message = "Consultant saved Successfully" }, JsonRequestBehavior.AllowGet)); } else { db.Entry(consultant).State = EntityState.Modified; db.SaveChanges(); return(Json(new { success = true, message = "Consultant updated Successfully" }, JsonRequestBehavior.AllowGet)); } } }
public ActionResult AddModify(Specialization spl) { using (HISDBEntities db = new HISDBEntities()) { if (spl.SpecializationID == 0) { db.Specializations.Add(spl); db.SaveChanges(); return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet)); } else { db.Entry(spl).State = EntityState.Modified; db.SaveChanges(); return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet)); } } }
public ActionResult PlaceOrder(List <OrderRequest> items) { bool hasItems = true; string orderNo = string.Empty; using (HISDBEntities db = new HISDBEntities()) { if (items != null && items.Count() > 0) { orderNo = items[0].OrderNo; if (items.Count() == 1 && items[0].MedicineID == 0) { hasItems = false; } if (hasItems) { foreach (OrderRequest or in items) { var po = new PurchaseOrder() { PONumber = or.OrderNo, OrderedDate = DateTime.Now, OrderedQty = or.PlacedQty.HasValue ? or.PlacedQty.Value : 0, MedicineID = or.MedicineID }; db.PurchaseOrders.Add(po); } } var reqOrder = db.OrderMasters.Where(o => o.OrderNO == orderNo).FirstOrDefault(); if (reqOrder != null) { reqOrder.Status = true; db.Entry(reqOrder).State = EntityState.Modified; } db.SaveChanges(); return(Json(new { success = true, message = string.Format("Order# - {0} placed Successfully", "") }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, message = "Error occured" }, JsonRequestBehavior.AllowGet)); } } }