private void btnConfirm_Click(object sender, EventArgs e) { bool result = false; try { BLLLoanManager BLLMngr = new BLLLoanManager(); result = BLLMngr.ApproveLoanDetails(LoanToBeApproved); if (result == true) { MessageBox.Show("Loan Approved"); OnLoanAdded(true); this.Close(); } else { MessageBox.Show("Loan Not Approved"); } } catch (Exception ex) { MessageBox.Show(ex.Message); throw; } }
// method to filter loans based on loan status private void FilterListByStatus(string status) { try { BLLLoanManager BLLMngr = new BLLLoanManager(); List<Loan> LoanList = BLLMngr.CallGetListOfLoans(); LoanList = LoanList.Where((loan) => loan.LoanStatus == status).ToList(); dgvMainFormApplicant.Visible = false; dgvMainFormLoans.Visible = true; dgvMainFormLoans.DataSource = LoanList; LoansInDGV = LoanList; } catch (Exception ex) { MessageBox.Show(ex.Message); throw; } }
// method to filter loans between dates private void FilterListByDateRange(DateTime startDate, DateTime endDate) { try { BLLLoanManager BLLMngr = new BLLLoanManager(); List<Loan> LoanList = BLLMngr.CallGetListOfLoans(); LoanList = LoanList.Where((loan) => loan.LoanApplicationDate >= startDate && loan.LoanApplicationDate <= endDate).ToList(); dgvMainFormApplicant.Visible = false; dgvMainFormLoans.Visible = true; dgvMainFormLoans.DataSource = LoanList; LoansInDGV = LoanList; } catch (Exception ex) { MessageBox.Show(ex.Message); throw; } }
// method to sort loans by atb descending private void SortLoansByATBDesc() { try { BLLLoanManager BLLMngr = new BLLLoanManager(); List<Loan> LoanList = BLLMngr.CallGetListOfLoans(); LoanList = LoanList.OrderByDescending((loan) => loan.ATB).ToList(); dgvMainFormApplicant.Visible = false; dgvMainFormLoans.Visible = true; dgvMainFormLoans.DataSource = LoanList; LoansInDGV = LoanList; } catch (Exception ex) { MessageBox.Show(ex.Message); throw; } }
// sort loans by date ascending private void SortLoansByDateAsc() { try { BLLLoanManager BLLMngr = new BLLLoanManager(); List<Loan> LoanList = BLLMngr.CallGetListOfLoans(); LoanList.Sort((loan1, loan2) => loan1.LoanApplicationDate.CompareTo(loan2.LoanApplicationDate)); dgvMainFormApplicant.Visible = false; dgvMainFormLoans.Visible = true; dgvMainFormLoans.DataSource = LoanList; LoansInDGV = LoanList; } catch (Exception ex) { MessageBox.Show(ex.Message); throw; } }
// method to find applicant by lrn private void SearchLRNNumber(int lrn) { try { BLLApplicantManager BLLMngrApp = new BLLApplicantManager(); List<Applicant> ApplicantList = BLLMngrApp.CallGetListOfApplicants(); BLLLoanManager BLLMngrLoan = new BLLLoanManager(); List<Loan> LoanList = BLLMngrLoan.CallGetListOfLoans(); Loan getLoan = null; foreach (Loan loan in LoanList) { if (loan.LRN == lrn) { getLoan = loan; } } int crn = getLoan.CRN; ApplicantList = ApplicantList.Where((applicant) => applicant.CRN == crn).ToList(); dgvMainFormLoans.Visible = false; dgvMainFormApplicant.Visible = true; dgvMainFormApplicant.DataSource = ApplicantList; ApplicantsInDGV = ApplicantList; } catch (Exception ex) { MessageBox.Show(ex.Message); throw; } }
// returns selected loan object on datagridview private Loan GetSelectedLoan() { Loan SelectLoan = null; int lrn = 0; int ColumnIndex = 0; int RowIndex = 0; try { BLLLoanManager BLLMngr = new BLLLoanManager(); List<Loan> LoanList = BLLMngr.CallGetListOfLoans(); if (dgvMainFormLoans.SelectedRows.Count > 0) { RowIndex = dgvMainFormLoans.SelectedRows[0].Index; lrn = (int)dgvMainFormLoans.Rows[RowIndex].Cells[ColumnIndex].Value; for (int i = 0; i < LoanList.Count; i++) { if (LoanList[i].LRN == lrn) { SelectLoan = LoanList[i]; break; } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } return SelectLoan; }
// method which gets list of loans from database and populates a datagridview with them private void PrimeLoanListDGV() { try { BLLLoanManager BLLMngr = new BLLLoanManager(); List<Loan> LoanList = BLLMngr.CallGetListOfLoans(); dgvMainFormApplicant.Visible = false; dgvMainFormLoans.Visible = true; dgvMainFormLoans.DataSource = LoanList; LoansInDGV = LoanList; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
// confirm button private void btnConfirm_Click(object sender, EventArgs e) { Loan loan = GetLoanDetailsFromForm(); bool result = false; try { BLLLoanManager BLLMngr = new BLLLoanManager(); result = BLLMngr.NewLoanDetails(loan, CR); if (result == true) { MessageBox.Show("Loan Details Succesfully Recorded"); OnLoanAdded(true); this.Close(); } else { MessageBox.Show("Error: loan details not recorded"); } } catch (Exception ex) { MessageBox.Show(ex.Message); throw; } }
// method to check applicants eligibility for loan private void CheckNewApplicantLoan() { try { // decimal weeklyNetPay, decimal atb, int repaymentPeriod, string creditRating Loan loan = GetLoanDetailsFromForm(); if (validations == true) { decimal atb = loan.ATB; int repayPeriod = loan.RepaymentPeriod; BLLLoanManager BLLMngr = new BLLLoanManager(); bool resultOfEligibilityCheck; resultOfEligibilityCheck = BLLMngr.CheckEligibilityOfNewApp(CRN, WNP, atb, repayPeriod, CR); decimal monthlyRepayment = BLLMngr.GetMontlyRepayment(atb, repayPeriod, CR); if (resultOfEligibilityCheck == true) { //public decimal GetMontlyRepayment(decimal atb, int repaymentPeriod, string creditRating) txtMonthlyRepayment.Text = monthlyRepayment.ToString(); MessageBox.Show("Eligible for loan"); btnSubmit.Enabled = false; btnConfirm.Enabled = true; } else if (resultOfEligibilityCheck == false) { MessageBox.Show("Not eligible for loan"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void MakePaymentOnLoan() { bool result = false; bool isValid = true; BLLLoanManager BLLMngr = new BLLLoanManager(); try { decimal redemptionCharge = 0; decimal payment = 0; if (rBtnRegularPayment.Checked) { if (txtPayment.Text != null) { isValid = decimal.TryParse(txtPayment.Text, out payment); if (isValid) { LoanBeingPay.PaymentsMade += payment; LoanBeingPay.LoanBalance -= payment; LoanBeingPay.RepaymentPeriod = LoanBeingPay.RepaymentPeriod - 1; LoanBeingPay.LoanStatus = "Live"; } else { txtPayment.Text = "Invalid Entry"; } } else { MessageBox.Show("Error: must specify payment amount"); } } else if (rBtnOverpayment.Checked) { if (txtPayment.Text != null) { isValid = decimal.TryParse(txtPayment.Text, out payment); if (isValid) { redemptionCharge = BLLMngr.RedemptionCharge(LoanBeingPay, payment); LoanBeingPay.PaymentsMade += payment; LoanBeingPay.LoanBalance -= payment; LoanBeingPay.RepaymentPeriod = LoanBeingPay.RepaymentPeriod - 1; LoanBeingPay.LoanStatus = "LPIA"; MessageBox.Show("Redemption Charge: " + redemptionCharge.ToString()); } else { txtPayment.Text = "Invalid Entry"; } } else { MessageBox.Show("Error: must specify payment amount"); } } else if (rBtnPayOffBalance.Checked) { LoanBeingPay.PaymentsMade = LoanBeingPay.PaymentsMade + LoanBeingPay.LoanBalance; txtPayment.Text = LoanBeingPay.PaymentsMade.ToString(); LoanBeingPay.LoanBalance = 0; LoanBeingPay.RepaymentPeriod = 0; LoanBeingPay.OutstandingLoansValue = LoanBeingPay.OutstandingLoansValue - LoanBeingPay.PaymentsMade; LoanBeingPay.LoanStatus = "PIF"; } if (isValid) { result = BLLMngr.PassMakeLoanPayment(LoanBeingPay); if (result == true) { MessageBox.Show("Payment Details succesfully recorded"); OnLoanAdded(true); this.Close(); } else { MessageBox.Show("Error: payment details not recorded"); } } } catch(Exception ex) { MessageBox.Show(ex.Message); throw; } }
private void btnConfirm_Click(object sender, EventArgs e) { bool result; try { BLLLoanManager BLLMngr = new BLLLoanManager(); result = BLLMngr.PassUpdatedLoanDetails(LoanToUpdate); if (result == true) { MessageBox.Show("Loan Details Succesfully Recorded"); OnLoanAdded(true); this.Close(); } else { MessageBox.Show("Error: loan details not recorded"); } } catch (Exception ex) { MessageBox.Show(ex.Message); throw; } }
// method for checking is loan update is valid private void CheckLoanUpdateValidity() { bool isValid = GetUpdatedLoanDetails(); if (isValid) { decimal atb = LoanToUpdate.ATB; int repaymentPeriod = LoanToUpdate.RepaymentPeriod; decimal weeklyNetPay = AppSeekingLoanUpdate.WeeklyNetPay; int crn = AppSeekingLoanUpdate.CRN; string creditRating = AppSeekingLoanUpdate.CreditRating; BLLLoanManager BLLMngr = new BLLLoanManager(); bool resultOfEligibilityCheck; resultOfEligibilityCheck = BLLMngr.CheckEligibilityOfNewApp(crn, weeklyNetPay, atb, repaymentPeriod, creditRating); decimal monthlyRepayment = BLLMngr.GetMontlyRepayment(atb, repaymentPeriod, creditRating); if (resultOfEligibilityCheck == true) { //public decimal GetMontlyRepayment(decimal atb, int repaymentPeriod, string creditRating) txtMonthlyRepayment.Text = monthlyRepayment.ToString(); MessageBox.Show("Eligible for loan update"); btnSubmit.Enabled = false; btnConfirm.Enabled = true; } else if (resultOfEligibilityCheck == false) { MessageBox.Show("Not eligible for loan update"); } } }