private void GuardarEmpleado()
 {
     try
     {
         string rpta = "";
         if (this.txtNombres.Text == string.Empty || this.txtApellidos.Text == string.Empty)
         {
             MensajeError("Nombre y Apellido son campos obligatoros");
             errorIcono.SetError(txtNombres, "Ingrese el al menos un Nombre");
             errorIcono.SetError(txtApellidos, "Ingrese el al menos un Apellido");
         }
         else
         {
             rpta = NEmpleado.Insertar(txtNombres.Text, txtApellidos.Text, txtTDocumento.Text,
                                       txtNDocumento.Text, txtDireccion.Text, dtpFechaNacimiento.Value, dtpFechaIngreso.Value,
                                       Convert.ToDouble(txtSueldo.Text), Convert.ToString(comboxGenero.SelectedItem), txtTelefono.Text,
                                       Convert.ToString(comboxTurno.SelectedItem), txtUsuario.Text, txtPasword.Text, Convert.ToString(comboxAcceso.SelectedItem));
         }
         if (rpta.Equals("OK"))
         {
             this.MensajeOk("Se agrego el Empleado correctamente");
         }
         else
         {
             this.MensajeError("Vuelva a intentarlo");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + ex.StackTrace);
     }
 }
Пример #2
0
        private void btnEditar_Click(object sender, EventArgs e)
        {
            String[] mensaje;

            if (this.txtId.Text == string.Empty)
            {
                mensaje = NEmpleado.Insertar(this.txtNombres.Text, this.txtApellidos.Text, this.cmbGenero.Text, this.dateFechaNacimiento.Text,
                                             this.txtCedula.Text, this.memoDireccion.Text, this.txtTelefono.Text, this.txtEmail.Text);

                if (mensaje[0] == "Y")
                {
                    this.txtId.Text = mensaje[1];
                }
            }
            else
            {
                mensaje = NEmpleado.Editar(this.txtNombres.Text, this.txtApellidos.Text, this.cmbGenero.Text, this.dateFechaNacimiento.Text,
                                           this.txtCedula.Text, this.memoDireccion.Text, this.txtTelefono.Text, this.txtEmail.Text, this.txtId.Text);
            }


            if (mensaje[0] == "Y")
            {
                refrescar_grid();
                Mensaje("Guardado con Exito");
            }
            else
            {
                MensajeError(mensaje[0]);
            }
        }
Пример #3
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (Operacion == "Insertar")
     {
         Obj.Insertar(
             txtNombre.Text,
             txtApellido.Text,
             txtCorreo.Text,
             txtContraseña.Text,
             Convert.ToInt32(cbCargo.SelectedValue));
         MetroFramework.MetroMessageBox.Show(this, "Registro Ingresado Correctamente", "Sistema Causas", MessageBoxButtons.OK, MessageBoxIcon.Information);
         Limpiar();
         MostrarEmpleado();
     }
     else if (Operacion == "Editar")
     {
         Obj.Editar(Convert.ToInt32(idEmpleado),
                    txtNombre.Text,
                    txtApellido.Text,
                    txtCorreo.Text,
                    txtContraseña.Text,
                    Convert.ToInt32(cbCargo.SelectedValue));
         Limpiar();
         Operacion = "Insertar";
         MostrarEmpleado();
         MetroFramework.MetroMessageBox.Show(this, "Registro Editado Correctamente", "Sistema Causas", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #4
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                string respuesta = "";
                if (this.txtNombre.Text == string.Empty || this.txtApellido.Text == string.Empty || this.txtNumero_Documento.Text == string.Empty || this.cbxTipo_Documento.Text == string.Empty || this.cbxSexo.Text == string.Empty || this.dtpFecha_Nacimiento.Text == string.Empty || this.cbxCargo.Text == string.Empty || this.txtUsuario.Text == string.Empty || this.txtClave.Text == string.Empty)
                {
                    MensajeError("Falta ingresar algunos datos relevantes");
                    errorIcono.SetError(txtNombre, "Ingrese el Nombre");
                    errorIcono.SetError(txtApellido, "Ingrese el Apellido");
                    errorIcono.SetError(txtNumero_Documento, "Ingrese el Numero de Documento");
                    errorIcono.SetError(cbxTipo_Documento, "Seleccione el Tipo de Documento");
                    errorIcono.SetError(cbxSexo, "Seleccione el Sexo");
                    errorIcono.SetError(dtpFecha_Nacimiento, "Ingrese la Fecha de Nacimiento");
                    errorIcono.SetError(cbxCargo, "Seleccione el Cargo");
                    errorIcono.SetError(txtUsuario, "Ingrese el Usuario");
                    errorIcono.SetError(txtClave, "Ingrese la Clave");
                }
                else
                {
                    if (this.IsNuevo)
                    {
                        respuesta = NEmpleado.Insertar(this.txtNombre.Text.Trim().ToUpper(), this.txtApellido.Text.Trim().ToUpper(), this.cbxSexo.Text, dtpFecha_Nacimiento.Text, cbxTipo_Documento.Text, txtNumero_Documento.Text, txtDireccion.Text, txtTelefono.Text, txtCorreo.Text, cbxCargo.Text, txtUsuario.Text, txtClave.Text);
                    }
                    else
                    {
                        respuesta = NEmpleado.Editar(Convert.ToInt32(this.txtID.Text), this.txtNombre.Text.Trim().ToUpper(), this.txtApellido.Text.Trim().ToUpper(), this.cbxSexo.Text, dtpFecha_Nacimiento.Text, cbxTipo_Documento.Text, txtNumero_Documento.Text, txtDireccion.Text, txtTelefono.Text, txtCorreo.Text, cbxCargo.Text, txtUsuario.Text, txtClave.Text);
                    }

                    if (respuesta.Equals("OK"))
                    {
                        if (this.IsNuevo)
                        {
                            this.MensajeOk("Se Insertó de forma correcta el registro");
                        }
                        else
                        {
                            this.MensajeOk("Se Actualizó de forma correcta el registro");
                        }
                    }
                    else
                    {
                        this.MensajeError(respuesta);
                    }

                    this.IsNuevo  = false;
                    this.IsEditar = false;
                    this.Botones();
                    this.Limpiar();
                    this.Mostrar();
                }

                gbxListado.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         string Rpta = "";
         if (this.txtNombre.Text == string.Empty || this.txtApellidos.Text == string.Empty || txtDocumento.Text == string.Empty || txtUsuario.Text == string.Empty || txtContraseña.Text == string.Empty)
         {
             MensajeError("Falta ingresar algunos datos, serán remarcados");
             errorIcono.SetError(txtNombre, "Ingrese el nombe");
             errorIcono.SetError(txtApellidos, "Ingrese el apellido");
             errorIcono.SetError(txtDocumento, "Ingrese el documento");
             errorIcono.SetError(txtUsuario, "Ingrese el usuario");
             errorIcono.SetError(txtContraseña, "Ingrese la contraseña");
         }
         else
         {
             if (this.IsNuevo)
             {
                 Rpta = NEmpleado.Insertar(this.txtNombre.Text.Trim().ToUpper(),
                                           this.txtApellidos.Text.Trim().ToUpper(), cboSexo.Text, dtpFechaNacimiento.Value, cboTipoDocumento.Text,
                                           txtDocumento.Text, txtDireccion.Text, cboTipoUsuario.Text, txtUsuario.Text, txtContraseña.Text,
                                           txtTelefono.Text, txtCelular.Text, txtCorreo.Text);
             }
             else
             {
                 Rpta = NEmpleado.Editar(Convert.ToInt32(this.txtIdEmpleado.Text), this.txtNombre.Text.Trim().ToUpper(),
                                         this.txtApellidos.Text.Trim().ToUpper(), cboSexo.Text, dtpFechaNacimiento.Value, cboTipoDocumento.Text,
                                         txtDocumento.Text, txtDireccion.Text, cboTipoUsuario.Text, txtUsuario.Text, txtContraseña.Text,
                                         txtTelefono.Text, txtCelular.Text, txtCorreo.Text);
             }
             if (Rpta.Equals("OK"))
             {
                 if (this.IsNuevo)
                 {
                     this.MensajeOK("Se insertó de forma correcta el registro");
                 }
                 else
                 {
                     this.MensajeOK("Se actualizó de forma correcta el registro");
                 }
             }
             else
             {
                 this.MensajeError(Rpta);
             }
             this.IsNuevo  = false;
             this.IsEditar = false;
             this.Botones();
             this.Limpiar();
             this.Mostrar();
             this.txtIdEmpleado.Text = "";
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + ex.StackTrace);
     }
 }
Пример #6
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         string rpta = "";
         if (this.txtNombre.Text == "              " || this.txtNombre.Text == "")
         {
             MensajeError("Hay Datos Por Completar");
             errorProvider1.SetError(this.txtNombre, "Rellene esta parte del Formulario");
         }
         else if (this.txtApellido.Text == "              ")
         {
             MensajeError("Hay Datos Por Completar");
             errorProvider1.SetError(this.txtNombre, "Rellene esta parte del Formulario");
         }
         else
         {
             if (this.IsNuevo)
             {
                 rpta = NEmpleado.Insertar(this.txtNombre.Text.Trim(), this.txtApellido.Text.Trim(), this.txtAlias.Text.Trim(), this.txtCedula.Text.Trim(), this.txtDireccion.Text.Trim(), this.cbSexo.Text.Trim(), Convert.ToInt32(this.txtTelefono.Text), Convert.ToInt32(this.txtSalario.Text), this.txtCorreo.Text.Trim(), this.txtUsuario.Text.Trim(), this.txtContrasena.Text.Trim(), this.cbAcceso.Text.Trim());
             }
             else
             {
                 rpta = NEmpleado.Editar(Convert.ToInt32(this.txtIdEmpleado.Text), this.txtNombre.Text.Trim(), this.txtApellido.Text.Trim(), this.txtAlias.Text.Trim(), this.txtCedula.Text.Trim(), this.txtDireccion.Text.Trim().ToUpper(), this.cbSexo.Text.Trim().ToUpper(), Convert.ToInt32(this.txtTelefono.Text), Convert.ToInt32(this.txtSalario.Text), this.txtCorreo.Text.Trim(), this.txtUsuario.Text.Trim(), this.txtContrasena.Text.Trim(), this.cbAcceso.Text.Trim());
             }
             if (rpta.Equals("Ok"))
             {
                 if (this.IsNuevo)
                 {
                     this.MensajeOK("Guardado Correctamente");
                 }
                 else
                 {
                     this.MensajeOK("Editado Correctamente");
                 }
             }
             else
             {
                 this.MensajeError(rpta);
             }
             this.Mostrar();
             this.Habilitar(false);
             this.btnNuevo.Enabled    = true;
             this.btnGuardar.Enabled  = false;
             this.btnEditar.Enabled   = true;
             this.btnCancelar.Enabled = false;
             this.Limpiar();
         }
     }
     catch (Exception ex)
     {
     }
 }
Пример #7
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                string rpta = "";
                if (this.txtNombre.Text == string.Empty && this.txtPaterno.Text == string.Empty)
                {
                    MensajeError("Falta ingresar Algunos Datos, seran Remarcados");
                    errorIcono.SetError(txtNombre, "Ingrese un Nombre");
                    errorIcono.SetError(txtPaterno, "Ingrese un Apellido Paterno");
                }
                else
                {
                    if (this.IsNuevo)
                    {
                        rpta = NEmpleado.Insertar(this.txtNombre.Text.Trim(), this.txtPaterno.Text.Trim(), this.txtMaterno.Text.Trim(), Convert.ToInt32(this.txtTelefono.Text.Trim()), this.txtCI.Text.Trim());
                    }
                    else
                    {
                        rpta = NEmpleado.Editar(Convert.ToInt32(this.txtIdEmpleado.Text), this.txtNombre.Text.Trim(), this.txtPaterno.Text.Trim(), this.txtMaterno.Text.Trim(), Convert.ToInt32(this.txtTelefono.Text.Trim()), this.txtCI.Text.Trim());
                    }

                    if (rpta.Equals("OK"))
                    {
                        if (this.IsNuevo)
                        {
                            this.MensajeOk("Se inserto Correctamente El Registro");
                        }
                        else
                        {
                            this.MensajeOk("Se Actualizo Correctamente El Registro");
                        }
                    }
                    else
                    {
                        this.MensajeError(rpta);
                    }
                    this.IsNuevo  = false;
                    this.IsEditar = false;
                    this.Botones();
                    this.Limpiar();
                    this.Mostrar();
                    this.pListas.Visible   = true;
                    this.pRegistro.Visible = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
Пример #8
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtNombre.Text) ||
         string.IsNullOrEmpty(txtApellido.Text) ||
         string.IsNullOrEmpty(txtCorreo.Text) ||
         string.IsNullOrEmpty(txtContraseña.Text) ||
         string.IsNullOrEmpty(cbCargo.Text))
     {
         MetroFramework.MetroMessageBox.Show(this, "Campos Sin rellenar", "Mod-Causas", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         if (Operacion == "Insertar")
         {
             obj.Insertar(
                 txtNombre.Text.ToUpper(),
                 txtApellido.Text.ToUpper(),
                 txtCorreo.Text,
                 txtContraseña.Text.ToUpper(),
                 Convert.ToInt32(cbCargo.SelectedValue));
             Limpiar();
             Mostrar();
             MetroFramework.MetroMessageBox.Show(this, "Registro Insertado", "Mod-Causas", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else if (Operacion == "Editar")
         {
             obj.Editar(Convert.ToInt32(lblId.Text),
                        txtNombre.Text.ToUpper(),
                        txtApellido.Text.ToUpper(),
                        txtCorreo.Text,
                        txtContraseña.Text.ToUpper(),
                        Convert.ToInt32(cbCargo.SelectedValue));
             Limpiar();
             Mostrar();
             Operacion = "Insertar";
             MetroFramework.MetroMessageBox.Show(this, "Registro Editado", "Mod-Causas", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
 }
Пример #9
0
        //metodo guardar datos
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            //insertar datos
            try
            {
                string rpta = "";
                if (this.txtIdentidad.Text == string.Empty ||
                    this.txtNombre.Text == string.Empty ||
                    this.txtApellido.Text == string.Empty ||
                    this.txtAnioNacimiento.Text == string.Empty ||
                    this.txtCelular.Text == string.Empty ||
                    this.txtSalario.Text == string.Empty ||
                    this.txtCargo.Text == string.Empty ||
                    this.txtUsuario.Text == string.Empty ||
                    this.txtPassword.Text == string.Empty)
                {
                    MensajeError("Falta ingresar algunos datos, serán remarcados.");
                    this.errorIcono.SetError(this.txtIdentidad, "Ingrese un número de identidad.");
                    this.errorIcono.SetError(this.txtNombre, "Ingrese un nombre.");
                    this.errorIcono.SetError(this.txtApellido, "Ingrese un apellido.");
                    this.errorIcono.SetError(this.txtCelular, "Ingrese un numero de celular.");
                    this.errorIcono.SetError(this.txtSalario, "Ingrese un salario.");
                    this.errorIcono.SetError(this.txtCargo, "Ingrese cargo que desempeña.");
                    this.errorIcono.SetError(this.txtUsuario, "Ingrese un nombre de usuario.");
                    this.errorIcono.SetError(this.txtPassword, "Ingrese una contraseña.");
                }
                else
                {
                    if (this.EsNuevo)
                    {
                        //nombre,descripcion,imagen,activa
                        rpta = NEmpleado.Insertar(
                            this.txtIdentidad.Text.Trim(),
                            this.txtNombre.Text.Trim().ToUpper(),
                            this.txtApellido.Text.Trim().ToUpper(),
                            Convert.ToInt32(this.txtAnioNacimiento.Text.Trim()),
                            this.txtCelular.Text.Trim(),
                            Convert.ToDouble(this.txtSalario.Text),
                            this.txtCargo.Text.Trim().ToUpper(),
                            Convert.ToInt32(this.determinarActivo(chkActivo)),
                            this.txtUsuario.Text.Trim(),
                            this.txtPassword.Text.Trim(),
                            this.txtPermisos.Text.Trim()
                            );
                    }
                    else
                    {
                        //id,nombre,descripcion,imagen,activa
                        rpta = NEmpleado.Editar(
                            Convert.ToInt32(this.txtIdempleado.Text.Trim()),
                            this.txtIdentidad.Text.Trim(),
                            this.txtNombre.Text.Trim().ToUpper(),
                            this.txtApellido.Text.Trim().ToUpper(),
                            Convert.ToInt32(this.txtAnioNacimiento.Text.Trim()),
                            this.txtCelular.Text.Trim(),
                            Convert.ToDouble(this.txtSalario.Text),
                            this.txtCargo.Text.Trim().ToUpper(),
                            Convert.ToInt32(this.determinarActivo(chkActivo)),
                            this.txtUsuario.Text.Trim(),
                            this.txtPassword.Text.Trim(),
                            this.txtPermisos.Text.Trim()
                            );
                    }

                    if (rpta.Equals("OK"))
                    {
                        if (this.EsNuevo)
                        {
                            this.MensajeOK("Se inserto de forma correcta el registro.");
                        }
                        else
                        {
                            this.MensajeOK("Se modificó de forma correcta el registro.");
                        }
                    }
                    else
                    {
                        this.MensajeError(rpta);
                    }

                    //preparamos para nuevos datos
                    this.EsNuevo  = false;
                    this.EsEditar = false;
                    this.Botones();
                    this.LimpiarControles();
                    this.MostrarDatos();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
        private void BtnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult Opcion;
                Opcion = MessageBox.Show("¿Está seguro de guardar estos datos?", "SEGURIDAD DEL SISTEMA", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (Opcion == DialogResult.Yes)
                {
                    string rpta = "";
                    if (this.txtDpi.Text == string.Empty || this.txtNombre1.Text == string.Empty ||
                        this.txtApellido1.Text == string.Empty || this.cbPuesto.Text == string.Empty)
                    {
                        MensajeError("Falta ingresar algunos datos, serán remarcados");
                        errorIcono.SetError(txtDpi, "Ingrese un Valor");
                        errorIcono.SetError(txtNombre1, "Ingrese un Valor");
                        errorIcono.SetError(txtApellido1, "Ingrese un Valor");
                        errorIcono.SetError(cbPuesto, "Ingrese un Valor");
                    }
                    else
                    {
                        System.IO.MemoryStream ms = new System.IO.MemoryStream();
                        this.pxFoto.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Png);

                        byte[] imagen = ms.GetBuffer();


                        if (this.IsNuevo)
                        {
                            rpta = NEmpleado.Insertar(this.txtDpi.Text, this.txtNombre1.Text, this.txtNombre2.Text, this.txtNombre3.Text, this.txtApellido1.Text, this.txtApellido2.Text, this.txtApellido3.Text,
                                                      this.dtFechaNac.Value, this.cbSexo.Text, this.txtDireccion.Text, Convert.ToInt32(this.cbMunicipio.SelectedValue), this.txtTelefono.Text, Convert.ToInt32(this.cbPuesto.SelectedValue), imagen,
                                                      this.txtCorreo.Text, this.cbEstado.Text, this.dtFecha_Ingreso.Value);
                        }
                        else
                        {
                            rpta = NEmpleado.Editar(Convert.ToInt32(this.txtIdEmpleado.Text),
                                                    this.txtDpi.Text, this.txtNombre1.Text, this.txtNombre2.Text, this.txtNombre3.Text, this.txtApellido1.Text, this.txtApellido2.Text, this.txtApellido3.Text,
                                                    this.dtFechaNac.Value, this.cbSexo.Text, this.txtDireccion.Text, Convert.ToInt32(this.cbMunicipio.SelectedValue), this.txtTelefono.Text, Convert.ToInt32(this.cbPuesto.SelectedValue), imagen,
                                                    this.txtCorreo.Text, this.cbEstado.Text, this.dtFecha_Ingreso.Value);
                        }

                        if (rpta.Equals("OK"))
                        {
                            if (this.IsNuevo)
                            {
                                this.MensajeOk("Se Insertó de forma correcta el registro");
                            }
                            else
                            {
                                this.MensajeOk("Se Actualizó de forma correcta el registro");
                            }
                        }
                        else
                        {
                            this.MensajeError(rpta);
                        }

                        this.IsNuevo  = false;
                        this.IsEditar = false;
                        this.Botones();
                        this.Limpiar();
                    }
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }