private void btnAceptar_Click(object sender, EventArgs e)
        {
            try {
                if (!string.IsNullOrEmpty(this.Errores))
                {
                    throw new FormatException("Error en los campos: " + "\n" + this.Errores);
                }
                if (cliente is null)
                {
                    servicio.InsertarCliente(CrearCliente(servicio.ProximoId()));
                    MessageBox.Show("Se ha ingresado correctamente el cliente");
                }
                else
                {
                    servicio.Update(CrearCliente(cliente.ID));
                    MessageBox.Show("Se ha modificado correctamente el cliente");
                }

                BorrarCampos();
            }
            catch (ClienteExistenteException ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (FormatException fex)
            {
                MessageBox.Show(fex.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void BtnGuarDatos_Click(object sender, EventArgs e)
        {
            ClienteServicio ser = new ClienteServicio();

            int cod = ser.InsertarCliente(txtNombre.Text, txtApellido.Text, txtDireccion.Text);

            MessageBox.Show("EL Cliente N° " + cod.ToString() + " se ha insertado correctamente");
        }
Пример #3
0
 private void btnIngresar_Click(object sender, EventArgs e)
 {
     try
     {
         if (ValidarCampos())
         {
             _clienteServicio.InsertarCliente(txtNombre.Text, txtApellido.Text, txtDireccion.Text, txtMail.Text, txtTelefono.Text, dtpFechaNac.Value);
             MessageBox.Show("Se ha añadido el cliente");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #4
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            try
            {
                string _STRdni             = txtDni.Text;
                int    _dni                = 0;
                string _nombre             = txtNombre.Text;
                string _apellido           = txtApellido.Text;
                string _direccion          = txtDireccion.Text;
                string _email              = txtEmail.Text;
                string _telefono           = txtTelefono.Text;
                string _STRfechaNacimiento = dateFecha.Text;
                bool   _activo             = false;

                if (checkActivo.Checked)
                {
                    _activo = true;
                }

                string msj = "";

                msj += Validaciones.ValidarNumero(_STRdni, "Dni", ref _dni);
                msj += Validaciones.ValidarSTRING(_nombre, "Nombre");
                msj += Validaciones.ValidarSTRING(_apellido, "Apellido");
                msj += Validaciones.ValidarSTRING(_direccion, "Direccion");
                msj += Validaciones.ValidarSTRING(_email, "Email");
                msj += Validaciones.ValidarSTRING(_telefono, "Telefono");

                if (!string.IsNullOrWhiteSpace(msj))
                {
                    MessageBox.Show(msj, "ERRORES");
                }
                else
                {
                    Cliente C = new Cliente(_dni, _nombre, _apellido, _direccion, _email, _telefono, _STRfechaNacimiento, _activo);

                    int salida = _clienteServicio.InsertarCliente(C);

                    MessageBox.Show("Cliente Agregado con exito ID: " + salida, "Mensaje del sistema");
                    LimpiarBotones();
                }
            }
            catch (Exception xe)
            {
                MessageBox.Show(xe.Message);
                LimpiarBotones();
            }
        }
Пример #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            string   nombre          = this.textBox1.Text;
            string   apellido        = this.textBox2.Text;
            string   direccion       = this.textBox3.Text;
            DateTime fechaNacimiento = this.dateTimePicker1.Value;
            string   email           = this.textBox4.Text;
            string   telefono        = this.textBox5.Text;

            // validar
            if (nombre.Length == 0 || apellido.Length == 0 || direccion.Length == 0)
            {
                MessageBox.Show("Nombre, apellido y direccion son campos requeridos");
                return;
            }

            if (telefono.Length > 0)
            {
                bool telefonoValido = validarNumero(telefono);
                if (!telefonoValido)
                {
                    MessageBox.Show("Telefono solo admite numeros");
                    return;
                }
            }

            Cliente cliente = new Cliente();

            cliente.Nombre          = nombre;
            cliente.Ape             = apellido;
            cliente.Direccion       = direccion;
            cliente.FechaNacimiento = fechaNacimiento;
            cliente.Email           = email;
            cliente.Telefono        = telefono;

            try
            {
                int id = _clienteService.InsertarCliente(cliente);
                MessageBox.Show("Resultado exitoso, el id del cliente insertado es " + id);
                clearForm();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                Console.WriteLine(ex);
            }
        }
Пример #6
0
 private void btnAgregar_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(this.Errores))
     {
         throw new FormatException("Error en los campos: " + "\n" + this.Errores);
     }
     else
     {
         clienteservicio.InsertarCliente(int.Parse(txtDNI.Text),
                                         txtNombre.Text,
                                         txtApellido.Text,
                                         txtEmail.Text,
                                         txtTelefono.Text,
                                         dateTimePicker1.Value,
                                         true,
                                         clienteservicio.ProximoId());
     }
     MessageBox.Show("Se ha ingresado correctamente el cliente");
     BorrarCampos();
 }
Пример #7
0
        private void btnIngresar_Click(object sender, EventArgs e)
        {
            string   dni             = txtDni.Text.Replace(".", "");
            string   nombre          = txtNombre.Text;
            string   apellido        = txtApellido.Text;
            string   direccion       = txtDireccion.Text;
            string   email           = txtEmail.Text;
            string   telefono        = txtTelefono.Text.Replace("-", "");
            DateTime fechaNacimiento = dtFechaNacimiento.Value;

            try
            {
                int retorno = _clienteServicio.InsertarCliente(dni, nombre, apellido, direccion, email, telefono, fechaNacimiento);

                MessageBox.Show("Cliente Ingresado Exitosamente. Cliente ID: " + retorno);
            }
            catch (Exception ex)
            {
                MessageBox.Show("ERROR -> " + ex.Message);
            }
        }
 private void btnAgregar_Click(object sender, EventArgs e)
 {
     try
     {
         if (!string.IsNullOrEmpty(this.Errores))
         {
             throw new FormatException("Error en los campos: " + "\n" + this.Errores);
         }
         ClienteServicio.InsertarCliente(CrearCliente());
         MessageBox.Show("Se ha ingresado correctamente el cliente");
         BorrarCampos();
     }
     catch (FormatException fex)
     {
         MessageBox.Show(fex.Message);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #9
0
        static void Main(string[] args)

        {
            try
            {
                ClienteServicio servicio = new ClienteServicio();
                int             cod      = servicio.InsertarCliente("Yumi", "quieroagregaruncliente", "enmicasacontuvieja");
                Console.WriteLine("Se ha insertado el cliente nro " + cod.ToString());

                List <Cliente> lst = servicio.TraerClientes();

                foreach (Cliente c in lst)
                {
                    Console.WriteLine(c);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Пример #10
0
        private void btnIngresar_Click(object sender, EventArgs e)
        {
            string   dni             = txtDNI.Text;
            string   nombre          = txtNombre.Text;
            string   apellido        = txtApellido.Text;
            string   mail            = txtMail.Text;
            string   telefono        = txtTelefono.Text;
            string   direccion       = txtDireccion.Text;
            DateTime fechaNacimiento = dtpFechaNac.Value;

            try
            {
                int retorno = _clienteServicio.InsertarCliente(nombre, apellido, direccion, dni, mail, telefono, fechaNacimiento);

                MessageBox.Show("Cliente se agrego con exito. Cliente ID: " + retorno);
            }

            catch (Exception ex)
            {
                MessageBox.Show("Error ->" + ex.Message);
            }
        }
Пример #11
0
        static void Main(string[] args)
        {
            try
            {
                ClienteServicio servicio = new ClienteServicio();

                int cod = servicio.InsertarCliente(generarCliente());

                Console.WriteLine("Se ha insertado el cliente nro " + cod.ToString());

                List <Cliente> lst = servicio.TraerClientes();

                foreach (Cliente c in lst)
                {
                    Console.WriteLine(c);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            Console.ReadKey();
        }
        private void btnAgregarClientes_Click(object sender, EventArgs e)
        {
            try
            {
                string _STRdni             = txtDNI.Text;
                int    _dni                = 0;
                string _nombre             = txtNombre.Text;
                string _apellido           = txtApellido.Text;
                string _direccion          = txtDireccion.Text;
                string _email              = txtEmail.Text;
                string _STRtelefono        = txtTelefono.Text;
                long   _telefono           = 0;
                string _STRfechaNacimiento = datetimePickerNacimiento.Text;
                bool   _activo             = false;


                int edad = DateTime.Today.Year - datetimePickerNacimiento.Value.Year;

                if (DateTime.Today < datetimePickerNacimiento.Value.AddYears(edad))
                {
                    edad--;
                }

                if (checkActivo.Checked)
                {
                    _activo = true;
                }

                string msj = "";

                msj += Validaciones.ValidarDNI(_STRdni, "Dni", ref _dni);
                msj += Validaciones.ValidarSTRING(_nombre, "Nombre");
                msj += Validaciones.ValidarSTRING(_apellido, "Apellido");
                msj += Validaciones.ValidarSTRING(_direccion, "Direccion");
                msj += Validaciones.ValidarSTRING(_email, "Email");
                msj += Validaciones.ValidarTelefono(_STRtelefono, "Telefono", ref _telefono);

                if (!string.IsNullOrWhiteSpace(msj))
                {
                    MessageBox.Show(msj, "ERRORES");
                }
                else if (edad < 18)
                {
                    throw new EdadInsuficienteException();
                }
                else
                {
                    Cliente C = new Cliente(_dni, _nombre, _apellido, _direccion, _telefono, _email, _activo, _STRfechaNacimiento);

                    int salida = _clienteServicio.InsertarCliente(C);

                    MessageBox.Show("Cliente Agregado con exito ID: " + salida, "Mensaje del sistema");

                    LimpiarBotones();
                }
            }
            catch (EdadInsuficienteException ez)
            {
                MessageBox.Show(ez.Message, "Mensaje del sistema");
            }
            catch (Exception xe)
            {
                MessageBox.Show(xe.Message);
                LimpiarBotones();
            }
        }