示例#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);
        }
示例#2
0
        private bool createChofer(DAOChofer dao)
        {
            bool success = false;

            if (this.CheckEmptyFields())
            {
                if (this.checkDNInot0())
                {
                    Persona persona = new Persona(this.tb_nombre.Text, this.tb_apellido.Text, this.tb_DNI.Text, this.tb_calle.Text, this.birthTimePicker.Value, this.id);
                    Chofer  chofer  = new Chofer(this.id, this.tb_telefono.Text, this.tb_mail.Text, this.cbHabilitado.Checked);

                    try
                    {
                        pers.crearPersona(persona);
                        chofer.setIdChofer(pers.getIdPersona(persona));
                        dao.crearChofer(chofer);
                        success = true;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message.ToString());
                    }

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