private void DisplayData() { string vWhere = string.Empty; if (!string.IsNullOrEmpty(txtFilter.Text)) { vWhere = " AND ChartOfAccounts.AccountName Like '%" + txtFilter.Text + "%'"; } if (int.Parse(CmbFilter.SelectedValue.ToString()) > 0) { vWhere += " AND ChartOfAccounts.AccountType=" + CmbFilter.SelectedValue; } try { DAL.ChartOfAccounts objDAL = new DAL.ChartOfAccounts(); objDAL.connectionstring = vConnectionString; dt = objDAL.getRecord(vWhere); Grid.AutoGenerateColumns = false; Grid.DataSource = dt; } catch (Exception exc) { MessageBox.Show(exc.Message.ToString()); } }
private void PopulateCombos() { try { DataTable dt = new DataTable(); DAL.ChartOfAccounts obj = new DAL.ChartOfAccounts(); obj.connectionstring = vConnectionString; dt = obj.getRecord(string.Empty); DataRow dr = dt.NewRow(); dr["AccountNo"] = "0"; dr["AccountName"] = "ALL"; dr["AccountType"] = ""; dt.Rows.Add(dr); CmbFilter.DataSource = dt; CmbFilter.ValueMember = "AccountNo"; CmbFilter.DisplayMember = "AccountName"; CmbFilter.SelectedValue = "0"; CmbFilter.SelectedText = "ALL"; } catch (Exception exc) { MessageBox.Show(exc.Message); } }