private void btnApplyChanges_Click(object sender, EventArgs e) { decimal new_LoansAmt = 0; //decimal new_totalAmt; lstMonthlyDeductions.Items[0].SubItems[4].Text = lblTotalSavings.Text; if (txtChangeLoanAmount.Text == string.Empty) { lstMonthlyDeductions.Items[0].SubItems[5].Text = lblTotalLoans.Text; new_LoansAmt = Convert.ToDecimal(lblTotalLoans.Text); } else { if (decimal.TryParse(txtChangeLoanAmount.Text, out new_LoansAmt)) { if (Convert.ToDecimal(txtChangeLoanAmount.Text) > 0) { lstMonthlyDeductions.Items[0].SubItems[5].Text = CheckForNumber.formatCurrency2(txtChangeLoanAmount.Text); new_LoansAmt = Convert.ToDecimal(txtChangeLoanAmount.Text); } else { MessageBox.Show("The new Loan Amount entered is invalid", "Deduction Info", MessageBoxButtons.OK, MessageBoxIcon.Error); lstMonthlyDeductions.Items[0].SubItems[5].Text = lblTotalLoans.Text; new_LoansAmt = Convert.ToDecimal(lblTotalLoans.Text); } } } lstMonthlyDeductions.Items[0].SubItems[6].Text = CheckForNumber.formatCurrency2(Convert.ToString(Convert.ToDecimal(lblTotalSavings.Text) + new_LoansAmt)); }
private void txtChangeLoanAmount_Leave(object sender, EventArgs e) { if (!FieldValidator.isBlank(txtChangeLoanAmount.Text) && CheckForNumber.isNumeric(txtChangeLoanAmount.Text)) { txtChangeLoanAmount.Text = CheckForNumber.formatCurrency2(txtChangeLoanAmount.Text); } }
private void btnChangeLoanAmt_Click(object sender, EventArgs e) { decimal new_LoansAmt; decimal new_totalAmt; if (lstVwLoans.SelectedItems.Count > 0 && txtChangeLoanAmount.Text != string.Empty) { if (decimal.TryParse(txtChangeLoanAmount.Text, out new_LoansAmt)) { if (Convert.ToDecimal(txtChangeLoanAmount.Text) > 0) { lstMonthlyDeductions.Items[0].SubItems[5].Text = CheckForNumber.formatCurrency2(txtChangeLoanAmount.Text); new_totalAmt = Convert.ToDecimal(lstMonthlyDeductions.Items[0].SubItems[4].Text) + Convert.ToDecimal(lstMonthlyDeductions.Items[0].SubItems[5].Text); lstMonthlyDeductions.Items[0].SubItems[6].Text = CheckForNumber.formatCurrency2(new_totalAmt.ToString()); } else { MessageBox.Show("The Amount entered is invalid", "Deduction Info", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("The Amount entered is invalid", "Deduction Info", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Select a Loan and Supply a new Loan Amount", "Deduction Info", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }
private void txtAmount_TextChanged(object sender, EventArgs e) { if (txtAmount.Text != string.Empty) { if (CheckForNumber.isNumeric(txtAmount.Text.Trim()) == true) { decimal interestAmount = (Convert.ToDecimal(txtAmount.Text)) * ((Convert.ToDecimal(txtLoanInterestRate.Text)) / 100); txtInterestAmount.Text = CheckForNumber.formatCurrency(interestAmount.ToString()); decimal totalRepaymentAmount = Convert.ToDecimal(txtAmount.Text) + interestAmount; txtTotalRepaymentAmount.Text = CheckForNumber.formatCurrency(totalRepaymentAmount.ToString()); decimal monthRepayment = totalRepaymentAmount / Convert.ToInt16(txtLoanDuration.Text); txtMonthRepayment.Text = CheckForNumber.formatCurrency(monthRepayment.ToString()); //enable btnSaveApplication btnSaveApplication.Enabled = true; } else { MessageBox.Show("Sorry, Invalid value has been entered for Amount", "Loan Application", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { btnSaveApplication.Enabled = false; } }
private void getSavingStatus() { SqlConnection conn = ConnectDB.GetConnection(); string strQuery = "Select SUM(Amount) as TotalSavings from Savings where MemberID=" + memberID; SqlCommand cmd = new SqlCommand(strQuery, conn); try { conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { reader.Read(); lblFinancialStatus.Text = "Savings: " + CheckForNumber.formatCurrency2(reader["TotalSavings"].ToString()); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.Close(); } lblFinancialStatus.Visible = true; }
private void datGrdVwLoanApplications_CellClick(object sender, DataGridViewCellEventArgs e) { if (datGrdVwLoanApplications.SelectedRows.Count > 0) { lblAmountPaid.Text = string.Empty; lblOutstandingAmt.Text = string.Empty; lblRepaymentStatus.Text = string.Empty; //MessageBox.Show(e.ColumnIndex.ToString()); string amountPaid = datGrdVwLoanApplications.SelectedRows[0].Cells[14].Value.ToString(); string outstanding = datGrdVwLoanApplications.SelectedRows[0].Cells[15].Value.ToString(); string repaymentStatus = datGrdVwLoanApplications.SelectedRows[0].Cells[16].Value.ToString(); //MessageBox.Show(amountPaid.ToString()); if (amountPaid != string.Empty) { lblAmountPaid.Text = CheckForNumber.formatCurrency2(amountPaid); } if (outstanding != string.Empty) { lblOutstandingAmt.Text = CheckForNumber.formatCurrency2(outstanding); } lblRepaymentStatus.Text = repaymentStatus; if (amountPaid == string.Empty || outstanding == string.Empty) { btnViewDetails.Enabled = false; } else { btnViewDetails.Enabled = true; } } }
private void displayTotalOfDataSet() { SqlConnection conn = ConnectDB.GetConnection(); cmdTotal = new SqlCommand(totalContributionOfDataSet, conn); try { conn.Open(); SqlDataReader reader = cmdTotal.ExecuteReader(); if (reader.HasRows) { reader.Read(); lblTotalAmountOfDataSet.Text = "Total: " + CheckForNumber.formatCurrency2(reader["TotalAmount"].ToString()); } else { lblTotalAmountOfDataSet.Text = "Total: 0.0"; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.Close(); } }
private void btnUpdate_Click(object sender, EventArgs e) { if (lstVSavings.SelectedItems.Count == 0) { MessageBox.Show("Select a Savings Type to Edit Savings Amount", "Edit Member Savings", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (txtAmount.Text == string.Empty) { MessageBox.Show("Amount is Required to Effect an Update", "Edit Member Savings", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (CheckForNumber.isNumeric(txtAmount.Text)) { updateMemberSavings(); } else { MessageBox.Show("Amount Entered is Invalid", "Edit Member Savings", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void getSelectedDetailsTotalSavings(string strFilter) { SqlConnection conn = ConnectDB.GetConnection(); string strQuery = "Select SUM(Amount) as Total from Savings " + strFilter; SqlCommand cmd = new SqlCommand(strQuery, conn); //MessageBox.Show(strQuery); try { conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { if (reader.Read()) { lblSelectedSavingsTotal.Text = "Total Savings: " + CheckForNumber.formatCurrency2(reader["Total"].ToString()); } } } catch (Exception ex) { MessageBox.Show("Total Savings: " + ex.Message); } finally { conn.Close(); } }
private void txtWithdrawAmt_TextChanged(object sender, EventArgs e) { if (txtWithdrawAmt.Text != string.Empty) { if (CheckForNumber.isNumeric(txtWithdrawAmt.Text)) { decimal withdrawalAmt = Convert.ToDecimal(txtWithdrawAmt.Text); decimal balance = memberTotalSavingsByType - (withdrawalAmt); lblAmtBalance.Text = CheckForNumber.formatCurrency2(balance.ToString()); //Enable or disable btn based on balance if (balance >= 0 && withdrawalAmt > 0) { btnPost.Enabled = true; } else { btnPost.Enabled = false; } } else { MessageBox.Show("Invalid Amount has been supplied", "Withdrawal", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { btnPost.Enabled = false; } }
private void txtAmount_Leave(object sender, EventArgs e) { if (CheckForNumber.isNumeric(txtAmount.Text.Trim())) { txtAmount.Text = CheckForNumber.formatCurrency(txtAmount.Text.Trim()); } }
private void addSavingsIntoListView() { bool alreadyExist = false; if (lstVwSavings.Items.Count != 0) { for (int i = 0; i < lstVwSavings.Items.Count; i++) { if (lstVwSavings.Items[i].SubItems[1].Text.Trim() == cboSavingsAcct.Text) { alreadyExist = true; } } } if (alreadyExist == false) { String[] row = { cboSavingsAcct.SelectedValue.ToString(), cboSavingsAcct.Text, txtAmount.Text }; ListViewItem item = new ListViewItem(row); lstVwSavings.Items.Add(item); //Add amount to total totalAmount = Convert.ToDecimal(txtAmount.Text) + totalAmount; lblTotalSavings.Text = "Total: " + CheckForNumber.formatCurrency2(totalAmount.ToString()); } else { MessageBox.Show("That Savings Account has already been added", "Savings", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btnChangeSavingsAmt_Click(object sender, EventArgs e) { decimal new_SavingsAmount; decimal totalSavingsRecalculated = 0; if (lstVwSavings.SelectedItems.Count > 0 && txtChangeSavingsAmt.Text != string.Empty) { int lstCountItem = lstVwSavings.Items.Count; if (Decimal.TryParse(txtChangeSavingsAmt.Text, out new_SavingsAmount)) { lstVwSavings.SelectedItems[0].SubItems[2].Text = CheckForNumber.formatCurrency2(txtChangeSavingsAmt.Text); for (int i = 0; i < lstCountItem; i++) { totalSavingsRecalculated += Convert.ToDecimal(lstVwSavings.Items[i].SubItems[2].Text); } lblTotalSavings.Text = CheckForNumber.formatCurrency2(totalSavingsRecalculated.ToString()); } else { MessageBox.Show("The Amount entered is invalid", "Deduction Info", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Select an a Savings Type and Supply an Amount", "Deduction Info", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }
private void txtInterest_Leave(object sender, EventArgs e) { decimal totalRepayment; decimal monthlyRepayment; int duration = Convert.ToInt16(lblDuration.Text); if (txtInterest.Text != string.Empty && (CheckForNumber.isNumeric(txtInterest.Text))) { if (txtAmount.Text != string.Empty && (CheckForNumber.isNumeric(txtAmount.Text))) { totalRepayment = Convert.ToDecimal(txtAmount.Text) + Convert.ToDecimal(txtInterest.Text); monthlyRepayment = totalRepayment / duration; txtTotalRepayment.Text = CheckForNumber.formatCurrency2(totalRepayment.ToString()); txtInterest.Text = CheckForNumber.formatCurrency2(txtInterest.Text); txtMonthlyRepayment.Text = monthlyRepayment.ToString(); } else { MessageBox.Show("Enter a valid Capital to proceed", "Loans", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Invalid data entry", "Loans", MessageBoxButtons.OK, MessageBoxIcon.Error); txtInterest.Text = string.Empty; } }
private void loadDataSetMemberSavings() { SqlConnection conn = ConnectDB.GetConnection(); string strQuery = "Select m.Month, sf.Year, sf.Amount, sf.SavingSource, sf.TransactionID, sf.Date from Savings sf " + "left join MonthByName m on sf.Month=m.MonthID " + "where MemberID=" + memberID + " order by savingsID desc"; string strQuery2 = "Select Sum(Amount) as TotalSavings from Savings where MemberID=" + memberID; SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = strQuery; SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); try { conn.Open(); da.Fill(ds, "Savings"); DataTable dt = ds.Tables["Savings"]; dtGrdVwSavings.DataSource = dt; int rowFound = dtGrdVwSavings.Rows.Count; dtGrdVwSavings.Columns["Amount"].DefaultCellStyle.Format = "N2"; dtGrdVwSavings.Columns["Amount"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dtGrdVwSavings.Columns["Year"].Width = 60; dtGrdVwSavings.Columns["Month"].Width = 80; if (rowFound > 0) { cmd.CommandText = strQuery2; SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { reader.Read(); string totalSavings = CheckForNumber.formatCurrency(reader["TotalSavings"].ToString()); lblMemberTotalSavings.Text = "Total: " + totalSavings; reader.Close(); } else { lblMemberTotalSavings.Text = "Total: 0.00"; } } else { lblMemberTotalSavings.Text = "Total: 0.00"; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.Close(); } }
private void cboLoanType_SelectedIndexChanged(object sender, EventArgs e) { if (cboLoanType.SelectedIndex == 0) { txtAmount.Enabled = false; } else { txtAmount.Enabled = true; if (cboLoanType.SelectedIndex > 0) { SqlConnection conn = ConnectDB.GetConnection(); string strQuery = "Select LoanTypeID, Duration, InterestRate from LoanType " + "where LoanTypeID=" + cboLoanType.SelectedValue.ToString(); SqlCommand cmd = new SqlCommand(strQuery, conn); //MessageBox.Show(cboLoanType.SelectedValue.ToString()); try { conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { reader.Read(); string strDuration = reader["Duration"].ToString(); strInterestRate = reader["InterestRate"].ToString(); string strBoth = strDuration + " Months | " + strInterestRate + "%"; lblDuration.Text = strDuration; lblInterestRate.Text = strInterestRate; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.Close(); } //calculate if amount is not empty if ((txtAmount.Text != string.Empty) && (CheckForNumber.isNumeric(txtAmount.Text))) { txtAmount_Leave(sender, e); if ((txtAmountPaid.Text != string.Empty) && (CheckForNumber.isNumeric(txtAmountPaid.Text))) { txtAmountPaid_Leave(sender, e); } else { txtAmountPaid.Text = "0"; txtAmountPaid_Leave(sender, e); } } } } }
private void dtGrdVwSavings_CellContentClick(object sender, DataGridViewCellEventArgs e) { string savingsAcct; decimal savingsTotal = 0; btnUpdate.Enabled = true; //MessageBox.Show(e.ColumnIndex.ToString()); if (e.ColumnIndex == 5) { string transactionID = dtGrdVwSavings.Rows[e.RowIndex].Cells[3].Value.ToString(); grpBoxDetails.Text = "Savings Details [" + transactionID + "]"; lblSavingsID.Text = transactionID; SqlConnection conn = ConnectDB.GetConnection(); string strQuery = "Select SavingsForwardID, SavingsTypeID, Amount, Comment from SavingsForward where TransactionID='" + transactionID + "'"; SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = strQuery; lstVwSavingDetails.Items.Clear(); try { conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { if ((reader["SavingsTypeID"].ToString()) == "99") { savingsAcct = "Shares Savings"; } else { savingsAcct = getSavingsAcctName(reader["SavingsTypeID"].ToString()); } string[] row = { reader["SavingsForwardID"].ToString(), reader["SavingsTypeID"].ToString(), savingsAcct, CheckForNumber.formatCurrency2(reader["Amount"].ToString()), reader["Comment"].ToString() }; ListViewItem item = new ListViewItem(row); lstVwSavingDetails.Items.Add(item); savingsTotal = savingsTotal + Convert.ToDecimal(reader["Amount"].ToString()); } } lblSavingsTotal.Text = CheckForNumber.formatCurrency2(savingsTotal.ToString()); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.Close(); } } }
private void PostDeductions_Load(object sender, EventArgs e) { decimal loanMonthlyRepayment; int memberID; int counter; decimal totalDeduction; SqlConnection conn = ConnectDB.GetConnection(); string strQuery = "Select m.MemberID, m.FileNo, m.Title + ' ' + m.LastName + ' ' + m.FirstName + ' ' + m.MiddleName as Name, " + "SUM(s.Amount) as Amount from Members m inner join MemberSavingsTypeAcct s on m.MemberID=s.MemberID group by m.MemberID,m.FileNo,m.Title,m.FirstName,m.LastName,m.MiddleName"; SqlCommand cmd = new SqlCommand(strQuery, conn); try { conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { counter = 0; while (reader.Read()) { counter++; memberID = Convert.ToInt32(reader["MemberID"].ToString()); //Total Monthly Savings totalSavings = Convert.ToDecimal(reader["Amount"]); //check for loan records loanMonthlyRepayment = getMonthlyLoan(memberID); //calculate monthly total deduction using the total savings plus monthly loan repayment totalDeduction = loanMonthlyRepayment + totalSavings; //add data to the lstDeductions String[] row = { counter.ToString(), reader["MemberID"].ToString(), reader["FileNo"].ToString(), reader["Name"].ToString(), CheckForNumber.formatCurrency2(totalSavings.ToString()), CheckForNumber.formatCurrency2(loanMonthlyRepayment.ToString()), CheckForNumber.formatCurrency(totalDeduction.ToString()) }; ListViewItem item = new ListViewItem(row); lstDeductions.Items.Add(item); } reader.Close(); lblRecordNo.Text = "No. of Records: " + counter.ToString(); } } catch (Exception ex) { MessageBox.Show("Post Deductions: - " + ex.Message); } finally { conn.Close(); } }
private void txtAmount_Leave(object sender, EventArgs e) { if (txtAmount.Text != string.Empty) { if (CheckForNumber.isNumeric(txtAmount.Text)) { txtAmount.Text = CheckForNumber.formatCurrency2(txtAmount.Text); } btnPostSavings.Enabled = true; } }
private void txtTotalRepayment_Leave(object sender, EventArgs e) { if (!FieldValidator.isBlank(txtTotalRepayment.Text)) { txtTotalRepayment.Text = CheckForNumber.formatCurrency2(txtTotalRepayment.Text); } else { MessageBox.Show("Total Repayment Amount cannot be left blank.", "Loans", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void txtPayAmount_TextChanged(object sender, EventArgs e) { if (CheckForNumber.isNumeric(txtPayAmount.Text) && (txtPayAmount.Text != string.Empty)) { btnPostRepayment.Enabled = true; } else { btnPostRepayment.Enabled = false; } }
private void txtSavingsAmount_Leave(object sender, EventArgs e) { bool isNumeric = CheckForNumber.isNumeric(txtSavingsAmount.Text.Trim()); if (isNumeric) { txtSavingsAmount.Text = CheckForNumber.formatCurrency(txtSavingsAmount.Text.Trim()); } else { MessageBox.Show("The amount is invalid. Please enter numeric values.", "SetUp Member Savings", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void getSelectedLoanDetail(string transactionID) { SqlConnection conn = ConnectDB.GetConnection(); string strQuery = "Select l.LoansID as [Id], l.TransactionID as [Transact. ID], " + "a.TotalRepayment, l.AmountPaid, l.OutstandingAmount, a.ApprovalStatus, " + "a.StartRepaymentMonth, a.StartRepaymentYear, t.Type, t.Duration, t.InterestRate, a.LoanAmount, a.InterestAmount, a.MonthlyRepayment " + "from Loans l inner join LoanApplication a on l.TransactionID=a.TransactionID " + "left join LoanType t on a.LoanTypeID=t.LoanTypeID " + "where a.ApprovalStatus='Yes' " + "and a.TransactionID='" + transactionID + "' order by l.LoansID desc"; SqlCommand cmd = new SqlCommand(strQuery, conn); try { conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { if (reader.Read()) { //MessageBox.Show(reader["StartRepaymentMonth"].ToString()); txtStartRepayment.Text = DateFunction.getMonthByName(Convert.ToInt32(reader["StartRepaymentMonth"])) + " " + reader["StartRepaymentYear"].ToString(); txtLoanType.Text = reader["Type"].ToString(); txtDuration.Text = reader["Duration"].ToString(); txtInterestRate.Text = reader["InterestRate"].ToString(); txtLoanAmount.Text = CheckForNumber.formatCurrency(reader["LoanAmount"].ToString()); txtRepaymentAmount.Text = CheckForNumber.formatCurrency(reader["TotalRepayment"].ToString()); txtInterestAmount.Text = CheckForNumber.formatCurrency(reader["InterestAmount"].ToString()); txtMonthlyRepayment.Text = CheckForNumber.formatCurrency(reader["MonthlyRepayment"].ToString()); txtAmountPaid.Text = CheckForNumber.formatCurrency(reader["AmountPaid"].ToString()); txtOutstanding.Text = CheckForNumber.formatCurrency(reader["OutstandingAmount"].ToString()); //alignment of controls txtLoanAmount.TextAlign = HorizontalAlignment.Right; txtRepaymentAmount.TextAlign = HorizontalAlignment.Right; txtInterestAmount.TextAlign = HorizontalAlignment.Right; txtMonthlyRepayment.TextAlign = HorizontalAlignment.Right; txtAmountPaid.TextAlign = HorizontalAlignment.Right; txtOutstanding.TextAlign = HorizontalAlignment.Right; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.Close(); } }
private void txtEntryFee_Leave(object sender, EventArgs e) { string strValue = txtEntryFee.Text.Trim(); if (CheckForNumber.isNumeric(strValue)) { txtEntryFee.Text = CheckForNumber.formatCurrency(txtEntryFee.Text); } else { MessageBox.Show("Value entered for Entrance Fee is Invalid", "Invalid Data", MessageBoxButtons.OK, MessageBoxIcon.Error); txtEntryFee.Clear(); } }
private void btnRemoveSavings_Click(object sender, EventArgs e) { if (lstVwSavings.SelectedItems.Count > 0) { decimal selAmount = Convert.ToDecimal(lstVwSavings.SelectedItems[0].SubItems[2].Text.ToString()); totalAmount = totalAmount - selAmount; lblTotalSavings.Text = "Total: " + CheckForNumber.formatCurrency2(totalAmount.ToString()); lstVwSavings.Items.RemoveAt(lstVwSavings.SelectedIndices[0]); } else { MessageBox.Show("Please select an item to remove from the list", "Savings", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void calculateSavingsTotal() { decimal savingsTotal = 0; if (lstVwSavingDetails.Items.Count > 0) { for (int i = 0; i < lstVwSavingDetails.Items.Count; i++) { //MessageBox.Show(lstVwSavingDetails.Items[i].SubItems[2].Text.ToString()); savingsTotal = savingsTotal + Convert.ToDecimal(lstVwSavingDetails.Items[i].SubItems[3].Text.ToString()); } lblSavingsTotal.Text = CheckForNumber.formatCurrency2(savingsTotal.ToString()); } }
private void getLoansInfo(string memberID) { //decimal loanMonthlyPayment = 0; //get loan amount decimal serviceLoanAmount = Convert.ToDecimal(lstMonthlyDeductions.Items[0].SubItems[5].Text); if (serviceLoanAmount > 0) { SqlConnection conn = ConnectDB.GetConnection(); string sqlQuery = "Select a.MonthlyRepayment,l.RepaymentAmount,l.AmountPaid,l.OutstandingAmount, lt.Type, lt.LoanTypeID from LoanApplication a " + "inner join Loans l on a.LoanApplicationID = l.LoanApplicationID " + "inner join LoanType lt on a.LoanTypeID=lt.LoanTypeID " + "where a.MemberID=@MemberID and l.OutstandingAmount<>0"; SqlCommand cmd = new SqlCommand(sqlQuery, conn); cmd.Parameters.Add("@MemberID", SqlDbType.NVarChar, 20); cmd.Parameters["@MemberID"].Value = memberID; try { conn.Open(); SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleResult); lstVwLoans.Items.Clear(); if (reader.HasRows) { reader.Read(); string[] row = { CheckForNumber.formatCurrency2(reader["MonthlyRepayment"].ToString()), CheckForNumber.formatCurrency2(reader["RepaymentAmount"].ToString()), CheckForNumber.formatCurrency2(reader["AmountPaid"].ToString()), CheckForNumber.formatCurrency2(reader["OutstandingAmount"].ToString()), reader["Type"].ToString(), reader["LoanTypeID"].ToString() }; ListViewItem item = new ListViewItem(row); lstVwLoans.Items.Add(item); lblTotalLoans.Text = CheckForNumber.formatCurrency2(reader["MonthlyRepayment"].ToString()); } reader.Close(); } catch (Exception ex) { MessageBox.Show("Get Loans Info: - " + ex.Message); } finally { conn.Close(); } } }
private void btnAddSavings_Click(object sender, EventArgs e) { //check if the proper data has been entered if (txtAmount.Text != string.Empty) { if (CheckForNumber.isNumeric(txtAmount.Text.Trim())) { addSavingsIntoListView(); txtAmount.Text = string.Empty; } } else { MessageBox.Show("The Amount has to be filled in", "Savings", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void datGridViewSavings_CellContentClick(object sender, DataGridViewCellEventArgs e) { int memberID; string theID = null; string totalSavings = string.Empty; //MessageBox.Show(e.ColumnIndex.ToString()); if (e.ColumnIndex == 0) { theID = datGridViewSavings.Rows[e.RowIndex].Cells[1].Value.ToString(); totalSavings = datGridViewSavings.Rows[e.RowIndex].Cells[4].Value.ToString().Trim(); //MessageBox.Show("ID: " + theID + "total Savings: " + totalSavings); } else if (e.ColumnIndex == 4) { theID = datGridViewSavings.Rows[e.RowIndex].Cells[0].Value.ToString(); totalSavings = datGridViewSavings.Rows[e.RowIndex].Cells[4].Value.ToString().Trim(); //MessageBox.Show("ID: " + theID); } //MessageBox.Show(totalSavings.ToString()); if ((e.ColumnIndex == 0 || e.ColumnIndex == 4) && totalSavings != string.Empty) { //MessageBox.Show(e.ColumnIndex.ToString() + "ID: " + theID); if (CheckForNumber.isNumeric(theID)) { memberID = Convert.ToInt16(theID); strFilter = "where m.MemberID=" + memberID + addFilter; displayAllMembersSavingsDetails(strFilter); strFilter = "where MemberID=" + memberID + addFilter2; getSelectedDetailsTotalSavings(strFilter); } } else { MessageBox.Show("There is no Savings yet for the Selected Member", "View Savings", MessageBoxButtons.OK, MessageBoxIcon.Information); datGridSavingsDetails.DataSource = null; datGridSavingsDetails.Columns.Clear(); datGridSavingsDetails.Rows.Clear(); lblSelectedSavingsTotal.Text = "Total: 0.0"; lblSavingsRecordDetail.Text = "No. of Records: 0"; } }
private bool fieldVerification() { bool verificationStatus = true; string errMessage = string.Empty; if (cboFileNo.Text == "-- Select a File No. --") { errMessage += "Specify Member Applying for the Loan by entering Member File No.\n"; } if (cboCategory.Text == "-- Select a Loan Category --") { errMessage += "Select a Loan Category and then pick a Loan Type\n"; } if (cboType.Text == "-- Select a Loan Type --") { errMessage += "Select a Loan Type for this application\n"; } if (txtAmount.Text == string.Empty) { errMessage += "No Loan Amount has been specified\n"; } if (!CheckForNumber.isNumeric(txtAmount.Text)) { errMessage += "Loan Amount is in invalid format\n"; } if (txtFormFee.Text == string.Empty || (!CheckForNumber.isNumeric(txtFormFee.Text))) { errMessage += "Form Fee is in invalid format\n"; } if (errMessage != string.Empty) { verificationStatus = false; MessageBox.Show(errMessage, "Loan Application", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(verificationStatus); }