Example #1
0
        private void BuscaRemuneraciones()
        {
            try
            {
                List <MssBD.Remuneraciones> _listRemus = new List <MssBD.Remuneraciones>();
                _NegRemu   = new Negocio.Documentos.Remuneracion();
                _listRemus = _NegRemu.BuscaRemuneraciones(_usuarioSesion, (Int32)_Finiquito.Finiquito_Id);

                gridRemuneraciones.DataSource = _listRemus;
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #2
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;
            }
        }