private void PopulateFields(string _loaNo) { ClearFields(); foreach (DataRow dr in ClsPEZAData.GetLOArequestByNumber(_loaNo).Rows) { tbLOANo.Text = dr["LOAno"].ToString().Trim(); dateEncoded.SelectedDate = Convert.ToDateTime(dr["LOAdate"]); cboPurpose.SelectedValue = dr["LOAtype"].ToString().Trim(); if (cboPurpose.SelectedValue.ToString().Trim() == "SC" || cboPurpose.SelectedValue.ToString().Trim() == "XX") { cboCustomer.ItemsSource = null; cboCustomer.ItemsSource = ClsPEZAData.GetSubContractorListFromCustomerMaster().DefaultView; int id = Convert.ToInt32(dr["LOAclient"]); cboCustomer.SelectedValue = id.ToString(); foreach (DataRow dr2 in ClsCantierDB.GetVendorAddress(id).Rows) { tbCustomerAddress.Text = dr2["Address"].ToString().Trim(); } } else { cboCustomer.ItemsSource = null; cboCustomer.ItemsSource = ClsCantierDB.GetCustomerList().DefaultView; cboCustomer.SelectedIndex = 0; int id = Convert.ToInt32(dr["LOAclient"]); cboCustomer.SelectedValue = id.ToString(); foreach (DataRow dr1 in ClsCantierDB.GetCustomerAddress(id).Rows) { tbCustomerAddress.Text = dr1["Address"].ToString().Trim(); } } tbSuretyBondNo.Text = dr["LoaBondNo"].ToString(); tbORNo.Text = dr["LOA_ORno"].ToString().Trim(); if (dr.IsNull("LOAdatePaid")) { datePayment.SelectedDate = null; } else { datePayment.SelectedDate = Convert.ToDateTime(dr["LOAdatePaid"]); } tbAmount.Text = dr["LOAamt"].ToString().Trim(); if (dr.IsNull("LOAexp")) { dateLOAExpire.SelectedDate = null; } else { dateLOAExpire.SelectedDate = Convert.ToDateTime(dr["LOAexp"]); } if (dr.IsNull("LOAbondExpDate")) { dateBondExp.SelectedDate = null; } else { dateBondExp.SelectedDate = Convert.ToDateTime(dr["LOAbondExpDate"]); } if (dr["LOAstatus"].ToString().Trim() == "A") { cboStatus.SelectedIndex = 0; } else if (dr["LOAstatus"].ToString().Trim() == "C") { cboStatus.SelectedIndex = 1; } else { cboStatus.SelectedIndex = -1; } PopulateLOAItemLists(_loaNo.Trim()); } PopulateCurrency(); ComputeTotalAmount(); }