示例#1
0
        private void BtnClientes_Click(object sender, EventArgs e)
        {
            IndexClientes Index = new IndexClientes();

            Index.Show();
            this.Hide();
        }
        private void btnSaveCliente_Click(object sender, EventArgs e)
        {
            if (cliente == null)
            {
                Cliente cliente = new Cliente();
                cliente.Nome           = txtBoxNome.Text;
                cliente.Cpf            = txtBoxCpf.Text;
                cliente.Rg             = txtBoxRg.Text;
                cliente.DataNascimento = txtBoxDataNascimento.ToString();

                if (new ClientesController().Create(cliente))
                {
                    MessageBox.Show("Cliente cadastrado com sucesso!");
                }
                else
                {
                    MessageBox.Show("Ocorreu um erro ao cadastrar o cliente.");
                }
            }
            else
            {
                cliente.Nome           = txtBoxNome.Text;
                cliente.Cpf            = txtBoxCpf.Text;
                cliente.Rg             = txtBoxRg.Text;
                cliente.DataNascimento = txtBoxDataNascimento.ToString();

                if (new ClientesController().Update(cliente.Id, cliente))
                {
                    MessageBox.Show("Cliente atualizado com sucesso!");
                }
                else
                {
                    MessageBox.Show("Ocorreu um erro ao atualizar o cliente.");
                }
            }
            IndexClientes Index = new IndexClientes();

            this.Hide();
            Index.Show();
        }