Exemplo n.º 1
0
        public void AddLoan(LoanUnit oUnit)
        {
            SqlCommand oCommand = new SqlCommand();

            oCommand.Connection = this.Connection;
            oCommand.CommandType = CommandType.StoredProcedure;

            oCommand.CommandText = "SP_INSERT_LOAN";

            oCommand.Parameters.Add(new SqlParameter("@DocNum", oUnit.DocumentNumber));
            oCommand.Parameters.Add(new SqlParameter("@CardCode", oUnit.CardCode));
            oCommand.Parameters.Add(new SqlParameter("@CardName", oUnit.CardName));
            oCommand.Parameters.Add(new SqlParameter("@TransType", oUnit.TransactionType));
            oCommand.Parameters.Add(new SqlParameter("@ModeOfPayment", oUnit.ModeOfPayment != null ? oUnit.ModeOfPayment : ""));
            oCommand.Parameters.Add(new SqlParameter("@Guarrantor", oUnit.Guarantor));
            oCommand.Parameters.Add(new SqlParameter("@LoanAmount", oUnit.LoanAmount));
            oCommand.Parameters.Add(new SqlParameter("@Terms", oUnit.Terms));
            oCommand.Parameters.Add(new SqlParameter("@InterestRate", oUnit.InterestRate));
            oCommand.Parameters.Add(new SqlParameter("@FreqOfPayment", oUnit.FrequencyOfPayment));
            oCommand.Parameters.Add(new SqlParameter("@PayDayCode", oUnit.PayDayCode));
            oCommand.Parameters.Add(new SqlParameter("@FirstPaymentDate", oUnit.FirstDateOfPayment));
            oCommand.Parameters.Add(new SqlParameter("@DateOfReleasing", oUnit.ReleaseDate));
            oCommand.Parameters.Add(new SqlParameter("@MonthlyPayment", oUnit.MonthlyPayment));
            oCommand.Parameters.Add(new SqlParameter("@NoOfPayment", oUnit.NumberOfPayment));
            oCommand.Parameters.Add(new SqlParameter("@TotalAmortization", oUnit.TotalAmortization));
            oCommand.Parameters.Add(new SqlParameter("@TotalInterest", oUnit.TotalInterest));
            oCommand.Parameters.Add(new SqlParameter("@DocStatus", oUnit.DocumentStatus));
            oCommand.Parameters.Add(new SqlParameter("@CreatedBy", oUnit.CreatedBy));
            oCommand.Parameters.Add(new SqlParameter("@DateCreated", oUnit.DateCreated));
            oCommand.Parameters.Add(new SqlParameter("@ModifiedBy", oUnit.ModifiedBy));
            oCommand.Parameters.Add(new SqlParameter("@DateModified", oUnit.DateModified));

            oCommand.ExecuteNonQuery();
        }
Exemplo n.º 2
0
        private void barSaveLoan_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (barSaveLoan.Caption == "Save")
            {
                LoanManager oConnectionManager = new LoanManager();
                LoanUnit oUnit = new LoanUnit();

                if (txtCardCode.Text == "")
                {
                    MessageBox.Show("Please select borrower before saving!!!", "Loan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                if (Convert.ToDouble(txtLoanAmount.EditValue) <= 0)
                {
                    MessageBox.Show("Please insert loan amount and click calculate button to generate schedule of payment!!!", "Loan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                if (this.LineScheduleOfPayment.Rows.Count <= 0)
                {
                    MessageBox.Show("Please click calculate button to generate schedule of payment!!!", "Loan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                txtLoanNo.Text = GetSeries();

                oConnectionManager.ConnectionString = this.ConnectionString;
                oConnectionManager.Open();

                if (oConnectionManager.IsExists(txtLoanNo.Text))
                {
                    MessageBox.Show("Loan Document Number is already exists!!!", "Exists", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                oUnit.DocumentNumber = txtLoanNo.Text;
                oUnit.CardCode = txtCardCode.Text;
                oUnit.CardName = txtCardName.Text;
                oUnit.TransactionType = cboTransType.Text;
                oUnit.Guarantor = txtGuarrantor.Text;
                oUnit.LoanAmount = Convert.ToDouble(txtLoanAmount.Text.Replace(",", ""));
                oUnit.Terms = Convert.ToInt16(txtTerms.Text);
                oUnit.InterestRate = Convert.ToDouble(txtInterestRate.Text);
                oUnit.FrequencyOfPayment = cboFrequencyOfPayment.EditValue.ToString();
                oUnit.PayDayCode = cboPayDayCode.EditValue != null ? cboPayDayCode.EditValue.ToString() : "";
                oUnit.FirstDateOfPayment = (DateTime)dtStartOfPayment.EditValue;
                oUnit.ReleaseDate = (DateTime)dtDateOfRelease.EditValue;
                oUnit.MonthlyPayment = Convert.ToDouble(string.Format("{0}", txtAmortization.Text));
                oUnit.NumberOfPayment = Convert.ToInt16(txtNoOfPayments.Text);
                oUnit.TotalAmortization = Convert.ToDouble(string.Format("{0}", txtTotalAmortization.Text));
                oUnit.TotalInterest = Convert.ToDouble(txtTotalInterest.Text);

                oUnit.DocumentStatus = txtStatus.Text;
                oUnit.CreatedBy = this.ActiveUserID;
                oUnit.DateCreated = (DateTime)dtCreated.EditValue;
                oUnit.ModifiedBy = txtModifiedBy.Text;
                oUnit.DateModified = (DateTime)dtModified.EditValue;

                oConnectionManager.AddLoan(oUnit);

                oConnectionManager.AddLineItems(txtLoanNo.Text, this.LineScheduleOfPayment);
                oConnectionManager.Close();

                barSaveLoan.Caption = "Update";
                txtLoanNo.Enabled = false;

                MessageBox.Show("Adding completed successfully!!!", "Add", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                LoanManager oConnectionManager = new LoanManager();
                LoanUnit oUnit = new LoanUnit();

                oConnectionManager.ConnectionString = this.ConnectionString;
                oConnectionManager.Open();
                oUnit.DocumentNumber = txtLoanNo.Text;
                oUnit.CardCode = txtCardCode.Text;
                oUnit.CardName = txtCardName.Text;
                oUnit.TransactionType = cboTransType.Text;
                oUnit.Guarantor = txtGuarrantor.Text;
                oUnit.LoanAmount = Convert.ToDouble(txtLoanAmount.Text.Replace(",", ""));
                oUnit.Terms = Convert.ToInt16(txtTerms.Text);
                oUnit.InterestRate = Convert.ToDouble(txtInterestRate.Text);
                oUnit.FrequencyOfPayment = cboFrequencyOfPayment.EditValue.ToString();
                oUnit.PayDayCode = cboPayDayCode.EditValue != null ? cboPayDayCode.EditValue.ToString() : "";
                oUnit.FirstDateOfPayment = (DateTime)dtStartOfPayment.EditValue;
                oUnit.ReleaseDate = (DateTime)dtDateOfRelease.EditValue;
                oUnit.MonthlyPayment = Convert.ToDouble(txtAmortization.Text.Replace(",", ""));
                oUnit.NumberOfPayment = Convert.ToInt16(txtNoOfPayments.Text);
                oUnit.TotalAmortization = Convert.ToDouble(txtTotalAmortization.Text.Replace(",", ""));
                oUnit.TotalInterest = Convert.ToDouble(txtTotalInterest.Text);
                oUnit.DocumentStatus = txtStatus.Text;
                oUnit.ModifiedBy = txtModifiedBy.Text;
                oUnit.DateModified = (DateTime)dtModified.EditValue;

                oConnectionManager.UpdateLoan(oUnit);

                oConnectionManager.DeleteLineItems(txtLoanNo.Text);
                oConnectionManager.AddLineItems(txtLoanNo.Text, this.LineScheduleOfPayment);

                oConnectionManager.Close();
                MessageBox.Show("Updating completed successfully!!!", "Update", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }