public ActionResult AddNewPartial(MiscellaneousTransactionDetailModel model) { if (ModelState.IsValid) { try { model.SOBId = SessionHelper.SOBId; bool validated = false; if (SessionHelper.MiscellaneousTransaction != null) { if (SessionHelper.MiscellaneousTransaction.MiscellaneousTransactionDetail.Any(rec => rec.LotNo == model.LotNo && rec.ItemId == model.ItemId)) { ViewData["EditError"] = "Lot Number must be unique"; return(PartialView("createPartial", MiscellaneousTransactionHelper.GetMiscellaneousTransactionDetail(model.SOBId, model.TransactionType, model.CodeCombinationId, model.TransactionDate))); } if (SessionHelper.MiscellaneousTransaction.MiscellaneousTransactionDetail.Any(rec => rec.LotNo == model.LotNo && rec.SerialNo == model.SerialNo)) { ViewData["EditError"] = "Serial Number must be unique"; return(PartialView("createPartial", MiscellaneousTransactionHelper.GetMiscellaneousTransactionDetail(model.SOBId, model.TransactionType, model.CodeCombinationId, model.TransactionDate))); } } if (LotNumberHelper.CheckLotNumAvailability(model.LotNo, model.ItemId, SessionHelper.SOBId).Any()) { ViewData["EditError"] = "Lot Number must be unique"; return(PartialView("createPartial", MiscellaneousTransactionHelper.GetMiscellaneousTransactionDetail(model.SOBId, model.TransactionType, model.CodeCombinationId, model.TransactionDate))); } //if (LotNumberHelper.CheckSerialNumAvailability(model.LotNo, model.SerialNo).Any()) //{ // ViewData["EditError"] = "Serial Number must be unique"; // return PartialView("createPartial", MiscellaneousTransactionHelper.GetMiscellaneousTransactionDetail(model.SOBId, model.TransactionType, model.CodeCombinationId, model.TransactionDate)); //} if (SessionHelper.MiscellaneousTransaction != null) { model.Id = SessionHelper.MiscellaneousTransaction.MiscellaneousTransactionDetail.Count() + 1; validated = true; } else { model.Id = 1; } if (validated) { MiscellaneousTransactionHelper.InsertMiscellaneousTransactionDetail(model); } } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("createPartial", MiscellaneousTransactionHelper.GetMiscellaneousTransactionDetail(model.SOBId, model.TransactionType, model.CodeCombinationId, model.TransactionDate))); }
public ActionResult Delete(string id) { try { MiscellaneousTransactionHelper.Delete(id); return(RedirectToAction("Index")); } catch (Exception ex) { return(RedirectToAction("Index", new { message = ex.Message })); } }
public ActionResult Edit(string id) { MiscellaneousTransactionModel model = MiscellaneousTransactionHelper.GetMiscellaneousTransaction(id); SessionHelper.MiscellaneousTransaction = model; model.SOBId = SessionHelper.SOBId; model.MiscellaneousTransactionDetail = MiscellaneousTransactionHelper.GetMiscellaneousTransactionDetail(model.SOBId, model.TransactionType, model.CodeCombinationId, model.TransactionDate).ToList(); model.CompanyId = AuthenticationHelper.CompanyId.Value; model.CodeCombination = getCodeCombinationList(model.SOBId); SessionHelper.MiscellaneousTransaction = model; return(View("Create", model)); }
public ActionResult Save(MiscellaneousTransactionModel model) { string message = ""; try { bool saved = false; if (SessionHelper.MiscellaneousTransaction != null) { SessionHelper.MiscellaneousTransaction.CodeCombinationId = model.CodeCombinationId; SessionHelper.MiscellaneousTransaction.CompanyId = model.CompanyId; SessionHelper.MiscellaneousTransaction.Id = model.Id; SessionHelper.MiscellaneousTransaction.SOBId = SessionHelper.SOBId; SessionHelper.MiscellaneousTransaction.TransactionDate = model.TransactionDate; SessionHelper.MiscellaneousTransaction.TransactionType = model.TransactionType; //Setting the parent fields.. foreach (var item in SessionHelper.MiscellaneousTransaction.MiscellaneousTransactionDetail) { item.TransactionType = model.TransactionType; item.CodeCombinationId = model.CodeCombinationId; item.CompanyId = AuthenticationHelper.CompanyId.Value; item.SOBId = SessionHelper.SOBId; item.TransactionDate = model.TransactionDate; } MiscellaneousTransactionHelper.Save(SessionHelper.MiscellaneousTransaction); SessionHelper.MiscellaneousTransaction = null; saved = true; } else { message = "No Miscellaneous Transaction information available!"; } return(Json(new { success = saved, message = message })); } catch (Exception e) { message = e.Message; return(Json(new { success = false, message = message })); } }
public ActionResult DeletePartial(MiscellaneousTransactionDetailModel model) { if (ModelState.IsValid) { try { model.SOBId = SessionHelper.SOBId; MiscellaneousTransactionModel MiscellaneousTransaction = SessionHelper.MiscellaneousTransaction; MiscellaneousTransactionHelper.DeleteMiscellaneousTransactionDetail(model); SessionHelper.MiscellaneousTransaction = MiscellaneousTransaction; IList <MiscellaneousTransactionDetailModel> MiscellaneousTransactionDetail = MiscellaneousTransactionHelper.GetMiscellaneousTransactionDetail(model.SOBId, model.TransactionType, model.CodeCombinationId, model.TransactionDate); return(PartialView("createPartial", MiscellaneousTransactionDetail)); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("createPartial")); }
public ActionResult MiscellaneousTransactionPartial(MiscellaneousTransactionListModel model) { return(PartialView("_List", MiscellaneousTransactionHelper.GetMiscellaneousTransactions(SessionHelper.SOBId))); }
public ActionResult CreatePartialClient(string transactionType, long codeCombinationId, DateTime transactionDate) { return(PartialView("createPartial", MiscellaneousTransactionHelper.GetMiscellaneousTransactionDetail(SessionHelper.SOBId, transactionType, codeCombinationId, transactionDate))); }
public ActionResult CreatePartial() { return(PartialView("createPartial", MiscellaneousTransactionHelper.GetMiscellaneousTransactionDetail(SessionHelper.SOBId, SessionHelper.MiscellaneousTransaction.TransactionType, SessionHelper.MiscellaneousTransaction.CodeCombinationId, SessionHelper.MiscellaneousTransaction.TransactionDate))); }