public ActionResult Review(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var LoanUpdate = db.tbl_loan_processing.Find(id); if (TryUpdateModel(LoanUpdate, "", new string[] { "status", "reviewed_by_name" })) { try { db.SaveChanges(); return(Json("Success", JsonRequestBehavior.AllowGet)); } catch (DataException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator."); } } return(View(LoanUpdate)); }
public JsonResult Save(tbl_cash_out model) { try { db_lendingEntities db = new db_lendingEntities(); tbl_cash_out tbl = new tbl_cash_out(); tbl.date_trans = model.date_trans; tbl.username = model.username; tbl.datefrom = model.datefrom; tbl.dateto = model.dateto; tbl.amount = model.amount; tbl.created_by = Session["UserName"].ToString(); tbl.date_created = DateTime.Now; db.tbl_cash_out.Add(tbl); db.SaveChanges(); return(Json("Success", JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json("Failed", JsonRequestBehavior.DenyGet)); throw ex; } }
public JsonResult SavePaymentDetails(tbl_payment_details model) { try { db_lendingEntities db = new db_lendingEntities(); tbl_payment_details tbl = new tbl_payment_details(); tbl.reference_no = model.reference_no; tbl.payment_type = model.payment_type; tbl.loan_no = model.loan_no; tbl.loan_name = model.loan_name; tbl.due_date = model.due_date; tbl.amount = model.amount; tbl.created_by = Session["UserName"].ToString(); tbl.date_created = DateTime.Now; db.tbl_payment_details.Add(tbl); db.SaveChanges(); return(Json("Success", JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json("Failed", JsonRequestBehavior.DenyGet)); throw ex; } }
public JsonResult SavePayment(tbl_payment model) { try { db_lendingEntities db = new db_lendingEntities(); tbl_payment tbl = new tbl_payment(); tbl.reference_no = model.reference_no; tbl.date_trans = model.date_trans; tbl.payor_id = model.payor_id; tbl.payor_name = model.payor_name; tbl.total_amount = model.total_amount; tbl.created_by = Session["UserName"].ToString(); tbl.date_created = DateTime.Now; db.tbl_payment.Add(tbl); db.SaveChanges(); return(Json(tbl.reference_no, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json("Failed", JsonRequestBehavior.DenyGet)); throw ex; } }
public JsonResult CreateAmortization(tbl_loan_processing_amortization_schedule model) { try { db_lendingEntities db = new db_lendingEntities(); tbl_loan_processing_amortization_schedule tbl = new tbl_loan_processing_amortization_schedule(); tbl.due_date = model.due_date; tbl.principal = model.principal; tbl.interest = model.interest; tbl.amount = model.amount; tbl.balance = model.balance; tbl.loan_no = model.loan_no; tbl.createdby = Session["UserName"].ToString(); db.tbl_loan_processing_amortization_schedule.Add(tbl); db.SaveChanges(); return(Json("Success", JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json("Failed", JsonRequestBehavior.DenyGet)); throw ex; } }
public ActionResult Update(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var LoanUpdate = db.tbl_customer.Find(id); if (TryUpdateModel(LoanUpdate, "", new string[] { "customer_no", "date_registered", "firstname", "middlename", "lastname", "civil_status", "address", "contact_no", "email", "date_of_birth", "birth_place", "occupation", "credit_limit", "annual_income" })) { try { db.SaveChanges(); return(Json("Success", JsonRequestBehavior.AllowGet)); } catch (DataException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator."); } } return(View(LoanUpdate)); }
public JsonResult Add(tbl_loan_type model) { try { db_lendingEntities db = new db_lendingEntities(); tbl_loan_type tbl = new tbl_loan_type(); tbl.code = "0"; tbl.description = model.description; tbl.interest = model.interest; tbl.interest_type = model.interest_type; tbl.days = model.days; db.tbl_loan_type.Add(tbl); db.SaveChanges(); return(Json("Success", JsonRequestBehavior.AllowGet)); } catch (DataException ex) { return(Json("Failed", JsonRequestBehavior.DenyGet)); throw ex; } }
public ActionResult Save(tbl_end_of_day_transactions model) { try { db_lendingEntities db = new db_lendingEntities(); var datetimenow = DateTime.Now; var datenow = datetimenow.Date; var result = from d in db.tbl_end_of_day_transactions where (d.date_trans >= datenow && d.date_trans <= datenow) orderby d.autonum ascending select d; if (result.Count() == 0) { tbl_end_of_day_transactions tbl = new tbl_end_of_day_transactions(); tbl.date_trans = model.date_trans; tbl.cash_begin = model.cash_begin; tbl.cash_release = model.cash_release; tbl.cash_collected = model.cash_collected; tbl.cash_replenished = model.cash_replenished; tbl.cash_pulled_out = model.cash_pulled_out; tbl.cash_end = model.cash_end; tbl.created_by = Session["UserName"].ToString(); tbl.date_created = DateTime.Now; db.tbl_end_of_day_transactions.Add(tbl); db.SaveChanges(); return(Json("Success", JsonRequestBehavior.AllowGet)); } else { //"date_trans", "cash_begin", "cash_release", "cash_collected", "cash_pulled_out", "cash_end" var update = db.tbl_end_of_day_transactions.SingleOrDefault(d => d.date_trans >= datenow && d.date_trans <= datenow); if (TryUpdateModel(update, "", new string[] { "date_trans", "cash_begin", "cash_release", "cash_collected", "cash_replenished", "cash_pulled_out", "cash_end" })) { db.SaveChanges(); } } return(Json("Success", JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json("Failed", JsonRequestBehavior.DenyGet)); throw ex; } }
public ActionResult Add1([Bind(Include = "autonum, code, description, interest, interest_type")] tbl_loan_type model) { try { if (ModelState.IsValid) { db.tbl_loan_type.Add(model); db.SaveChanges(); return(RedirectToAction("Index")); } } catch (DataException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } return(View(model)); }
public JsonResult Registration(tbl_user_validation_registration model) { try { db_lendingEntities db = new db_lendingEntities(); tbl_user tbl = new tbl_user(); tbl.firstname = model.firstname; tbl.lastname = model.lastname; tbl.email = model.email; tbl.username = model.username; if (model.password != null) { tbl.password = FormsAuthentication.HashPasswordForStoringInConfigFile(model.password.Trim(), "md5"); } //string hash = FormsAuthentication.HashPasswordForStoringInConfigFile(model.password.Trim(), "md5"); if (model.gender == "Female") { tbl.gender = "F"; } else if (model.gender == "Male") { tbl.gender = "M"; } else { tbl.gender = "U"; } tbl.user_rank_id = 3; tbl.department_id = 1; tbl.system_type = "LS"; db.tbl_user.Add(tbl); db.SaveChanges(); return(Json("Success", JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json("Failed", JsonRequestBehavior.DenyGet)); throw ex; } }
public JsonResult Create(tbl_loan_processing model) { try { db_lendingEntities db = new db_lendingEntities(); tbl_loan_processing tbl = new tbl_loan_processing(); tbl.customer_id = model.customer_id; tbl.customer_name = model.customer_name; tbl.loan_no = model.loan_no; tbl.loantype_id = model.loantype_id; tbl.loan_name = model.loan_name; tbl.loan_granted = model.loan_granted; tbl.loan_interest_rate = model.loan_interest_rate; tbl.payment_scheme = model.payment_scheme; tbl.due_date = model.due_date; tbl.loan_date = model.loan_date; tbl.installment_no = model.installment_no; tbl.total_receivable = model.total_receivable; tbl.net_proceeds = model.net_proceeds; tbl.amortization_id = model.amortization_id; tbl.finance_charge_id = model.finance_charge_id; tbl.status = model.status; tbl.prepared_by_id = model.prepared_by_id; tbl.prepared_by_name = model.prepared_by_name; tbl.reviewed_by_id = model.reviewed_by_id; tbl.reviewed_by_name = model.reviewed_by_name; tbl.approved_by_id = model.approved_by_id; tbl.approved_by_name = model.approved_by_name; tbl.date_created = DateTime.Now; tbl.created_by = Session["UserName"].ToString(); db.tbl_loan_processing.Add(tbl); db.SaveChanges(); return(Json("Success", JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json("Failed", JsonRequestBehavior.DenyGet)); throw ex; } }
public JsonResult AddFee(tbl_fees_validation model) { try { db_lendingEntities db = new db_lendingEntities(); tbl_fees tbl = new tbl_fees(); tbl.fees_description = model.fees_description; db.tbl_fees.Add(tbl); db.SaveChanges(); return(Json("Success", JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json("Failed", JsonRequestBehavior.DenyGet)); throw ex; } }
public JsonResult SaveLedger(tbl_loan_ledger model) { try { db_lendingEntities db = new db_lendingEntities(); tbl_loan_ledger tbl = new tbl_loan_ledger(); tbl.date_trans = model.date_trans; tbl.trans_type = model.trans_type; tbl.reference_no = model.reference_no; tbl.loan_no = model.loan_no; tbl.loan_type_name = model.loan_type_name; tbl.customer_id = model.customer_id; tbl.customer_name = model.customer_name; tbl.interest_type = model.interest_type; tbl.interest_rate = model.interest_rate; tbl.interest = model.interest; tbl.amount_paid = model.amount_paid; tbl.principal = model.principal; tbl.balance = model.balance; tbl.date_created = DateTime.Now; tbl.created_by = Session["UserName"].ToString(); db.tbl_loan_ledger.Add(tbl); db.SaveChanges(); return(Json(tbl.reference_no, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json("Failed", JsonRequestBehavior.DenyGet)); throw ex; } }
public ActionResult Save(string id) { try { using (db = new db_lendingEntities()) { string message = ""; var result = from d in db.tbl_loan_processing where d.loan_no.Equals(id) select d; foreach (var dt in result) { DateTime newDueDate = (DateTime)dt.due_date; var dueDate = newDueDate.ToString("MM/dd/yyyy"); DateTime newLoanDate = (DateTime)dt.loan_date; var loanDate = newLoanDate.ToString("MM/dd/yyyy"); decimal loanBalance = decimal.Round((decimal)GetLedgerBalance(dt.loan_no), 2, MidpointRounding.AwayFromZero); decimal restructuredInterest = 0; decimal restructuredInterestTotal = 0; decimal newLoanBalance = loanBalance; int loop = interestLoop(dt.loan_no); for (int i = 0; i < loop; i++) { restructuredInterest = decimal.Round(newLoanBalance * ((decimal)dt.loan_interest_rate / 100), 2, MidpointRounding.AwayFromZero); newLoanBalance = newLoanBalance + restructuredInterest; restructuredInterestTotal = restructuredInterestTotal + restructuredInterest; } if (loanBalance > 0) { db_lendingEntities dbSave = new db_lendingEntities(); tbl_loan_ledger tbl = new tbl_loan_ledger(); tbl.date_trans = _serverDateTime; tbl.trans_type = "Late Payment Interest"; tbl.reference_no = ""; tbl.loan_no = dt.loan_no; tbl.loan_type_name = dt.loan_name; tbl.customer_id = dt.customer_id; tbl.customer_name = dt.customer_name.ToUpper(); tbl.interest_type = GetInterestType(dt.loan_name); tbl.interest_rate = dt.loan_interest_rate; tbl.interest = restructuredInterestTotal; tbl.amount_paid = 0; tbl.principal = 0; tbl.balance = 0; tbl.date_created = DateTime.Now; tbl.created_by = Session["UserName"].ToString(); dbSave.tbl_loan_ledger.Add(tbl); dbSave.SaveChanges(); message = "Success!"; } else { message = "Failed!"; } } return(Json(new { success = true, message = message }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public JsonResult GenerateInterest(string loanNo) { using (db = new db_lendingEntities()) { var result = from d in db.tbl_loan_processing where d.loan_no == loanNo && d.status == "Released" && d.due_date < _serverDateTime orderby d.loantype_id ascending select d; foreach (var dt in result) { var balance = (decimal)GetLedgerBalance(dt.loan_no); if (balance > 0) { var interestRate = (decimal)dt.loan_interest_rate; decimal noOfDays = 0; var dateStart = GetInterestStartDate(dt.loan_no); var skipIinterest = false; if (GetInterestType(dt.loan_name) == "1") { noOfDays = decimal.ToInt32((_serverDateTime - dateStart).Value.Days); } else { skipIinterest = true; //if ((decimal.ToInt32((_serverDateTime - dateStart).Value.Days)) >= 1) //{ // if ((decimal.ToInt32((_serverDateTime - dateStart).Value.Days)) == 1) // { // if (NoOfInterest(dt.loan_no) >= // (decimal.ToInt32((_serverDateTime - dateStart).Value.Days))) // { // skipIinterest = true; // } // noOfDays = 1; // } // else // { // noOfDays = (_serverDateTime - dateStart).Value.Days; // noOfDays = (noOfDays / 30); // noOfDays = decimal.Ceiling(noOfDays); // if (NoOfInterest(dt.loan_no) >= noOfDays) // { // skipIinterest = true; // } // } //} } decimal totalInterest = 0; for (var c = 0; c < noOfDays; c++) { var interest = (balance * (interestRate / 100)); balance = balance + interest; totalInterest = totalInterest + interest; } if (skipIinterest == false) { db_lendingEntities dbSave = new db_lendingEntities(); tbl_loan_ledger tbl = new tbl_loan_ledger(); tbl.date_trans = _serverDateTime; tbl.trans_type = "Late Payment Interest"; tbl.reference_no = ""; tbl.loan_no = dt.loan_no; tbl.loan_type_name = dt.loan_name; tbl.customer_id = dt.customer_id; tbl.customer_name = dt.customer_name; tbl.interest_type = GetInterestType(dt.loan_name); tbl.interest_rate = dt.loan_interest_rate; tbl.interest = totalInterest; tbl.amount_paid = 0; tbl.principal = 0; tbl.balance = 0; tbl.date_created = DateTime.Now; tbl.created_by = Session["UserName"].ToString(); dbSave.tbl_loan_ledger.Add(tbl); dbSave.SaveChanges(); } } } } return(Json("Success", JsonRequestBehavior.AllowGet)); }
public JsonResult AddCustomer(tbl_customer_validation model) { try { db_lendingEntities db = new db_lendingEntities(); tbl_customer tbl = new tbl_customer(); if (model.date_registered != null) { tbl.customer_no = model.customer_no; } else { tbl.date_registered = model.date_registered; } // if (model.lastname != null) { tbl.lastname = model.lastname.ToUpper(); } else { } if (model.firstname != null) { tbl.firstname = model.firstname.ToUpper(); } else { } // if (model.middlename != null) { tbl.middlename = model.middlename.ToUpper(); } else { } if (model.civil_status != null) { tbl.civil_status = model.civil_status; } else { } if (model.address != null) { tbl.address = model.address.ToUpper(); } else { } if (model.contact_no != null) { tbl.contact_no = model.contact_no; } else { } if (model.email != null) { tbl.email = model.email; } else { } if (model.date_of_birth != null) { tbl.date_of_birth = model.date_of_birth; } else { } if (model.birth_place != null) { tbl.birth_place = model.birth_place.ToUpper(); } else { } if (model.occupation != null) { tbl.occupation = model.occupation.ToUpper(); } else { } if (model.credit_limit != null) { tbl.credit_limit = model.credit_limit; } else { } if (model.annual_income != null) { tbl.annual_income = model.annual_income; } else { } db.tbl_customer.Add(tbl); db.SaveChanges(); return(Json("Success", JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json("Failed", JsonRequestBehavior.DenyGet)); throw ex; } }