Exemplo n.º 1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Camadas.BLL.Cliente bllCliente = new Camadas.BLL.Cliente();
            dtgCliente.DataSource = bllCliente.Select();

            habilitaCampos(false);
        }
Exemplo n.º 2
0
        private void btnBusca_Click(object sender, EventArgs e)
        {
            Camadas.BLL.Cliente          bllCliente = new Camadas.BLL.Cliente();
            List <Camadas.MODEL.Cliente> lstCli     = new List <Camadas.MODEL.Cliente>();

            if (rdbTodos.Checked)
            {
                lstCli = bllCliente.Select();
            }
            else if (txtBusca.Text != string.Empty)
            {
                if (rdbCodigo.Checked)
                {
                    lstCli = bllCliente.SelectById(Convert.ToInt32(txtBusca.Text));
                }
                else if (rdbNome.Checked)
                {
                    lstCli = bllCliente.SelectByNome(txtBusca.Text);
                }
            }
            else
            {
                MessageBox.Show("Não foi Informado o Valor de Pesquisa");
            }

            dtgCliente.DataSource = lstCli;
        }
Exemplo n.º 3
0
        private void btnRemover_Click(object sender, EventArgs e)
        {
            if (Convert.ToInt32(txtId.Text) > 0)
            {
                Camadas.MODEL.Cliente cliente    = new Camadas.MODEL.Cliente();
                Camadas.BLL.Cliente   bllCliente = new Camadas.BLL.Cliente();

                cliente.id = Convert.ToInt32(txtId.Text);
                DialogResult result;
                result = MessageBox.Show("Deseja Remover o cliente Selecionado?",
                                         "Remover Cliente",
                                         MessageBoxButtons.YesNo,
                                         MessageBoxIcon.Question,
                                         MessageBoxDefaultButton.Button1);
                if (result == DialogResult.Yes)
                {
                    bllCliente.Delete(cliente);
                    MessageBox.Show("Cliente Removido com Sucesso...");
                }
                else
                {
                    MessageBox.Show("Não confirmada Remoção de Cliente...", "Remover");
                }


                dtgCliente.DataSource = bllCliente.Select();
                habilitaCampos(false);
            }
            else
            {
                MessageBox.Show("Não há registros Selecionados", "Remover");
            }
        }
Exemplo n.º 4
0
        private void btnGravar_Click(object sender, EventArgs e)
        {
            Camadas.MODEL.Cliente cliente    = new Camadas.MODEL.Cliente();
            Camadas.BLL.Cliente   bllCliente = new Camadas.BLL.Cliente();

            cliente.id          = Convert.ToInt32(txtId.Text);
            cliente.nome        = txtNome.Text;
            cliente.endereco    = txtEndereco.Text;
            cliente.cidade      = txtCidade.Text;
            cliente.estado      = txtEstado.Text;
            cliente.aniversario = Convert.ToDateTime(txtAniversario.Text);

            string msg;

            if (OP == 'I')
            {
                msg = "Deseja confirmar Inserção dos Dados?";
            }
            else
            {
                msg = "Deseja confirmar Alteração dos Dados?";
            }

            DialogResult resp;

            resp = MessageBox.Show(msg, "Gravar", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);

            if (resp == DialogResult.OK)
            {
                if (OP == 'I')
                {
                    bllCliente.Insert(cliente);
                }
                else
                {
                    bllCliente.Update(cliente);
                }
            }

            dtgCliente.DataSource = bllCliente.Select();


            OP = 'X';
            habilitaCampos(false);
        }