public void refresh()
 {
     try
     {
         ldtLoanApplication = loLoanApplication.getAllData("ViewAll", "", "");
         GlobalFunctions.refreshGrid(ref dgvList, ldtLoanApplication);
         viewDetails();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        private void LoanApplicationDetailsUI_Load(object sender, EventArgs e)
        {
            try
            {
                this.BackColor          = Color.FromArgb(int.Parse(GlobalVariables.FormBackColor));
                cboClient.DataSource    = loClient.getClientLists();
                cboClient.ValueMember   = "Id";
                cboClient.DisplayMember = "Client Name";
                cboClient.SelectedIndex = -1;

                cboBranch.DataSource    = loBranch.getAllData("ViewAll", "", "");
                cboBranch.ValueMember   = "Id";
                cboBranch.DisplayMember = "Description";
                cboBranch.SelectedIndex = -1;

                cboZone.DataSource    = loZone.getAllData("ViewAll", "", "");
                cboZone.ValueMember   = "Id";
                cboZone.DisplayMember = "Description";
                cboZone.SelectedIndex = -1;

                cboCollector.DataSource    = loCollector.getAllData("ViewAll", "", "");
                cboCollector.ValueMember   = "Id";
                cboCollector.DisplayMember = "Employee Name";
                cboCollector.SelectedIndex = -1;

                cboProduct.DataSource    = loProduct.getAllData("ViewAll", "", "");
                cboProduct.ValueMember   = "Id";
                cboProduct.DisplayMember = "Description";
                cboProduct.SelectedIndex = -1;

                cboPaymentFrequency.Text = "";
                txtTerms.Text            = "0";
                txtInterestRate.Text     = "0.00";
                txtServiceFeeRate.Text   = "0.00";

                if (lOperation == GlobalVariables.Operation.Edit)
                {
                    foreach (DataRow _dr in loLoanApplication.getAllData("", lLoanApplicationId, "").Rows)
                    {
                        txtLoanApplicationId.Text    = _dr["Loan Application Id"].ToString();
                        dtpDate.Value                = GlobalFunctions.ConvertToDate(_dr["Date"].ToString());
                        txtApplicationStatus.Text    = _dr["Application Status"].ToString();
                        txtLoanCycle.Text            = _dr["Loan Cycle"].ToString();
                        cboClient.SelectedValue      = _dr["ClientId"].ToString();
                        cboBranch.SelectedValue      = _dr["BranchId"].ToString();
                        cboZone.SelectedValue        = _dr["ZoneId"].ToString();
                        cboCollector.SelectedValue   = _dr["CollectorId"].ToString();
                        cboProduct.SelectedValue     = _dr["ProductId"].ToString();
                        cboPaymentFrequency.Text     = _dr["Payment Frequency"].ToString();
                        txtTerms.Text                = _dr["Terms"].ToString();
                        dtpStartDate.Value           = GlobalFunctions.ConvertToDate(_dr["Start Date"].ToString());
                        dtpMaturityDate.Value        = GlobalFunctions.ConvertToDate(_dr["Maturity Date"].ToString());
                        txtInterestRate.Text         = string.Format("{0:n}", decimal.Parse(_dr["Interest Rate"].ToString()));
                        txtServiceFeeRate.Text       = string.Format("{0:n}", decimal.Parse(_dr["Service Fee Rate"].ToString()));
                        txtLoanAmount.Text           = string.Format("{0:n}", decimal.Parse(_dr["Loan Amount"].ToString()));
                        txtInterestAmount.Text       = string.Format("{0:n}", decimal.Parse(_dr["Interest Amount"].ToString()));
                        txtTotalAmountDue.Text       = string.Format("{0:n}", decimal.Parse(_dr["Total Amount Due"].ToString()));
                        txtInstallmentAmountDue.Text = string.Format("{0:n}", decimal.Parse(_dr["Installment Amount Due"].ToString()));
                        txtServiceFeeAmount.Text     = string.Format("{0:n}", decimal.Parse(_dr["Service Fee Amount"].ToString()));
                        txtLoanReleaseAmount.Text    = string.Format("{0:n}", decimal.Parse(_dr["Loan Release Amount"].ToString()));
                        txtRemarks.Text              = _dr["Remarks"].ToString();
                    }
                }
                else
                {
                    txtApplicationStatus.Text = "In Progress";
                    txtLoanApplicationId.Text = "New";
                }
            }
            catch (Exception ex)
            {
                ErrorMessageUI em = new ErrorMessageUI(ex.Message, this.Name, "LoanApplicationDetailsUI_Load");
                em.ShowDialog();
                return;
            }
        }