private void FormCliente_Load(object sender, EventArgs e) { Camadas.BLL.Cliente bllCli = new Camadas.BLL.Cliente(); dataGridView1.DataSource = bllCli.Select(); Habilitar(false); pnlPesquisa.Visible = false; }
private void btnFiltrar_Click(object sender, EventArgs e) { if (txtPesquisa.Text != String.Empty) { Camadas.BLL.Cliente bllCli = new Camadas.BLL.Cliente(); List <Camadas.Model.Cliente> lstCliente = new List <Camadas.Model.Cliente>(); if (rdbId.Checked == true) { lstCliente = bllCli.SelectByIdCliente(Convert.ToInt32(txtPesquisa.Text)); } else if (rdbNome.Checked == true) { lstCliente = bllCli.SelectByNome(txtPesquisa.Text); } else if (rdbCidade.Checked == true) { lstCliente = bllCli.SelectByCidade(txtPesquisa.Text); } dataGridView1.DataSource = ""; dataGridView1.DataSource = lstCliente; } else { string msg = "Campo Pesquisa está Vazio..."; MessageBox.Show(msg, "Pesquisa", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btnDeletar_Click(object sender, EventArgs e) { Camadas.BLL.Cliente bllCli = new Camadas.BLL.Cliente(); Camadas.Model.Cliente cliente = new Camadas.Model.Cliente(); string msg; if (lblIdCliente.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.idCliente = Convert.ToInt32(lblIdCliente.Text); bllCli.Delete(cliente); } } else { msg = "Não há registro para remoção..."; MessageBox.Show(msg, "Remover", MessageBoxButtons.OK, MessageBoxIcon.Information); } dataGridView1.DataSource = ""; dataGridView1.DataSource = bllCli.Select(); limparCampos(); Habilitar(false); }
private void rdbTodos_CheckedChanged(object sender, EventArgs e) { lblPesquisa.Visible = false; txtPesquisa.Visible = false; btnFiltrar.Visible = false; Camadas.BLL.Cliente bllCliente = new Camadas.BLL.Cliente(); dataGridView1.DataSource = ""; dataGridView1.DataSource = bllCliente.Select(); }
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 idCliente = Convert.ToInt32(lblIdCliente.Text); string msg; if (idCliente == -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.idCliente = idCliente; cliente.nome = txtNome.Text; cliente.endereco = txtEndereco.Text; cliente.telefone = txtTelefone.Text; cliente.celular = txtCelular.Text; cliente.cidade = txtCidade.Text; cliente.estado = txtEstado.Text; if (idCliente == -1) { bllCli.Insert(cliente); } else { bllCli.Update(cliente); } } dataGridView1.DataSource = ""; dataGridView1.DataSource = bllCli.Select(); limparCampos(); Habilitar(false); }