public List <InputViewModels> TodaysJournal() { var model = new InputViewModels(); List <InputViewModels> list = new List <InputViewModels>(); try { var journalList = _db.sp_TodaysJournal(); foreach (var item in journalList) { model = new InputViewModels(); DateTime?trxDate = item.TransactionDate; string strTrxDate = trxDate.Value.ToString("dd MMM yyyy"); model.Date = strTrxDate; model.Account = item.AccountName; model.BankAccount = item.FacilityName; model.Description = item.Description; model.CashIn = item.Origin.Equals("Cash In") ? item.Amount.ToString() : string.Empty; model.CashOut = item.Origin.Equals("Cash Out") ? item.Amount.ToString() : string.Empty; list.Add(model); } } catch (Exception e) { Logging.getInstance().CreateLogError(e); throw e; } return(list); }
// GET: Input //[CheckAuthorize(Roles = "Input")] public ActionResult Index() { InputViewModels model = new InputViewModels(); model.TodaysJournal = Journals(); ViewBag.AccountList = common.ToSelectList(AccountDetailsBusinessLogic.getInstance().getAccountDetailDDL(), "ID", "NAME", string.Empty); ViewBag.BankAccountList = common.ToSelectList(BankFacilityBusinessLogic.getInstance().getBankFacilityDDL(), "ID", "NAME", string.Empty); return(View(model)); }
public ActionResult Index(InputViewModels model) { int _out; int year = 2020; int month = 1; int day = 1; if (Int32.TryParse(model.Date.Substring(6, 4), out _out)) { year = _out; } if (Int32.TryParse(model.Date.Substring(0, 2), out _out)) { month = _out; } if (Int32.TryParse(model.Date.Substring(3, 2), out _out)) { day = _out; } DateTime tmpDate = new DateTime(year, month, day); model.Date = tmpDate.ToString("yyyy-MMM-dd"); int msg = InputBusinessLogic.getInstance().InputJournal(model); if (msg == -1) { TempData["Success"] = "Successfully was inserted"; return(RedirectToAction("Index")); } else { if (msg == 1) { TempData["Error"] = "amount cannot be greater than ceiling"; } else { TempData["Error"] = "Unsuccessfully was inserted"; } } model.TodaysJournal = Journals(); ViewBag.AccountList = common.ToSelectList(AccountDetailsBusinessLogic.getInstance().getAccountDetailDDL(), "ID", "NAME", model.Account); ViewBag.BankAccountList = common.ToSelectList(BankFacilityBusinessLogic.getInstance().getBankFacilityDDL(), "ID", "NAME", model.BankAccount); return(View(model)); }
public int InputJournal(InputViewModels model) { try { if ((Convert.ToDecimal(model.Amount.Replace(".", "")) > Convert.ToDecimal(_db.sp_GetBalanceCeilingByBankFacilityId(model.BankAccount).FirstOrDefault().Value)) && model.Origin.Equals("Cash Out")) { return(1); } decimal amt = Convert.ToDecimal(model.Amount.Replace(".", "")); return(_db.sp_InputJournal(model.Date == string.Empty ? DateTime.Now : Convert.ToDateTime(model.Date), model.Account, model.BankAccount, amt, model.Description, model.Origin, SessionManager.userId())); } catch (Exception e) { Logging.getInstance().CreateLogError(e); throw e; } }