Esempio n. 1
0
        private bool Valida()
        {
            if (_ConsultaEmp == null)
            {
                MessageBox.Show(String.Concat("Debe seleccionar a algún empleado."), "Mss", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                return(false);
            }

            if (txtFechaInicio.Value.Date > txtFechaVencimiento.Value.Date)
            {
                MessageBox.Show(String.Concat("Fecha de inicio de Anexo no puede ser mayor a la fecha de vencimiento de éste."), "Mss", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                return(false);
            }

            if (txtFechaInicio.Value.Date == txtFechaVencimiento.Value.Date)
            {
                MessageBox.Show(String.Concat("Fecha de inicio de Anexo no puede ser igual a la fecha de vencimiento de éste."), "Mss", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                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);
            }

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

            // Valida si existe Contrato de persona
            if (!_Contrato.ValidaContrato(_ConsultaEmp.Rut))
            {
                MessageBox.Show(String.Concat(PrimeraMayuscula(_ConsultaEmp.Nombres.ToLower()), " ", PrimeraMayuscula(_ConsultaEmp.ApellidoPaterno.ToLower()), " no posee contrato. Debe estar contratado anteriormente."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }

            _Documento = new Negocio.Documentos.Documento();
            // Valida si ya tiene contrato Indefinido
            //if (_Documento.RetornaContratoId(_ConsultaEmp))
            //{
            //    MessageBox.Show(String.Concat(PrimeraMayuscula(_ConsultaEmp.Nombres.ToLower()), " ", PrimeraMayuscula(_ConsultaEmp.ApellidoPaterno.ToLower()), " ya posee contrato Indefinido, no se puede realizar un Anexo de Contrato."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //    return false;
            //}

            if (DialogResult.Cancel == MessageBox.Show(String.Concat("Realmente desea generar Anexo a '", PrimeraMayuscula(txtNombres.Text), " ", PrimeraMayuscula(txtApellidoPaterno.Text), "'"), "Mss", MessageBoxButtons.OKCancel, MessageBoxIcon.Question))
            {
                return(false);
            }

            return(true);
        }
Esempio n. 2
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. 3
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;

                if (!ValidaDatos())
                {
                    return;
                }

                String mensaje = string.Empty;

                _finiquito = new Negocio.Documentos.Finiquitos(_usuarioSesion);

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

                _finiquito._RutaFinal      = String.Concat(Folder.SelectedPath.ToString(), "\\");
                _finiquito._per            = _ConsultaEmp;
                _finiquito._Articulo       = cboArticulo.Text;
                _finiquito._Motivo         = txtMotivo.Text.Trim();
                _finiquito._NumeroArticulo = txtNumeroArt.Text.Trim();

                Double vacaciones, totalremu = 0;
                if (!Double.TryParse(txtVacaciones.Text.Replace("$", "").Replace(",", "").Replace(".", ""), out vacaciones))
                {
                    vacaciones = 0;
                }
                if (!Double.TryParse(txtTotalRemuneraciones.Text.Replace("$", "").Replace(",", "").Replace(".", ""), out totalremu))
                {
                    totalremu = 0;
                }

                _finiquito._Vacaciones = vacaciones;
                _finiquito._Total      = totalremu;

                _finiquito._RutaInicioProyecto = System.Windows.Forms.Application.StartupPath;

                IDictionary <int, Negocio.Documentos.Remuneracion> _listRemu = new Dictionary <int, Negocio.Documentos.Remuneracion>();

                foreach (DataGridViewRow item in gridRemuneraciones.Rows)
                {
                    if (gridRemuneraciones["FechaInicio", item.Index].Value != null &&
                        gridRemuneraciones["FechaVencimiento", item.Index].Value != null &&
                        gridRemuneraciones["Monto", item.Index].Value != null)
                    {
                        Negocio.Documentos.Remuneracion _remu = new Negocio.Documentos.Remuneracion();

                        DateTime aaa;
                        double   _monto;

                        if (double.TryParse(gridRemuneraciones["Monto", item.Index].Value.ToString(), out _monto))
                        {
                            if (_monto == 0)
                            {
                                continue;
                            }
                            _remu.Monto = _monto;
                        }
                        else
                        {
                            continue;
                        }

                        if (DateTime.TryParse(gridRemuneraciones["FechaInicio", item.Index].Value.ToString(), out aaa))
                        {
                            _remu.FechaInicio = aaa;
                        }
                        else
                        {
                            _remu.FechaInicio = DateTime.Now;
                        }

                        if (DateTime.TryParse(gridRemuneraciones["FechaVencimiento", item.Index].Value.ToString(), out aaa))
                        {
                            _remu.FechaTermino = aaa;
                        }
                        else
                        {
                            _remu.FechaInicio = DateTime.Now;
                        }

                        _listRemu.Add(item.Index, _remu);
                    }
                }

                if (_usuarioSesion.Privilegio_Id < 2)
                {
                    Folder.ShowDialog();
                    if (Folder.SelectedPath.ToString() != string.Empty)
                    {
                        _finiquito._RutaFinal = String.Concat(Folder.SelectedPath.ToString(), "\\");
                        if (!_finiquito.GeneraFiniquito(ref mensaje, _listRemu))
                        {
                            if (mensaje == string.Empty)
                            {
                                MessageBox.Show(String.Concat("Ha ocurrido un problema al generar finiquito."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                        else
                        {
                            MessageBox.Show(String.Concat("Finiquito se ha generado con éxito."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                else
                {
                    //Registra Finiquito
                    Int32 _Doc_Id = 0;
                    _Documento = new Negocio.Documentos.Documento();
                    if (!_Documento.RegistrarDocumento(3, _usuarioSesion, _ConsultaEmp, true, 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 Finiquito."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        if (_Documento.RegistrarFiniquito(3, _usuarioSesion, _ConsultaEmp, true, String.Concat(Folder.SelectedPath.ToString(), "\\"), ref mensaje, _Doc_Id, _finiquito, _listRemu))
                        {
                            MessageBox.Show(String.Concat("Finiquito 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 Finiquito."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                            else
                            {
                                MessageBox.Show(String.Concat(mensaje), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                }
            }
            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.MdiParent = this;
                mensa.Show();
            }
            catch (Exception ex)
            {
                Cursor.Current = Cursors.Default;
                MensajeControlado mensa = new MensajeControlado("", ex.Message, ex);
                mensa.Show();
                return;
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Esempio n. 4
0
        private void btnAnexo_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                String  mensaje  = string.Empty;
                Boolean Visacion = false;

                if (!Valida())
                {
                    return;
                }

                _Anexos    = new Negocio.Documentos.Anexos(_usuarioSesion);
                _Documento = new Negocio.Documentos.Documento();

                _ConsultaEmp.FechaIngreso     = txtFechaInicio.Value;
                _ConsultaEmp.FechaVencimiento = txtFechaVencimiento.Value;
                _Anexos._FechaAnexo           = txtFechaAnexo.Value;
                _Anexos._TipoContrato         = cboTipoContrato.Text;

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

                Int32 _ContratoId = 0;
                if (!_Documento.RetornaContratoId(_ConsultaEmp, ref mensaje, ref _ContratoId))
                {
                    if (mensaje == string.Empty)
                    {
                        MessageBox.Show(String.Concat("Ha ocurrido un problema al consultar contrato Previo."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }

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

                //Registra Anexo
                Int32 _Doc_Id = 0;
                _Documento = new Negocio.Documentos.Documento();
                if (!_Documento.RegistrarDocumento(2, _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 Anexo."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                else
                {
                    if (!Visacion)
                    {
                        Folder.ShowDialog();
                        if (Folder.SelectedPath.ToString() != string.Empty)
                        {
                            _Anexos._RutaFinal = String.Concat(Folder.SelectedPath.ToString(), "\\");

                            if (!_Anexos.GeneraAnexo(ref mensaje))
                            {
                                if (mensaje == string.Empty)
                                {
                                    MessageBox.Show(String.Concat("Ha ocurrido un problema al generar Anexo."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    return;
                                }
                            }
                        }
                    }

                    if (_Documento.RegistrarAnexo(2, _usuarioSesion, _ConsultaEmp, Visacion, String.Concat(Folder.SelectedPath.ToString(), "\\"), ref mensaje, _ContratoId))
                    {
                        MessageBox.Show(String.Concat("Anexo 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 Anexo."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            MessageBox.Show(String.Concat(mensaje), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Cursor.Current = Cursors.Default;
                MensajeControlado mensa = new MensajeControlado("", ex.Message, ex);
                mensa.Show();
                return;
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }