Ejemplo n.º 1
0
 private void frmCliente_Load(object sender, EventArgs e)
 {
     Camadas.BLL.Cliente bllCliente = new Camadas.BLL.Cliente();
     dgvClientes.DataSource = bllCliente.Select();
     pnlPesquisa.Visible    = false;
     Habilitar(false);
 }
Ejemplo n.º 2
0
        private void btnFiltrar_Click(object sender, EventArgs e)
        {
            List <Camadas.Model.Cliente> lstcliente = new List <Camadas.Model.Cliente>();

            Camadas.BLL.Cliente bllcliente = new Camadas.BLL.Cliente();

            if (rbdId.Checked)
            {
                if (txtPesquisa.Text != string.Empty)
                {
                    lstCliente = bllcliente.SelectById(Convert.ToInt32(txtPesquisa.Text));
                }
                else
                {
                    MessageBox.Show("ID vazio", "Pesquisa", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else if (rbdNome.Checked)
            {
                lstCliente = bllcliente.SelectByNome(txtPesquisa.Text.Trim());
            }

            dgvClientes.DataSource = "";
            dgvClientes.DataSource = lstCliente;
        }
Ejemplo n.º 3
0
        private void btnRemover_Click(object sender, EventArgs e)
        {
            Camadas.BLL.Cliente   bllCli  = new Camadas.BLL.Cliente();
            Camadas.Model.Cliente cliente = new Camadas.Model.Cliente();
            string msg;

            if (lblId.Text != string.Empty)
            {
                msg = "Deseja Remover o Cliente Selecionado?";
                DialogResult resp;
                resp = MessageBox.Show(msg, "Remover", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                if (resp == DialogResult.Yes)
                {
                    cliente.id = Convert.ToInt32(lblId.Text);
                    bllCli.Delete(cliente);
                }
            }
            else
            {
                msg = "Não há registro para remoção...";
                MessageBox.Show(msg, "Remover", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            dgvClientes.DataSource = "";
            dgvClientes.DataSource = bllCli.Select();
            limparCampos();
            Habilitar(false);
        }
Ejemplo n.º 4
0
 private void rbdTodos_CheckedChanged(object sender, EventArgs e)
 {
     lblPesquisa.Visible = false;
     txtPesquisa.Visible = false;
     btnFiltrar.Visible  = false;
     Camadas.BLL.Cliente bllProd = new Camadas.BLL.Cliente();
     dgvClientes.DataSource = "";
     dgvClientes.DataSource = bllProd.Select();
 }
Ejemplo n.º 5
0
        private void btnGravar_Click(object sender, EventArgs e)
        {
            Camadas.BLL.Cliente   bllCli  = new Camadas.BLL.Cliente();
            Camadas.Model.Cliente cliente = new Camadas.Model.Cliente();
            int id = Convert.ToInt32(lblId.Text);

            string msg;

            if (id == -1)
            {
                msg = "Confirma inserção dos dados?";
            }
            else
            {
                msg = "Confirma alteração dos dados?";
            }

            DialogResult resp;

            resp = MessageBox.Show(msg, "Gravar", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
            if (resp == DialogResult.Yes)
            {
                cliente.id       = id;
                cliente.nome     = txtNome.Text;
                cliente.endereco = txtEndereco.Text;
                cliente.numero   = txtNumero.Text;
                cliente.cidade   = txtCidade.Text;
                cliente.estado   = txtEstado.Text;
                cliente.fone     = txtFone.Text;

                if (id == -1)
                {
                    bllCli.Insert(cliente);
                }
                else
                {
                    bllCli.Uptade(cliente);
                }
            }
            dgvClientes.DataSource = "";
            dgvClientes.DataSource = bllCli.Select();
            limparCampos();
            Habilitar(false);
        }