private void btnRemover_Click(object sender, EventArgs e) { string msg; if (txtId.Text != string.Empty) { msg = "Confirma Remoção do Cliente " + txtNome.Text + "?"; DialogResult resp; resp = MessageBox.Show(msg, "Remover", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (resp == DialogResult.Yes) { int id = Convert.ToInt32(txtId.Text); Camadas.BLL.BLLcliente bllCliente = new Camadas.BLL.BLLcliente(); Camadas.Model.Modelcliente cliente = new Camadas.Model.Modelcliente(); cliente.id = id; // informar outros campos caso necessite no bll bllCliente.Delete(cliente); dgvClientes.DataSource = ""; dgvClientes.DataSource = bllCliente.Select(); } } else { msg = "Não há registro para remoção..."; MessageBox.Show(msg, "Remover", MessageBoxButtons.OK, MessageBoxIcon.Information); } limparCampos(); Habilitar(false); }
private void rdbTodos_CheckedChanged(object sender, EventArgs e) { lblPesquisa.Visible = false; txtPesquisa.Visible = false; btnFiltrar.Visible = false; Camadas.BLL.BLLcliente bllCliente = new Camadas.BLL.BLLcliente(); dgvClientes.DataSource = ""; dgvClientes.DataSource = bllCliente.Select(); }
private void FrmCliente_Load(object sender, EventArgs e) { Camadas.BLL.BLLcliente bllCliente = new Camadas.BLL.BLLcliente(); dgvClientes.DataSource = bllCliente.Select(); Camadas.DAL.DALLcliente dalCli = new Camadas.DAL.DALLcliente(); dgvClientes.DataSource = dalCli.Select(); Habilitar(false); pnlPesquisa.Visible = false; }
private void button1_Click(object sender, EventArgs e) { Camadas.BLL.BLLcliente BLLcliente = new Camadas.BLL.BLLcliente(); Camadas.Model.Modelcliente cliente = new Camadas.Model.Modelcliente(); int id = Convert.ToInt32(txtId.Text); string msg = ""; if (id == -1) // id=-1 (Inclusão) e id!=-1 (atualização) { msg = "Confirma Inclusão dos Dados?"; } else { msg = "Confirma Atualização dos Dados?"; } DialogResult resp; resp = MessageBox.Show(msg, "Gravar", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (resp == DialogResult.Yes) { cliente.nome = txtNome.Text; cliente.cpf_cnpj = txtCpf_cnpj.Text; cliente.cidade = txtCidade.Text; cliente.cep = txtCep.Text; cliente.endereco = txtEndereco.Text; cliente.uf = txtUF.Text; cliente.email = txtEmail.Text; cliente.fone = txtFone.Text; if (id == -1) //-1 indica inserir { BLLcliente.Insert(cliente); } else { cliente.id = Convert.ToInt32(txtId.Text); BLLcliente.Update(cliente); } } dgvClientes.DataSource = ""; dgvClientes.DataSource = BLLcliente.Select(); limparCampos(); //limpa campos Habilitar(false); //desabilita controles }
private void btnFiltrar_Click(object sender, EventArgs e) { if (rdbNome.Checked == true) { Camadas.Model.Modelcliente oCli = new Camadas.Model.Modelcliente(); oCli.nome = txtPesquisa.Text; Camadas.BLL.BLLcliente bllcli = new Camadas.BLL.BLLcliente(); dgvClientes.DataSource = bllcli.Select(2, oCli); } else if (rdbCodigo.Checked == true) { Camadas.Model.Modelcliente oCli = new Camadas.Model.Modelcliente(); oCli.id = Convert.ToInt32(txtPesquisa.Text.ToString()); Camadas.BLL.BLLcliente bllcli = new Camadas.BLL.BLLcliente(); dgvClientes.DataSource = bllcli.Select(1, oCli); }//fim if busca produto }