private void btnCancel_Click(object sender, EventArgs e) { try { if (!GlobalFunctions.checkRights("tsmLoanApplication", "Cancel")) { return; } DataTable _dt = loLoanApplication.getLoanApplicationStatus(dgvList.CurrentRow.Cells[0].Value.ToString()); if (_dt.Rows.Count > 0) { foreach (DataRow _drStatus in _dt.Rows) { if (_drStatus[0].ToString() == "In Process") { MessageBoxUI _mbStatus = new MessageBoxUI("Only APPROVED application can be Cancelled!", GlobalVariables.Icons.Warning, GlobalVariables.Buttons.OK); _mbStatus.ShowDialog(); return; } else if (_drStatus[0].ToString() == "Cancelled") { MessageBoxUI _mbStatus = new MessageBoxUI("Loan application is already CANCELLED!", GlobalVariables.Icons.Warning, GlobalVariables.Buttons.OK); _mbStatus.ShowDialog(); return; } else if (_drStatus[0].ToString() == "Posted") { MessageBoxUI _mbStatus = new MessageBoxUI("You cannot cancel a POSTED application!", GlobalVariables.Icons.Warning, GlobalVariables.Buttons.OK); _mbStatus.ShowDialog(); return; } } } else { MessageBoxUI _mbStatus = new MessageBoxUI("Loan Application Id does not exist!", GlobalVariables.Icons.Warning, GlobalVariables.Buttons.OK); _mbStatus.ShowDialog(); return; } if (dgvList.Rows.Count > 0) { DialogResult _dr = new DialogResult(); MessageBoxUI _mb = new MessageBoxUI("Are sure you want to continue cancelling this Loan Application?", GlobalVariables.Icons.QuestionMark, GlobalVariables.Buttons.YesNo); _mb.ShowDialog(); _dr = _mb.Operation; if (_dr == DialogResult.Yes) { LendingCancelReasonUI loLendingCancelReason = new LendingCancelReasonUI(); loLendingCancelReason.ShowDialog(); if (loLendingCancelReason.lReason == "") { MessageBoxUI _mb1 = new MessageBoxUI("You must have a reason in cancelling entry!", GlobalVariables.Icons.Error, GlobalVariables.Buttons.OK); _mb1.ShowDialog(); return; } else { if (loLoanApplication.cancel(dgvList.CurrentRow.Cells[0].Value.ToString(), loLendingCancelReason.lReason)) { MessageBoxUI _mb1 = new MessageBoxUI("Loan Application record has been successfully cancelled!", GlobalVariables.Icons.Information, GlobalVariables.Buttons.OK); _mb1.ShowDialog(); refresh(); } } } } } catch (Exception ex) { ErrorMessageUI em = new ErrorMessageUI(ex.Message, this.Name, "btnApprove_Click"); em.ShowDialog(); return; } }