private void btnApprove_Click(object sender, EventArgs e) { try { if (!GlobalFunctions.checkRights("tsmLoanApplication", "Approve")) { 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() == "Approved") { MessageBoxUI _mbStatus = new MessageBoxUI("Loan application is already APPROVED!", GlobalVariables.Icons.Warning, GlobalVariables.Buttons.OK); _mbStatus.ShowDialog(); return; } else if (_drStatus[0].ToString() == "Cancelled") { MessageBoxUI _mbStatus = new MessageBoxUI("You cannot approve a CANCELLED application!", GlobalVariables.Icons.Warning, GlobalVariables.Buttons.OK); _mbStatus.ShowDialog(); return; } else if (_drStatus[0].ToString() == "Posted") { MessageBoxUI _mbStatus = new MessageBoxUI("You cannot approve 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 approving this Loan Application record?", GlobalVariables.Icons.QuestionMark, GlobalVariables.Buttons.YesNo); _mb.ShowDialog(); _dr = _mb.Operation; if (_dr == DialogResult.Yes) { try { if (loLoanApplication.approve(dgvList.CurrentRow.Cells[0].Value.ToString())) { MessageBoxUI _mb1 = new MessageBoxUI("Loan Application record has been successfully approved!", GlobalVariables.Icons.Information, GlobalVariables.Buttons.OK); _mb1.ShowDialog(); refresh(); } } catch (Exception ex) { MessageBoxUI mb = new MessageBoxUI(ex, GlobalVariables.Icons.Error, GlobalVariables.Buttons.OK); mb.ShowDialog(); return; } } } } catch (Exception ex) { ErrorMessageUI em = new ErrorMessageUI(ex.Message, this.Name, "btnApprove_Click"); em.ShowDialog(); return; } }