private void btnCadastrar_Click(object sender, EventArgs e) { if (txtNome.Text == "" || txtApelido.Text == "" || txtCPF.Text == "" || txtEndereco.Text == "" || txtValor.Text == "") { MessageBox.Show("Você não preencheu todos os campos.\n Faça corretamente e tente novamente."); } else { Cliente = new Cliente(); ctrCliente = new ctrCliente(); Cliente.nome = txtNome.Text; Cliente.apelido = txtApelido.Text; Cliente.cpf = txtCPF.Text; Cliente.endereco = txtEndereco.Text; Cliente.valor = Convert.ToDouble(txtValor.Text); ctrCliente.Novo_Cliente(Cliente); } }
private void btnConsultar_Click(object sender, EventArgs e) { if (txtID.Text == "") { MessageBox.Show("Digite um ID Por Favor!!"); } else { Cliente = new Cliente(); ctrCliente = new ctrCliente(); try { Cliente.id = Convert.ToInt32(txtID.Text); Cliente = ctrCliente.Consultar(Cliente); atualizarTextBox(); } catch { MessageBox.Show("Digite Somente Números"); } } }
private void btnConsultar_Click(object sender, EventArgs e) { if (txtID.Text == "") { MessageBox.Show("Digite um ID Por Favor!!"); } else { Cliente = new Cliente(); ctrCliente = new ctrCliente(); try { Cliente.id = Convert.ToInt32(txtID.Text); Cliente = ctrCliente.Consultar(Cliente); atualizarTextBox(); } catch { MessageBox.Show("Digite Somente Números"); } } void atualizarTextBox() { if (Cliente == null) { MessageBox.Show("Cliente não encontrado"); } else { txtNome.Text = Cliente.nome; txtApelido.Text = Cliente.apelido; txtCPF.Text = Cliente.cpf; txtEndereco.Text = Cliente.endereco; txtValor.Text = Convert.ToString(Cliente.valor); } } }