public void CarregarDadosGrid() { try { BLL.Cliente cat = new BLL.Cliente(); dataGridView1.DataSource = cat.Listar(textBox1.Text, 1).Tables[0]; // textBox1.Focus(); //a propriedade DATASOURCE do datagrid é a fonte de dados. Esta propriedade recebe (=) do objeto USU o método LISTAR usando como parametro o texto TEXT.TRIM().TOUPPER() digitado no TEXTBOX1. Esse DATASOURCE usará a tabela zero TABLES[0] do método LISTAR if (dataGridView1.Rows.Count == 0) { btnAlterar.Enabled = false; btnConsultar.Enabled = false; btnAtivar.Enabled = false; btnDesativar.Enabled = false; } else { btnAlterar.Enabled = true; btnConsultar.Enabled = true; btnAtivar.Enabled = true; btnDesativar.Enabled = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); //throw; } }
public void CarregarDadosGrid() { try { BLL.Cliente cli = new BLL.Cliente(); dataGridView1.DataSource = cli.Listar(textBox1.Text.Trim().ToUpper(), 1).Tables[0]; textBox1.Focus(); if (dataGridView1.Rows.Count == 0) { btnEditar.Enabled = false; btnConsultar.Enabled = false; btnDesativar.Enabled = false; btnAtivar.Enabled = false; btnExcluir.Enabled = false; } else { btnEditar.Enabled = true; btnConsultar.Enabled = true; btnDesativar.Enabled = true; btnAtivar.Enabled = true; btnExcluir.Enabled = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); //throw; } }
public void CarregarCombo(object o, EventArgs e) { BLL.Produto c = new BLL.Produto(); cbProduto.DataSource = c.ListarProdDisponiveis().Tables[0]; cbProduto.DisplayMember = "NomeProduto"; cbProduto.ValueMember = "CodigoProduto"; cbProduto.SelectedIndex = -1; BLL.Vendedor n = new BLL.Vendedor(); cbVendedor.DataSource = n.Listar(String.Empty, (byte)BLL.FuncoesGerais.TipoStatus.Ativo).Tables[0]; cbVendedor.DisplayMember = "NomeVendedor"; cbVendedor.ValueMember = "CodigoVendedor"; BLL.Cliente cl = new BLL.Cliente(); cbCliente.DataSource = cl.Listar(String.Empty, (byte)BLL.FuncoesGerais.TipoStatus.Ativo).Tables[0]; cbCliente.DisplayMember = "NomeCliente"; cbCliente.ValueMember = "CodigoCliente"; }