Esempio n. 1
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            try
            {
                MssBD.EstructuraSueldos _estruct = (MssBD.EstructuraSueldos)cboEstructuras.SelectedItem;
                if (DialogResult.Cancel == MessageBox.Show(String.Concat("Realmente desea eliminar Estructura de Sueldo ", _estruct.Estructura_Codigo, " ", _estruct.Descripcion),
                                                           "Mss", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation))
                {
                    return;
                }

                Cursor.Current = Cursors.WaitCursor;

                if (!_estru.EliminaEstructura(_usuarioSesion, _estruct))
                {
                    MessageBox.Show("Se ha eliminado Estructura de Sueldos con éxito", "Mss", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    BtnLimpiar_Click(sender, e);
                }
                else
                {
                    MessageBox.Show("No se ha podido eliminado Estructura de Sueldos.", "Mss", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Esempio n. 2
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                MssBD.EstructuraSueldos _struct = new MssBD.EstructuraSueldos();

                if (ValidaPantala(ref _struct))
                {
                    if (_estru.VerificaCódigo(_struct))
                    {
                        if (_estru.ModificaEstructura(_usuarioSesion, _struct))
                        {
                            MessageBox.Show(String.Concat("Estructura de Sueldo '", _struct.Descripcion, "' se ha guardado con éxito."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            BtnLimpiar_Click(sender, e);
                            PintaPantalla();
                        }
                        else
                        {
                            MessageBox.Show("No se ha podido guardadar Estructura de Sueldos.", "Mss", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                    }
                    else
                    {
                        if (_estru.GuardarEstructura(_usuarioSesion, _struct))
                        {
                            MessageBox.Show("Estructura de Sueldo se ha guardado con éxito.", "Mss", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            BtnLimpiar_Click(sender, e);
                            PintaPantalla();
                        }
                        else
                        {
                            MessageBox.Show("No se ha podido guardadar Estructura de Sueldos.", "Mss", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Cursor.Current = Cursors.Default;
                MensajeControlado mensa = new MensajeControlado("", ex.Message, ex);
                mensa.Show();
                return;
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Esempio n. 3
0
        private bool ValidaDatos(MssBD.CentrosDeCostos _centroGuardar)
        {
            try
            {
                if (txtCentroEdit.Text == string.Empty)
                {
                    MessageBox.Show("Falta ingresar Codigo del nuevo Centro de costo", "Mss", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }
                else
                {
                    _centroGuardar.Centro_Codigo = Int32.Parse(txtCentroEdit.Text);
                }

                if (nuevo)
                {
                    if (_centro.VerificaCódigo(_centroGuardar))
                    {
                        MessageBox.Show(String.Concat("Éste código ", _centroGuardar.Centro_Codigo.ToString(), " de Centro de Costo ya existe"), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return(false);
                    }
                }

                if (txtDescripcion.Text == string.Empty)
                {
                    MessageBox.Show("Falta ingresar descripción del nuevo Centro de costo", "Mss", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }
                else
                {
                    _centroGuardar.CentroNombre = txtDescripcion.Text;
                }

                _centroGuardar.Vigencia  = chkVigencia.Checked;
                _centroGuardar.Direccion = txtDireccion.Text;

                if (chkSi.Checked)
                {
                    MssBD.EstructuraSueldos est = (MssBD.EstructuraSueldos)cboEstructura.SelectedItem;
                    _centroGuardar.EstructuraSueldo_Id = est.Estructura_Codigo;
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Esempio n. 4
0
        private void cboEstructuras_SelectedIndexChanged(object sender, EventArgs e)
        {
            MssBD.EstructuraSueldos _estructura = (MssBD.EstructuraSueldos)cboEstructuras.SelectedItem;

            if (_estructura != null)
            {
                txtEstructuraCodigo.Text = _estructura.Estructura_Codigo.ToString();
                txtDescipcion.Text       = _estructura.Descripcion;
                txtSueldoBase.Text       = _estructura.SueldoBase.ToString();
                txtGratificacion.Text    = _estructura.Gratificacion.ToString();
                txtBonoAsistencia.Text   = _estructura.BonoAsistencia.ToString();
                txtBonoProduccion.Text   = _estructura.BonoProduccion.ToString();
                txtColacion.Text         = _estructura.Colacion.ToString();
                txtMovilizacion.Text     = _estructura.Movilizacion.ToString();
            }
            FormatCampos();
        }
Esempio n. 5
0
        private bool ValidaDatos(ref MssBD.EstructuraSueldos _est, ref MssBD.Afp _Afp, ref MssBD.Isapres _Isapre, ref MssBD.CentrosDeCostos _Cen)
        {
            if (_ConsultaEmp == null)
            {
                MessageBox.Show(String.Concat("Debe seleccionar a algún empleado."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            try
            {
                _est = (MssBD.EstructuraSueldos)cboEstructuraSueldo.SelectedItem;
            }
            catch (Exception)
            {
                MessageBox.Show(String.Concat("Empledo no posee una estructura de sueldo asociada. No se podrá generar Contrato."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                _est = null;
                return(false);
            }

            try
            {
                _Afp = (MssBD.Afp)cboAfp.SelectedItem;
            }
            catch (Exception)
            {
                MessageBox.Show(String.Concat("Empledo no posee Afp asociada. No se podrá generar Contrato."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                _Afp = null;
                return(false);
            }

            try
            {
                _Isapre = (MssBD.Isapres)cboIsapre.SelectedItem;
            }
            catch (Exception)
            {
                MessageBox.Show(String.Concat("Empledo no posee Isapre asociada. No se podrá generar Contrato."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                _Isapre = null;
                return(false);
            }

            try
            {
                _Cen = (MssBD.CentrosDeCostos)cboCentroCostoInfo.SelectedItem;
            }
            catch (Exception)
            {
                MessageBox.Show(String.Concat("Empledo no posee Centro de Costo asociado. No se podrá generar Contrato."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                _Isapre = null;
                return(false);
            }

            if (String.Equals(txtDireccion.Text, String.Empty))
            {
                MessageBox.Show(String.Concat("Empledo no posee dirección. No se podrá generar Contrato."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(false);
            }

            if (String.Equals(cboEstadoCivil.Text, String.Empty))
            {
                MessageBox.Show(String.Concat("Empledo no posee estado Civil. No se podrá generar Contrato."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(false);
            }
            if (txtFechaInicio.Value.Date > txtFechaVencimiento.Value.Date)
            {
                MessageBox.Show(String.Concat("Fecha de inicio de Contrato no puede ser mayor a la fecha de vencimiento de éste."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            if (txtFechaInicio.Value.Date == txtFechaVencimiento.Value.Date && !cboTipoContrato.Text.Equals("INDEFINIDO"))
            {
                MessageBox.Show(String.Concat("Fecha de inicio de Contrato no puede ser igual a la fecha de vencimiento de éste."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            if (DateTime.Compare(txtFechaInicio.Value.Date, txtFechaVencimiento.Value.Date) > 365 && !cboTipoContrato.Text.Equals("INDEFINIDO"))
            {
                MessageBox.Show(String.Concat("Fecha de inicio de Contrato no puede ser igual a la fecha de vencimiento de éste."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            if (txtTeleFijo.Text.Replace("(", "").Replace(")", "").Replace("_", "").Replace("+", "") == string.Empty && txtTeleCel.Text.Replace("(", "").Replace(")", "").Replace("_", "").Replace("+56", "") == string.Empty)
            {
                MessageBox.Show(String.Concat("Empleado debe tener al menos un teléfono para generar el contrato."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            if (txtCargo.Text == string.Empty)
            {
                MessageBox.Show(String.Concat("Empleado debe tener un cargo profesional para generar el contrato."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            if (txtAnticipo.Text == string.Empty)
            {
                MessageBox.Show(String.Concat("Empleado debe tener Anticipo para generar el contrato."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            if (txtInstalacion.Text == string.Empty)
            {
                MessageBox.Show(String.Concat("Empleado debe tener una Instalacíon asociada para generar el contrato."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            return(true);
        }
Esempio n. 6
0
        private void btnGenerarContrato_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                MssBD.CentrosDeCostos   _cen = new MssBD.CentrosDeCostos();
                MssBD.EstructuraSueldos _est = new MssBD.EstructuraSueldos();
                MssBD.Afp     _Afp           = new MssBD.Afp();
                MssBD.Isapres _Isapre        = new MssBD.Isapres();

                String  mensaje  = string.Empty;
                Boolean Visacion = true;

                _Contrato = new Negocio.Documentos.Contratos(_usuarioSesion);

                // Valida si existe Contrato d persona
                if (_Contrato.ValidaContrato(_ConsultaEmp.Rut))
                {
                    MessageBox.Show(String.Concat(PrimeraMayuscula(_ConsultaEmp.Nombres), " ", PrimeraMayuscula(_ConsultaEmp.ApellidoPaterno), " ya posee contrato. Si desea cambiar información del Contrato creado por favor generar Anexo para éste empleado.w2|9uv      uuu"), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                if (!ValidaDatos(ref _est, ref _Afp, ref _Isapre, ref _cen))
                {
                    return;
                }

                if (DialogResult.Cancel == MessageBox.Show(String.Concat("Realmente desea generar Contrato a '", txtNombres.Text, " ", txtApellidoPaterno.Text, "' \n", "Con la Estructura de Sueldo '", _est.Descripcion, "'"), "Mss", MessageBoxButtons.OKCancel, MessageBoxIcon.Question))
                {
                    return;
                }

                _ConsultaEmp.FechaIngreso     = txtFechaInicio.Value;
                _ConsultaEmp.FechaVencimiento = txtFechaVencimiento.Value;

                _ConsultaEmp.Afp_Id              = _Afp.Afp_Id;
                _ConsultaEmp.Isapre_Id           = _Isapre.Isapre_Id;
                _ConsultaEmp.EstructuraSueldo_Id = _est.EstructuraSueldo_Id;
                _ConsultaEmp.TipoContrato        = cboTipoContrato.Text;
                _ConsultaEmp.CentroCosto_Id      = _cen.CentroId;

                //Valores de Pantalla a Contrato
                Double _anticipo = 0;

                _Contrato._RutaFinal            = String.Concat(Folder.SelectedPath.ToString(), "\\");
                _Contrato._SegundoParrafo       = txtSegundoParrafo.Text;
                _Contrato._DireccionInstalacion = txtInstalacion.Text;

                if (Double.TryParse(txtAnticipo.Text, out _anticipo))
                {
                    _Contrato._Anticipo = _anticipo;
                }

                _Contrato._per = _ConsultaEmp;
                _Contrato._RutaInicioProyecto = System.Windows.Forms.Application.StartupPath;

                //Registra Contrato, en caso que usuario no tenga permisos necesarios.
                Int32 _Doc_Id = 0;
                _Documento = new Negocio.Documentos.Documento();

                Folder.ShowDialog();
                if (Folder.SelectedPath.ToString() == string.Empty)
                {
                    return;
                }

                if (_usuarioSesion.Privilegio_Id < 2)
                {
                    Visacion = false;
                }

                if (!_Documento.RegistrarDocumento(1, _usuarioSesion, _ConsultaEmp, Visacion, String.Concat(Folder.SelectedPath.ToString(), "\\"), ref mensaje, ref _Doc_Id))
                {
                    if (mensaje == string.Empty)
                    {
                        MessageBox.Show(String.Concat("Ha ocurrido un problema al registrar visado de Contrato."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        MessageBox.Show(String.Concat(mensaje), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    if (_Documento.RegistrarContrato(1, _usuarioSesion, _ConsultaEmp, Visacion, String.Concat(Folder.SelectedPath.ToString(), "\\"), ref mensaje, _Doc_Id))
                    {
                        if (!Visacion)
                        {
                            MessageBox.Show(String.Concat("Contrato se ha registrado con éxito."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    else
                    {
                        if (mensaje == string.Empty)
                        {
                            MessageBox.Show(String.Concat("Ha ocurrido un problema al registrar visado de Contrato."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            MessageBox.Show(String.Concat(mensaje), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }

                //En caso que usuario va a generar contrato por Permisos
                if (!Visacion)
                {
                    _Contrato._RutaFinal = String.Concat(Folder.SelectedPath.ToString(), "\\");
                    if (!_Contrato.GeneraContrato(ref mensaje))
                    {
                        if (mensaje == string.Empty)
                        {
                            MessageBox.Show(String.Concat("Ha ocurrido un problema al generar el Contrato."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            MessageBox.Show(String.Concat(mensaje), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show(String.Concat("Contrato se ha generado con éxito."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                MensajeControlado mensa = new MensajeControlado(String.Concat("Éste error se produce por que Window no ha podido reproducir el documento.", Environment.NewLine,
                                                                              "Para poder solucionar este problema debe cerrar documentos Offices en su computador o evitar la sobre carga de procesos en su computador que pueda ocacionar que su computador no tengo la suficiente memoria para crear el nuevo documento."), ex.Message, ex);
                mensa.Show();
                return;
            }
            catch (Exception ex)
            {
                Cursor.Current = Cursors.Default;
                MensajeControlado mensa = new MensajeControlado("", ex.Message, ex);
                mensa.Show();
                return;
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Esempio n. 7
0
        private bool ValidaPantala(ref MssBD.EstructuraSueldos _struct)
        {
            try
            {
                if (txtEstructuraCodigo.Text == string.Empty)
                {
                    MessageBox.Show("Falta código de Estructuras.", "Mss", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return(false);
                }
                if (txtDescipcion.Text == string.Empty)
                {
                    MessageBox.Show("Falta descripción de Estructuras.", "Mss", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return(false);
                }

                Double _monto    = 0;
                Int32  _montoInt = 0;

                if (Int32.TryParse(txtEstructuraCodigo.Text.Replace(".", string.Empty).Replace(",", string.Empty).Replace(" ", string.Empty), out _montoInt))
                {
                    _struct.Estructura_Codigo = _montoInt;
                }
                else
                {
                    _struct.Estructura_Codigo = 0;
                }

                _struct.Descripcion = txtDescipcion.Text;

                if (Double.TryParse(txtSueldoBase.Text.Replace(".", string.Empty).Replace(",", string.Empty).Replace(" ", string.Empty), out _monto))
                {
                    _struct.SueldoBase = _monto;
                }
                else
                {
                    _struct.SueldoBase = 0;
                }

                if (Double.TryParse(txtGratificacion.Text.Replace(".", string.Empty).Replace(",", string.Empty).Replace(" ", string.Empty), out _monto))
                {
                    _struct.Gratificacion = _monto;
                }
                else
                {
                    _struct.Gratificacion = 0;
                }

                if (Double.TryParse(txtBonoAsistencia.Text.Replace(".", string.Empty).Replace(",", string.Empty).Replace(" ", string.Empty), out _monto))
                {
                    _struct.BonoAsistencia = _monto;
                }
                else
                {
                    _struct.BonoAsistencia = 0;
                }

                if (Double.TryParse(txtBonoProduccion.Text.Replace(".", string.Empty).Replace(",", string.Empty).Replace(" ", string.Empty), out _monto))
                {
                    _struct.BonoProduccion = _monto;
                }
                else
                {
                    _struct.BonoProduccion = 0;
                }

                if (Double.TryParse(txtColacion.Text.Replace(".", string.Empty).Replace(",", string.Empty).Replace(" ", string.Empty), out _monto))
                {
                    _struct.Colacion = _monto;
                }
                else
                {
                    _struct.Colacion = 0;
                }

                if (Double.TryParse(txtMovilizacion.Text.Replace(".", string.Empty).Replace(",", string.Empty).Replace(" ", string.Empty), out _monto))
                {
                    _struct.Movilizacion = _monto;
                }
                else
                {
                    _struct.Movilizacion = 0;
                }

                if (Double.TryParse(txtTurno.Text.Replace(".", string.Empty).Replace(",", string.Empty).Replace(" ", string.Empty), out _monto))
                {
                    _struct.BonoTurno = _monto;
                }
                else
                {
                    _struct.BonoTurno = 0;
                }

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }