Example #1
0
        private void BtnCrearCli_Click(object sender, EventArgs e)
        {
            ClientesNegocio clientesCrear = new ClientesNegocio();

            try
            {
                Clientes cli = new Clientes();

                cli.Dni         = Convert.ToInt32(txtDni.Text.Trim());
                cli.Nombre      = txtNombre.Text.Trim();
                cli.Apellido    = txtApellido.Text.Trim();
                cli.FechaNac    = dtpFechaNac.Value;
                cli.Calle       = txtDireccion.Text.Trim();
                cli.Sexo        = cbxSexoCliente.Text.Trim();
                cli.IdLocalidad = Convert.ToInt32(cbxCodigoPostal.Text.Trim());
                cli.Estado      = true;

                clientesCrear.AgregarCliente(cli);
                MessageBox.Show("Agregado con éxito");

                Clientess clie = new Clientess();
                this.Close();
                clie.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            if (validarCampoCedula() && validarCampoContacto() && validarCampoNombre())
            {
                DialogResult dialogResult = MessageBox.Show("Esta seguro que desea agregar nuevo cliente?", "Nuevo Cliente", MessageBoxButtons.OKCancel);
                if (dialogResult == DialogResult.OK)
                {
                    clientesEntidad.Nombre     = txtNombre.Text;
                    clientesEntidad.CedulaORnc = txtCedulaORnc.Text;
                    clientesEntidad.Direccion  = txtDireccion.Text;
                    clientesEntidad.Contacto_1 = txtContacto1.Text;
                    clientesEntidad.Contacto_2 = txtContacto2.Text;

                    if (!string.IsNullOrEmpty(txtDescuento.Text))
                    {
                        clientesEntidad.Descuento = Convert.ToDouble(txtDescuento.Text);
                    }
                    else
                    {
                        clientesEntidad.Descuento = 0;
                    }

                    var result = clientesNegocio.AgregarCliente(clientesEntidad);

                    respuesta = result.Item1;
                    clienteID = result.Item2;
                    validarInsertCliente(respuesta, clienteID);
                }
            }
            else
            {
                MessageBox.Show("Por favor complete los campos con error.");
            }
        }
Example #3
0
        private void AgregarCliente()
        {
            try
            {
                if (ValidarCampos())
                {
                    DialogResult dialogResult = MessageBox.Show("Esta seguro que desea agregar nuevo cliente?",
                                                                "Nuevo Cliente", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

                    if (dialogResult == DialogResult.OK)
                    {
                        clienteEntidad.Nombre     = txtNombre.Text;
                        clienteEntidad.CedulaORnc = txtCedulaORnc.Text;
                        clienteEntidad.Direccion  = txtDireccion.Text;
                        clienteEntidad.Contacto_1 = txtContacto1.Text;
                        clienteEntidad.Contacto_2 = txtContacto2.Text;
                        clienteEntidad.Contacto_2 = txtContacto2.Text;

                        if (!string.IsNullOrEmpty(txtDescuento.Text))
                        {
                            clienteEntidad.Descuento = Convert.ToDouble(txtDescuento.Text);
                        }
                        else
                        {
                            clienteEntidad.Descuento = 0;
                        }
                        if (!string.IsNullOrEmpty(txtCredito.Text))
                        {
                            clienteEntidad.Credito = Convert.ToDouble(txtCredito.Text);
                        }
                        else
                        {
                            clienteEntidad.Credito = 0;
                        }
                        var result = clientesNegocio.AgregarCliente(clienteEntidad);

                        respuesta = result.Item1;
                        clienteID = result.Item2;
                        ValidarClienteAgregado(respuesta, clienteID);
                    }
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show("Error: Cliente no pudo ser agregado, verifique que el cliente no exista e intente de nuevo por favor.",
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Loggeator.EscribeEnArchivo(exc.ToString());
            }
        }
Example #4
0
        private void AltaCliente()
        {
            string Apellido   = txtApellido.Text;
            string Nombre     = txtNombre.Text;
            string dni        = txtDNI.Text;
            string direccion  = txtDireccion.Text;
            string localidad  = txtLocalidad.Text;
            string telefono   = txtTelefono.Text;
            string Comentario = txtComentario.Text;
            string Email      = txtEmail.Text;

            clienteNegocio.AgregarCliente(Apellido, Nombre, dni, direccion, localidad, telefono, Comentario, Email);

            XtraMessageBox.Show("Se agregó el cliente correctamente", "Alta Cliente", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }