public void CarregarDadosGrid()
        {
            try
            {
                dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells;
                BLL.FormaPagamento f = new BLL.FormaPagamento();
                dataGridView1.DataSource = f.Listar(textBox1.Text.Trim().ToUpper(), 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)
                {
                    btnEditar.Enabled = false;
                }
                else
                {
                    btnEditar.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                //throw;
            }
        }
        private void Fixar(Object o, EventArgs e)
        {
            try
            {
                var b = (Button)o;
                //variávl 'b' é o botão 'o'
                if (MessageBox.Show(b.Text, "Atencao", MessageBoxButtons.YesNo, MessageBoxIcon.Error, MessageBoxDefaultButton.Button2) == DialogResult.No)
                {
                    return;
                }
                BLL.FormaPagamento forn = new BLL.FormaPagamento();
                forn.CodigoForma = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value);
                //propriedade '.codigo' do objeto 'usu' recebe '=' o valor 'value' da primeira coluna 'cells[0]' da linha atual 'currentrow' do grid 'datagridview1'
                switch (b.Text)
                {
                case "Excluir": forn.Excluir(); break;
                }
                String msg = "";
                if (b.Text == "Excluir")
                {
                    msg = "Forma de pagamento excluida com sucesso";
                }

                MessageBox.Show(msg, "Sucesso");
                CarregarDadosGrid();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                //throw;
            }
        }
 public void CadastrarForma(object o, EventArgs e)
 {
     BLL.FormaPagamento f = new BLL.FormaPagamento();
     f.NomeForma = txtNome.Text.ToUpper();
     f.IncluirComParametro();
     MessageBox.Show("Cadastrado com sucesso !!!");
 }
 public void EditarForma(object o, EventArgs e)
 {
     BLL.FormaPagamento f = new BLL.FormaPagamento();
     f.CodigoForma = Codigo;
     f.NomeForma   = txtNome.Text;
     f.AlterarComParametro();
     MessageBox.Show("Forma de pagamento alterada com sucesso");
 }
        private void CarregarCombo(object o, EventArgs e)
        {
            BLL.Produto        c = new BLL.Produto();
            BLL.FormaPagamento f = new BLL.FormaPagamento();

            cbProduto.DataSource    = c.Listar(String.Empty, (byte)BLL.FuncoesGerais.TipoStatus.Ativo).Tables[0];
            cbProduto.DisplayMember = "Nome";
            cbProduto.ValueMember   = "CodigoProduto";
            comboBox1.DataSource    = f.Listar(String.Empty, (byte)BLL.FuncoesGerais.TipoStatus.Ativo).Tables[0];
            comboBox1.DisplayMember = "NomeFormaPgto";
            comboBox1.ValueMember   = "CodigoFormaPgto";
            comboBox2.DataSource    = f.Listar(String.Empty, (byte)BLL.FuncoesGerais.TipoStatus.Ativo).Tables[0];
            comboBox2.DisplayMember = "NomeFormaPgto";
            comboBox2.ValueMember   = "CodigoFormaPgto";
            cbProduto.SelectedIndex = -1;
        }