private void btnSave_Click(object sender, EventArgs e) { if (txtNumber.Text.Trim().Equals("")) { MessageBox.Show("Select application from application list", "Select application", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); dgvLoanList.Focus(); } else if (txtAmount.Text.Trim().Equals("") || txtAmount.Text.Trim().Equals("0")) { MessageBox.Show("Enter loan amount", "Enter loan amount", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); txtAmount.Focus(); } else if (cmbEmi.SelectedIndex == -1) { MessageBox.Show("Select number of loan EMI count", "Loan EMI count", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); cmbEmi.Focus(); } else if (txtEvidenceNumber.Text.Trim().Equals("") || txtEvidenceNumber2.Text.Trim().Equals("")) { MessageBox.Show("Select both guarantor", "Select both guarantor", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else if (!txtEvidenceNumber.Text.Trim().Equals("") && !txtEvidenceNumber2.Text.Trim().Equals("") && txtEvidenceNumber.Text.Trim().Equals(txtEvidenceNumber2.Text.Trim())) { MessageBox.Show("Both guarantor should be different", "Both Guarantor", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { try { Loan _obj = new Loan(); if (_obj.CheckLoanRunning(Convert.ToInt32(txtNumber.Text.Trim()))) { MessageBox.Show("Old loan is still running for member", "Old loan is still running", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { string strXML = CreateInsertXML(); bool blnSuccess = false; string strPaymentId = string.Empty; int loanId = 0; blnSuccess = _obj.AddNewLoan(strXML, Convert.ToInt32(cmbEmi.Text.Trim()) + 4, out loanId, out strPaymentId); if (blnSuccess) { MessageBox.Show("New loan added successfully!", "New loan added", MessageBoxButtons.OK, MessageBoxIcon.Information); LoanApplicationForm loanApplication = new LoanApplicationForm(loanId); loanApplication.ShowDialog(); PaymentReceipt receipt = new PaymentReceipt(strPaymentId); receipt.ShowDialog(); btnClear_Click(sender, e); } else { MessageBox.Show("Transaction failed. Try again later", "Transaction failed", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } } catch (Exception ex) { MessageBox.Show("Transaction failed. Try again later", "Transaction failed", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); LogError.LogEvent("", ex.Message, "Add New Loan"); } } }