public bool Insert(StockItemEntryModel model) { using (EHMSEntities ent = new EHMSEntities()) { if (ent.SetupStockItemEntries.Where(x => x.StockItemName == model.StockItemName).Any()) { return(false); } var objToSave = AutoMapper.Mapper.Map <StockItemEntryModel, SetupStockItemEntry>(model); objToSave.Status = true; objToSave.CreatedBy = 1; objToSave.CreatedDate = DateTime.Now; ent.SetupStockItemEntries.Add(objToSave); ent.SaveChanges(); //int id = ent.SetupStockItemEntry.Where(x=>x.StockItemEntryId==ent.SetupStockItemEntry.Max(y=>y.StockItemEntryId)).SingleOrDefault().StockItemEntryId; var obj = new StockItemMaster(); obj.StockItemEntryId = objToSave.StockItemEntryId; obj.UnitId = model.StockUnitId; obj.Quantity = model.OpeningStock; obj.Status = true; obj.CreatedBy = 1; obj.CreatedDate = DateTime.Now; ent.StockItemMasters.Add(obj); ent.SaveChanges(); return(true); } }
public ActionResult Create(StockItemEntryModel model) { if (ModelState.IsValid) { try { // TODO: Add insert logic here if (pro.Insert(model)) { TempData["success"] = HospitalManagementSystem.UtilityMessage.save; return(RedirectToAction("Index")); } else { TempData["success"] = "Record with this item name already exists in database!"; return(View(model)); } } catch { return(View()); } } else { return(View(model)); } }
public ActionResult Index() { StockItemEntryModel model = new StockItemEntryModel(); model.StockItemEntryList = pro.GetList(); return(View(model)); }
// // GET: /StockItemEntry/Edit/5 public ActionResult Edit(int id) { EHMSEntities ent = new EHMSEntities(); var obj = ent.SetupStockItemEntries.Where(x => x.StockItemEntryId == id).SingleOrDefault(); StockItemEntryModel model = new StockItemEntryModel(); AutoMapper.Mapper.Map(obj, model); return(View(model)); }
// // GET: /StockBreakage/ public ActionResult Index() { EHMSEntities ent = new EHMSEntities(); StockItemEntryModel model = new StockItemEntryModel(); model.StockItemEntryList = new List <StockItemEntryModel>(AutoMapper.Mapper.Map <IEnumerable <SetupStockItemEntry>, IEnumerable <StockItemEntryModel> >(ent.SetupStockItemEntries.Where(x => x.Status == true && ent.StockBreakages.Any(y => y.ItemId == x.StockItemEntryId)))); return(View(model)); }
public void Update(StockItemEntryModel model) { EHMSEntities ent = new EHMSEntities(); var obj = ent.StockItemMasters.Where(x => x.StockItemEntryId == model.StockItemEntryId).SingleOrDefault(); obj.Quantity = obj.Quantity + model.OpeningStock - obj.SetupStockItemEntry.OpeningStock; obj.UnitId = model.StockUnitId; model.CreatedBy = obj.CreatedBy; model.CreatedDate = obj.CreatedDate; model.Status = obj.Status; AutoMapper.Mapper.Map(model, obj.SetupStockItemEntry); ent.Entry(obj).State = System.Data.EntityState.Modified; ent.SaveChanges(); }
// // GET: /StockItemEntry/Create public ActionResult Create() { EHMSEntities ent = new EHMSEntities(); StockItemEntryModel model = new StockItemEntryModel(); try { model.StockCategoryId = ent.SetupStockCategories.Where(x => x.Status == true).FirstOrDefault().StockCategoryID; } catch { } return(View(model)); }
public ActionResult Edit(int id, StockItemEntryModel model) { if (ModelState.IsValid) { try { // TODO: Add update logic here pro.Update(model); TempData["success"] = HospitalManagementSystem.UtilityMessage.edit; return(RedirectToAction("Index")); } catch { return(View(model)); } } else { return(View(model)); } }
public ActionResult StockItemPurchaseDetail() { StockItemEntryModel model = new StockItemEntryModel(); return(PartialView("StockItemPurchaseDetail")); }