Exemplo n.º 1
0
        private bool createClient(DAOClientes dao)
        {
            bool success = false;

            if (this.CheckEmptyFields())
            {
                if (this.checkDNInot0())
                {
                    Persona persona = new Persona(this.fieldName.Text, this.fieldSurname.Text, this.fieldDocument.Text, this.fieldStreet.Text, this.birthTimePicker.Value, this.idPersona);
                    Cliente cliente = new Cliente(this.fieldTelephone.Text, this.fieldMail.Text, this.fieldZipcode.Text, this.idPersona, this.checkHabilitado.Checked);

                    try
                    {
                        dao.crearPersona(persona);
                        cliente.setIdCliente(dao.getIdPersona(persona));
                        dao.crearCliente(cliente);
                        success = true;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message.ToString());
                    }

                    MessageBox.Show("El cliente fue creado exitosamente");
                    this.Close();
                }
            }
            return(success);
        }