private void rbTodos_CheckedChanged(object sender, EventArgs e) { CAMADAS.BLL.ClienteBLL bllCli = new CAMADAS.BLL.ClienteBLL(); lblInserir.Text = ""; txtPesquisar.Text = ""; txtPesquisar.Enabled = false; pesquisarBtn.Enabled = false; dgvClientes.DataSource = ""; dgvClientes.DataSource = bllCli.SelectAll(); }
public Cliente() { InitializeComponent(); txtPesquisar.Enabled = false; pesquisarBtn.Enabled = false; limparCampos(); desabilitarBotoes(true); rbTodos.Checked = true; desabilitarCamposInfo(); CAMADAS.BLL.ClienteBLL cliBLL = new CAMADAS.BLL.ClienteBLL(); dgvClientes.DataSource = cliBLL.SelectAll(); }
private void btnSalvar_Click(object sender, EventArgs e) { CAMADAS.MODEL.Cliente cliente = new CAMADAS.MODEL.Cliente(); cliente.id = lblId.Text != "" ? Convert.ToInt32(lblId.Text) : -1; cliente.usuario = txtUsuario.Text; cliente.senha = txtSenha.Text; cliente.nome = txtNome.Text; cliente.endereco = txtEndereco.Text; cliente.saldo = Math.Round(Convert.ToDouble(txtSaldo.Text), 2); cliente.imagem = btnCarregarImagem.Text; CAMADAS.BLL.ClienteBLL cliBLL = new CAMADAS.BLL.ClienteBLL(); if (this.acao == "cadastro") { if (pbFotoCliente.Image != null) { string[] partes = carregarImagemCliente.SafeFileName.Split('.'); cliente.imagem = cliente.usuario + "." + partes[partes.Length - 1]; cliBLL.Insert(cliente, pbFotoCliente.Image); limparCampos(); } else { MessageBox.Show("Escolha uma imagem!"); } } else if (this.acao == "editar") { if (lblId.Text != "") { cliBLL.Update(cliente, pbFotoCliente.Image); limparCampos(); } else { MessageBox.Show("Selecione um Cliente!"); } } else if (this.acao == "deletar") { if (lblId.Text != "") { cliente.id = Convert.ToInt32(lblId.Text); cliBLL.DeleteByCliente(cliente); limparCampos(); } else { MessageBox.Show("Selecione um Cliente!"); } } recarregarTabela(); }
private void recarregarTabela() { CAMADAS.BLL.ClienteBLL cliBLL = new CAMADAS.BLL.ClienteBLL(); if (rbTodos.Checked) { dgvClientes.DataSource = cliBLL.SelectAll(); } else if (rbId.Checked) { dgvClientes.DataSource = cliBLL.SelectById(Convert.ToInt32(txtPesquisar.Text)); } else if (rbNome.Checked) { dgvClientes.DataSource = cliBLL.SelectByNome(txtPesquisar.Text); } }