private void btnSubmit_Click(object sender, EventArgs e)
        {
            Loan loan = new Loan();
            Decimal loanAmount;
            Decimal.TryParse(txtLoanAmount.Text, out loanAmount);
            loan.Amount = loanAmount;
            loan.Type = (LoanType)cmbLoanType.SelectedIndex;

            Applicant applicant = new Applicant();
            applicant.Name = txtName.Text;
            applicant.SSN = txtSSN.Text;
            applicant.Gender = (GenderType)cmbGender.SelectedIndex;
            applicant.Loans.Add(loan);

            try {
                ApplicantManager.Save(applicant);
            } catch(OracleException oraEx){
                string errorMessage = oraEx.Message;
                errorMessage = errorMessage.Substring(0, errorMessage.IndexOf("\n"));
                errorMessage = errorMessage.Substring(errorMessage.IndexOf(":") + 1);
                errorMessage = errorMessage.Trim();
                MessageBox.Show(errorMessage);
            }

            BindDataGrid();
        }
Beispiel #2
0
 public static int Save(Loan loan, OracleConnection oraDbConn, OracleTransaction oraTrans)
 {
     if(loan.Id == null){
         return Insert(loan, oraDbConn, oraTrans);
     } else {
         return Update(loan);
     }
 }
Beispiel #3
0
 private static Loan FillDataRecord(IDataRecord myDataRecord)
 {
     Loan loan = new Loan();
     loan.Id = myDataRecord.GetInt32(myDataRecord.GetOrdinal("Id"));
     loan.ApplicantId = myDataRecord.GetInt32(myDataRecord.GetOrdinal("ApplicantID"));
     loan.Amount = myDataRecord.GetDecimal(myDataRecord.GetOrdinal("Amount"));
     loan.Type = (LoanType)myDataRecord.GetInt32(myDataRecord.GetOrdinal("Type"));
     return loan;
 }
Beispiel #4
0
        private static int Insert(Loan loan, OracleConnection oraDbConn, OracleTransaction oraTrans)
        {
            int LoanId = 0;

            using (OracleCommand insertLoanCommand = new OracleCommand()) {
                insertLoanCommand.CommandType = CommandType.StoredProcedure;
                insertLoanCommand.CommandText = "LoansPKG.insertLoan";
                insertLoanCommand.Connection = oraDbConn;
                insertLoanCommand.Transaction = oraTrans;

                insertLoanCommand.Parameters.AddWithValue("AppId", loan.ApplicantId);
                insertLoanCommand.Parameters.AddWithValue("LoanType", loan.Type);
                insertLoanCommand.Parameters.AddWithValue("LoanAmount", loan.Amount);

                OracleParameter outputLoanId = new OracleParameter("LoanId", OracleType.Number);
                outputLoanId.Direction = ParameterDirection.Output;
                insertLoanCommand.Parameters.Add(outputLoanId);
                insertLoanCommand.ExecuteNonQuery();
                LoanId = Convert.ToInt32(outputLoanId.Value);
            }

            return LoanId;
        }
Beispiel #5
0
 private static int Update(Loan loan)
 {
     throw new NotImplementedException();
 }
 public static int Save(Loan loan, OracleConnection oraDbConn, OracleTransaction oraTrans)
 {
     loan.Id = LoanDB.Save(loan, oraDbConn, oraTrans);
     return (int)loan.Id;
 }