コード例 #1
0
        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);
            }
        }
コード例 #2
0
ファイル: frmAltaCliente.cs プロジェクト: DMPapa/EjBanco
 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();
 }
コード例 #3
0
        private Cliente CargarCliente()
        {
            string nombre    = txtnombre.Text;
            string apellido  = txtapellido.Text;
            string direccion = txtdireccion.Text;
            string mail      = txtmail.Text;
            string telefono  = txttelefono.Text;

            bool     estado   = checkBox1.Checked;
            DateTime fechanac = dateTimePicker1.Value;

            string msj = "";

            msj += ValidacionesHelper.ValidarFecha(fechanac);
            msj += ValidacionesHelper.ValidarInt(txtdni.Text, "Dni");
            msj += ValidacionesHelper.ValidarSTRING(nombre, "Nombre");
            msj += ValidacionesHelper.ValidarSTRING(apellido, "Apellido");
            msj += ValidacionesHelper.ValidarSTRING(direccion, "Direccion");
            msj += ValidacionesHelper.ValidarSTRING(mail, "Email");
            msj += ValidacionesHelper.ValidarSTRING(telefono, "Telefono");

            if (!string.IsNullOrWhiteSpace(msj))
            {
                throw new Exception(msj.ToString());
            }
            int     dni     = int.Parse(txtdni.Text);
            Cliente cliente = new Cliente(dni, nombre, apellido, direccion, estado, mail, telefono, fechanac, _clienteServicio.ProximoId());

            return(cliente);
        }
コード例 #4
0
 private Cliente CrearCliente()
 {
     return(new Cliente(ClienteServicio.ProximoId(), txtNombre.Text, txtApellido.Text, txtDireccion.Text, txtTelefono.Text, txtMail.Text));
 }