Ejemplo n.º 1
0
 private void BtnInsertar_Click(object sender, EventArgs e)
 {
     try
     {
         string Rpta = "";
         if (TxtNombre.Text == string.Empty || TxtEmail.Text == string.Empty)
         {
             this.MensajeError("Falta ingresar unos datos");
             ErrorIcono.SetError(TxtNombre, "Ingresa un nombre");
             ErrorIcono.SetError(TxtEmail, "Ingresa un email");
         }
         else
         {
             Rpta = NPersona.Insertar("Cliente", TxtNombre.Text.Trim(), CboTipoDoc.Text, TxtNumDoc.Text.Trim(), TxtDireccion.Text.Trim(), TxtTelefono.Text.Trim(), TxtEmail.Text.Trim());
             if (Rpta.Equals("OK"))
             {
                 this.MensajeOK("Se insertaron los datos de manera correcta");
                 this.Listar();
             }
             else
             {
                 this.MensajeError(Rpta);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + ex.StackTrace);
     }
 }
Ejemplo n.º 2
0
        private void BtnInsertar_Click(object sender, EventArgs e)
        {
            try
            {
                string Rpta = "";
                if (txtNombre.Text == string.Empty)
                {
                    this.MensajeError("Falta ingresa algunos datos, seran remarcados.");

                    Erroricono.SetError(txtNombre, "Ingrese un nombre");
                }
                else
                {
                    Rpta = NPersona.Insertar("Cliente", txtNombre.Text.Trim(), CboTipoDocumento.Text, txtNumDocumento.Text.Trim(), txtDireccion.Text.Trim(), txtTelefono.Text.Trim(), txtEmail.Text.Trim());
                    if (Rpta.Equals("OK"))
                    {
                        this.MensajeOK("Se inserto de forma correcta el registro");
                        this.Limpiar();
                        this.Listar();
                    }
                    else
                    {
                        this.MensajeError(Rpta);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
Ejemplo n.º 3
0
 private void botonInsertar_Click(object sender, EventArgs e)
 {
     try
     {
         string respuesta = "";
         if (textoNombre.Text == string.Empty)
         {
             this.MensajeError("Falta ingresar algunos datos, seran remarcados");
             errorIcono.SetError(textoNombre, "ingrese nombre");
         }
         else
         {
             respuesta = NPersona.Insertar("Proveedor", textoNombre.Text.Trim(), comboTipoDocumento.Text, textoNumeroDocumento.Text.Trim(),
                                           textoDireccion.Text.Trim(), textoTelefono.Text.Trim(), textoEmail.Text.Trim());
             if (respuesta.Equals("OK"))
             {
                 this.MensajeOk("Se Registro correctamente");
                 this.Listar();
             }
             else
             {
                 this.MensajeError(respuesta);
             }
         }
     }
     catch (Exception exepcion)
     {
         MessageBox.Show(exepcion.Message + exepcion.StackTrace);
     }
 }
Ejemplo n.º 4
0
 private void btnInsertar_Click(object sender, EventArgs e)
 {
     try
     {
         string Rpta = "";
         if (txtNombre.Text == string.Empty || txtApellido.Text == string.Empty || txtTelefono.Text == string.Empty || txtEdad.Text == string.Empty)
         {
             this.MensajeError("ERROR: No puede dejar campos vacios");
         }
         else
         {
             Rpta = NPersona.Insertar(txtNombre.Text, txtApellido.Text, txtTelefono.Text, Int32.Parse(txtEdad.Text));
             if (Rpta.Equals("OK"))
             {
                 this.MensajeOk("se inserto correctamente");
                 this.Limpiar();
                 this.Listar();
             }
             else
             {
                 this.MensajeError(Rpta);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + ex.StackTrace);
     }
 }
Ejemplo n.º 5
0
 //Lee los datos de los textbox y los envia a la capa de Negocio para realizar la insercion en la base de datos
 private void Insertar()
 {
     try
     {
         var edad = 0;
         if (string.IsNullOrEmpty(txtNombre.Text) || string.IsNullOrEmpty(txtApellido.Text) || string.IsNullOrEmpty(txtTelefono.Text)) //Verifica si todos los campos excepto edad estan llenos
         {
             this.MensajeError("Falta ingresar un dato, por favor revisar");
         }
         if (int.TryParse(txtEdad.Text.Trim(), out edad)) //Revisa si edad almacena una cadena que puede interpretarse como un numero entero, de ser asi lo almacena en la variable edad
         {
             var Rpta = NPersona.Insertar(txtNombre.Text.Trim(), txtApellido.Text.Trim(), txtTelefono.Text.Trim(), edad);
             if (Rpta.Equals("OK"))
             {
                 this.MensajeOk("Se inserto el registro correctamente");
                 this.Listar();
                 this.Limpiar();
             }
             else
             {
                 this.MensajeError(Rpta);
             }
         }
         else //Si no es un numero entero, entonces se envia un mensaje de error
         {
             this.MensajeError("La edad debe ser un dato númerico, por favor revisar");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + ex.StackTrace);
     }
 }
Ejemplo n.º 6
0
        private void Guardar()
        {
            try
            {
                string   rpta    = "";
                string   tipoDoc = "";
                int?     idTipoCliente;
                DateTime fecNac;
                if (this.txtNombre.Text.Trim() == string.Empty)
                {
                    MensajeError("Ingrese el nombre del cliente");
                    errorIcono.SetError(txtNombre, "Ingrese el nombre");
                }
                else
                {
                    if (this.txtFechaNac.Text == "")
                    {
                        fecNac = DateTime.MinValue;
                    }
                    else
                    {
                        fecNac = Convert.ToDateTime(this.txtFechaNac.Text);
                    }
                    if (this.cbTipoDoc.SelectedIndex == -1)
                    {
                        tipoDoc = "";
                    }
                    else
                    {
                        tipoDoc = this.cbTipoDoc.SelectedItem.ToString();
                    }

                    if (cbTipoCliente.SelectedIndex == -1)
                    {
                        idTipoCliente = null;
                    }
                    else
                    {
                        idTipoCliente = Convert.ToInt32(cbTipoCliente.SelectedValue.ToString());
                    }

                    if (cbTipoDoc.SelectedIndex == 0 && txtNumDoc.Text.Trim().Length != 8)
                    {
                        MessageBox.Show("Ingrese un número de documento válido");
                        return;
                    }
                    else if (cbTipoDoc.SelectedIndex == 1 && txtNumDoc.Text.Trim().Length != 11)
                    {
                        MessageBox.Show("Ingrese un número de documento válido");
                        return;
                    }
                    else if (cbTipoDoc.SelectedIndex == 2 && txtNumDoc.Text.Trim().Length != 11)
                    {
                        MessageBox.Show("Ingrese un número de documento válido");
                        return;
                    }


                    if (this.IsNuevo)
                    {
                        /*rpta = NCliente.Insertar(this.txtNombre.Text.Trim().ToUpper(), fecNac, tipoDoc,
                         *                       this.txtNumDoc.Text.Trim(), this.txtDireccion.Text.Trim(), this.txtEmail.Text.Trim(), this.txtTelefono.Text.Trim(),idTipoCliente,"C");*/
                        rpta = NPersona.Insertar(this.txtNombre.Text.Trim().ToUpper(), fecNac, tipoDoc, this.txtNumDoc.Text.Trim(), this.txtDireccion.Text.Trim().ToUpper(),
                                                 this.txtEmail.Text.Trim(), this.txtTelefono.Text.Trim(), idTipoCliente, "C", "", "", 00.00m, DateTime.MinValue, "A", null);
                    }
                    else
                    {
                        /*
                         * rpta = NCliente.Editar(Convert.ToInt32(this.txtIdCliente.Text), this.txtNombre.Text.Trim().ToUpper(), fecNac,
                         *  tipoDoc, this.txtNumDoc.Text.Trim(), this.txtDireccion.Text.Trim(), this.txtEmail.Text.Trim(), this.txtTelefono.Text.Trim(), idTipoCliente);*/
                        rpta = NPersona.Editar(Convert.ToInt32(this.txtIdCliente.Text), this.txtNombre.Text.Trim().ToUpper(), fecNac, tipoDoc, this.txtNumDoc.Text.Trim(), this.txtDireccion.Text.Trim().ToUpper(),
                                               this.txtEmail.Text.Trim(), this.txtTelefono.Text.Trim(), idTipoCliente, "C", "", "", 00.00m, DateTime.MinValue, "A", null);
                    }

                    if (rpta.Equals("OK"))
                    {
                        if (this.IsNuevo)
                        {
                            this.MensajeOK("Se insertó correcatamente");
                        }
                        else
                        {
                            this.MensajeOK("Se actualizó correctamente");
                        }
                    }
                    else
                    {
                        this.MensajeError(rpta);
                    }

                    this.IsNuevo  = false;
                    this.IsEditar = false;
                    this.Botones();
                    this.Limpiar();
                    this.Mostrar();
                    this.tabControl2.SelectedIndex = 0;
                    txtBuscar.Clear();
                    txtBuscar.Select();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
Ejemplo n.º 7
0
        private void Guardar()
        {
            try
            {
                string rpta = "";

                DateTime fecNac;

                if (this.cbCargo.SelectedIndex == -1)
                {
                    MensajeError("Seleccione un cargo");
                    errorIcono.SetError(cbCargo, "Seleccionar cargo");
                }
                else if (this.txtNombre.Text.Trim() == string.Empty)
                {
                    MensajeError("Ingrese el nombre del trabajador");
                    errorIcono.SetError(txtNombre, "Ingrese el nombre");
                }
                else if (this.cbTipoDoc.SelectedIndex == -1)
                {
                    MensajeError("Seleccione un tipo de documento");
                    errorIcono.SetError(cbTipoDoc, "Seleccionar tipo");
                }
                else if (this.txtNumDoc.Text.Trim() == string.Empty)
                {
                    MensajeError("Ingrese el número de documento");
                    errorIcono.SetError(txtNumDoc, "Ingrese el número de documento");
                }
                else if (this.txtFechaNac.Text.Trim() == string.Empty)
                {
                    MensajeError("Seleccione la fecha de Nacimiento");
                    errorIcono.SetError(txtFechaNac, "Seleccione la fecha de nacimiento");
                }
                else if (this.txtDireccion.Text.Trim() == string.Empty)
                {
                    MensajeError("Ingrese la dirección del trabajador");
                    errorIcono.SetError(txtDireccion, "Ingrese la dirección");
                }
                else if (this.txtTelefono.Text.Trim() == string.Empty)
                {
                    MensajeError("Ingrese el telefono del trabajador");
                    errorIcono.SetError(txtTelefono, "Ingrese el telefono");
                }
                else if (this.txtSueldo.Text.Trim() == string.Empty)
                {
                    MensajeError("Ingrese el sueldo");
                    errorIcono.SetError(txtSueldo, "Ingrese el telefono del trabajador");
                }
                else
                {
                    if (this.txtFechaNac.Text == "")
                    {
                        fecNac = DateTime.MinValue;
                    }
                    else
                    {
                        fecNac = Convert.ToDateTime(this.txtFechaNac.Text);
                    }

                    if (this.IsNuevo)
                    {
                        /*rpta = NTrabajador.Insertar(this.txtNombre.Text.Trim().ToUpper(), this.txtApellidos.Text.Trim().ToUpper(), this.cbTipoDoc.SelectedItem.ToString(),
                         *                          this.txtNumDoc.Text.Trim(), sexo, fecNac, this.txtDireccion.Text.Trim(), this.txtTelefono.Text.Trim(), this.txtEmail.Text.Trim(),
                         *                          "A", Convert.ToInt32(this.cbCargo.SelectedValue.ToString()), this.txtUsuario.Text.Trim(), this.txtPass.Text.Trim(),
                         *                          Convert.ToDecimal(txtSueldo.Text.Trim()),dtFecha.Value);*/
                        rpta = NPersona.Insertar(this.txtNombre.Text.Trim().ToUpper() + " " + this.txtApellidos.Text.Trim().ToUpper(), fecNac, cbTipoDoc.SelectedItem.ToString(),
                                                 this.txtNumDoc.Text.Trim(), this.txtDireccion.Text.Trim().ToUpper(), this.txtEmail.Text.Trim(), this.txtTelefono.Text.Trim(), null, "T", txtUsuario.Text.Trim(),
                                                 txtPass.Text, Convert.ToDecimal(txtSueldo.Text.Trim()), dtFecha.Value, "A", Convert.ToInt32(this.cbCargo.SelectedValue.ToString()));
                    }
                    else
                    {
                        /*  rpta = NTrabajador.Editar(Convert.ToInt32(this.txtIdTrabajador.Text), this.txtNombre.Text.Trim().ToUpper(), this.txtApellidos.Text.Trim().ToUpper(), this.cbTipoDoc.SelectedItem.ToString(),
                         *                            this.txtNumDoc.Text.Trim(), sexo, fecNac, this.txtDireccion.Text.Trim(), this.txtTelefono.Text.Trim(), this.txtEmail.Text.Trim(),
                         *                            "A", Convert.ToInt32(this.cbCargo.SelectedValue.ToString()), this.txtUsuario.Text.Trim(), this.txtPass.Text.Trim(),
                         *                            Convert.ToDecimal(txtSueldo.Text.Trim()),dtFecha.Value);*/

                        rpta = NPersona.Editar(Convert.ToInt32(this.txtIdTrabajador.Text), this.txtNombre.Text.Trim().ToUpper() + " " + this.txtApellidos.Text.Trim().ToUpper(), fecNac,
                                               cbTipoDoc.SelectedItem.ToString(), this.txtNumDoc.Text.Trim(), this.txtDireccion.Text.Trim().ToUpper(), this.txtEmail.Text.Trim(), this.txtTelefono.Text.Trim(),
                                               null, "T", txtUsuario.Text.Trim(), txtPass.Text, Convert.ToDecimal(txtSueldo.Text.Trim()), dtFecha.Value, "A", Convert.ToInt32(this.cbCargo.SelectedValue.ToString()));
                    }

                    if (rpta.Equals("OK"))
                    {
                        if (this.IsNuevo)
                        {
                            this.MensajeOK("Se insertó correcatamente");
                        }
                        else
                        {
                            this.MensajeOK("Se actualizó correctamente");
                        }
                    }
                    else
                    {
                        this.MensajeError(rpta);
                    }

                    this.IsNuevo  = false;
                    this.IsEditar = false;
                    this.Botones();
                    this.Limpiar();
                    this.Mostrar();
                    this.tabControl2.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
Ejemplo n.º 8
0
        private void Guardar()
        {
            try
            {
                string rpta    = "";
                string tipoDoc = "";
                int?   idTipoCliente;
                if (this.txtNombre.Text.Trim() == string.Empty)
                {
                    MensajeError("Ingrese el nombre del cliente");
                    errorIcono.SetError(txtNombre, "Ingrese el nombre");
                }
                else
                {
                    if (this.cbTipoDoc.SelectedIndex == -1)
                    {
                        tipoDoc = "";
                    }
                    else
                    {
                        tipoDoc = this.cbTipoDoc.SelectedItem.ToString();
                    }

                    if (cbTipoCliente.SelectedIndex == -1)
                    {
                        idTipoCliente = null;
                    }
                    else
                    {
                        idTipoCliente = Convert.ToInt32(cbTipoCliente.SelectedValue.ToString());
                    }

                    if (cbTipoDoc.SelectedIndex == 0 && txtNumDoc.Text.Trim().Length != 8)
                    {
                        MessageBox.Show("Ingrese un número de documento válido");
                        return;
                    }
                    else if (cbTipoDoc.SelectedIndex == 1 && txtNumDoc.Text.Trim().Length != 11)
                    {
                        MessageBox.Show("Ingrese un número de documento válido");
                        return;
                    }
                    else if (cbTipoDoc.SelectedIndex == 2 && txtNumDoc.Text.Trim().Length != 11)
                    {
                        MessageBox.Show("Ingrese un número de documento válido");
                        return;
                    }

                    IsNuevo = true;
                    if (this.IsNuevo)
                    {
                        /*rpta = NCliente.Insertar(this.txtNombre.Text.Trim().ToUpper(), fecNac, tipoDoc,
                         *                       this.txtNumDoc.Text.Trim(), this.txtDireccion.Text.Trim(), this.txtEmail.Text.Trim(), this.txtTelefono.Text.Trim(),idTipoCliente,"C");*/
                        rpta = NPersona.Insertar(this.txtNombre.Text.Trim().ToUpper(), DateTime.MinValue, tipoDoc, this.txtNumDoc.Text.Trim(), this.txtDireccion.Text.Trim().ToUpper(),
                                                 "", "", idTipoCliente, "C", "", "", 00.00m, DateTime.MinValue, "A", null);
                    }

                    if (rpta.Equals("OK"))
                    {
                        if (this.IsNuevo)
                        {
                            frmVistaClientePagoVenta.f1.Mostrar();
                            this.Close();
                        }
                    }
                    else
                    {
                        this.MensajeError(rpta);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }