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 txtChangeLoanAmount_Leave(object sender, EventArgs e) { if (!FieldValidator.isBlank(txtChangeLoanAmount.Text) && CheckForNumber.isNumeric(txtChangeLoanAmount.Text)) { txtChangeLoanAmount.Text = CheckForNumber.formatCurrency2(txtChangeLoanAmount.Text); } }
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 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 txtAmount_Leave(object sender, EventArgs e) { if (CheckForNumber.isNumeric(txtAmount.Text.Trim())) { txtAmount.Text = CheckForNumber.formatCurrency(txtAmount.Text.Trim()); } }
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 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 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 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 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 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 void txtWithdrawAmt_Leave(object sender, EventArgs e) { if (txtWithdrawAmt.Text != string.Empty) { if (CheckForNumber.isNumeric(txtWithdrawAmt.Text)) { txtWithdrawAmt.Text = CheckForNumber.formatCurrency2(txtWithdrawAmt.Text); } else { MessageBox.Show("Invalid Amount has been supplied", "Withdrawal", MessageBoxButtons.OK, MessageBoxIcon.Error); txtWithdrawAmt.Text = string.Empty; } } else { MessageBox.Show("Amount has not been supplied", "Withdrawal", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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); }
private void txtAmountPaid_Leave(object sender, EventArgs e) { if (!FieldValidator.isBlank(txtAmountPaid.Text) && CheckForNumber.isNumeric(txtAmountPaid.Text)) { decimal totalAmountRepayment = Convert.ToDecimal(txtTotalRepayment.Text); decimal amountPaid = Convert.ToDecimal(txtAmountPaid.Text); decimal outstandingAmount; if (amountPaid > totalAmountRepayment) { MessageBox.Show("Sorry, that Amount Paid exceeds the Total Repayment Amount.", "Loans", MessageBoxButtons.OK, MessageBoxIcon.Error); txtAmountPaid.Text = string.Empty; } else { txtAmountPaid.Text = CheckForNumber.formatCurrency2(txtAmountPaid.Text); outstandingAmount = totalAmountRepayment - amountPaid; txtOutstandingAmt.Text = CheckForNumber.formatCurrency2(outstandingAmount.ToString()); //check outstanding amount and set paymentStatus if (outstandingAmount == 0) { paymentStatus = "PAID"; paymentFinished = "Yes"; dateFinishedPayment = dtPickerPaymentFinished.Value.ToString(); lblPaymentFinishedDate.Visible = true; dtPickerPaymentFinished.Visible = true; } else { paymentStatus = "Paying"; paymentFinished = "No"; dateFinishedPayment = string.Empty; lblPaymentFinishedDate.Visible = false; dtPickerPaymentFinished.Visible = false; } } } }
private void txtAmount_Leave(object sender, EventArgs e) { if (CheckForNumber.isNumeric(txtAmount.Text.Trim())) { decimal amount = Convert.ToDecimal(txtAmount.Text); if (amount > 0) { txtAmount.Text = CheckForNumber.formatCurrency(txtAmount.Text); } else { MessageBox.Show("Amount entered is Invalid.\nAmount should not be zero or less than.", "Make Contributions", MessageBoxButtons.OK, MessageBoxIcon.Error); txtAmount.Text = string.Empty; } } else { MessageBox.Show("Amount entered is Invalid.\nAmount should be numeric.", "Make Contributions", MessageBoxButtons.OK, MessageBoxIcon.Error); txtAmount.Text = string.Empty; } }
private void txtAmount_Leave(object sender, EventArgs e) { if (txtAmount.Text != string.Empty && (CheckForNumber.isNumeric(txtAmount.Text))) { if (Convert.ToDecimal(txtAmount.Text) > 0) { txtAmountPaid.Enabled = true; decimal loanAmount = Convert.ToDecimal(txtAmount.Text); decimal interestRate = Convert.ToDecimal(lblInterestRate.Text); string strDuration = lblDuration.Text; decimal duration = decimal.Parse(strDuration); decimal totalRepayment; decimal monthlyRepayment; decimal interestAmount = loanAmount * (interestRate / 100); txtInterest.Text = CheckForNumber.formatCurrency2(interestAmount.ToString()); totalRepayment = loanAmount + interestAmount; monthlyRepayment = totalRepayment / duration; txtTotalRepayment.Text = CheckForNumber.formatCurrency2(totalRepayment.ToString()); txtAmount.Text = CheckForNumber.formatCurrency2(txtAmount.Text); txtMonthlyRepayment.Text = CheckForNumber.formatCurrency2(monthlyRepayment.ToString()); } else { txtAmountPaid.Enabled = false; MessageBox.Show("The Amount is required to proceed", "Loans", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { txtAmountPaid.Text = string.Empty; txtAmountPaid.Enabled = false; } }
private void txtPayAmount_Leave(object sender, EventArgs e) { if (CheckForNumber.isNumeric(txtPayAmount.Text)) { txtPayAmount.Text = CheckForNumber.formatCurrency(txtPayAmount.Text); btnPostRepayment.Enabled = true; int loanSize = loanServicing.Count - 1; int loopTimes = 0; decimal amountToPay; decimal totalRepaymentAmount; decimal amountPaidAlready; decimal outstanding; decimal newOutstanding; decimal newAmountPaid; decimal excess = 0; string servicingTransactionID = string.Empty; totalRepaymentAmount = Convert.ToDecimal(txtServicingRepaymentAmt.Text); amountPaidAlready = Convert.ToDecimal(txtServicingAmtPaid.Text); amountToPay = Convert.ToDecimal(txtPayAmount.Text); outstanding = totalRepaymentAmount - amountPaidAlready; txtExtraFeedback.Text = string.Empty; txtPaymentStatus.Text = string.Empty; txtCalAmountPaid.Text = string.Empty; while (loanSize >= 0) { loopTimes++; if (amountToPay <= outstanding) { newAmountPaid = amountToPay + amountPaidAlready; newOutstanding = totalRepaymentAmount - (newAmountPaid); if (excess == 0) { txtCalOutstanding.Text = CheckForNumber.formatCurrency(newOutstanding.ToString()); txtCalAmountPaid.Text = CheckForNumber.formatCurrency(newAmountPaid.ToString()); } txtExtraFeedback.Text += "\n\n------------------------"; txtExtraFeedback.Text += servicingTransactionID + Environment.NewLine + "Repayment: " + CheckForNumber.formatCurrency(totalRepaymentAmount.ToString()) + Environment.NewLine; txtExtraFeedback.Text += "Paying: " + CheckForNumber.formatCurrency(amountToPay.ToString()) + Environment.NewLine; txtExtraFeedback.Text += "Outstanding: " + CheckForNumber.formatCurrency(newOutstanding.ToString()) + Environment.NewLine; if (newOutstanding == 0) { txtPaymentStatus.Text = "Paid"; } else { txtPaymentStatus.Text = "Paying"; } break; } else { //newAmountPaid = amountToPay + totalRepaymentAmount; decimal noteAmountPaid; noteAmountPaid = amountToPay; excess = amountToPay - outstanding; amountToPay = excess; //MessageBox.Show("Amount Paid: " + totalRepaymentAmount.ToString()); //MessageBox.Show("Excess: " + excess); txtCalOutstanding.Text = "0.00"; txtCalAmountPaid.Text += totalRepaymentAmount + ", "; txtPaymentStatus.Text = "Paid"; txtExtraFeedback.Text += "\n\n------------------------"; txtExtraFeedback.Text += servicingTransactionID + Environment.NewLine + "Repayment: " + CheckForNumber.formatCurrency(totalRepaymentAmount.ToString()) + Environment.NewLine; txtExtraFeedback.Text += "Paying: " + CheckForNumber.formatCurrency(noteAmountPaid.ToString()) + Environment.NewLine; txtExtraFeedback.Text += "Excess: " + CheckForNumber.formatCurrency(excess.ToString()) + Environment.NewLine; } loanSize--; if (loanSize < 0) { if (excess > 0) { txtExtraFeedback.Text += "\n\n------------------------"; txtExtraFeedback.Text += "Savings Deposit: " + CheckForNumber.formatCurrency(excess.ToString()); } break; } SqlConnection conn = ConnectDB.GetConnection(); servicingTransactionID = loanServicing[loanSize]; servicingTransactionID = servicingTransactionID.Substring(servicingTransactionID.IndexOf("-") + 1).Trim(); string strQuery2 = "Select RepaymentAmount,OutstandingAmount,AmountPaid from Loans where TransactionID='" + servicingTransactionID + "'"; SqlCommand cmdQuery = new SqlCommand(strQuery2, conn); conn.Open(); SqlDataReader reader = cmdQuery.ExecuteReader(); reader.Read(); outstanding = Convert.ToDecimal(reader["OutstandingAmount"]); totalRepaymentAmount = Convert.ToDecimal(reader["RepaymentAmount"]); amountPaidAlready = Convert.ToDecimal(reader["AmountPaid"]); } } else { txtCalAmountPaid.Clear(); txtCalOutstanding.Clear(); } }
private void btnPost_Click(object sender, EventArgs e) { if (CheckForNumber.isNumeric(txtWithdrawAmt.Text) && (Convert.ToDecimal(txtWithdrawAmt.Text) > 0)) { DialogResult res = MessageBox.Show("Do you wish to post this Transaction?", "Withdrawal", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { #region ExecutePost string strMonth = dateTimePicker1.Value.Month.ToString(); string strYear = dateTimePicker1.Value.Year.ToString(); string transactionID = "WIT" + DateTime.Now.ToString("ddMMyyhhmmss"); SqlConnection conn = ConnectDB.GetConnection(); conn.Open(); SqlTransaction mySqlTrans = conn.BeginTransaction(); string strInsertSavings = "Insert into Savings(MemberID,SavingSource,Amount,Month,Year,TransactionID)values(@MemberID," + "@SavingSource,@Amount,@Month,@Year,@TransactionID)"; string strInsertSavingsWithdrawal = "Insert into SavingsWithdrawal(SavingsID,MemberID,SavingsTypeID,Amount," + "WithdrawAmount,Balance)values(@SavingsID,@MemberID,@SavingsTypeID,@Amount,@WithdrawalAmount,@Balance)"; string strQuery = "Select SavingsID from Savings where TransactionID=@TransactionID"; SqlCommand cmd = conn.CreateCommand(); cmd.Transaction = mySqlTrans; cmd.CommandType = CommandType.Text; cmd.CommandText = strInsertSavings; #region cmdParameters cmd.Parameters.Add("@MemberID", SqlDbType.Int); cmd.Parameters["@MemberID"].Value = memberID; cmd.Parameters.Add("@SavingSource", SqlDbType.NVarChar, 50); cmd.Parameters["@SavingSource"].Value = "Withdrawal"; cmd.Parameters.Add("@Amount", SqlDbType.Decimal); cmd.Parameters["@Amount"].Value = "-" + txtWithdrawAmt.Text; cmd.Parameters.Add("@Month", SqlDbType.NVarChar, 50); cmd.Parameters["@Month"].Value = strMonth; cmd.Parameters.Add("@Year", SqlDbType.NVarChar, 50); cmd.Parameters["@Year"].Value = strYear; cmd.Parameters.Add("@TransactionID", SqlDbType.NVarChar, 30); cmd.Parameters["@TransactionID"].Value = transactionID; #endregion cmdParameters try { int rowAffected = cmd.ExecuteNonQuery(); if (rowAffected > 0) { cmd.CommandText = strQuery; cmd.Parameters["@TransactionID"].Value = transactionID; int savingsID = Convert.ToInt16(cmd.ExecuteScalar()); cmd.CommandText = strInsertSavingsWithdrawal; #region cmdParameters - strInsertSavingsWithrawal cmd.Parameters.Add("@SavingsID", SqlDbType.Int); cmd.Parameters["@SavingsID"].Value = savingsID; cmd.Parameters["@MemberID"].Value = memberID; cmd.Parameters.Add("@SavingsTypeID", SqlDbType.Int); cmd.Parameters["@SavingsTypeID"].Value = cboSavingsType.SelectedValue; cmd.Parameters["@Amount"].Value = lblAcctAmount.Text; cmd.Parameters.Add("@WithdrawalAmount", SqlDbType.Decimal); cmd.Parameters["@WithdrawalAmount"].Value = txtWithdrawAmt.Text; cmd.Parameters.Add("@Balance", SqlDbType.Decimal); cmd.Parameters["@Balance"].Value = lblAmtBalance.Text; #endregion rowAffected = cmd.ExecuteNonQuery(); if (rowAffected > 0) { mySqlTrans.Commit(); MessageBox.Show("Transaction is Successfully Posted", "Withdrawal", MessageBoxButtons.OK, MessageBoxIcon.Information); string logDescription = cboSavingsType.Text + " withdrawal of " + txtWithdrawAmt.Text + " from Member with ID " + memberID; txtWithdrawAmt.Text = string.Empty; txtWithdrawAmt.Enabled = false; btnPost.Enabled = false; getPreviousWithdrawals(); ActivityLog.logActivity(UserID, "Withdrawal", logDescription); } else { mySqlTrans.Rollback(); MessageBox.Show("An error has occurred!", "Withdrawal", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { mySqlTrans.Rollback(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.Close(); } #endregion } } else { MessageBox.Show("Withdrawal Amount has not been Supplied", "Withdrawal", MessageBoxButtons.OK, MessageBoxIcon.Information); } }