public void CarregarDadosGrid()
        {
            try
            {
                BLL.Categoria cat = new BLL.Categoria();
                dataGridView1.DataSource = cat.Listar(textBox1.Text).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;
            }
        }
예제 #2
0
 private void CarregarCombo(object o, EventArgs e)
 {
     BLL.Categoria c = new BLL.Categoria();
     cbCat.DataSource    = c.Listar(String.Empty).Tables[0];
     cbCat.DisplayMember = "Descricao";
     cbCat.ValueMember   = "CategoriaID";
 }
        private void CarregarCombos(object o, EventArgs e)
        {
            BLL.Categoria c = new BLL.Categoria();

            cbCategoria.DataSource    = c.Listar(String.Empty, (byte)BLL.FuncoesGerais.TipoStatus.Ativo).Tables[0];
            cbCategoria.DisplayMember = "NomeCategoria";
            cbCategoria.ValueMember   = "CodigoCategoria";

            BLL.UnidadeVenda u = new BLL.UnidadeVenda();
            cbUnidadeVenda.DataSource    = u.Listar(String.Empty, (byte)BLL.FuncoesGerais.TipoStatus.Ativo).Tables[0];
            cbUnidadeVenda.DisplayMember = "Abreviacao";
            cbUnidadeVenda.ValueMember   = "CodigoUnidadeVenda";

            BLL.Fornecedor f = new BLL.Fornecedor();
            cbFornecedor.DataSource    = f.Listar(String.Empty, (byte)BLL.FuncoesGerais.TipoStatus.Ativo).Tables[0];
            cbFornecedor.ValueMember   = "CodigoFornecedor";
            cbFornecedor.DisplayMember = "NomeFantasia";
        }