示例#1
0
        private void gridContratos_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                if (gridContratos.Rows.Count < 1)
                {
                    return;
                }

                var selectedUser = (MssBD.VW_DOC_Finiquitos) this.gridContratos.CurrentRow.DataBoundItem;

                Visar_Remuneraciones _remu = new Visar_Remuneraciones(_usuarioSesion, selectedUser);
                _remu.MdiParent = this.MdiParent;
                _remu.Show();
            }
            catch (Exception ex)
            {
                Cursor.Current = Cursors.Default;
                MensajeControlado mensa = new MensajeControlado("", ex.Message, ex);
                mensa.Show();
                return;
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
示例#2
0
        private void btnImagen_Click(object sender, EventArgs e)
        {
            try
            {
                // Se crea el OpenFileDialog
                _OpenFile = new OpenFileDialog();
                // Se muestra al usuario esperando una acción
                DialogResult result = _OpenFile.ShowDialog();

                // Si seleccionó un archivo (asumiendo que es una imagen lo que seleccionó)
                // la mostramos en el PictureBox de la inferfaz
                if (result == DialogResult.OK)
                {
                    txtImagen.Image = Image.FromFile(_OpenFile.FileName);
                    MemoryStream _ms = new MemoryStream();
                    txtImagen.Image.Save(_ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                    _PersonaSeleccionada.Imagen = _ms.ToArray();
                }
            }
            catch (Exception ex)
            {
                Cursor.Current = Cursors.Default;
                MensajeControlado mensa = new MensajeControlado("", ex.Message, ex);
                mensa.Show();
                return;
            }
        }
示例#3
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                MssBD.CentrosDeCostos _cent = (MssBD.CentrosDeCostos)cboCentroCostos.SelectedItem;

                if (DialogResult.Cancel == MessageBox.Show(String.Concat("Realmente desea eliminar el centro '", _cent.CentroNombre, "'"), "Mss", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation))
                {
                    return;
                }

                if (_centro.EliminaCentroCosto(_usuarioSesion, _cent))
                {
                    MessageBox.Show("Se ha eliminado Centro de Costos con éxito", "Mss", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    BtnLimpiar_Click(sender, e);
                }
                else
                {
                    MessageBox.Show("No se ha podido eliminado Centro de Costos.", "Mss", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                Cursor.Current = Cursors.Default;
                MensajeControlado mensa = new MensajeControlado("", ex.Message, ex);
                mensa.Show();
                return;
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
示例#4
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                if (txtPassword.Text != txtPassword2.Text)
                {
                    MessageBox.Show("Contraseñas no son iguales, favor corregir", "Mss", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                _usuarioSesion.Usuario_Password = txtPassword.Text;

                Negocio.Usuario _negUsu = new Negocio.Usuario();
                _negUsu.CambioContraseña(_usuarioSesion);

                MessageBox.Show("Se ha guardado contraseña con éxito.", "Mss", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                if (nuevo)
                {
                    this.Hide();
                }
            }
            catch (Exception ex)
            {
                Cursor.Current = Cursors.Default;
                MensajeControlado mensa = new MensajeControlado("", ex.Message, ex);
                mensa.Show();
                return;
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
示例#5
0
文件: Inicio.cs 项目: MatAravena/Mss
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtUsuario.Text == string.Empty && txtPassword.Text == string.Empty)
                {
                    MessageBox.Show("Usuario Inválido.", "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtUsuario.Focus();
                    Cursor.Current = Cursors.Default;
                    return;
                }

                Cursor.Current = Cursors.WaitCursor;
                MssBD.Usuarios _usu = new MssBD.Usuarios();
                _usu.Usuario_Nombre   = txtUsuario.Text;
                _usu.Usuario_Password = txtPassword.Text;
                Boolean nuevo = false;

                if (!_UsuNeg.ConsultaUsuarioIngreso(out _usu, _usu.Usuario_Nombre, _usu.Usuario_Password, ref nuevo))
                {
                    MessageBox.Show("Usuario Inválido.", "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtUsuario.Focus();
                    Cursor.Current = Cursors.Default;
                    return;
                }

                if (nuevo)
                {
                    Cursor.Current = Cursors.Default;
                    Usuario usu = new Usuario(_usu, true);
                    usu._personal = usu._personal;
                    usu.nuevo     = true;
                    usu.ShowDialog();

                    usu.Hide();
                }

                this.Hide();
                Principal per = new Principal(_usu);
                per.IsMdiContainer = true;
                per.ShowDialog();

                Cursor.Current = Cursors.Default;
            }
            catch (Exception ex)
            {
                MensajeControlado mensa = new MensajeControlado("", ex.Message, ex);
                //mensa.MdiParent = this;
                mensa.Show();
                return;
            }
        }
示例#6
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                if (txtRutDato.Text != string.Empty && txtDvDato.Text != string.Empty)
                {
                    MssBD.Personal _persEliminar = new MssBD.Personal();
                    _persEliminar.Rut = Int32.Parse(txtRutDato.Text.Replace(".", "").Replace(",", ""));
                    _persEliminar.Dv  = txtDvDato.Text;

                    if (!_Empleado.ExistePersonal(_persEliminar))
                    {
                        MessageBox.Show(String.Concat("Empleado no existe en la Base de Datos."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }

                    if (DialogResult.Cancel == MessageBox.Show(String.Concat("Realmente desea eliminar al Personal '", _persEliminar.Nombres, _persEliminar.ApellidoPaterno, _persEliminar.ApellidoMaterno, "'"), "Mss", MessageBoxButtons.OKCancel, MessageBoxIcon.Question))
                    {
                        return;
                    }

                    if (_Empleado.EliminaPersonal(_usuarioSesion, _persEliminar))
                    {
                        MessageBox.Show("Se ha eliminado Empleado con éxito", "Mss", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        BtnLimpiar_Click(sender, e);
                        _PersonaSeleccionada = null;
                    }
                    else
                    {
                        MessageBox.Show("No se ha podido eliminado Empleado.", "Mss", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show(String.Concat("Debe seleccionar personal o ingresar Rut y Digito verificador en la sección 'Datos del Personal'."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    _PersonaSeleccionada = null;
                    return;
                }
            }
            catch (Exception ex)
            {
                Cursor.Current = Cursors.Default;
                MensajeControlado mensa = new MensajeControlado("", ex.Message, ex);
                mensa.Show();
                return;
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
示例#7
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;
            }
        }
示例#8
0
 public static Boolean _MensajeControlado(String mensaje, Exception ex)
 {
     try
     {
         Cursor.Current = Cursors.Default;
         MensajeControlado mensa = new MensajeControlado("", ex.Message, ex);
         mensa.Show();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
示例#9
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                MssBD.CentrosDeCostos _centroGuardar = new MssBD.CentrosDeCostos();
                Int32 CentroCodigo = 0;
                Int32.TryParse(txtCentroEdit.Text, out CentroCodigo);

                if (!ValidaDatos(_centroGuardar))
                {
                    return;
                }

                if (_centro.VerificaCódigo(CentroCodigo))
                {
                    if (DialogResult.Cancel == MessageBox.Show(String.Concat("¿Realmente desea modificar centro de costo?"), "Mss", MessageBoxButtons.OKCancel, MessageBoxIcon.Question))
                    {
                        return;
                    }

                    if (_centro.ModificaCentro(_usuarioSesion, _centroGuardar))
                    {
                        MessageBox.Show(String.Concat("Centro de costo '", _centroGuardar.CentroNombre, "' se ha guardado con éxito."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    if (_centro.GuardarCentro(_usuarioSesion, _centroGuardar))
                    {
                        MessageBox.Show(String.Concat("Nuevo centro de costo '", _centroGuardar.CentroNombre, "' se ha guardado con éxito."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }

                BtnLimpiar_Click(sender, e);
                // if(_centro.GuardarCentro(  Mss_Proyecto.CentroDeCostos egg))
            }
            catch (Exception ex)
            {
                Cursor.Current = Cursors.Default;
                MensajeControlado mensa = new MensajeControlado("", ex.Message, ex);
                mensa.Show();
                return;
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
示例#10
0
 private void btnImagenElimina_Click(object sender, EventArgs e)
 {
     try
     {
         txtImagen.Image             = null;
         _PersonaSeleccionada.Imagen = null;
     }
     catch (Exception ex)
     {
         Cursor.Current = Cursors.Default;
         MensajeControlado mensa = new MensajeControlado("", ex.Message, ex);
         mensa.Show();
         return;
     }
 }
示例#11
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                if (txtRutDato.Text != string.Empty && txtDvDato.Text != string.Empty)
                {
                    MssBD.Personal _emp = new MssBD.Personal();

                    if (ValidaDatos(_emp))
                    {
                        bool nuevo = false;

                        //if (!_Empleado.ExistePersonal(_emp))
                        //{
                        //    Usuario _us = new Usuario();
                        //    _us.nuevo = true;
                        //}

                        if (_Empleado.GuardaPersonal(_usuarioSesion, _emp, ref nuevo))
                        {
                            MessageBox.Show(String.Concat("Información de Personal se ha guardado con éxito."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            BuscaEmpleado();
                        }
                        else
                        {
                            MessageBox.Show(String.Concat("No se ha podido guardar la información del Personal."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                else
                {
                    MessageBox.Show(String.Concat("Debe seleccionar personal o ingresar Rut y Digito verificador en la sección 'Datos del Personal'."), "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;
            }
        }
示例#12
0
 private void BuscaLog()
 {
     try
     {
         Cursor.Current      = Cursors.WaitCursor;
         _Logs               = new Negocio.LogClass();
         gridLogs.DataSource = _Logs.BuscaLog(_UsuarioSesion, txtDesde.Value, txtHasta.Value);
     }
     catch (Exception ex)
     {
         Cursor.Current = Cursors.Default;
         MensajeControlado mensa = new MensajeControlado("", ex.Message, ex);
         mensa.Show();
         return;
     }
     finally
     {
         Cursor.Current = Cursors.Default;
     }
 }
示例#13
0
 private void BuscaDocumentosVisados()
 {
     try
     {
         Cursor.Current = Cursors.WaitCursor;
         MssBD.VW_DOC_Anexos _vw = new MssBD.VW_DOC_Anexos();
         gridContratos.DataSource = _Doc.BuscaAnexos_Visar(_usuarioSesion, txtDesde.Value, txtHasta.Value);
     }
     catch (Exception ex)
     {
         Cursor.Current = Cursors.Default;
         MensajeControlado mensa = new MensajeControlado("", ex.Message, ex);
         mensa.Show();
         return;
     }
     finally
     {
         Cursor.Current = Cursors.Default;
     }
 }
示例#14
0
 private void cboPrivilegios_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         int privi = 0;
         if (int.TryParse(cboPrivilegios.SelectedValue.ToString(), out privi))
         {
             if (privi == 5)
             {
                 txtCargo.Text = "Guardia";
                 return;
             }
         }
     }
     catch (Exception ex)
     {
         Cursor.Current = Cursors.Default;
         MensajeControlado mensa = new MensajeControlado("", ex.Message, ex);
         mensa.Show();
         return;
     }
 }
示例#15
0
 private void btnNuevo_Click_1(object sender, EventArgs e)
 {
     try
     {
         Cursor.Current           = Cursors.WaitCursor;
         txtEstructuraCodigo.Text = _estru.EncuentraUltimoCodigo().ToString();
         BtnLimpiar_Click(sender, e);
         btnEliminar.Enabled = false;
         btnNuevo.Enabled    = false;
         grp.Enabled         = false;
     }
     catch (Exception ex)
     {
         Cursor.Current = Cursors.Default;
         MensajeControlado mensa = new MensajeControlado("", ex.Message, ex);
         mensa.Show();
         return;
     }
     finally
     {
         Cursor.Current = Cursors.Default;
     }
 }
示例#16
0
        private void gridEmpleados_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (gridEmpleados.Rows.Count < 1)
                {
                    return;
                }
                Cursor.Current = Cursors.WaitCursor;

                var selectedUser = (MssBD.CON_Empleados_Rut_Centro_Result) this.gridEmpleados.CurrentRow.DataBoundItem;
                _ConsultaEmp = selectedUser;

                txtRutDato.Text = selectedUser.Rut.ToString();

                if (txtRutDato.Text != string.Empty)
                {
                    txtRutDato.Text = string.Format("{0:#,##0}", double.Parse(txtRutDato.Text));
                }
                else
                {
                    txtRutDato.Text = "0";
                }

                txtDvDato.Text          = selectedUser.Dv;
                txtApellidoPaterno.Text = selectedUser.ApellidoPaterno;
                txtApellidoMaterno.Text = selectedUser.ApellidoMaterno;
                txtNombres.Text         = selectedUser.Nombres;
                txtDireccion.Text       = selectedUser.Direccion;

                txtFechaInicio.Value      = selectedUser.FechaIngreso.Value;
                txtFechaVencimiento.Value = selectedUser.FechaVencimiento.Value;
                cboTipoContrato.Text      = selectedUser.TipoContrato;

                if (selectedUser.FechaNacimiento != null)
                {
                    txtFechaNacimiento.Value = (DateTime)selectedUser.FechaNacimiento;
                }
                else
                {
                    txtFechaNacimiento.Value = DateTime.Parse("19000101");
                }

                txtTeleFijo.Text = selectedUser.TelFijo;
                txtTeleCel.Text  = selectedUser.TelCelular;
                try
                {
                    cboEstadoCivil.SelectedItem = selectedUser.EstadoCivil;
                }
                catch (Exception)
                {
                }
            }
            catch (Exception ex)
            {
                Cursor.Current = Cursors.Default;
                MensajeControlado mensa = new MensajeControlado("", ex.Message, ex);
                mensa.Show();
                return;
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
示例#17
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;
            }
        }
示例#18
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;
            }
        }
示例#19
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                List <MssBD.VW_DOC_Contratos> _ListGrilla  = new List <MssBD.VW_DOC_Contratos>();
                List <MssBD.VW_DOC_Contratos> _ListGuardar = new List <MssBD.VW_DOC_Contratos>();

                gridContratos.Refresh();

                _ListGrilla = (List <MssBD.VW_DOC_Contratos>) this.gridContratos.DataSource;

                if (this.gridContratos.DataSource == null || _ListGrilla.Count() < 1)
                {
                    return;
                }

                foreach (DataGridViewRow item in this.gridContratos.Rows)
                {
                    if ((Boolean)item.Cells["porVisarDataGridViewCheckBoxColumn"].Value)
                    {
                        _ListGuardar.Add((MssBD.VW_DOC_Contratos)item.DataBoundItem);
                    }
                }

                //for (int i = 0; i < gridContratos.Rows.Count; i++)
                //{
                //    DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)gridContratos.Rows[i].Cells["porVisarDataGridViewCheckBoxColumn"];
                //    if ((Boolean)checkCell.Value)
                //    {
                //        _ListGuardar.Add((MssBD.VW_DOC_Contratos)gridContratos.Rows[i].DataBoundItem);
                //    }
                //}

                foreach (var item in _ListGrilla)
                {
                    if ((Boolean)item.PorVisar)
                    {
                        _ListGuardar.Add((MssBD.VW_DOC_Contratos)item);
                    }
                }

                if (_ListGuardar.Count == 0)
                {
                    MessageBox.Show(String.Concat("Debe seleccionar algún Contrato a autorizar."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                String mensaje = string.Empty;
                Folder.ShowDialog();
                if (Folder.SelectedPath.ToString() != string.Empty)
                {
                    Negocio.Documentos.Contratos _Contrato = new Negocio.Documentos.Contratos(_usuarioSesion);

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

                    if (!_Contrato.GenereContratosMasivos(ref mensaje, _ListGuardar, String.Concat(Folder.SelectedPath.ToString(), "\\")))
                    {
                        if (mensaje == string.Empty)
                        {
                            MessageBox.Show(String.Concat("Ha ocurrido un problema al generar Contrato."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            MessageBox.Show(String.Concat(mensaje), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show(String.Concat("Contratos se han generado con éxito."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

                    BuscaDocumentosVisados();
                }
            }
            catch (Exception ex)
            {
                Cursor.Current = Cursors.Default;
                MensajeControlado mensa = new MensajeControlado("", ex.Message, ex);
                mensa.Show();
                return;
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
示例#20
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;
            }
        }