Пример #1
0
        private void frmListaConceptos_Load(object sender, EventArgs e)
        {
            cnx = new SqlConnection(cdn);
            cmd = new SqlCommand();
            cmd.Connection = cnx;

            Periodos.Core.PeriodosHelper ph = new Periodos.Core.PeriodosHelper();
            ph.Command = cmd;

            Periodos.Core.Periodos periodo = new Periodos.Core.Periodos();
            periodo.idempresa = GLOBALES.IDEMPRESA;

            List<Periodos.Core.Periodos> lstPeriodos = new List<Periodos.Core.Periodos>();
            try
            {
                cnx.Open();
                lstPeriodos = ph.obtenerPeriodos(periodo);
                cnx.Close();
                cnx.Dispose();
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: Al obtener los periodos de la empresa.\r\n\r\n" + error.Message, "Error");
                cnx.Dispose();
            }

            cmbPeriodos.DataSource = lstPeriodos;
            cmbPeriodos.DisplayMember = "pago";
            cmbPeriodos.ValueMember = "dias";

            dgvConceptos.RowHeadersVisible = false;
            ListaConceptos();
            CargaPerfil();
        }
Пример #2
0
        private void cmbCliente_SelectionChangeCommitted(object sender, EventArgs e)
        {
            cnx = new MySqlConnection();
            cnx.ConnectionString = cdn;
            cmd            = new MySqlCommand();
            cmd.Connection = cnx;

            Periodos.Core.PeriodosHelper ph = new Periodos.Core.PeriodosHelper();
            ph.Command = cmd;

            Periodos.Core.Periodos p = new Periodos.Core.Periodos();
            p.idcliente = int.Parse(cmbCliente.SelectedValue.ToString());

            List <Periodos.Core.Periodos> lstPeriodo = new List <Periodos.Core.Periodos>();

            try
            {
                cnx.Open();
                lstPeriodo = ph.obtenerPeriodoCliente(p);
                cnx.Close();
                cnx.Dispose();
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
                this.Dispose();
            }

            cmbPeriodo.DataSource    = lstPeriodo.ToList();
            cmbPeriodo.DisplayMember = "pago";
            cmbPeriodo.ValueMember   = "idperiodo";
        }
Пример #3
0
        private void toolBaja_Click(object sender, EventArgs e)
        {
            DialogResult respuesta = MessageBox.Show("¿Quiere eliminar el periodo?", "Confirmación", MessageBoxButtons.YesNo);

            if (respuesta == DialogResult.Yes)
            {
                string cdn  = ConfigurationManager.ConnectionStrings["cdnNomina"].ConnectionString;
                int    fila = dgvPeriodos.CurrentCell.RowIndex;
                int    id   = int.Parse(dgvPeriodos.Rows[fila].Cells[0].Value.ToString());
                cnx            = new MySqlConnection(cdn);
                cmd            = new MySqlCommand();
                cmd.Connection = cnx;
                Periodos.Core.PeriodosHelper ph = new Periodos.Core.PeriodosHelper();
                ph.Command = cmd;
                Periodos.Core.Periodos periodo = new Periodos.Core.Periodos();
                periodo.idperiodo = id;
                periodo.estatus   = 0;
                try
                {
                    cnx.Open();
                    ph.bajaPeriodo(periodo);
                    cnx.Close();
                    cnx.Dispose();
                    ListaPeriodos();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
                }
            }
        }
Пример #4
0
        private void frmSeleccionPeriodo_Load(object sender, EventArgs e)
        {
            cnx = new SqlConnection(cdn);
            cmd = new SqlCommand();
            cmd.Connection = cnx;

            ph = new Periodos.Core.PeriodosHelper();
            ph.Command = cmd;

            Periodos.Core.Periodos periodo = new Periodos.Core.Periodos();
            periodo.idempresa = GLOBALES.IDEMPRESA;

            lstPeriodos = new List<Periodos.Core.Periodos>();
            try
            {
                cnx.Open();
                lstPeriodos = ph.obtenerPeriodos(periodo);
                cnx.Close();
                cnx.Dispose();
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: \r\n \r\n" + error.Message, "Error");
            }

            cmbPeriodo.DataSource = lstPeriodos;
            cmbPeriodo.DisplayMember = "pago";
            cmbPeriodo.ValueMember = "idperiodo";

            if (GLOBALES.OBRACIVIL)
                chkObraCivil.Visible = true;
            else
                chkObraCivil.Visible = false;
        }
        private void calculo(double valor, int tipo)
        {
            int DiasDePago = 0;
            double FactorDePago = 0;
            cnx = new SqlConnection();
            cnx.ConnectionString = cdn;
            cmd = new SqlCommand();
            cmd.Connection = cnx;

            Periodos.Core.PeriodosHelper ph = new Periodos.Core.PeriodosHelper();
            Periodos.Core.Periodos p = new Periodos.Core.Periodos();
            Factores.Core.FactoresHelper fh = new Factores.Core.FactoresHelper();
            Factores.Core.Factores f = new Factores.Core.Factores();

            ph.Command = cmd;
            fh.Command = cmd;

            p.idperiodo = idperiodo;
            f.anio = antiguedad;

            try
            {
                cnx.Open();
                DiasDePago = (int)ph.DiasDePago(p);
                FactorDePago = double.Parse(fh.FactorDePago(f).ToString());
                cnx.Close();
                cnx.Dispose();
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
                this.Dispose();
            }

            switch (tipo)
            {
                case 0:
                    txtSD.Text = (double.Parse(txtSDI.Text) / FactorDePago).ToString("F6");
                    txtSueldo.Text = (double.Parse(txtSD.Text) * DiasDePago).ToString("F6");
                    break;
                case 1:
                    txtSD.Text = (double.Parse(txtSueldo.Text) / DiasDePago).ToString("F6");
                    txtSDI.Text = (double.Parse(txtSD.Text) * FactorDePago).ToString("F6");
                    break;
            }
        }
        private int ObtenerDiasProporcionales(DateTime fechaingreso)
        {
            cnx = new SqlConnection();
            cnx.ConnectionString = cdn;
            cmd = new SqlCommand();
            cmd.Connection = cnx;

            ph = new Periodos.Core.PeriodosHelper();
            ph.Command = cmd;

            Periodos.Core.Periodos p = new Periodos.Core.Periodos();
            p.idperiodo = idPeriodo;
            int diasPago = 0;
            try { cnx.Open(); diasPago = (int)ph.DiasDePago(p); cnx.Close(); }
            catch { MessageBox.Show("Error: Al obtener los dias de pago.", "Error"); }

            DateTime dt = fechaingreso.Date;

            int diasProporcionales = 0;
            if (diasPago == 7)
            {
                while (dt.DayOfWeek != DayOfWeek.Monday) dt = dt.AddDays(-1);
                periodoInicio = dt;
                periodoFin = dt.AddDays(6);
                diasProporcionales = (int)(periodoFin.Date - fechaingreso.Date).TotalDays + 1;
            }
            else
            {
                if (dt.Day <= 15)
                {
                    periodoInicio = new DateTime(dt.Year, dt.Month, 1);
                    periodoFin = new DateTime(dt.Year, dt.Month, 15);
                    diasProporcionales = (int)(periodoFin.Date - fechaingreso.Date).TotalDays + 1;
                }
                else
                {
                    int diasMes = DateTime.DaysInMonth(dt.Year, dt.Month);
                    int diasNoLaborados = 0;
                    periodoInicio = new DateTime(dt.Year, dt.Month, 16);
                    periodoFin = new DateTime(dt.Year, dt.Month, DateTime.DaysInMonth(dt.Year, dt.Month));
                    diasNoLaborados = (int)(fechaingreso.Date - periodoInicio).TotalDays;
                    diasProporcionales = 15 - diasNoLaborados;
                }
            }
            return diasProporcionales;
        }
Пример #7
0
        private void btnCalcular_Click(object sender, EventArgs e)
        {
            if (txtSueldo.Text.Length != 0)
            {
                int    DiasDePago   = 0;
                double FactorDePago = 0;
                cnx = new MySqlConnection();
                cnx.ConnectionString = cdn;
                cmd            = new MySqlCommand();
                cmd.Connection = cnx;

                Periodos.Core.PeriodosHelper ph = new Periodos.Core.PeriodosHelper();
                Periodos.Core.Periodos       p  = new Periodos.Core.Periodos();
                Factores.Core.FactoresHelper fh = new Factores.Core.FactoresHelper();
                Factores.Core.Factores       f  = new Factores.Core.Factores();

                ph.Command = cmd;
                fh.Command = cmd;

                p.idperiodo = int.Parse(cmbPeriodo.SelectedValue.ToString());
                f.anio      = 0;

                try
                {
                    cnx.Open();
                    DiasDePago   = (int)ph.DiasDePago(p);
                    FactorDePago = double.Parse(fh.FactorDePago(f).ToString());
                    cnx.Close();
                    cnx.Dispose();

                    txtSD.Text  = (double.Parse(txtSueldo.Text) / DiasDePago).ToString("F4");
                    txtSDI.Text = (double.Parse(txtSD.Text) * FactorDePago).ToString("F4");
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
                    this.Dispose();
                }
            }
        }
Пример #8
0
        private void ListaPeriodos()
        {
            string cdn = ConfigurationManager.ConnectionStrings["cdnNomina"].ConnectionString;
            cnx = new SqlConnection(cdn);
            cmd = new SqlCommand();
            cmd.Connection = cnx;
            Periodos.Core.PeriodosHelper ph = new Periodos.Core.PeriodosHelper();
            ph.Command = cmd;
            Periodos.Core.Periodos periodos = new Periodos.Core.Periodos();
            periodos.idempresa = GLOBALES.IDEMPRESA;

            try
            {
                cnx.Open();
                lstPeriodos = ph.obtenerPeriodos(periodos);
                cnx.Close();
                cnx.Dispose();

                var periodo = from p in lstPeriodos
                              select new
                              {
                                  IdPeriodo = p.idperiodo,
                                  Pago = p.pago
                              };

                dgvPeriodos.DataSource = periodo.ToList();

                for (int i = 0; i < dgvPeriodos.Columns.Count; i++)
                {
                    dgvPeriodos.AutoResizeColumn(i);
                }
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
            }
        }
Пример #9
0
        private void CargaComboBox()
        {
            cnx = new SqlConnection();
            cnx.ConnectionString = cdn;
            cmd = new SqlCommand();
            cmd.Connection = cnx;

            cath = new Catalogos.Core.CatalogosHelper();
            cath.Command = cmd;
            Catalogos.Core.Catalogo ts = new Catalogos.Core.Catalogo();
            ts.grupodescripcion = "SALARIO";

            Catalogos.Core.Catalogo tr = new Catalogos.Core.Catalogo();
            tr.grupodescripcion = "TIPO DE REGIMEN";

            Catalogos.Core.Catalogo mp = new Catalogos.Core.Catalogo();
            mp.grupodescripcion = "METODO DE PAGO";

            dh = new Departamento.Core.DeptoHelper();
            dh.Command = cmd;
            Departamento.Core.Depto depto = new Departamento.Core.Depto();
            depto.idempresa = GLOBALES.IDEMPRESA;

            ph = new Puestos.Core.PuestosHelper();
            ph.Command = cmd;
            Puestos.Core.Puestos puesto = new Puestos.Core.Puestos();
            puesto.idempresa = GLOBALES.IDEMPRESA;

            edoh = new Estados.Core.EstadosHelper();
            edoh.Command = cmd;

            pdh = new Periodos.Core.PeriodosHelper();
            pdh.Command = cmd;
            Periodos.Core.Periodos periodo = new Periodos.Core.Periodos();
            periodo.idempresa = GLOBALES.IDEMPRESA;

            sh = new Salario.Core.SalariosHelper();
            sh.Command = cmd;

            List<Catalogos.Core.Catalogo> lstTipoSalario = new List<Catalogos.Core.Catalogo>();
            List<Departamento.Core.Depto> lstDepto = new List<Departamento.Core.Depto>();
            List<Puestos.Core.Puestos> lstPuesto = new List<Puestos.Core.Puestos>();
            List<Estados.Core.Estados> lstEstados = new List<Estados.Core.Estados>();
            List<Periodos.Core.Periodos> lstPeriodos = new List<Periodos.Core.Periodos>();
            List<Salario.Core.Salarios> lstSalario = new List<Salario.Core.Salarios>();
            List<Catalogos.Core.Catalogo> lstTipoRegimen = new List<Catalogos.Core.Catalogo>();
            List<Catalogos.Core.Catalogo> lstMetodoPago = new List<Catalogos.Core.Catalogo>();

            try
            {
                cnx.Open();
                lstTipoSalario = cath.obtenerGrupo(ts);
                lstDepto = dh.obtenerDepartamentos(depto);
                lstPuesto = ph.obtenerPuestos(puesto);
                lstEstados = edoh.obtenerEstados();
                lstPeriodos = pdh.obtenerPeriodos(periodo);
                lstSalario = sh.obtenerSalarios();
                lstTipoRegimen = cath.obtenerGrupo(tr);
                lstMetodoPago = cath.obtenerGrupo(mp);
                cnx.Close();
                cnx.Dispose();
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
                this.Dispose();
            }

            cmbTipoSalario.DataSource = lstTipoSalario.ToList();
            cmbTipoSalario.DisplayMember = "descripcion";
            cmbTipoSalario.ValueMember = "id";

            cmbDepartamento.DataSource = lstDepto.ToList();
            cmbDepartamento.DisplayMember = "descripcion";
            cmbDepartamento.ValueMember = "id";

            cmbPuesto.DataSource = lstPuesto.ToList();
            cmbPuesto.DisplayMember = "nombre";
            cmbPuesto.ValueMember = "idpuesto";

            cmbEstado.DataSource = lstEstados.ToList();
            cmbEstado.DisplayMember = "nombre";
            cmbEstado.ValueMember = "idestado";

            cmbPeriodo.DataSource = lstPeriodos.ToList();
            cmbPeriodo.DisplayMember = "pago";
            cmbPeriodo.ValueMember = "idperiodo";

            cmbZona.DataSource = lstSalario.ToList();
            cmbZona.DisplayMember = "zona";
            cmbZona.ValueMember = "idsalario";

            cmbTipoRegimen.DataSource = lstTipoRegimen.ToList();
            cmbTipoRegimen.DisplayMember = "descripcion";
            cmbTipoRegimen.ValueMember = "id";

            cmbMetodoPago.SelectedIndex = 2;

            //cmbMetodoPago.DataSource = lstMetodoPago.ToList();
            //cmbMetodoPago.DisplayMember = "descripcion";
            //cmbMetodoPago.ValueMember = "id";
        }
Пример #10
0
        private void cmbPeriodo_SelectedIndexChanged(object sender, EventArgs e)
        {
            cnx = new SqlConnection(cdn);
            cmd = new SqlCommand();
            cmd.Connection = cnx;

            CalculoNomina.Core.NominaHelper nh = new CalculoNomina.Core.NominaHelper();
            nh.Command = cmd;

            Periodos.Core.PeriodosHelper ph = new Periodos.Core.PeriodosHelper();
            ph.Command = cmd;

            Periodos.Core.Periodos p = new Periodos.Core.Periodos();
            if (!FLAG_COMBOBOX)
            {
                Periodos.Core.Periodos a = (Periodos.Core.Periodos)cmbPeriodo.SelectedValue;
                p.idperiodo = a.idperiodo;
            }
            else
                p.idperiodo = int.Parse(cmbPeriodo.SelectedValue.ToString());

            List<CalculoNomina.Core.tmpPagoNomina> lstPeriodos = new List<CalculoNomina.Core.tmpPagoNomina>();
            lstvPeriodos.Items.Clear();

            try
            {
                cnx.Open();
                periodo = int.Parse(ph.DiasDePago(p).ToString());
                cnx.Close();
            }
            catch (Exception error) { MessageBox.Show("Error: \r\n \r\n" + error.Message, "Error"); }

            switch (cmbTipoNomina.Text)
            {
                case "Normal":
                    try
                    {
                        cnx.Open();
                        lstPeriodos = nh.obtenerPeriodosNomina(GLOBALES.IDEMPRESA, GLOBALES.NORMAL, periodo);
                        cnx.Close();
                        cnx.Dispose();
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Error: Al obtener los periodos de la empresa.", "Error");
                        cnx.Dispose();
                        return;
                    }
                    break;

                case "Extraordinaria normal":
                    try
                    {
                        cnx.Open();
                        lstPeriodos = nh.obtenerPeriodosNomina(GLOBALES.IDEMPRESA, GLOBALES.EXTRAORDINARIO_NORMAL, periodo);
                        cnx.Close();
                        cnx.Dispose();
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Error: Al obtener los periodos de la empresa.", "Error");
                        cnx.Dispose();
                        return;
                    }
                    break;
            }

            for (int i = 0; i < lstPeriodos.Count; i++)
            {
                ListViewItem Lista;
                Lista = lstvPeriodos.Items.Add(lstPeriodos[i].fechainicio.ToShortDateString());
                Lista.SubItems.Add(lstPeriodos[i].fechafin.ToShortDateString());
            }
        }
Пример #11
0
        public static List<CalculoNomina.Core.tmpPagoNomina> DEDUCCIONES(List<CalculoNomina.Core.Nomina> lstConceptosDeducciones,
            List<CalculoNomina.Core.tmpPagoNomina> lstPercepciones, DateTime inicio, DateTime fin, int tipoNomina)
        {
            #region VARIABLES GLOBALES
            string cdn = ConfigurationManager.ConnectionStrings["cdnNomina"].ConnectionString;
            SqlConnection cnx = new SqlConnection(cdn);
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = cnx;
            #endregion

            #region VARIABLES
            bool activoInfonavit = false;
            #endregion

            #region LISTA PARA DATOS DEL TRABAJADOR
            List<CalculoNomina.Core.tmpPagoNomina> lstValoresNomina;
            List<CalculoNomina.Core.tmpPagoNomina> lstValoresDefinitivos;
            #endregion

            #region CALCULO
            lstValoresNomina = new List<CalculoNomina.Core.tmpPagoNomina>();
            decimal isrAntes = 0, subsidioAntes = 0;

            for (int i = 0; i < lstConceptosDeducciones.Count; i++)
            {
                decimal percepciones = lstPercepciones.Where(e => e.idtrabajador == lstConceptosDeducciones[i].idtrabajador && e.tipoconcepto == "P").Sum(e => e.cantidad);

                switch (lstConceptosDeducciones[i].noconcepto)
                {

                    #region CONCEPTO IMSS
                    case 99:
                        int vsmdf, idsalario;
                        decimal porcentajeImss, excedenteVsmdf, sm, sdiTrabajador;

                        Configuracion.Core.ConfiguracionHelper ch = new Configuracion.Core.ConfiguracionHelper();
                        ch.Command = cmd;

                        Imss.Core.ImssHelper ih = new Imss.Core.ImssHelper();
                        ih.Command = cmd;

                        Imss.Core.Imss imss = new Imss.Core.Imss();
                        imss.secalcula = true;

                        Empleados.Core.EmpleadosHelper empleadosHelper = new Empleados.Core.EmpleadosHelper();
                        empleadosHelper.Command = cmd;
                        Empleados.Core.Empleados empleadoImss = new Empleados.Core.Empleados();
                        empleadoImss.idtrabajador = lstConceptosDeducciones[i].idtrabajador;

                        Salario.Core.SalariosHelper sh = new Salario.Core.SalariosHelper();
                        sh.Command = cmd;
                        Salario.Core.Salarios salario = new Salario.Core.Salarios();

                        cnx.Open();
                        vsmdf = int.Parse(ch.obtenerValorConfiguracion("VSMDF").ToString());
                        porcentajeImss = ih.CuotaObreroPatronal(imss);
                        excedenteVsmdf = ih.ExcedenteVSM(5);
                        idsalario = int.Parse(empleadosHelper.obtenerIdSalarioMinimo(lstConceptosDeducciones[i].idtrabajador).ToString());
                        salario.idsalario = idsalario;
                        sm = decimal.Parse(sh.obtenerSalarioValor(salario).ToString());
                        sdiTrabajador = decimal.Parse(empleadosHelper.obtenerSalarioDiarioIntegrado(empleadoImss).ToString());
                        cnx.Close();

                        string formulaDiasAPagar = "[DiasLaborados]-[Faltas]-[DiasIncapacidad]";
                        CalculoFormula cfImss = new CalculoFormula(lstConceptosDeducciones[i].idtrabajador, inicio, fin, formulaDiasAPagar);
                        int diasAPagar = int.Parse(cfImss.calcularFormula().ToString());

                        decimal tresVSMG = vsmdf * sm;
                        decimal excedenteImss = 0;
                        decimal valorImss = (sdiTrabajador * (porcentajeImss / 100)) * diasAPagar;
                        decimal totalImss = 0;
                        if (sdiTrabajador > tresVSMG)
                        {
                            excedenteImss = (sdiTrabajador - tresVSMG) * (excedenteVsmdf / 100) * diasAPagar;
                            totalImss = valorImss + excedenteImss;
                        }
                        else
                            totalImss = valorImss;

                        CalculoNomina.Core.tmpPagoNomina imssNomina = new CalculoNomina.Core.tmpPagoNomina();
                        imssNomina.idtrabajador = lstConceptosDeducciones[i].idtrabajador;
                        imssNomina.idempresa = GLOBALES.IDEMPRESA;
                        imssNomina.idconcepto = lstConceptosDeducciones[i].id;
                        imssNomina.noconcepto = lstConceptosDeducciones[i].noconcepto;
                        imssNomina.tipoconcepto = lstConceptosDeducciones[i].tipoconcepto;
                        imssNomina.fechainicio = inicio.Date;
                        imssNomina.fechafin = fin.Date;
                        imssNomina.exento = 0;
                        imssNomina.gravado = 0;
                        imssNomina.cantidad = totalImss;
                        imssNomina.diaslaborados = 0;
                        imssNomina.guardada = false;
                        imssNomina.tiponomina = tipoNomina;
                        imssNomina.modificado = false;

                        lstValoresNomina.Add(imssNomina);
                        break;
                    #endregion

                    #region CONCEPTO ISR ANTES DE SUBSIDIO
                    case 8:

                        decimal excedente = 0, ImpMarginal = 0, isr = 0;
                        List<TablaIsr.Core.TablaIsr> lstIsr = new List<TablaIsr.Core.TablaIsr>();
                        TablaIsr.Core.IsrHelper isrh = new TablaIsr.Core.IsrHelper();
                        isrh.Command = cmd;

                        CalculoNomina.Core.tmpPagoNomina isrAntesSubsidio = new CalculoNomina.Core.tmpPagoNomina();
                        isrAntesSubsidio.idtrabajador = lstConceptosDeducciones[i].idtrabajador;
                        isrAntesSubsidio.idempresa = GLOBALES.IDEMPRESA;
                        isrAntesSubsidio.idconcepto = lstConceptosDeducciones[i].id;
                        isrAntesSubsidio.noconcepto = lstConceptosDeducciones[i].noconcepto;
                        isrAntesSubsidio.tipoconcepto = lstConceptosDeducciones[i].tipoconcepto;
                        isrAntesSubsidio.fechainicio = inicio.Date;
                        isrAntesSubsidio.fechafin = fin.Date;
                        isrAntesSubsidio.exento = 0;
                        isrAntesSubsidio.gravado = 0;

                        if (percepciones != 0)
                        {
                            decimal baseGravableIsr = lstPercepciones.Where(e => e.idtrabajador == lstConceptosDeducciones[i].idtrabajador).Sum(e => e.gravado);

                            Empleados.Core.EmpleadosHelper eh = new Empleados.Core.EmpleadosHelper();
                            eh.Command = cmd;

                            cnx.Open();
                            int idperiodo = (int)eh.obtenerIdPeriodo(lstConceptosDeducciones[i].idtrabajador);
                            cnx.Close();

                            Periodos.Core.PeriodosHelper ph = new Periodos.Core.PeriodosHelper();
                            ph.Command = cmd;

                            Periodos.Core.Periodos p = new Periodos.Core.Periodos();
                            p.idperiodo = idperiodo;

                            cnx.Open();
                            int dias = (int)ph.DiasDePago(p);
                            cnx.Close();

                            TablaIsr.Core.TablaIsr _isr = new TablaIsr.Core.TablaIsr();
                            _isr.inferior = (baseGravableIsr / dias) * decimal.Parse((30.4).ToString());

                            cnx.Open();
                            lstIsr = isrh.isrCorrespondiente(_isr);
                            cnx.Close();

                            excedente = ((baseGravableIsr / dias) * decimal.Parse((30.4).ToString())) - lstIsr[0].inferior;
                            ImpMarginal = excedente * (lstIsr[0].porcentaje / 100);
                            isr = ImpMarginal + lstIsr[0].cuota;

                            isrAntesSubsidio.cantidad = (isr / decimal.Parse((30.4).ToString())) * dias;
                            isrAntes = (isr / decimal.Parse((30.4).ToString())) * dias;
                        }
                        else
                        {
                            isrAntes = 0;
                            isrAntesSubsidio.cantidad = 0;
                            //double vacaciones = lstPercepciones.Where(e => e.idtrabajador == lstPercepciones[i].idtrabajador && e.noconcepto == 7).Sum(e => e.cantidad);
                            //if (vacaciones != 0)
                            //{
                            //    double baseGravableIsr = lstPercepciones.Where(e => e.idtrabajador == lstConceptosDeducciones[i].idtrabajador).Sum(e => e.gravado);

                            //    Empleados.Core.EmpleadosHelper eh = new Empleados.Core.EmpleadosHelper();
                            //    eh.Command = cmd;

                            //    cnx.Open();
                            //    int idperiodo = (int)eh.obtenerIdPeriodo(lstConceptosDeducciones[i].idtrabajador);
                            //    cnx.Close();

                            //    Periodos.Core.PeriodosHelper ph = new Periodos.Core.PeriodosHelper();
                            //    ph.Command = cmd;

                            //    Periodos.Core.Periodos p = new Periodos.Core.Periodos();
                            //    p.idperiodo = idperiodo;

                            //    cnx.Open();
                            //    int dias = (int)ph.DiasDePago(p);
                            //    cnx.Close();

                            //    TablaIsr.Core.TablaIsr _isr = new TablaIsr.Core.TablaIsr();
                            //    _isr.inferior = (baseGravableIsr / dias) * 30.4;

                            //    cnx.Open();
                            //    lstIsr = isrh.isrCorrespondiente(_isr);
                            //    cnx.Close();

                            //    excedente = ((baseGravableIsr / dias) * 30.4) - lstIsr[0].inferior;
                            //    ImpMarginal = excedente * (lstIsr[0].porcentaje / 100);
                            //    isr = ImpMarginal + lstIsr[0].cuota;

                            //    isrAntesSubsidio.cantidad = isr;
                            //    isrAntes = isr;
                            //}
                            //else
                            //{
                            //    isrAntes = 0;
                            //    isrAntesSubsidio.cantidad = 0;
                            //}
                        }

                        isrAntesSubsidio.guardada = false;
                        isrAntesSubsidio.tiponomina = tipoNomina;
                        isrAntesSubsidio.modificado = false;
                        lstValoresNomina.Add(isrAntesSubsidio);
                        break;
                    #endregion

                    #region SUBSIDIO
                    case 15:
                        //double sueldoSubsidio = lstPercepciones.Where(e => e.idtrabajador == lstConceptosDeducciones[i].idtrabajador && e.noconcepto == 1).Sum(e => e.cantidad);

                        CalculoNomina.Core.tmpPagoNomina subsidioNomina = new CalculoNomina.Core.tmpPagoNomina();
                        subsidioNomina.idtrabajador = lstConceptosDeducciones[i].idtrabajador;
                        subsidioNomina.idempresa = GLOBALES.IDEMPRESA;
                        subsidioNomina.idconcepto = lstConceptosDeducciones[i].id;
                        subsidioNomina.noconcepto = lstConceptosDeducciones[i].noconcepto;
                        subsidioNomina.tipoconcepto = lstConceptosDeducciones[i].tipoconcepto;
                        subsidioNomina.fechainicio = inicio.Date;
                        subsidioNomina.fechafin = fin.Date;
                        subsidioNomina.exento = 0;
                        subsidioNomina.gravado = 0;

                        if (percepciones != 0)
                        {
                            decimal baseGravableSubsidio = lstPercepciones.Where(e => e.idtrabajador == lstConceptosDeducciones[i].idtrabajador).Sum(e => e.gravado);

                            Empleados.Core.EmpleadosHelper eh = new Empleados.Core.EmpleadosHelper();
                            eh.Command = cmd;

                            cnx.Open();
                            int idperiodo = (int)eh.obtenerIdPeriodo(lstConceptosDeducciones[i].idtrabajador);
                            cnx.Close();

                            Periodos.Core.PeriodosHelper ph = new Periodos.Core.PeriodosHelper();
                            ph.Command = cmd;

                            Periodos.Core.Periodos p = new Periodos.Core.Periodos();
                            p.idperiodo = idperiodo;

                            cnx.Open();
                            int dias = (int)ph.DiasDePago(p);
                            cnx.Close();

                            TablaSubsidio.Core.SubsidioHelper ts = new TablaSubsidio.Core.SubsidioHelper();
                            ts.Command = cmd;
                            TablaSubsidio.Core.TablaSubsidio subsidio = new TablaSubsidio.Core.TablaSubsidio();
                            subsidio.desde = (baseGravableSubsidio / dias) * decimal.Parse((30.4).ToString());

                            decimal cantidad = 0;
                            cnx.Open();
                            cantidad = decimal.Parse(ts.obtenerCantidadSubsidio(subsidio).ToString());
                            cnx.Close();

                            subsidioNomina.cantidad = (cantidad / decimal.Parse((30.4).ToString())) * dias;
                            subsidioAntes = (cantidad / decimal.Parse((30.4).ToString())) * dias;
                        }
                        else
                        {
                            subsidioNomina.cantidad = 0;
                            subsidioAntes = 0;
                            //double vacacionesSubsidio = lstPercepciones.Where(e => e.idtrabajador == lstConceptosDeducciones[i].idtrabajador && e.noconcepto == 7).Sum(e => e.cantidad);
                            //if (vacacionesSubsidio != 0)
                            //{
                            //    double baseGravableSubsidio = lstPercepciones.Where(e => e.idtrabajador == lstConceptosDeducciones[i].idtrabajador).Sum(e => e.gravado);

                            //    Empleados.Core.EmpleadosHelper eh = new Empleados.Core.EmpleadosHelper();
                            //    eh.Command = cmd;

                            //    cnx.Open();
                            //    int idperiodo = (int)eh.obtenerIdPeriodo(lstConceptosDeducciones[i].idtrabajador);
                            //    cnx.Close();

                            //    Periodos.Core.PeriodosHelper ph = new Periodos.Core.PeriodosHelper();
                            //    ph.Command = cmd;

                            //    Periodos.Core.Periodos p = new Periodos.Core.Periodos();
                            //    p.idperiodo = idperiodo;

                            //    cnx.Open();
                            //    int dias = (int)ph.DiasDePago(p);
                            //    cnx.Close();

                            //    TablaSubsidio.Core.SubsidioHelper ts = new TablaSubsidio.Core.SubsidioHelper();
                            //    ts.Command = cmd;
                            //    TablaSubsidio.Core.TablaSubsidio subsidio = new TablaSubsidio.Core.TablaSubsidio();
                            //    subsidio.desde = (baseGravableSubsidio / dias) * 30.4;

                            //    double cantidad = 0;
                            //    cnx.Open();
                            //    cantidad = double.Parse(ts.obtenerCantidadSubsidio(subsidio).ToString());
                            //    cnx.Close();

                            //    subsidioNomina.cantidad = cantidad;
                            //    subsidioAntes = cantidad;
                            //}
                            //else
                            //{
                            //    subsidioNomina.cantidad = 0;
                            //    subsidioAntes = 0;
                            //}
                        }

                        subsidioNomina.guardada = false;
                        subsidioNomina.tiponomina = tipoNomina;
                        subsidioNomina.modificado = false;
                        lstValoresNomina.Add(subsidioNomina);
                        break;
                    #endregion

                    #region SUBSIDIO DEFINITIVO
                    case 16:
                        CalculoNomina.Core.tmpPagoNomina subsidioDefinitivo = new CalculoNomina.Core.tmpPagoNomina();
                        subsidioDefinitivo.idtrabajador = lstConceptosDeducciones[i].idtrabajador;
                        subsidioDefinitivo.idempresa = GLOBALES.IDEMPRESA;
                        subsidioDefinitivo.idconcepto = lstConceptosDeducciones[i].id;
                        subsidioDefinitivo.noconcepto = lstConceptosDeducciones[i].noconcepto;
                        subsidioDefinitivo.tipoconcepto = lstConceptosDeducciones[i].tipoconcepto;
                        subsidioDefinitivo.fechainicio = inicio.Date;
                        subsidioDefinitivo.fechafin = fin.Date;
                        subsidioDefinitivo.exento = 0;
                        subsidioDefinitivo.gravado = 0;

                        //double sueldoSubsidioDefinitivo = lstPercepciones.Where(e => e.idtrabajador == lstConceptosDeducciones[i].idtrabajador && e.noconcepto == 1).Sum(e => e.cantidad);

                        if (percepciones != 0)
                        {
                            Empleados.Core.EmpleadosHelper esh = new Empleados.Core.EmpleadosHelper();
                            esh.Command = cmd;

                            cnx.Open();
                            int idperiodoSubsidio = (int)esh.obtenerIdPeriodo(lstConceptosDeducciones[i].idtrabajador);
                            cnx.Close();

                            Periodos.Core.PeriodosHelper psh = new Periodos.Core.PeriodosHelper();
                            psh.Command = cmd;

                            Periodos.Core.Periodos ps = new Periodos.Core.Periodos();
                            ps.idperiodo = idperiodoSubsidio;

                            cnx.Open();
                            int diasSubsidio = (int)psh.DiasDePago(ps);
                            cnx.Close();

                            if (subsidioAntes > isrAntes)
                                subsidioDefinitivo.cantidad = subsidioAntes - isrAntes;
                            else
                                subsidioDefinitivo.cantidad = 0;
                        }
                        else
                        {
                            subsidioDefinitivo.cantidad = 0;
                            //double vacacionSubsidioDefinitivo = lstPercepciones.Where(e => e.idtrabajador == lstConceptosDeducciones[i].idtrabajador && e.noconcepto == 7).Sum(e => e.cantidad);
                            //if (vacacionSubsidioDefinitivo != 0)
                            //{
                            //    Empleados.Core.EmpleadosHelper esh = new Empleados.Core.EmpleadosHelper();
                            //    esh.Command = cmd;

                            //    cnx.Open();
                            //    int idperiodoSubsidio = (int)esh.obtenerIdPeriodo(lstConceptosDeducciones[i].idtrabajador);
                            //    cnx.Close();

                            //    Periodos.Core.PeriodosHelper psh = new Periodos.Core.PeriodosHelper();
                            //    psh.Command = cmd;

                            //    Periodos.Core.Periodos ps = new Periodos.Core.Periodos();
                            //    ps.idperiodo = idperiodoSubsidio;

                            //    cnx.Open();
                            //    int diasSubsidio = (int)psh.DiasDePago(ps);
                            //    cnx.Close();

                            //    if (subsidioAntes > isrAntes)
                            //        subsidioDefinitivo.cantidad = subsidioAntes - isrAntes;
                            //    else
                            //        subsidioDefinitivo.cantidad = 0;
                            //}
                            //else
                            //    subsidioDefinitivo.cantidad = 0;
                        }

                        subsidioDefinitivo.guardada = false;
                        subsidioDefinitivo.tiponomina = tipoNomina;
                        subsidioDefinitivo.modificado = false;
                        lstValoresNomina.Add(subsidioDefinitivo);
                        break;
                    #endregion

                    #region ISR DEFINITIVO
                    case 17:
                        CalculoNomina.Core.tmpPagoNomina isrDefinitivo = new CalculoNomina.Core.tmpPagoNomina();
                        isrDefinitivo.idtrabajador = lstConceptosDeducciones[i].idtrabajador;
                        isrDefinitivo.idempresa = GLOBALES.IDEMPRESA;
                        isrDefinitivo.idconcepto = lstConceptosDeducciones[i].id;
                        isrDefinitivo.noconcepto = lstConceptosDeducciones[i].noconcepto;
                        isrDefinitivo.tipoconcepto = lstConceptosDeducciones[i].tipoconcepto;
                        isrDefinitivo.fechainicio = inicio.Date;
                        isrDefinitivo.fechafin = fin.Date;
                        isrDefinitivo.exento = 0;
                        isrDefinitivo.gravado = 0;

                        //double sueldoIsrDefinitivo = lstPercepciones.Where(e => e.idtrabajador == lstConceptosDeducciones[i].idtrabajador && e.noconcepto == 1).Sum(e => e.cantidad);

                        if (percepciones != 0)
                        {
                            Empleados.Core.EmpleadosHelper eih = new Empleados.Core.EmpleadosHelper();
                            eih.Command = cmd;

                            cnx.Open();
                            int idperiodoIsr = (int)eih.obtenerIdPeriodo(lstConceptosDeducciones[i].idtrabajador);
                            cnx.Close();

                            Periodos.Core.PeriodosHelper pih = new Periodos.Core.PeriodosHelper();
                            pih.Command = cmd;

                            Periodos.Core.Periodos pi = new Periodos.Core.Periodos();
                            pi.idperiodo = idperiodoIsr;

                            cnx.Open();
                            int diasIsr = (int)pih.DiasDePago(pi);
                            cnx.Close();

                            if (subsidioAntes > isrAntes)
                            {
                                isrDefinitivo.cantidad = 0;
                            }
                            else
                            {
                                isrDefinitivo.cantidad = isrAntes - subsidioAntes;
                            }
                        }
                        else
                        {
                            isrDefinitivo.cantidad = 0;
                            //double vacacionIsrDefinitivo = lstPercepciones.Where(e => e.idtrabajador == lstConceptosDeducciones[i].idtrabajador && e.noconcepto == 7).Sum(e => e.cantidad);
                            //if (vacacionIsrDefinitivo != 0)
                            //{
                            //    Empleados.Core.EmpleadosHelper eih = new Empleados.Core.EmpleadosHelper();
                            //    eih.Command = cmd;

                            //    cnx.Open();
                            //    int idperiodoIsr = (int)eih.obtenerIdPeriodo(lstConceptosDeducciones[i].idtrabajador);
                            //    cnx.Close();

                            //    Periodos.Core.PeriodosHelper pih = new Periodos.Core.PeriodosHelper();
                            //    pih.Command = cmd;

                            //    Periodos.Core.Periodos pi = new Periodos.Core.Periodos();
                            //    pi.idperiodo = idperiodoIsr;

                            //    cnx.Open();
                            //    int diasIsr = (int)pih.DiasDePago(pi);
                            //    cnx.Close();

                            //    double isptIsr = 0;
                            //    if (subsidioAntes > isrAntes)
                            //    {
                            //        isrDefinitivo.cantidad = 0;
                            //    }
                            //    else
                            //    {
                            //        isptIsr = ((isrAntes - subsidioAntes) / 30.4) * diasIsr;

                            //        if (isptIsr <= 0)
                            //        {
                            //            isrDefinitivo.cantidad = 0;
                            //        }
                            //        else
                            //        {
                            //            isrDefinitivo.cantidad = isptIsr;
                            //        }
                            //    }
                            //}
                            //else
                            //    isrDefinitivo.cantidad = 0;
                        }

                        isrDefinitivo.guardada = false;
                        isrDefinitivo.tiponomina = tipoNomina;
                        isrDefinitivo.modificado = false;
                        lstValoresNomina.Add(isrDefinitivo);
                        break;
                    #endregion

                    #region OTRAS DEDUCCIONES
                    default:
                        //double sueldoDeducciones = lstPercepciones.Where(e => e.idtrabajador == lstConceptosDeducciones[i].idtrabajador && e.noconcepto == 1).Sum(e => e.cantidad);

                        CalculoNomina.Core.tmpPagoNomina vn = new CalculoNomina.Core.tmpPagoNomina();
                        vn.idtrabajador = lstConceptosDeducciones[i].idtrabajador;
                        vn.idempresa = GLOBALES.IDEMPRESA;
                        vn.idconcepto = lstConceptosDeducciones[i].id;
                        vn.noconcepto = lstConceptosDeducciones[i].noconcepto;
                        vn.tipoconcepto = lstConceptosDeducciones[i].tipoconcepto;
                        vn.fechainicio = inicio.Date;
                        vn.fechafin = fin.Date;
                        vn.guardada = false;
                        vn.tiponomina = tipoNomina;
                        vn.modificado = false;

                        #region SUELDO DIFERENTE DE CERO
                        if (percepciones != 0)
                        {
                            Infonavit.Core.InfonavitHelper infh = new Infonavit.Core.InfonavitHelper();
                            infh.Command = cmd;

                            Infonavit.Core.Infonavit inf = new Infonavit.Core.Infonavit();
                            inf.idtrabajador = lstConceptosDeducciones[i].idtrabajador;
                            inf.idempresa = GLOBALES.IDEMPRESA;

                            if (lstConceptosDeducciones[i].noconcepto == 9 || lstConceptosDeducciones[i].noconcepto == 21)
                            {
                                cnx.Open();
                                activoInfonavit = (bool)infh.activoInfonavit(inf);
                                cnx.Close();

                                if (activoInfonavit)
                                {
                                    CalculoFormula cf = new CalculoFormula(lstConceptosDeducciones[i].idtrabajador, inicio.Date, fin.Date, lstConceptosDeducciones[i].formula);
                                    vn.cantidad = decimal.Parse(cf.calcularFormula().ToString());
                                    vn.exento = 0;
                                    vn.gravado = 0;
                                }
                                else
                                {

                                    vn.cantidad = 0;
                                    vn.exento = 0;
                                    vn.gravado = 0;
                                }
                            }
                            else
                            {
                                CalculoFormula cf = new CalculoFormula(lstConceptosDeducciones[i].idtrabajador, inicio.Date, fin.Date, lstConceptosDeducciones[i].formula);
                                vn.cantidad = decimal.Parse(cf.calcularFormula().ToString());
                                vn.exento = 0;
                                vn.gravado = 0;
                            }
                                lstValoresNomina.Add(vn);
                        }
                        else
                        {
                            vn.cantidad = 0;
                            vn.exento = 0;
                            vn.gravado = 0;
                            lstValoresNomina.Add(vn);
                        }
                        break;
                        #endregion
                    #endregion
                }
            }
            #endregion

            #region EXISTENCIA DEL CONCEPTO EN TABLA
            int existe = 0;
            CalculoNomina.Core.NominaHelper nh = new CalculoNomina.Core.NominaHelper();
            nh.Command = cmd;
            lstValoresDefinitivos = new List<CalculoNomina.Core.tmpPagoNomina>();
            for (int i = 0; i < lstValoresNomina.Count; i++)
            {
                CalculoNomina.Core.tmpPagoNomina vn = new CalculoNomina.Core.tmpPagoNomina();
                vn.idtrabajador = lstValoresNomina[i].idtrabajador;
                vn.idempresa = GLOBALES.IDEMPRESA;
                vn.idconcepto = lstValoresNomina[i].idconcepto;
                vn.noconcepto = lstValoresNomina[i].noconcepto;
                vn.tipoconcepto = lstValoresNomina[i].tipoconcepto;
                vn.fechainicio = lstValoresNomina[i].fechainicio;
                vn.fechafin = lstValoresNomina[i].fechafin;
                vn.guardada = lstValoresNomina[i].guardada;
                vn.tiponomina = lstValoresNomina[i].tiponomina;
                vn.modificado = lstValoresNomina[i].modificado;
                vn.exento = lstValoresNomina[i].exento;
                vn.gravado = lstValoresNomina[i].gravado;
                vn.cantidad = lstValoresNomina[i].cantidad;

                cnx.Open();
                existe = (int)nh.existeConcepto(vn);
                cnx.Close();

                if (existe == 0)
                {
                    lstValoresDefinitivos.Add(vn);
                }
                else
                {
                    cnx.Open();
                    nh.actualizaConcepto(vn);
                    cnx.Close();
                }
            }
            #endregion

            return lstValoresDefinitivos;
        }
        private decimal ObtieneSueldo(decimal sd)
        {
            int DiasDePago = 0;
            decimal sueldo = 0;
            cnx = new SqlConnection();
            cnx.ConnectionString = cdn;
            cmd = new SqlCommand();
            cmd.Connection = cnx;

            ph = new Periodos.Core.PeriodosHelper();
            Periodos.Core.Periodos p = new Periodos.Core.Periodos();

            ph.Command = cmd;

            p.idperiodo = idPeriodo;

            try
            {
                cnx.Open();
                DiasDePago = (int)ph.DiasDePago(p);
                cnx.Close();

                sueldo = sd * DiasDePago;
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: \r\n \r\n Al obtener los dias de pago y/o factor de pago. \r\n" + error.Message, "Error");
                this.Dispose();
            }
            return sueldo;
        }
Пример #13
0
        private void toolAplicar_Click(object sender, EventArgs e)
        {
            if (dgvCargaFaltas.Rows.Count == 0)
            {
                MessageBox.Show("No se puede aplicar verifique.", "Error");
                return;
            }

            int idEmpleado = 0;
            bool EsAlta = false, EsReingreso = false, EsBaja = false;

            cnx = new SqlConnection(cdn);
            cmd = new SqlCommand();
            cmd.Connection = cnx;

            fh = new Faltas.Core.FaltasHelper();
            fh.Command = cmd;

            emph = new Empleados.Core.EmpleadosHelper();
            emph.Command = cmd;

            Altas.Core.AltasHelper ah = new Altas.Core.AltasHelper();
            ah.Command = cmd;

            Reingreso.Core.ReingresoHelper rh = new Reingreso.Core.ReingresoHelper();
            rh.Command = cmd;

            Bajas.Core.BajasHelper bh = new Bajas.Core.BajasHelper();
            bh.Command = cmd;

            Periodos.Core.PeriodosHelper ph = new Periodos.Core.PeriodosHelper();
            ph.Command = cmd;

            List<Altas.Core.Altas> lstAlta;
            List<Reingreso.Core.Reingresos> lstReingreso;
            List<Bajas.Core.Bajas> lstBaja;

            foreach (DataGridViewRow fila in dgvCargaFaltas.Rows)
            {
                try
                {
                    cnx.Open();
                    idEmpleado = (int)emph.obtenerIdTrabajador(fila.Cells["noempleado"].Value.ToString(), idEmpresa);
                    cnx.Close();

                }
                catch (Exception error)
                {
                    MessageBox.Show("Error: Obtener ID del empleado. \r\n \r\n" + error.Message, "Error");
                    return;
                }

                int idperiodo = 0;
                try
                {
                    cnx.Open();
                    idperiodo = (int)emph.obtenerIdPeriodo(idEmpleado);
                    cnx.Close();
                }
                catch
                {
                    MessageBox.Show("Error: al obtener el Id del Periodo.", "Error");
                    cnx.Dispose();
                    return;
                }

                Altas.Core.Altas alta = new Altas.Core.Altas();
                alta.idempresa = GLOBALES.IDEMPRESA;
                alta.idtrabajador = idEmpleado;
                alta.periodoInicio = _inicioPeriodo.Date;
                alta.periodoFin = _finPeriodo.Date;

                Reingreso.Core.Reingresos reingreso = new Reingreso.Core.Reingresos();
                reingreso.idempresa = GLOBALES.IDEMPRESA;
                reingreso.idtrabajador = idEmpleado;
                reingreso.periodoinicio = _inicioPeriodo.Date;
                reingreso.periodofin = _finPeriodo.Date;

                Bajas.Core.Bajas baja = new Bajas.Core.Bajas();
                baja.idempresa = GLOBALES.IDEMPRESA;
                baja.idtrabajador = idEmpleado;
                baja.periodoinicio = _inicioPeriodo.Date;
                baja.periodofin = _finPeriodo.Date;

                lstAlta = new List<Altas.Core.Altas>();
                lstReingreso = new List<Reingreso.Core.Reingresos>();
                lstBaja = new List<Bajas.Core.Bajas>();

                Periodos.Core.Periodos p = new Periodos.Core.Periodos();
                p.idperiodo = idperiodo;

                int periodo = 0;
                try
                {
                    cnx.Open();
                    periodo = (int)ph.DiasDePago(p);

                    lstAlta = ah.obtenerAlta(alta);
                    lstReingreso = rh.obtenerReingreso(reingreso);
                    lstBaja = bh.obtenerBaja(baja);
                    cnx.Close();
                }
                catch
                {
                    MessageBox.Show("Error: al obtener los dias de pago.", "Error");
                    cnx.Dispose();
                    return;
                }

                if (lstAlta.Count != 0)
                    EsAlta = true;
                if (lstBaja.Count != 0)
                    EsBaja = true;
                if (lstReingreso.Count != 0)
                    EsReingreso = true;

                int falta = int.Parse(fila.Cells["faltas"].Value.ToString());
                DateTime fecha = DateTime.Parse(fila.Cells["fechainicio"].Value.ToString());

                if (falta > 15)
                    falta = 15;

                for (int i = 0; i < falta; i++)
                {
                    int existe = 0;
                    int existeFalta = 0;
                    int existeVacacion = 0;
                    try
                    {
                        cnx.Open();
                        existeFalta = (int)fh.existeFalta(idEmpleado, fecha.AddDays(i).Date);
                        cnx.Close();
                    }
                    catch
                    {
                        MessageBox.Show("Error: Al verificar existencia de falta.", "Error");
                        cnx.Dispose();
                        return;
                    }

                    if (existeFalta == 0)
                    {
                        Incidencias.Core.IncidenciasHelper ih = new Incidencias.Core.IncidenciasHelper();
                        ih.Command = cmd;

                        Vacaciones.Core.VacacionesHelper vh = new Vacaciones.Core.VacacionesHelper();
                        vh.Command = cmd;

                        bool FLAG_FALTAS = false;

                        if (EsAlta)
                        {
                            if (fecha.AddDays(i).Date < lstAlta[0].fechaingreso.Date)
                            {
                                MessageBox.Show("Error: Alta del empleado: " + fila.Cells["noempleado"].Value.ToString() + ", Fecha de Ingreso = " + lstAlta[0].fechaingreso.Date.ToShortDateString() + "\r\n Fecha de la falta es menor.", "Error");
                                FLAG_FALTAS = true;
                            }
                            else
                                FLAG_FALTAS = false;
                        }

                        if (EsReingreso)
                        {
                            if (fecha.AddDays(i).Date < lstReingreso[0].fechaingreso.Date)
                            {
                                MessageBox.Show("Error: Alta del empleado: " + fila.Cells["noempleado"].Value.ToString() + ", Fecha de Reingreso = " + lstReingreso[0].fechaingreso.Date.ToShortDateString() + "\r\n Fecha de la falta es menor.", "Error");
                                FLAG_FALTAS = true;
                            }
                            else
                                FLAG_FALTAS = false;
                        }

                        if (EsBaja)
                        {
                            if (fecha.AddDays(i).Date > lstBaja[0].fecha.Date)
                            {
                                MessageBox.Show("Error: Alta del empleado " + fila.Cells["noempleado"].Value.ToString() +
                                    ", Fecha de Reingreso = " + lstBaja[0].fecha.Date.ToShortDateString() +
                                    "\r\n Fecha de la falta es mayor.", "Error");
                                FLAG_FALTAS = true;
                            }
                            else
                                FLAG_FALTAS = false;
                        }

                        if (!FLAG_FALTAS)
                        {
                            try
                            {
                                cnx.Open();
                                existe = (int)ih.existeIncidenciaEnFalta(idEmpleado, fecha.AddDays(i).Date);
                                existeVacacion = (int)vh.existeVacacionEnFalta(idEmpleado, fecha.AddDays(i).Date);
                                cnx.Close();
                            }
                            catch
                            {
                                MessageBox.Show("Error: Al guardar la falta.", "Error");
                                cnx.Dispose();
                                return;
                            }

                            if (existe == 0 && existeVacacion == 0)
                                try
                                {
                                    Faltas.Core.Faltas f = new Faltas.Core.Faltas();
                                    f.idempresa = GLOBALES.IDEMPRESA;
                                    f.idtrabajador = idEmpleado;
                                    f.periodo = periodo;
                                    f.faltas = 1;
                                    f.fechainicio = DateTime.Parse(dgvCargaFaltas.Rows[0].Cells["fechainicio"].Value.ToString());
                                    f.fechafin = DateTime.Parse(dgvCargaFaltas.Rows[0].Cells["fechafin"].Value.ToString());
                                    f.fecha = fecha.AddDays(i).Date;

                                    cnx.Open();
                                    fh.insertaFalta(f);
                                    cnx.Close();
                                }
                                catch
                                {
                                    MessageBox.Show("Error: Al guardar la falta.", "Error");
                                    cnx.Dispose();
                                }
                            else
                                MessageBox.Show("La falta ingresada, se empalma con una incapacidad y/o dia de vacación del trabajador.", "Error");
                        }
                    }
                }
                EsAlta = false; EsReingreso = false; EsBaja = false;
            }
            MessageBox.Show("Faltas importadas", "Confirmación");
            cnx.Dispose();
            dgvCargaFaltas.Rows.Clear();
        }
Пример #14
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            DateTime periodoInicio, periodoFin;
            bool EsAlta = false, EsReingreso = false, EsBaja = false;

            cnx = new SqlConnection(cdn);
            cmd = new SqlCommand();
            cmd.Connection = cnx;

            Empleados.Core.EmpleadosHelper emph = new Empleados.Core.EmpleadosHelper();
            emph.Command = cmd;

            Altas.Core.AltasHelper ah = new Altas.Core.AltasHelper();
            ah.Command = cmd;

            Reingreso.Core.ReingresoHelper rh = new Reingreso.Core.ReingresoHelper();
            rh.Command = cmd;

            Bajas.Core.BajasHelper bh = new Bajas.Core.BajasHelper();
            bh.Command = cmd;

            List<Altas.Core.Altas> lstAlta = new List<Altas.Core.Altas>();
            List<Reingreso.Core.Reingresos> lstReingreso = new List<Reingreso.Core.Reingresos>();
            List<Bajas.Core.Bajas> lstBaja = new List<Bajas.Core.Bajas>();

            Altas.Core.Altas alta = new Altas.Core.Altas();
            alta.idempresa = GLOBALES.IDEMPRESA;
            alta.idtrabajador = idTrabajador;
            alta.periodoInicio = _inicioPeriodo.Date;
            alta.periodoFin = _finPeriodo.Date;

            Reingreso.Core.Reingresos reingreso = new Reingreso.Core.Reingresos();
            reingreso.idempresa = GLOBALES.IDEMPRESA;
            reingreso.idtrabajador = idTrabajador;
            reingreso.periodoinicio = _inicioPeriodo.Date;
            reingreso.periodofin = _finPeriodo.Date;

            Bajas.Core.Bajas baja = new Bajas.Core.Bajas();
            baja.idempresa = GLOBALES.IDEMPRESA;
            baja.idtrabajador = idTrabajador;
            baja.periodoinicio = _inicioPeriodo.Date;
            baja.periodofin = _finPeriodo.Date;

            int idperiodo = 0;
            try
            {
                cnx.Open();
                idperiodo = (int)emph.obtenerIdPeriodo(idTrabajador);

                lstAlta = ah.obtenerAlta(alta);
                lstReingreso = rh.obtenerReingreso(reingreso);
                lstBaja = bh.obtenerBaja(baja);
                cnx.Close();
            }
            catch
            {
                MessageBox.Show("Error: al obtener el Id del Periodo.","Error");
                cnx.Dispose();
                return;
            }

            Periodos.Core.PeriodosHelper ph = new Periodos.Core.PeriodosHelper();
            ph.Command = cmd;

            Periodos.Core.Periodos p = new Periodos.Core.Periodos();
            p.idperiodo = idperiodo;

            int periodo = 0;
            try
            {
                cnx.Open();
                periodo = (int)ph.DiasDePago(p);
                cnx.Close();
            }
            catch
            {
                MessageBox.Show("Error: al obtener los dias de pago.", "Error");
                cnx.Dispose();
                return;
            }

            if (periodo == 7)
            {
                DateTime dt = dtpFecha.Value.Date;
                while (dt.DayOfWeek != DayOfWeek.Monday) dt = dt.AddDays(-1);
                periodoInicio = dt;
                periodoFin = dt.AddDays(6);
            }
            else
            {
                if (dtpFecha.Value.Day <= 15)
                {
                    periodoInicio = new DateTime(dtpFecha.Value.Year, dtpFecha.Value.Month, 1);
                    periodoFin = new DateTime(dtpFecha.Value.Year, dtpFecha.Value.Month, 15);
                }
                else
                {
                    periodoInicio = new DateTime(dtpFecha.Value.Year, dtpFecha.Value.Month, 16);
                    periodoFin = new DateTime(dtpFecha.Value.Year, dtpFecha.Value.Month, DateTime.DaysInMonth(dtpFecha.Value.Year, dtpFecha.Value.Month));
                }
            }

            if (lstAlta.Count != 0)
                EsAlta = true;
            if (lstBaja.Count != 0)
                EsBaja = true;
            if (lstReingreso.Count != 0)
                EsReingreso = true;

            Faltas.Core.FaltasHelper fh = new Faltas.Core.FaltasHelper();
            fh.Command = cmd;

            List<Faltas.Core.Faltas> lstFaltas = new List<Faltas.Core.Faltas>();

            int faltas = int.Parse(txtFalta.Text);
            if (int.Parse(txtFalta.Text) > 15)
                faltas = 15;

            for (int i = 0; i < faltas; i++)
            {
                int existe = 0;
                int existeVacacion = 0;
                try
                {
                    cnx.Open();
                    existe = (int)fh.existeFalta(idTrabajador, dtpFecha.Value.AddDays(i).Date);
                    cnx.Close();
                }
                catch
                {
                    MessageBox.Show("Error: Al verificar existencia de falta.", "Error");
                    cnx.Dispose();
                    return;
                }

                if (existe != 0)
                {
                    MessageBox.Show("Ya existe una falta con esa fecha.", "Error");
                    //return;
                }
                else
                {
                    Incidencias.Core.IncidenciasHelper ih = new Incidencias.Core.IncidenciasHelper();
                    ih.Command = cmd;

                    Vacaciones.Core.VacacionesHelper vh = new Vacaciones.Core.VacacionesHelper();
                    vh.Command = cmd;

                    bool FLAG_FALTAS = false;

                    if (EsAlta)
                    {
                        if (dtpFecha.Value.AddDays(i).Date < lstAlta[0].fechaingreso.Date)
                        {
                            MessageBox.Show("Error: Alta del empleado, Fecha de Ingreso = " + lstAlta[0].fechaingreso.Date.ToShortDateString() + "\r\n Fecha de la falta es menor.", "Error");
                            FLAG_FALTAS = true;
                        }
                        else
                            FLAG_FALTAS = false;
                    }

                    if (EsReingreso)
                    {
                        if (dtpFecha.Value.AddDays(i).Date < lstReingreso[0].fechaingreso.Date)
                        {
                            MessageBox.Show("Error: Alta del empleado, Fecha de Reingreso = " + lstReingreso[0].fechaingreso.Date.ToShortDateString() + "\r\n Fecha de la falta es menor.", "Error");
                            FLAG_FALTAS = true;
                        }
                        else
                            FLAG_FALTAS = false;
                    }

                    if (EsBaja)
                    {
                        if (dtpFecha.Value.AddDays(i).Date > lstBaja[0].fecha.Date)
                        {
                            MessageBox.Show("Error: Alta del empleado, Fecha de Reingreso = " + lstBaja[0].fecha.Date.ToShortDateString() + "\r\n Fecha de la falta es mayor.", "Error");
                            FLAG_FALTAS = true;
                        }
                        else
                            FLAG_FALTAS = false;
                    }

                    if (!FLAG_FALTAS)
                    {
                        try
                        {
                            cnx.Open();
                            existe = (int)ih.existeIncidenciaEnFalta(idTrabajador, dtpFecha.Value.AddDays(i).Date);
                            existeVacacion = (int)vh.existeVacacionEnFalta(idTrabajador, dtpFecha.Value.AddDays(i).Date);
                            cnx.Close();
                        }
                        catch
                        {
                            MessageBox.Show("Error: Al guardar la falta.", "Error");
                            cnx.Dispose();
                            return;
                        }

                        if (existe == 0 && existeVacacion == 0)
                        {
                            Faltas.Core.Faltas falta = new Faltas.Core.Faltas();
                            falta.idtrabajador = idTrabajador;
                            falta.idempresa = GLOBALES.IDEMPRESA;
                            falta.faltas = 1;
                            falta.fechainicio = periodoInicio.Date;
                            falta.fechafin = periodoFin.Date;
                            falta.fecha = dtpFecha.Value.AddDays(i).Date;
                            falta.periodo = periodo;
                            lstFaltas.Add(falta);
                        }
                        else
                            MessageBox.Show("La falta ingresada, se empalma con una incapacidad y/o dia de vacación del trabajador.",
                                "Error");
                    }

                }
            }

            if (lstFaltas.Count != 0)
            {
                SqlBulkCopy bulk = new SqlBulkCopy(cnx);
                fh.bulkCommand = bulk;

                DataTable dtFalta = new DataTable();
                DataRow dtFilaFalta;
                dtFalta.Columns.Add("id", typeof(Int32));
                dtFalta.Columns.Add("idtrabajador", typeof(Int32));
                dtFalta.Columns.Add("idempresa", typeof(Int32));
                dtFalta.Columns.Add("periodo", typeof(Int32));
                dtFalta.Columns.Add("faltas", typeof(Int32));
                dtFalta.Columns.Add("fechainicio", typeof(DateTime));
                dtFalta.Columns.Add("fechafin", typeof(DateTime));
                dtFalta.Columns.Add("fecha", typeof(DateTime));

                for (int i = 0; i < lstFaltas.Count; i++)
                {
                    dtFilaFalta = dtFalta.NewRow();
                    dtFilaFalta["id"] = i + 1;
                    dtFilaFalta["idtrabajador"] = lstFaltas[i].idtrabajador;
                    dtFilaFalta["idempresa"] = lstFaltas[i].idempresa;
                    dtFilaFalta["periodo"] = lstFaltas[i].periodo;
                    dtFilaFalta["faltas"] = lstFaltas[i].faltas;
                    dtFilaFalta["fechainicio"] = lstFaltas[i].fechainicio;
                    dtFilaFalta["fechafin"] = lstFaltas[i].fechafin;
                    dtFilaFalta["fecha"] = lstFaltas[i].fecha;
                    dtFalta.Rows.Add(dtFilaFalta);
                }

                try
                {
                    cnx.Open();
                    fh.bulkFaltas(dtFalta, "tmpFaltas");
                    fh.stpFaltas();
                    cnx.Close();
                    cnx.Dispose();
                    muestraFaltas();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error: \r\n \r\n" + error.Message + "\r\n \r\n Error Bulk Faltas.", "Error");
                }
            }
        }
Пример #15
0
        private void toolBaja_Click(object sender, EventArgs e)
        {
            DialogResult respuesta = MessageBox.Show("¿Quiere eliminar el periodo?", "Confirmación", MessageBoxButtons.YesNo);
            if (respuesta == DialogResult.Yes)
            {
                string cdn = ConfigurationManager.ConnectionStrings["cdnNomina"].ConnectionString;
                int fila = dgvPeriodos.CurrentCell.RowIndex;
                int id = int.Parse(dgvPeriodos.Rows[fila].Cells[0].Value.ToString());
                cnx = new SqlConnection(cdn);
                cmd = new SqlCommand();
                cmd.Connection = cnx;
                Periodos.Core.PeriodosHelper ph = new Periodos.Core.PeriodosHelper();
                ph.Command = cmd;
                Periodos.Core.Periodos periodo = new Periodos.Core.Periodos();
                periodo.idperiodo = id;

                try
                {
                    cnx.Open();
                    ph.bajaPeriodo(periodo);
                    cnx.Close();
                    cnx.Dispose();
                    ListaPeriodos();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
                }
            }
        }
Пример #16
0
        void b_OnBuscar(int id, string nombre)
        {
            _idEmpleado = id;
            _nombreEmpleado = nombre;

            lblEmpleado.Text = nombre;

            cnx = new SqlConnection();
            cnx.ConnectionString = cdn;
            cmd = new SqlCommand();
            cmd.Connection = cnx;
            eh = new Empleados.Core.EmpleadosHelper();
            ph = new Periodos.Core.PeriodosHelper();
            eh.Command = cmd;
            ph.Command = cmd;

            Empleados.Core.Empleados empleado = new Empleados.Core.Empleados();
            empleado.idtrabajador = _idEmpleado;

            Periodos.Core.Periodos per = new Periodos.Core.Periodos();
            per.idempresa = GLOBALES.IDEMPRESA;

            List<Empleados.Core.Empleados> lstEmpleado = new List<Empleados.Core.Empleados>();
            List<Periodos.Core.Periodos> lstPeriodos = new List<Periodos.Core.Periodos>();

            try
            {
                cnx.Open();
                lstEmpleado = eh.obtenerEmpleado(empleado);
                lstPeriodos = ph.obtenerPeriodos(per);
                cnx.Close();

            }
            catch (Exception error)
            {
                MessageBox.Show("Error: \r\n \r\n" + error.Message, "Error");
            }

            var datos = from e in lstEmpleado
                        join p in lstPeriodos on e.idperiodo equals p.idperiodo
                        select new
                        {
                            p.dias,
                            e.idperiodo,
                            e.noempleado
                        };
            foreach (var d in datos)
            {
                periodo = d.dias;
                idperiodo = d.idperiodo;
                mtxtNoEmpleado.Text = d.noempleado;
            }

            dh = new Departamento.Core.DeptoHelper();
            dh.Command = cmd;

            Departamento.Core.Depto depto = new Departamento.Core.Depto();
            depto.id = lstEmpleado[0].iddepartamento;

            List<Departamento.Core.Depto> lstDepto = new List<Departamento.Core.Depto>();

            try
            {
                cnx.Open();
                lstDepto = dh.obtenerDepartamento(depto);
                cnx.Close();
                cnx.Dispose();
            }
            catch (Exception)
            {

                throw;
            }

            txtDepartamento.Text = lstDepto[0].descripcion;
            //obtenerPeriodoActual();
        }
Пример #17
0
        private void frmBaja_Load(object sender, EventArgs e)
        {
            lblNombreEmpleado.Text = _nombreEmpleado;

            cnx = new SqlConnection(cdn);
            cmd = new SqlCommand();
            cmd.Connection = cnx;

            eh = new Empleados.Core.EmpleadosHelper();
            ph = new Periodos.Core.PeriodosHelper();
            eh.Command = cmd;
            ph.Command = cmd;

            Empleados.Core.Empleados empleado = new Empleados.Core.Empleados();
            empleado.idtrabajador = _idempleado;

            Periodos.Core.Periodos per = new Periodos.Core.Periodos();
            per.idempresa = GLOBALES.IDEMPRESA;

            Catalogos.Core.CatalogosHelper ch = new Catalogos.Core.CatalogosHelper();
            ch.Command = cmd;

            Catalogos.Core.Catalogo c = new Catalogos.Core.Catalogo();
            c.grupodescripcion = "BAJA";

            List<Catalogos.Core.Catalogo> lstBaja = new List<Catalogos.Core.Catalogo>();
            List<Empleados.Core.Empleados> lstEmpleado = new List<Empleados.Core.Empleados>();
            List<Periodos.Core.Periodos> lstPeriodos = new List<Periodos.Core.Periodos>();

            try
            {
                cnx.Open();
                lstEmpleado = eh.obtenerEmpleado(empleado);
                lstPeriodos = ph.obtenerPeriodos(per);
                lstBaja = ch.obtenerGrupo(c);
                cnx.Close();
                cnx.Dispose();
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
            }

            cmbMotivoBaja.DataSource = lstBaja.ToList();
            cmbMotivoBaja.DisplayMember = "descripcion";
            cmbMotivoBaja.ValueMember = "id";

            var datos = from emp in lstEmpleado
                        join p in lstPeriodos on emp.idperiodo equals p.idperiodo
                        select new
                        {
                            p.dias,
                            emp.idperiodo
                        };
            foreach (var d in datos)
            {
                periodo = d.dias;
            }
        }
        private void workVacaciones_DoWork(object sender, DoWorkEventArgs e)
        {
            int idEmpleado = 0;
            cnx = new SqlConnection(cdn);
            cmd = new SqlCommand();
            cmd.Connection = cnx;

            List<Vacaciones.Core.VacacionesPrima> lstMovimientos = new List<Vacaciones.Core.VacacionesPrima>();

            vh = new Vacaciones.Core.VacacionesHelper();
            vh.Command = cmd;

            emph = new Empleados.Core.EmpleadosHelper();
            emph.Command = cmd;

            ph = new Periodos.Core.PeriodosHelper();
            ph.Command = cmd;

            foreach (DataGridViewRow fila in dgvCargaVacaciones.Rows)
            {
                try
                {
                    cnx.Open();
                    idEmpleado = (int)emph.obtenerIdTrabajador(fila.Cells["noempleado"].Value.ToString(), idEmpresa);
                    cnx.Close();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error: Obtener ID del concepto. \r\n \r\n" + error.Message, "Error");
                    cnx.Dispose();
                    this.Dispose();
                }

                Empleados.Core.Empleados empleado = new Empleados.Core.Empleados();
                empleado.idtrabajador = idEmpleado;

                List<Empleados.Core.Empleados> lstEmpleado = new List<Empleados.Core.Empleados>();

                try
                {
                    cnx.Open();
                    lstEmpleado = emph.obtenerEmpleado(empleado);
                    cnx.Close();
                }
                catch
                {
                    MessageBox.Show("Error: Al obtener la antigüedad del empleado.", "Error");
                    cnx.Dispose();
                    this.Dispose();
                }

                Vacaciones.Core.DiasDerecho dd = new Vacaciones.Core.DiasDerecho();
                dd.anio = lstEmpleado[0].antiguedadmod;

                int dias = 0;
                try
                {
                    cnx.Open();
                    dias = (int)vh.diasDerecho(dd);
                    cnx.Close();
                }
                catch
                {
                    MessageBox.Show("Error: Al obtener los dias por derecho del empleado.", "Error");
                    cnx.Dispose();
                    return;
                }

                Faltas.Core.FaltasHelper fh = new Faltas.Core.FaltasHelper();
                fh.Command = cmd;

                Faltas.Core.Faltas falta = new Faltas.Core.Faltas();
                falta.idempresa = GLOBALES.IDEMPRESA;
                falta.idtrabajador = idEmpleado;
                falta.fechainicio = DateTime.Parse(dgvCargaVacaciones.Rows[0].Cells["inicio"].Value.ToString());
                falta.fechafin = DateTime.Parse(dgvCargaVacaciones.Rows[0].Cells["fin"].Value.ToString());

                int existeFaltas = 0;
                try
                {
                    cnx.Open();
                    existeFaltas = (int)fh.existeFalta(falta);
                    cnx.Close();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error: Al obtener las faltas del trabajador. \r\n" + error.Message, "Error");
                    cnx.Dispose();
                    return;
                }

                int idperiodo = 0;
                try
                {
                    cnx.Open();
                    idperiodo = (int)emph.obtenerIdPeriodo(idEmpleado);
                    cnx.Close();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error: Al obtener el id del periodo. \r\n" + error.Message, "Error");
                    cnx.Dispose();
                    return;
                }
                Periodos.Core.Periodos p = new Periodos.Core.Periodos();
                p.idperiodo = idperiodo;

                int diasPeriodo = 0;
                try
                {
                    cnx.Open();
                    diasPeriodo = (int)ph.DiasDePago(p);
                    cnx.Close();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error: Al obtener los dias del periodo. \r\n" + error.Message, "Error");
                    cnx.Dispose();
                    return;
                }

                int diasPagoReales = int.Parse(fila.Cells["diaspago"].Value.ToString()) + existeFaltas;
                if (diasPagoReales >= diasPeriodo)
                {
                    diasPagoReales = diasPeriodo - existeFaltas;
                    MessageBox.Show("Existen faltas del trabajador, se ajustarán las vacaciones.", "Información");
                }
                else
                {
                    diasPagoReales = int.Parse(fila.Cells["diaspago"].Value.ToString());
                }

                Vacaciones.Core.VacacionesPrima vp = new Vacaciones.Core.VacacionesPrima();
                vp.idtrabajador = idEmpleado;
                vp.idempresa = GLOBALES.IDEMPRESA;
                vp.periodoinicio = DateTime.Parse(dgvCargaVacaciones.Rows[0].Cells["inicio"].Value.ToString());
                vp.periodofin = DateTime.Parse(dgvCargaVacaciones.Rows[0].Cells["fin"].Value.ToString());
                vp.diasderecho = dias;
                vp.fechapago = DateTime.Now.Date;
                vp.vacacionesprima = fila.Cells["concepto"].Value.ToString() == "Prima Vacacional" ? "P" : "V";

                if (fila.Cells["concepto"].Value.ToString() == "Prima Vacacional")
                {
                    vp.diaspago = diasPagoReales;
                    vp.diaspendientes = dias - diasPagoReales;
                    vp.fechainicio = DateTime.Now.Date;
                    vp.fechafin = DateTime.Now.Date;
                }
                else
                {
                    vp.diaspago = diasPagoReales;
                    vp.diaspendientes = dias - diasPagoReales;
                    vp.fechainicio = DateTime.Parse(fila.Cells["fechaaplicacion"].Value.ToString());
                    vp.fechafin = DateTime.Parse(fila.Cells["fechaaplicacion"].Value.ToString()).AddDays(diasPagoReales - 1);
                }

                lstMovimientos.Add(vp);
            }

            bulk = new SqlBulkCopy(cnx);
            vh.bulkCommand = bulk;

            DataTable dt = new DataTable();
            DataRow dtFila;
            dt.Columns.Add("id", typeof(Int32));
            dt.Columns.Add("idtrabajador", typeof(Int32));
            dt.Columns.Add("idempresa", typeof(Int32));
            dt.Columns.Add("periodoinicio", typeof(DateTime));
            dt.Columns.Add("periodofin", typeof(DateTime));
            dt.Columns.Add("diasderecho", typeof(Int32));
            dt.Columns.Add("diaspago", typeof(Int32));
            dt.Columns.Add("diaspendientes", typeof(Int32));
            dt.Columns.Add("fechapago", typeof(DateTime));
            dt.Columns.Add("vacacionesprima", typeof(String));
            dt.Columns.Add("fechainicio", typeof(DateTime));
            dt.Columns.Add("fechafin", typeof(DateTime));

            int index = 1;
            for (int i = 0; i < lstMovimientos.Count; i++)
            {
                dtFila = dt.NewRow();
                dtFila["id"] = i + 1;
                dtFila["idtrabajador"] = lstMovimientos[i].idtrabajador;
                dtFila["idempresa"] = lstMovimientos[i].idempresa;
                dtFila["periodoinicio"] = lstMovimientos[i].periodoinicio;
                dtFila["periodofin"] = lstMovimientos[i].periodofin;
                dtFila["diasderecho"] = lstMovimientos[i].diasderecho;
                dtFila["diaspago"] = lstMovimientos[i].diaspago;
                dtFila["diaspendientes"] = lstMovimientos[i].diaspendientes;
                dtFila["fechapago"] = lstMovimientos[i].fechapago;
                dtFila["vacacionesprima"] = lstMovimientos[i].vacacionesprima;
                dtFila["fechainicio"] = lstMovimientos[i].fechainicio;
                dtFila["fechafin"] = lstMovimientos[i].fechafin;
                dt.Rows.Add(dtFila);
                index++;
            }

            try
            {
                cnx.Open();
                vh.bulkVacaciones(dt, "tmpVacacionesPrima");
                vh.stpVacaciones();
                cnx.Close();
                cnx.Dispose();
            }
            catch (Exception error)
            {
                MessageBox.Show("Error (DataTable): \r\n \r\n" + error.Message, "Error");
            }
        }
Пример #19
0
        private void btnCalcular_Click(object sender, EventArgs e)
        {
            if (idempleado == 0)
            {
                MessageBox.Show("Debe especificar el empleado.", "Información");
                return;
            }

            if (txtSueldo.Text.Length != 0)
            {
                int    DiasDePago   = 0;
                double FactorDePago = 0;
                int    Periodo      = 0;
                cnx = new MySqlConnection();
                cnx.ConnectionString = cdn;
                cmd            = new MySqlCommand();
                cmd.Connection = cnx;

                Periodos.Core.PeriodosHelper   ph = new Periodos.Core.PeriodosHelper();
                Periodos.Core.Periodos         p  = new Periodos.Core.Periodos();
                Factores.Core.FactoresHelper   fh = new Factores.Core.FactoresHelper();
                Factores.Core.Factores         f  = new Factores.Core.Factores();
                Empleados.Core.EmpleadosHelper eh = new Empleados.Core.EmpleadosHelper();
                Empleados.Core.Empleados       em = new Empleados.Core.Empleados();

                ph.Command = cmd;
                fh.Command = cmd;
                eh.Command = cmd;

                try
                {
                    em.idtrabajador = idempleado;
                    List <Empleados.Core.Empleados> lstEmpleado = eh.obtenerEmpleado(em);
                    for (int i = 0; i < lstEmpleado.Count; i++)
                    {
                        Periodo = lstEmpleado[i].idperiodo;
                    }
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
                    this.Dispose();
                }

                p.idperiodo = Periodo;
                f.anio      = 0;

                try
                {
                    cnx.Open();
                    DiasDePago   = (int)ph.DiasDePago(p);
                    FactorDePago = double.Parse(fh.FactorDePago(f).ToString());
                    cnx.Close();
                    cnx.Dispose();

                    txtSD.Text  = (double.Parse(txtSueldo.Text) / DiasDePago).ToString("F4");
                    txtSDI.Text = (double.Parse(txtSD.Text) * FactorDePago).ToString("F4");
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
                    this.Dispose();
                }
            }
        }
Пример #20
0
        private void frmImpresionRecibos_Load(object sender, EventArgs e)
        {
            cmbTipoNomina.SelectedIndex = 0;

            lstvPeriodos.View = View.Details;
            lstvPeriodos.CheckBoxes = false;
            lstvPeriodos.GridLines = false;
            lstvPeriodos.Columns.Add("Inicio", 100, HorizontalAlignment.Left);
            lstvPeriodos.Columns.Add("Fin", 100, HorizontalAlignment.Left);

            lstvDepartamentos.View = View.Details;
            lstvDepartamentos.CheckBoxes = true;
            lstvDepartamentos.GridLines = false;
            lstvDepartamentos.Columns.Add("Id", 60, HorizontalAlignment.Left);
            lstvDepartamentos.Columns.Add("Departamento", 150, HorizontalAlignment.Left);

            lstvEmpleados.View = View.Details;
            lstvEmpleados.CheckBoxes = true;
            lstvEmpleados.GridLines = false;
            lstvEmpleados.Columns.Add("Id", 60, HorizontalAlignment.Left);
            lstvEmpleados.Columns.Add("No. Empleado", 70, HorizontalAlignment.Left);
            lstvEmpleados.Columns.Add("Nombre", 250, HorizontalAlignment.Left);

            cnx = new SqlConnection(cdn);
            cmd = new SqlCommand();
            cmd.Connection = cnx;

            Periodos.Core.PeriodosHelper ph = new Periodos.Core.PeriodosHelper();
            ph.Command = cmd;

            Periodos.Core.Periodos p = new Periodos.Core.Periodos();
            p.idempresa = GLOBALES.IDEMPRESA;

            List<Periodos.Core.Periodos> lstPeriodos = new List<Periodos.Core.Periodos>();

            try
            {
                cnx.Open();
                lstPeriodos = ph.obtenerPeriodos(p);
                cnx.Close();
                cnx.Dispose();
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: Al obtener los periodos de la empresa.\r\n\r\n" + error.Message, "Error");
                cnx.Dispose();
            }

            cmbPeriodo.DataSource = lstPeriodos;
            cmbPeriodo.DisplayMember = "pago";
            cmbPeriodo.ValueMember = "idperiodo";

            FLAG_COMBOBOX = true;
        }
Пример #21
0
        public static List<CalculoNomina.Core.tmpPagoNomina> PERCEPCIONES(List<CalculoNomina.Core.Nomina> lstConceptosPercepciones,
            DateTime inicio, DateTime fin, int tipoNomina)
        {
            #region VARIABLES GLOBALES
            string cdn = ConfigurationManager.ConnectionStrings["cdnNomina"].ConnectionString;
            SqlConnection cnx = new SqlConnection(cdn);
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = cnx;
            #endregion

            #region LISTA PARA DATOS DEL TRABAJADOR
            List<CalculoNomina.Core.tmpPagoNomina> lstValoresNomina;
            List<CalculoNomina.Core.tmpPagoNomina> lstValoresDefinitivos;
            #endregion

            #region CALCULO
            lstValoresNomina = new List<CalculoNomina.Core.tmpPagoNomina>();
            for (int i = 0; i < lstConceptosPercepciones.Count; i++)
            {
                CalculoNomina.Core.tmpPagoNomina vn = new CalculoNomina.Core.tmpPagoNomina();
                vn.idtrabajador = lstConceptosPercepciones[i].idtrabajador;
                vn.idempresa = GLOBALES.IDEMPRESA;
                vn.idconcepto = lstConceptosPercepciones[i].id;
                vn.noconcepto = lstConceptosPercepciones[i].noconcepto;
                vn.tipoconcepto = lstConceptosPercepciones[i].tipoconcepto;
                vn.fechainicio = inicio.Date;
                vn.fechafin = fin.Date;
                vn.guardada = false;
                vn.tiponomina = tipoNomina;
                vn.modificado = false;

                CalculoFormula formula = new CalculoFormula(lstConceptosPercepciones[i].idtrabajador, inicio.Date, fin.Date, lstConceptosPercepciones[i].formula);
                vn.cantidad = decimal.Parse(formula.calcularFormula().ToString());

                CalculoFormula formulaExcento = new CalculoFormula(lstConceptosPercepciones[i].idtrabajador, inicio.Date, fin.Date, lstConceptosPercepciones[i].formulaexento);
                vn.exento = decimal.Parse(formulaExcento.calcularFormula().ToString());

                Empleados.Core.EmpleadosHelper eh = new Empleados.Core.EmpleadosHelper();
                eh.Command = cmd;

                cnx.Open();
                int idperiodo = (int)eh.obtenerIdPeriodo(lstConceptosPercepciones[i].idtrabajador);
                cnx.Close();

                Periodos.Core.PeriodosHelper ph = new Periodos.Core.PeriodosHelper();
                ph.Command = cmd;

                Periodos.Core.Periodos p = new Periodos.Core.Periodos();
                p.idperiodo = idperiodo;

                cnx.Open();
                int dias = (int)ph.DiasDePago(p);
                cnx.Close();

                Conceptos.Core.ConceptosHelper ch = new Conceptos.Core.ConceptosHelper();
                ch.Command = cmd;

                Conceptos.Core.Conceptos c = new Conceptos.Core.Conceptos();
                c.idempresa = GLOBALES.IDEMPRESA;
                c.noconcepto = lstConceptosPercepciones[i].noconcepto;
                c.tipoconcepto = lstConceptosPercepciones[i].tipoconcepto;
                c.periodo = dias;

                cnx.Open();
                bool grava = (bool)ch.gravaConcepto(c);
                bool exenta = (bool)ch.exentaConcepto(c);
                cnx.Close();

                if (grava && !exenta)
                    vn.gravado = vn.cantidad;

                if (grava && exenta)
                {
                    if (vn.cantidad <= vn.exento)
                    {
                        vn.exento = vn.cantidad;
                        vn.gravado = 0;
                    }
                    else
                    {
                        vn.gravado = vn.cantidad - vn.exento;
                    }
                }

                if (!grava && exenta)
                {
                    vn.gravado = 0;
                    vn.exento = vn.cantidad;
                }

                #region SWITCH SUELDO CERO
                switch (lstConceptosPercepciones[i].noconcepto)
                {
                    case 1:
                        if (vn.cantidad == 0)
                        {
                            vn.gravado = 0;
                            lstValoresNomina.Add(vn);

                            Vacaciones.Core.VacacionesHelper vh = new Vacaciones.Core.VacacionesHelper();
                            vh.Command = cmd;
                            Vacaciones.Core.VacacionesPrima vp = new Vacaciones.Core.VacacionesPrima();
                            vp.idtrabajador = lstConceptosPercepciones[i].idtrabajador;
                            vp.idempresa = GLOBALES.IDEMPRESA;
                            vp.periodofin = fin.Date;
                            vp.periodoinicio = inicio.Date;
                            vp.vacacionesprima = "V";

                            cnx.Open();
                            int diasVacaciones = (int)vh.pagoVacacionesPrima(vp);
                            cnx.Close();

                            if (diasVacaciones == 0)
                            {
                                i++;
                                int contadorDatosNomina = i;
                                for (int j = i; j < lstConceptosPercepciones.Count; j++)
                                {
                                    contadorDatosNomina = j;
                                    if (lstConceptosPercepciones[j].idtrabajador == vn.idtrabajador)
                                    {
                                        CalculoNomina.Core.tmpPagoNomina vnCero = new CalculoNomina.Core.tmpPagoNomina();
                                        vnCero.idtrabajador = lstConceptosPercepciones[j].idtrabajador;
                                        vnCero.idempresa = GLOBALES.IDEMPRESA;
                                        vnCero.idconcepto = lstConceptosPercepciones[j].id;
                                        vnCero.noconcepto = lstConceptosPercepciones[j].noconcepto;
                                        vnCero.tipoconcepto = lstConceptosPercepciones[j].tipoconcepto;
                                        vnCero.fechainicio = inicio.Date;
                                        vnCero.fechafin = fin.Date;
                                        vnCero.guardada = false;
                                        vnCero.tiponomina = tipoNomina;
                                        vnCero.modificado = false;
                                        vnCero.cantidad = 0;
                                        vnCero.exento = 0;
                                        vnCero.gravado = 0;
                                        lstValoresNomina.Add(vnCero);
                                    }
                                    else
                                    {
                                        --contadorDatosNomina;
                                        break;
                                    }
                                }
                                i = contadorDatosNomina;
                            }
                        }
                        else
                            lstValoresNomina.Add(vn);
                        break;
                    default:
                        lstValoresNomina.Add(vn);
                        break;
                }
                #endregion
            }
            #endregion

            #region EXISTENCIA DEL CONCEPTO EN TABLA
            int existe = 0;
            CalculoNomina.Core.NominaHelper nh = new CalculoNomina.Core.NominaHelper();
            nh.Command = cmd;
            lstValoresDefinitivos = new List<CalculoNomina.Core.tmpPagoNomina>();
            for (int i = 0; i < lstValoresNomina.Count; i++)
            {
                CalculoNomina.Core.tmpPagoNomina vn = new CalculoNomina.Core.tmpPagoNomina();
                vn.idtrabajador = lstValoresNomina[i].idtrabajador;
                vn.idempresa = GLOBALES.IDEMPRESA;
                vn.idconcepto = lstValoresNomina[i].idconcepto;
                vn.noconcepto = lstValoresNomina[i].noconcepto;
                vn.tipoconcepto = lstValoresNomina[i].tipoconcepto;
                vn.fechainicio = lstValoresNomina[i].fechainicio;
                vn.fechafin = lstValoresNomina[i].fechafin;
                vn.guardada = lstValoresNomina[i].guardada;
                vn.tiponomina = lstValoresNomina[i].tiponomina;
                vn.modificado = lstValoresNomina[i].modificado;
                vn.exento = lstValoresNomina[i].exento;
                vn.gravado = lstValoresNomina[i].gravado;
                vn.cantidad = lstValoresNomina[i].cantidad;

                cnx.Open();
                existe = (int)nh.existeConcepto(vn);
                cnx.Close();

                if (existe == 0)
                {
                    lstValoresDefinitivos.Add(vn);
                }
                else
                {
                    cnx.Open();
                    nh.actualizaConcepto(vn);
                    cnx.Close();
                }
            }
            #endregion

            return lstValoresDefinitivos;
        }
Пример #22
0
        private void guardar(int tipoGuardar)
        {
            int existe = 0;
            //SE VALIDA SI TODOS LOS CAMPOS HAN SIDO LLENADOS.
            string control = GLOBALES.VALIDAR(this, typeof(TextBox));
            if (!control.Equals(""))
            {
                MessageBox.Show("Falta el campo: " + control, "Información");
                return;
            }

            control = GLOBALES.VALIDAR(this, typeof(MaskedTextBox));
            if (!control.Equals(""))
            {
                MessageBox.Show("Falta el campo: " + control, "Información");
                return;
            }

            if (txtNSS.Text.Length != 11)
            {
                MessageBox.Show("El campo NSS es mayor o meno a 11 dígitos.", "Error");
                return;
            }

            int idtrabajador;

            cnx = new SqlConnection();
            cnx.ConnectionString = cdn;
            cmd = new SqlCommand();
            cmd.Connection = cnx;
            eh = new Empleados.Core.EmpleadosHelper();
            eh.Command = cmd;

            CalculoNomina.Core.NominaHelper nh = new CalculoNomina.Core.NominaHelper();
            nh.Command = cmd;

            Empleados.Core.Empleados existeEmpleado = new Empleados.Core.Empleados();
            existeEmpleado.nss = txtNSS.Text.Trim().Substring(0, 10);
            existeEmpleado.digitoverificador = int.Parse(txtNSS.Text.Trim().Substring(10, 1));
            existeEmpleado.idempresa = GLOBALES.IDEMPRESA;

            int existeNss;
            try
            {
                cnx.Open();
                existeNss = (int)eh.existeEmpleado(existeEmpleado);
                cnx.Close();
            }
            catch
            {
                MessageBox.Show("Error al validar existencia de empleado.", "Error");
                return;
            }

            Empleados.Core.Empleados em = new Empleados.Core.Empleados();
            em.nombres = txtNombre.Text;
            em.paterno = txtApPaterno.Text;
            em.materno = txtApMaterno.Text;
            em.noempleado = mtxtNoEmpleado.Text;
            em.nombrecompleto = txtApPaterno.Text + (string.IsNullOrEmpty(txtApMaterno.Text) ? "" : " " + txtApMaterno.Text) + " " + txtNombre.Text;
            em.fechaingreso = dtpFechaIngreso.Value;
            em.antiguedad = int.Parse(txtAntiguedad.Text);
            em.fechaantiguedad = dtpFechaAntiguedad.Value;
            em.fechanacimiento = dtpFechaNacimiento.Value;
            em.antiguedadmod = int.Parse(txtAntiguedadMod.Text);
            em.edad = int.Parse(txtEdad.Text);
            em.idempresa = GLOBALES.IDEMPRESA;
            em.rfc = txtRFC.Text;
            em.curp = txtCURP.Text;
            em.nss = txtNSS.Text.Trim().Substring(0, 10);
            em.digitoverificador = int.Parse(txtNSS.Text.Trim().Substring(10, 1));

            em.idperiodo = int.Parse(cmbPeriodo.SelectedValue.ToString());
            em.idsalario = int.Parse(cmbZona.SelectedValue.ToString());
            em.tiposalario = int.Parse(cmbTipoSalario.SelectedValue.ToString());
            em.tiporegimen = int.Parse(cmbTipoRegimen.SelectedValue.ToString());

            em.sdi = decimal.Parse(txtSDI.Text);
            em.sd = decimal.Parse(txtSD.Text);
            em.sueldo = decimal.Parse(txtSueldo.Text);

            em.cuenta = mtxtCuentaBancaria.Text;
            em.clabe = mtxtCuentaClabe.Text;
            em.idbancario = mtxtIdBancario.Text;
            em.metodopago = cmbMetodoPago.Text;
            //em.metodopago = int.Parse(cmbMetodoPago.SelectedValue.ToString());

            if (chkObraCivil.Checked)
                em.obracivil = true;
            else
                em.obracivil = false;

            //hh = new Historial.Core.HistorialHelper();
            //hh.Command = cmd;
            //Historial.Core.Historial h = new Historial.Core.Historial();
            //h.idempresa = GLOBALES.IDEMPRESA;
            //h.tipomovimiento = GLOBALES.mALTA;
            //h.valor = decimal.Parse(txtSDI.Text);
            //h.fecha_imss = dtpFechaIngreso.Value;
            //h.fecha_sistema = DateTime.Now;
            //h.motivobaja = 0;
            //h.iddepartamento = int.Parse(cmbDepartamento.SelectedValue.ToString());
            //h.idpuesto = int.Parse(cmbPuesto.SelectedValue.ToString());

            ih = new Imagen.Core.ImagenesHelper();
            ih.Command = cmd;

            Imagen.Core.Imagenes img = null;

            //Empresas.Core.EmpresasHelper empresash = new Empresas.Core.EmpresasHelper();
            //empresash.Command = cmd;
            //Empresas.Core.Empresas empresa = new Empresas.Core.Empresas();
            //empresa.idempresa = GLOBALES.IDEMPRESA;

            try
            {
                if (ImagenAsignada == true)
                {
                    img = new Imagen.Core.Imagenes();
                    img.imagen = GLOBALES.IMAGEN_BYTES(bmp);
                    img.tipopersona = GLOBALES.pEMPLEADO;
                }
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: " + error.Message, "Error");
            }

            switch (_tipoOperacion)
            {
                case 0:
                    try
                    {
                        //Empleados.Core.EmpleadosEstatus ee = new Empleados.Core.EmpleadosEstatus();
                        //ee.estatus = GLOBALES.ACTIVO;
                        //ee.idempresa = GLOBALES.IDEMPRESA;

                        em.estatus = GLOBALES.ACTIVO;
                        em.idusuario = GLOBALES.IDUSUARIO;
                        em.iddepartamento = int.Parse(cmbDepartamento.SelectedValue.ToString());
                        em.idpuesto = int.Parse(cmbPuesto.SelectedValue.ToString());

                        if (existeNss != 0)
                        {
                            MessageBox.Show("El empleado que desea ingresar ya existe actualmente. \r\n \r\n Es necesario realizar un reingreso.", "Error");
                            return;
                        }

                        cnx.Open();
                        eh.insertaEmpleado(em);
                        idtrabajador = (int)eh.obtenerIdTrabajador(em);

                        //h.idtrabajador = idtrabajador;
                        //hh.insertarHistorial(h);

                        //ee.idtrabajador = idtrabajador;
                        //eh.insertaEmpleadoEstatus(ee);

                        //a.idtrabajador = idtrabajador;
                        //a.registropatronal = empresash.obtenerRegistroPatronal(empresa).ToString();
                        //ah.insertaAlta(a);

                        if (ImagenAsignada == true)
                        {
                            img.idpersona = idtrabajador;
                            ih.insertaImagen(img);
                        }

                        cnx.Close();
                        cnx.Dispose();
                    }
                    catch (Exception error)
                    {
                        MessageBox.Show("Error al ingresar el empleado. \r\n \r\n Error: " + error.Message);
                    }
                    break;
                case 2:
                    try
                    {
                        em.idtrabajador = _idempleado;
                        em.iddepartamento = idDepto;
                        em.idpuesto = idPuesto;

                        pdh = new Periodos.Core.PeriodosHelper();
                        pdh.Command = cmd;

                        Periodos.Core.Periodos p = new Periodos.Core.Periodos();
                        p.idperiodo = int.Parse(cmbPeriodo.SelectedValue.ToString());
                        int diasPago = 0;
                        try { cnx.Open(); diasPago = (int)pdh.DiasDePago(p); cnx.Close(); }
                        catch { MessageBox.Show("Error: Al obtener los dias de pago.", "Error"); }

                        DateTime dt = dtpFechaIngreso.Value.Date;
                        DateTime periodoInicio, periodoFin;
                        int diasProporcionales = 0;
                        if (diasPago == 7)
                        {
                            while (dt.DayOfWeek != DayOfWeek.Monday) dt = dt.AddDays(-1);
                            periodoInicio = dt;
                            periodoFin = dt.AddDays(6);
                            diasProporcionales = (int)(periodoFin.Date - dtpFechaIngreso.Value.Date).TotalDays + 1;
                        }
                        else
                        {
                            if (dt.Day <= 15)
                            {
                                periodoInicio = new DateTime(dt.Year, dt.Month, 1);
                                periodoFin = new DateTime(dt.Year, dt.Month, 15);
                                diasProporcionales = (int)(periodoFin.Date - dtpFechaIngreso.Value.Date).TotalDays + 1;
                            }
                            else
                            {
                                int diasMes = DateTime.DaysInMonth(dt.Year, dt.Month);
                                int diasNoLaborados = 0;
                                periodoInicio = new DateTime(dt.Year, dt.Month, 16);
                                periodoFin = new DateTime(dt.Year, dt.Month, DateTime.DaysInMonth(dt.Year, dt.Month));
                                diasNoLaborados = (int)(dtpFechaIngreso.Value.Date - periodoInicio).TotalDays;

                                switch (diasMes)
                                {
                                    case 28:
                                        diasProporcionales = 15 - diasNoLaborados;
                                        break;
                                    case 29:
                                        diasProporcionales = 15 - diasNoLaborados;
                                        break;
                                    case 30:
                                        diasProporcionales = (diasMes - 15) - diasNoLaborados;
                                        break;
                                    case 31:
                                        diasProporcionales = (diasMes - 16) - diasNoLaborados;
                                        break;
                                }
                            }
                        }

                        Altas.Core.AltasHelper ah = new Altas.Core.AltasHelper();
                        ah.Command = cmd;
                        Altas.Core.Altas a = new Altas.Core.Altas();
                        a.idempresa = GLOBALES.IDEMPRESA;
                        a.contrato = 4;
                        a.jornada = 12;
                        a.nss = txtNSS.Text;
                        a.rfc = txtRFC.Text;
                        a.curp = txtCURP.Text;
                        a.paterno = txtApPaterno.Text;
                        a.materno = txtApMaterno.Text;
                        a.nombre = txtNombre.Text;
                        a.fechaingreso = dtpFechaIngreso.Value;
                        a.diasproporcionales = diasProporcionales;
                        a.sdi = decimal.Parse(txtSDI.Text);
                        a.fechanacimiento = dtpFechaNacimiento.Value;
                        a.estado = cmbEstado.Text;
                        a.noestado = int.Parse(cmbEstado.SelectedValue.ToString());
                        a.sexo = ObtieneSexo();
                        a.periodoInicio = periodoInicio;
                        a.periodoFin = periodoFin;

                        cnx.Open();
                        eh.actualizaEmpleado(em);

                        a.idtrabajador = _idempleado;
                        ah.actualizaAlta(a);

                        if (ImagenAsignada == true)
                        {
                            img.idpersona = _idempleado;
                            img.tipopersona = GLOBALES.pEMPLEADO;
                            existe = (int)ih.ExisteImagen(img);
                            if (existe != 0)
                                ih.actualizaImagen(img);
                            else
                                ih.insertaImagen(img);
                        }
                        cnx.Close();
                        cnx.Dispose();
                    }
                    catch (Exception error)
                    {
                        MessageBox.Show("Error al actualizar el empleado. \r\n \r\n Error: " + error.Message);
                    }
                    break;
            }

            switch (tipoGuardar)
            {
                case 0:
                    GLOBALES.LIMPIAR(this, typeof(TextBox));
                    GLOBALES.LIMPIAR(this, typeof(MaskedTextBox));
                    GLOBALES.REFRESCAR(this, typeof(ComboBox));
                    break;
                case 1:
                    if (OnNuevoEmpleado != null)
                        OnNuevoEmpleado(_tipoOperacion);
                    this.Dispose();
                    break;
            }
        }
Пример #23
0
        private void toolEliminar_Click(object sender, EventArgs e)
        {
            int fila = dgvBajasSua.CurrentCell.RowIndex;
            int idPeriodo = 0, diasPeriodo = 0;
            string cdn = ConfigurationManager.ConnectionStrings["cdnNomina"].ConnectionString;
            cnx = new SqlConnection(cdn);
            cmd = new SqlCommand();
            cmd.Connection = cnx;

            Bajas.Core.BajasHelper bh = new Bajas.Core.BajasHelper();
            bh.Command = cmd;

            CalculoNomina.Core.NominaHelper nh = new CalculoNomina.Core.NominaHelper();
            nh.Command = cmd;

            Periodos.Core.PeriodosHelper ph = new Periodos.Core.PeriodosHelper();
            ph.Command = cmd;

            Periodos.Core.Periodos periodo = new Periodos.Core.Periodos();

            Empleados.Core.EmpleadosHelper eh = new Empleados.Core.EmpleadosHelper();
            eh.Command = cmd;

            List<Bajas.Core.Bajas> lstBaja = new List<Bajas.Core.Bajas>();
            List<CalculoNomina.Core.tmpPagoNomina> lstNomina = new List<CalculoNomina.Core.tmpPagoNomina>();

            try
            {
                cnx.Open();
                idPeriodo = int.Parse(eh.obtenerIdPeriodo(int.Parse(dgvBajasSua.Rows[fila].Cells[1].Value.ToString())).ToString());
                periodo.idperiodo = idPeriodo;
                diasPeriodo = int.Parse(ph.DiasDePago(periodo).ToString());
                lstBaja = bh.obtenerBaja(int.Parse(dgvBajasSua.Rows[fila].Cells[0].Value.ToString()));
                lstNomina = nh.obtenerUltimaNominaTrabajador(GLOBALES.IDEMPRESA, int.Parse(dgvBajasSua.Rows[fila].Cells[1].Value.ToString()), diasPeriodo);
                cnx.Close();
            }
            catch (Exception)
            {
                MessageBox.Show("Error: Al obtener los datos de la baja.", "Error");
                cnx.Dispose();
                return;
            }

            if (lstNomina.Count != 0)
                if (lstBaja[0].periodoinicio == lstNomina[0].fechainicio && lstBaja[0].periodofin == lstNomina[0].fechafin)
                {
                    MessageBox.Show("La baja pertenece a un periodo cerrado. No se puede eliminar.", "Información");
                    return;
                }

            DialogResult respuesta = MessageBox.Show("¿Quiere eliminar la baja?. \r\n \r\n CUIDADO. Esta acción eliminará permanentemente el registro.", "Confirmación", MessageBoxButtons.YesNo);
            if (respuesta == DialogResult.Yes)
            {
                Historial.Core.HistorialHelper hh = new Historial.Core.HistorialHelper();
                hh.Command = cmd;

                Empleados.Core.EmpleadosEstatus ee = new Empleados.Core.EmpleadosEstatus();
                ee.idtrabajador = int.Parse(dgvBajasSua.Rows[fila].Cells[1].Value.ToString());
                ee.idempresa = GLOBALES.IDEMPRESA;
                ee.estatus = GLOBALES.ACTIVO;

                Bajas.Core.Bajas baja = new Bajas.Core.Bajas();
                baja.idtrabajador = int.Parse(dgvBajasSua.Rows[fila].Cells[1].Value.ToString());
                baja.idempresa = GLOBALES.IDEMPRESA;
                baja.fecha = DateTime.Parse(dgvBajasSua.Rows[fila].Cells[8].Value.ToString()).Date;

                Historial.Core.Historial historial = new Historial.Core.Historial();
                historial.idtrabajador = int.Parse(dgvBajasSua.Rows[fila].Cells[1].Value.ToString());
                historial.idempresa = GLOBALES.IDEMPRESA;
                historial.fecha_imss = DateTime.Parse(dgvBajasSua.Rows[fila].Cells[8].Value.ToString()).Date;

                try
                {
                    cnx.Open();
                    bh.eliminaBaja(baja);
                    eh.bajaEmpleado(ee);
                    eh.actualizaEstatus(int.Parse(dgvBajasSua.Rows[fila].Cells[1].Value.ToString()));
                    cnx.Close();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error: Al eliminar la baja. \r\n" + error.Message, "Error");
                    cnx.Dispose();
                    return;
                }

                try
                {
                    cnx.Open();
                    hh.eliminaHistorial(historial);
                    cnx.Close();
                    cnx.Dispose();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error: Al eliminar el movimiento del historial.\r\n" + error.Message, "Error");
                    cnx.Dispose();
                    return;
                }

                MessageBox.Show("Registro eliminado.", "Confirmación");
                ListaEmpleados();
            }
        }
Пример #24
0
        private void dtpFecha_ValueChanged(object sender, EventArgs e)
        {
            cnx = new SqlConnection(cdn);
            cmd = new SqlCommand();
            cmd.Connection = cnx;

            CalculoNomina.Core.NominaHelper nh = new CalculoNomina.Core.NominaHelper();
            nh.Command = cmd;
            List<CalculoNomina.Core.tmpPagoNomina> lstUltimaNomina = new List<CalculoNomina.Core.tmpPagoNomina>();

            eh = new Empleados.Core.EmpleadosHelper();
            eh.Command = cmd;

            Periodos.Core.PeriodosHelper ph = new Periodos.Core.PeriodosHelper();
            ph.Command = cmd;

            Periodos.Core.Periodos periodo = new Periodos.Core.Periodos();

            int dias = 0;
            try
            {
                cnx.Open();
                periodo.idperiodo = (int)eh.obtenerIdPeriodo(_idempleado);
                dias = int.Parse(ph.DiasDePago(periodo).ToString());
                lstUltimaNomina = nh.obtenerUltimaNominaTrabajador(GLOBALES.IDEMPRESA, _idempleado, dias);
                cnx.Close();
            }
            catch (Exception)
            {
                MessageBox.Show("Error: Al obtener la ultima nómina del trabajador.", "Error");
                cnx.Dispose();
            }

            if (lstUltimaNomina.Count != 0)
                if (dtpFecha.Value.Date <= lstUltimaNomina[0].fechafin)
                {
                    MessageBox.Show("La fecha de aplicación seleccionada no es valida.\r\n\r\n" +
                                    "Se empalma con la ultima nomina del trabajador, por favor verifique.", "Información");
                }

            if (dias == 7)
            {
                DateTime dt = dtpFecha.Value;
                while (dt.DayOfWeek != DayOfWeek.Monday) dt = dt.AddDays(-1);
                inicioPeriodo = dt;
                finPeriodo = dt.AddDays(6);
            }
            else
            {
                if (dtpFecha.Value.Day <= 15)
                {
                    inicioPeriodo = new DateTime(dtpFecha.Value.Year, dtpFecha.Value.Month, 1);
                    finPeriodo = new DateTime(dtpFecha.Value.Year, dtpFecha.Value.Month, 15);
                }
                else
                {
                    inicioPeriodo = new DateTime(dtpFecha.Value.Year, dtpFecha.Value.Month, 16);
                    finPeriodo = new DateTime(dtpFecha.Value.Year, dtpFecha.Value.Month, DateTime.DaysInMonth(dtpFecha.Value.Year, dtpFecha.Value.Month));
                }
            }
        }
Пример #25
0
        private void frmExportarEmpleado_Load(object sender, EventArgs e)
        {
            lstvCampos.View = View.Details;
            lstvCampos.CheckBoxes = false;
            lstvCampos.GridLines = false;
            lstvCampos.MultiSelect = false;
            lstvCampos.Columns.Add("Campos", 100, HorizontalAlignment.Left);

            lstvOrdenCampos.View = View.Details;
            lstvOrdenCampos.CheckBoxes = false;
            lstvOrdenCampos.MultiSelect = false;
            lstvOrdenCampos.GridLines = false;
            lstvOrdenCampos.Columns.Add("Campos", 100, HorizontalAlignment.Left);

            cnx = new SqlConnection(cdn);
            cmd = new SqlCommand();
            cmd.Connection = cnx;

            eh = new Exportacion.Core.ExportacionHelper();
            eh.Command = cmd;

            ph = new Periodos.Core.PeriodosHelper();
            ph.Command = cmd;

            Periodos.Core.Periodos periodo = new Periodos.Core.Periodos();
            periodo.idempresa = GLOBALES.IDEMPRESA;

            List<Periodos.Core.Periodos> lstPeriodos = new List<Periodos.Core.Periodos>();
            List<Exportacion.Core.Exportacion> lstExportacion = new List<Exportacion.Core.Exportacion>();

            try {
                cnx.Open();
                lstExportacion = eh.obtenerDatos(GLOBALES.IDEMPRESA, "frmListaEmpleados");
                lstPeriodos = ph.obtenerPeriodos(periodo);
                cnx.Close();
                cnx.Dispose();
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: Al obtener campos a exportar.\r\n \r\n" + error.Message,"Error");
                this.Dispose();
            }

            for (int i = 0; i < lstExportacion.Count; i++)
            {
                lstvCampos.Items.Add(lstExportacion[i].campo);
                if (lstExportacion[i].activo)
                    lstvOrdenCampos.Items.Add(lstExportacion[i].campo);
            }

            cmbPeriodo.DataSource = lstPeriodos;
            cmbPeriodo.DisplayMember = "pago";
            cmbPeriodo.ValueMember = "dias";

            cmbTipoNomina.SelectedIndex = 0;

            if (_tipoReporte == GLOBALES.EXPORTACATALOGO_GENERAL)
            {
                cmbPeriodo.Enabled = false;
                cmbTipoNomina.Enabled = false;
                dtpFechaInicio.Enabled = false;
            }
            else
            {
                cmbPeriodo.Enabled = true;
                cmbTipoNomina.Enabled = true;
                dtpFechaInicio.Enabled = true;
            }
        }
Пример #26
0
        private void frmReingresoEmpleado_Load(object sender, EventArgs e)
        {
            cnx = new SqlConnection(cdn);
            cmd = new SqlCommand();
            cmd.Connection = cnx;

            Departamento.Core.DeptoHelper dh = new Departamento.Core.DeptoHelper();
            Puestos.Core.PuestosHelper ph = new Puestos.Core.PuestosHelper();
            Periodos.Core.PeriodosHelper periodoh = new Periodos.Core.PeriodosHelper();
            Factores.Core.FactoresHelper fh = new Factores.Core.FactoresHelper();
            Empleados.Core.EmpleadosHelper emph = new Empleados.Core.EmpleadosHelper();

            emph.Command = cmd;
            dh.Command = cmd;
            ph.Command = cmd;
            periodoh.Command = cmd;
            fh.Command = cmd;

            Departamento.Core.Depto depto = new Departamento.Core.Depto();
            Puestos.Core.Puestos puesto = new Puestos.Core.Puestos();
            Periodos.Core.Periodos periodo = new Periodos.Core.Periodos();
            Factores.Core.Factores factor = new Factores.Core.Factores();
            Empleados.Core.Empleados empleado = new Empleados.Core.Empleados();

            empleado.idtrabajador = _idempleado;
            depto.idempresa = GLOBALES.IDEMPRESA;
            puesto.idempresa = GLOBALES.IDEMPRESA;
            periodo.idempresa = GLOBALES.IDEMPRESA;

            List<Departamento.Core.Depto> lstDepto = new List<Departamento.Core.Depto>();
            List<Puestos.Core.Puestos> lstPuesto = new List<Puestos.Core.Puestos>();
            List<Periodos.Core.Periodos> lstPeriodo = new List<Periodos.Core.Periodos>();
            lstEmpleado = new List<Empleados.Core.Empleados>();

            try {
                cnx.Open();
                lstDepto = dh.obtenerDepartamentos(depto);
                lstPuesto = ph.obtenerPuestos(puesto);
                lstPeriodo = periodoh.obtenerPeriodos(periodo);
                lstEmpleado = emph.obtenerEmpleado(empleado);
                cnx.Close();
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: \r\n \r\n" + error.Message, "Error");
            }

            cmbDepartamento.DataSource = lstDepto.ToList();
            cmbDepartamento.DisplayMember = "descripcion";
            cmbDepartamento.ValueMember = "id";

            cmbPuesto.DataSource = lstPuesto.ToList();
            cmbPuesto.DisplayMember = "nombre";
            cmbPuesto.ValueMember = "idpuesto";

            cmbPeriodo.DataSource = lstPeriodo.ToList();
            cmbPeriodo.DisplayMember = "pago";
            cmbPeriodo.ValueMember = "idperiodo";

            txtNombreCompleto.Text = _nombreEmpleado;
            mtxtNoEmpleado.Text = lstEmpleado[0].noempleado;
            cmbMetodoPago.SelectedIndex = 2;
            mtxtCuentaBancaria.Text = lstEmpleado[0].cuenta;
            mtxtCuentaClabe.Text = lstEmpleado[0].clabe;
            mtxtIdBancario.Text = lstEmpleado[0].idbancario;

            if (GLOBALES.OBRACIVIL)
                chkObraCivil.Visible = true;
            else
                chkObraCivil.Visible = false;
        }
Пример #27
0
        private void frmReportes_Load(object sender, EventArgs e)
        {
            dtpFinPeriodo.Enabled = false;

            cmbDeptoInicial.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
            cmbDeptoInicial.AutoCompleteSource = AutoCompleteSource.ListItems;
            cmbDeptoFinal.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
            cmbDeptoFinal.AutoCompleteSource = AutoCompleteSource.ListItems;

            cmbEmpleadoInicial.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
            cmbEmpleadoInicial.AutoCompleteSource = AutoCompleteSource.ListItems;
            cmbEmpleadoFinal.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
            cmbEmpleadoFinal.AutoCompleteSource = AutoCompleteSource.ListItems;

            cnx = new SqlConnection(cdn);
            cmd = new SqlCommand();
            cmd.Connection = cnx;

            dh = new Departamento.Core.DeptoHelper();
            dh.Command = cmd;

            Departamento.Core.Depto depto = new Departamento.Core.Depto();
            depto.idempresa = GLOBALES.IDEMPRESA;
            depto.estatus = GLOBALES.ACTIVO;

            ph = new Periodos.Core.PeriodosHelper();
            ph.Command = cmd;

            Periodos.Core.Periodos periodo = new Periodos.Core.Periodos();
            periodo.idempresa = GLOBALES.IDEMPRESA;

            List<Departamento.Core.Depto> lstDeptosDe = new List<Departamento.Core.Depto>();
            List<Departamento.Core.Depto> lstDeptosHasta = new List<Departamento.Core.Depto>();
            List<Periodos.Core.Periodos> lstPeriodos = new List<Periodos.Core.Periodos>();

            try
            {
                cnx.Open();
                lstDeptosDe = dh.obtenerDepartamentos(depto);
                lstDeptosHasta = dh.obtenerDepartamentos(depto);
                lstPeriodos = ph.obtenerPeriodos(periodo);
                cnx.Close();
                cnx.Dispose();
            }
            catch (Exception error) { MessageBox.Show("Error: \r\n \r\n" + error.Message, "Error"); }

            cmbDeptoInicial.DataSource = lstDeptosDe;
            cmbDeptoInicial.DisplayMember = "descripcion";
            cmbDeptoInicial.ValueMember = "id";

            cmbDeptoFinal.DataSource = lstDeptosHasta;
            cmbDeptoFinal.DisplayMember = "descripcion";
            cmbDeptoFinal.ValueMember = "id";

            cmbPeriodo.DataSource = lstPeriodos.ToList();
            cmbPeriodo.DisplayMember = "pago";
            cmbPeriodo.ValueMember = "idperiodo";

            cmbTipoReporte.SelectedIndex = 0;
            cmbTipoNomina.SelectedIndex = 0;
            cmbNetoCero.SelectedIndex = 0;
            cmbOrden.SelectedIndex = 3;

            if (_ReportePreNomina)
            {
                dtpInicioPeriodo.Value = _inicio;
                dtpFinPeriodo.Value = _fin;
                cmbPeriodo.Enabled = true;
                dtpInicioPeriodo.Enabled = false;
                dtpFinPeriodo.Enabled = false;
                cmbTipoReporte.Enabled = false;
                cmbDeptoInicial.Enabled = false;
                cmbDeptoFinal.Enabled = false;
                cmbEmpleadoInicial.Enabled = false;
                cmbEmpleadoFinal.Enabled = false;

                if (_noReporte == 2)
                {
                    cmbOrden.Items.Clear();
                    cmbOrden.Items.Add("Departamento");
                    cmbOrden.SelectedIndex = 0;
                }
                else
                {
                    cmbOrden.Items.Clear();
                    cmbOrden.Items.Add("No. de Empleado");
                    cmbOrden.Items.Add("Departamento");
                    cmbOrden.Items.Add("No. de Empleado, Departamento");
                    cmbOrden.Items.Add("Departamento, No. de Empleado");
                    cmbOrden.SelectedIndex = 0;
                }

                if (_noReporte == 9 || _noReporte == 1)
                {
                    cmbEmpleadoInicial.Enabled = true;
                    cmbEmpleadoFinal.Enabled = true;
                }
            }
            FLAG_COMBOBOX = true;
        }
Пример #28
0
        private void frmPeriodos_Load(object sender, EventArgs e)
        {
            cnx = new MySqlConnection();
            cnx.ConnectionString = cdn;
            cmd            = new MySqlCommand();
            cmd.Connection = cnx;
            Clientes.Core.ClientesHelper ch = new Clientes.Core.ClientesHelper();
            ch.Command = cmd;

            //DataTable dtClientes = new DataTable();
            List <Clientes.Core.Clientes> lstClientes = new List <Clientes.Core.Clientes>();

            Clientes.Core.Clientes cliente = new Clientes.Core.Clientes();
            cliente.plaza = GLOBALES.IDPLAZA;

            try
            {
                cnx.Open();
                lstClientes = ch.obtenerClientes(cliente);
                //dtClientes = ch.dtObtenerClientes(cliente);
                cnx.Close();
                cnx.Dispose();
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
            }

            cmbCliente.DataSource    = lstClientes.ToList();
            cmbCliente.ValueMember   = "idcliente";
            cmbCliente.DisplayMember = "nombre";

            if (_tipoOperacion == GLOBALES.CONSULTAR || _tipoOperacion == GLOBALES.MODIFICAR)
            {
                ph         = new Periodos.Core.PeriodosHelper();
                ph.Command = cmd;

                Periodos.Core.Periodos p = new Periodos.Core.Periodos();
                p.idperiodo = _idperiodo;

                List <Periodos.Core.Periodos> lstPeriodo;

                try
                {
                    cnx.Open();
                    lstPeriodo = ph.obtenerPeriodo(p);
                    cnx.Close();
                    cnx.Dispose();

                    for (int i = 0; i < lstPeriodo.Count; i++)
                    {
                        cmbCliente.SelectedValue   = lstPeriodo[i].idperiodo;
                        cmbPago.SelectedText       = lstPeriodo[i].pago;
                        txtDias.Text               = lstPeriodo[i].dias.ToString();
                        cmbDiaInicio.SelectedText  = lstPeriodo[i].inicio;
                        cmbDiaTermino.SelectedText = lstPeriodo[i].termino;
                    }
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
                }

                if (_tipoOperacion == GLOBALES.CONSULTAR)
                {
                    toolTitulo.Text = "Consulta Periodo";
                    GLOBALES.INHABILITAR(this, typeof(TextBox));
                    GLOBALES.INHABILITAR(this, typeof(ComboBox));
                }
                else
                {
                    toolTitulo.Text = "Edición Periodo";
                }
            }

            cmbPago.SelectedIndex       = 0;
            cmbDiaInicio.SelectedIndex  = 0;
            cmbDiaTermino.SelectedIndex = 6;
        }
        private decimal ObtieneSD(decimal sdi)
        {
            int DiasDePago = 0;
            decimal FactorDePago = 0;
            decimal sd = 0;
            cnx = new SqlConnection();
            cnx.ConnectionString = cdn;
            cmd = new SqlCommand();
            cmd.Connection = cnx;

            ph = new Periodos.Core.PeriodosHelper();
            Periodos.Core.Periodos p = new Periodos.Core.Periodos();

            fh = new Factores.Core.FactoresHelper();
            Factores.Core.Factores f = new Factores.Core.Factores();

            ph.Command = cmd;
            fh.Command = cmd;

            p.idperiodo = idPeriodo;
            f.anio = 0;

            try
            {
                cnx.Open();
                DiasDePago = (int)ph.DiasDePago(p);
                FactorDePago = decimal.Parse(fh.FactorDePago(f).ToString());
                cnx.Close();

                sd = (sdi / FactorDePago);
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: \r\n \r\n Al obtener los dias de pago y/o factor de pago. \r\n" + error.Message, "Error");
                this.Dispose();
            }
            return sd;
        }
Пример #30
0
        private void frmEnvioRecibos_Load(object sender, EventArgs e)
        {
            cmbTipoNomina.SelectedIndex = 0;

            cnx = new SqlConnection(cdn);
            cmd = new SqlCommand();
            cmd.Connection = cnx;

            Departamento.Core.DeptoHelper dh = new Departamento.Core.DeptoHelper();
            dh.Command = cmd;
            Configuracion.Core.ConfiguracionHelper confh = new Configuracion.Core.ConfiguracionHelper();
            confh.Command = cmd;

            Periodos.Core.PeriodosHelper ph = new Periodos.Core.PeriodosHelper();
            ph.Command = cmd;

            Periodos.Core.Periodos p = new Periodos.Core.Periodos();
            p.idempresa = GLOBALES.IDEMPRESA;

            List<Periodos.Core.Periodos> lstPeriodos = new List<Periodos.Core.Periodos>();

            try
            {
                cnx.Open();
                lstPeriodos = ph.obtenerPeriodos(p);
                correoEnvio = confh.obtenerValorConfiguracion("CorreoEnvio").ToString();
                passwordEnvio = confh.obtenerValorConfiguracion("PasswordEnvio").ToString();
                puertoEnvio = int.Parse(confh.obtenerValorConfiguracion("PuertoEnvio").ToString());
                ruta = confh.obtenerValorConfiguracion("RutaRecibos").ToString();
                servidorEnvio = confh.obtenerValorConfiguracion("ServidorEnvio").ToString();
                if(int.Parse(confh.obtenerValorConfiguracion("UsaSSL").ToString()) == 1)
                    usaSSL = true;
                else
                    usaSSL = false;
                cnx.Close();
                cnx.Dispose();
            }
            catch (Exception)
            {
                MessageBox.Show("Error: Al obtener los periodos de la empresa.", "Error");
                cnx.Dispose();
                return;
            }

            lstvPeriodos.View = View.Details;
            lstvPeriodos.CheckBoxes = false;
            lstvPeriodos.GridLines = false;
            lstvPeriodos.Columns.Add("Inicio", 100, HorizontalAlignment.Left);
            lstvPeriodos.Columns.Add("Fin", 100, HorizontalAlignment.Left);

            lstvDepartamentos.View = View.Details;
            lstvDepartamentos.CheckBoxes = true;
            lstvDepartamentos.GridLines = false;
            lstvDepartamentos.Columns.Add("Id", 60, HorizontalAlignment.Left);
            lstvDepartamentos.Columns.Add("Departamento", 150, HorizontalAlignment.Left);

            cmbPeriodo.DataSource = lstPeriodos;
            cmbPeriodo.DisplayMember = "pago";
            cmbPeriodo.ValueMember = "idperiodo";

            FLAG_COMBOBOX = true;

            this.Visor.RefreshReport();
        }
Пример #31
0
        private void frmPeriodo_Load(object sender, EventArgs e)
        {
            cnx = new SqlConnection();
            cnx.ConnectionString = cdn;
            cmd = new SqlCommand();
            cmd.Connection = cnx;

            eh = new Empleados.Core.EmpleadosHelper();
            eh.Command = cmd;

            Departamento.Core.DeptoHelper dh = new Departamento.Core.DeptoHelper();
            dh.Command = cmd;

            List<Departamento.Core.Depto> lstDepartamento = new List<Departamento.Core.Depto>();
            List<Empleados.Core.Empleados> lstEmpleado = new List<Empleados.Core.Empleados>();
            List<Periodos.Core.Periodos> lstPeriodos = new List<Periodos.Core.Periodos>();

            Empleados.Core.Empleados empleado = new Empleados.Core.Empleados();
            empleado.idtrabajador = _idEmpleado;

            Departamento.Core.Depto dpto = new Departamento.Core.Depto();
            dpto.idempresa = GLOBALES.IDEMPRESA;

            Periodos.Core.PeriodosHelper ph = new Periodos.Core.PeriodosHelper();
            ph.Command = cmd;

            Periodos.Core.Periodos periodo = new Periodos.Core.Periodos();
            periodo.idempresa = GLOBALES.IDEMPRESA;

            try
            {
                cnx.Open();
                lstPeriodos = ph.obtenerPeriodos(periodo);
                lstEmpleado = eh.obtenerEmpleado(empleado);
                lstDepartamento = dh.obtenerDepartamentos(dpto);
                cnx.Close();
            }
            catch (Exception error)
            {
                MessageBox.Show("Error al obtener los dias del periodo. \r\n \r\n La ventana se cerrará. \r\n \r\n" + error.Message, "Error");
                cnx.Dispose();
                this.Dispose();
            }

            cmbPeriodo.DataSource = lstPeriodos.ToList();
            cmbPeriodo.DisplayMember = "pago";
            cmbPeriodo.ValueMember = "idperiodo";

            var dato = from emp in lstEmpleado
                       join d in lstDepartamento on emp.iddepartamento equals d.id
                       select new
                       {
                           emp.noempleado,
                           emp.nombrecompleto,
                           d.descripcion,
                           emp.idperiodo
                       };
            foreach (var inf in dato)
            {
                mtxtNoEmpleado.Text = inf.noempleado;
                txtNombre.Text = inf.nombrecompleto;
                txtDepartamento.Text = inf.descripcion;
                cmbPeriodo.SelectedValue = inf.idperiodo;
            }
        }
Пример #32
0
        private void guardar(int tipoGuardar)
        {
            int existe = 0;
            //SE VALIDA SI TODOS LOS TEXTBOX HAN SIDO LLENADOS.
            string control = GLOBALES.VALIDAR(this,typeof(TextBox));
            if (!control.Equals(""))
            {
                MessageBox.Show("Falta el campo: " + control, "Información");
                return;
            }

            control = GLOBALES.VALIDAR(this, typeof(MaskedTextBox));
            if (!control.Equals(""))
            {
                MessageBox.Show("Falta el campo: " + control, "Información");
                return;
            }

            int idempresa;

            cnx = new SqlConnection();
            cnx.ConnectionString = cdn;
            cmd = new SqlCommand();
            cmd.Connection = cnx;
            eh = new Empresas.Core.EmpresasHelper();
            eh.Command = cmd;

            Empresas.Core.Empresas em = new Empresas.Core.Empresas();
            em.nombre = txtNombre.Text;
            em.rfc = txtRfc.Text;
            em.registro = txtRegistroPatronal.Text;
            em.digitoverificador = int.Parse(txtDigitoVerificador.Text);
            em.representante = txtRepresentante.Text;
            em.estatus = 1;
            em.regimen = txtRegimen.Text;
            em.certificado = txtCertificado.Text;
            em.llave = txtLlave.Text;
            em.password = txtPassword.Text;
            em.nocertificado = txtNoCertificado.Text;
            em.vigenciacertificado = dtpVigencia.Value.Date;
            em.observacion = txtObservacion.Text;

            dh = new Direccion.Core.DireccionesHelper();
            dh.Command = cmd;

            Direccion.Core.Direcciones d = new Direccion.Core.Direcciones();
            d.calle = txtCalle.Text;
            d.exterior = txtExterior.Text;
            d.interior = txtInterior.Text;
            d.colonia = txtColonia.Text;
            d.ciudad = txtMunicipio.Text;
            d.estado = txtEstado.Text;
            d.pais = txtPais.Text;
            d.cp = txtCP.Text;
            d.tipodireccion = GLOBALES.dFISCAL;
            d.tipopersona = GLOBALES.pEMPRESA;

            ih = new Imagen.Core.ImagenesHelper();
            ih.Command = cmd;

            Imagen.Core.Imagenes img = null;

            Periodos.Core.PeriodosHelper ph = new Periodos.Core.PeriodosHelper();
            ph.Command = cmd;

            Periodos.Core.Periodos periodo = new Periodos.Core.Periodos();
            periodo.dias = int.Parse(txtDias.Text);
            periodo.estatus = GLOBALES.ACTIVO;
            periodo.pago = cmbPago.Text;

            CalculoNomina.Core.NominaHelper nh = new CalculoNomina.Core.NominaHelper();
            nh.Command = cmd;

            CalculoNomina.Core.PagoNomina pn = new CalculoNomina.Core.PagoNomina();
            pn.idtrabajador = 0;
            pn.idconcepto = 0;
            pn.noconcepto = 0;
            pn.tipoconcepto = "P";
            pn.exento = 0;
            pn.gravado = 0;
            pn.cantidad = 0;
            pn.fechainicio = inicioPeriodo;
            pn.fechafin = finPeriodo;
            pn.noperiodo = 0;
            pn.diaslaborados = 0;
            pn.idusuario = 0;
            pn.tiponomina = 0;
            pn.fechapago = finPeriodo;
            pn.iddepartamento = 0;
            pn.idpuesto = 0;

            try
            {
                if (ImagenAsignada == true)
                {
                    img = new Imagen.Core.Imagenes();
                    img.imagen = GLOBALES.IMAGEN_BYTES(bmp);
                    img.tipopersona = GLOBALES.pEMPRESA;
                }
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: " + error.Message, "Error");
            }

            switch (_tipoOperacion)
            {
                case 0:
                    try
                    {
                        cnx.Open();
                        eh.insertaEmpresa(em);
                        idempresa = (int)eh.obtenerIdEmpresa(em);
                        d.idpersona = idempresa;
                        dh.insertaDireccion(d);
                        if (ImagenAsignada == true)
                        {
                            img.idpersona = idempresa;
                            ih.insertaImagen(img);
                        }
                        periodo.idempresa = idempresa;
                        ph.insertaPeriodo(periodo);
                        pn.idempresa = idempresa;
                        nh.insertaPrimerPeriodoNomina(pn);
                        cnx.Close();
                        cnx.Dispose();
                    }
                    catch (Exception error)
                    {
                        MessageBox.Show("Error al ingresar la empresa. \r\n \r\n Error: " + error.Message);
                    }
                    break;
                case 2:
                    try
                    {
                        em.idempresa = _idempresa;
                        d.iddireccion = _iddireccion;
                        d.idpersona = _idempresa;

                        cnx.Open();
                        eh.actualizaEmpresa(em);
                        dh.actualizaDireccion(d);
                        if (ImagenAsignada == true)
                        {
                            img.idpersona = _idempresa;
                            img.tipopersona = GLOBALES.pEMPRESA;
                            existe = (int)ih.ExisteImagen(img);
                            if (existe != 0)
                                ih.actualizaImagen(img);
                            else
                                ih.insertaImagen(img);
                        }
                        cnx.Close();
                        cnx.Dispose();
                    }
                    catch (Exception error)
                    {
                        MessageBox.Show("Error al actualizar la empresa. \r\n \r\n Error: " + error.Message);
                    }
                    break;
            }

            switch (tipoGuardar)
            {
                case 0:
                    GLOBALES.LIMPIAR(this,typeof(TextBox));
                    GLOBALES.LIMPIAR(this, typeof(MaskedTextBox));
                    //limpiar(this, typeof(TextBox));
                    break;
                case 1:
                    if (OnNuevaEmpresa != null)
                        OnNuevaEmpresa(_tipoOperacion);
                    this.Dispose();
                    break;
            }
        }
Пример #33
0
        private void btnCalcular_Click(object sender, EventArgs e)
        {
            if (txtAntiguedadMod.Text.Length == 0)
                return;

            if (txtSDI.Text.Length != 0)
            {
                int DiasDePago = 0;
                double FactorDePago = 0;
                cnx = new SqlConnection();
                cnx.ConnectionString = cdn;
                cmd = new SqlCommand();
                cmd.Connection = cnx;

                Periodos.Core.PeriodosHelper ph = new Periodos.Core.PeriodosHelper();
                Periodos.Core.Periodos p = new Periodos.Core.Periodos();
                Factores.Core.FactoresHelper fh = new Factores.Core.FactoresHelper();
                Factores.Core.Factores f = new Factores.Core.Factores();

                ph.Command = cmd;
                fh.Command = cmd;

                p.idperiodo = int.Parse(cmbPeriodo.SelectedValue.ToString());
                f.anio = int.Parse(txtAntiguedadMod.Text);

                try
                {
                    cnx.Open();
                    DiasDePago = (int)ph.DiasDePago(p);
                    FactorDePago = double.Parse(fh.FactorDePago(f).ToString());
                    cnx.Close();
                    cnx.Dispose();

                    //txtSalarioDiario.Text = (double.Parse(txtSueldo.Text) / DiasDePago).ToString("F6");
                    //txtSDI.Text = (double.Parse(txtSalarioDiario.Text) * FactorDePago).ToString("F6");
                    txtSalarioDiario.Text = (double.Parse(txtSDI.Text) / FactorDePago).ToString("F6");
                    txtSueldo.Text = (double.Parse(txtSalarioDiario.Text) * DiasDePago).ToString("F6");

                }
                catch (Exception error)
                {
                    MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
                    this.Dispose();
                }
            }
        }
Пример #34
0
        private void frmConceptosEmpresa_Load(object sender, EventArgs e)
        {
            cnx = new SqlConnection(cdn);
            cmd = new SqlCommand();
            cmd.Connection = cnx;

            Periodos.Core.PeriodosHelper ph = new Periodos.Core.PeriodosHelper();
            ph.Command = cmd;

            Periodos.Core.Periodos p = new Periodos.Core.Periodos();
            p.idempresa = GLOBALES.IDEMPRESA;

            List<Periodos.Core.Periodos> lstPeriodos = new List<Periodos.Core.Periodos>();

            try
            {
                cnx.Open();
                lstPeriodos = ph.obtenerPeriodos(p);
                cnx.Close();
                cnx.Dispose();
            }
            catch (Exception)
            {
                MessageBox.Show("Error: Al Obtener los periodos de la empresa", "Error");
                cnx.Dispose();
            }

            cmbPeriodo.DataSource = lstPeriodos;
            cmbPeriodo.DisplayMember = "pago";
            cmbPeriodo.ValueMember = "idperiodo";
        }
Пример #35
0
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            string rp;
            //SE VALIDA SI TODOS LOS CAMPOS HAN SIDO LLENADOS.
            string control = GLOBALES.VALIDAR(this, typeof(TextBox));
            if (!control.Equals(""))
            {
                MessageBox.Show("Falta el campo: " + control, "Información");
                return;
            }

            control = GLOBALES.VALIDAR(this, typeof(MaskedTextBox));
            if (!control.Equals(""))
            {
                MessageBox.Show("Falta el campo: " + control, "Información");
                return;
            }

            cnx = new SqlConnection(cdn);
            cmd = new SqlCommand();
            cmd.Connection = cnx;

            Empleados.Core.EmpleadosHelper empleadoh = new Empleados.Core.EmpleadosHelper();
            Historial.Core.HistorialHelper hh = new Historial.Core.HistorialHelper();
            Reingreso.Core.ReingresoHelper rh = new Reingreso.Core.ReingresoHelper();
            Empresas.Core.EmpresasHelper eh = new Empresas.Core.EmpresasHelper();
            Infonavit.Core.InfonavitHelper ih = new Infonavit.Core.InfonavitHelper();

            empleadoh.Command = cmd;
            hh.Command = cmd;
            rh.Command = cmd;
            eh.Command = cmd;
            ih.Command = cmd;

            Empleados.Core.Empleados empleado = new Empleados.Core.Empleados();
            Empleados.Core.EmpleadosEstatus ee = new Empleados.Core.EmpleadosEstatus();
            Historial.Core.Historial historia = new Historial.Core.Historial();
            Reingreso.Core.Reingresos reingreso = new Reingreso.Core.Reingresos();
            Empresas.Core.Empresas empresa = new Empresas.Core.Empresas();

            empleado.idtrabajador = _idempleado;
            empleado.idempresa = lstEmpleado[0].idempresa;
            empleado.fechaingreso = dtpFechaReingreso.Value;
            empleado.fechaantiguedad = dtpFechaAntiguedad.Value;
            empleado.antiguedad = int.Parse(txtAntiguedad.Text);
            empleado.antiguedadmod = int.Parse(txtAntiguedadMod.Text);
            empleado.iddepartamento = int.Parse(cmbDepartamento.SelectedValue.ToString());
            empleado.idpuesto = int.Parse(cmbPuesto.SelectedValue.ToString());
            empleado.idperiodo = int.Parse(cmbPeriodo.SelectedValue.ToString());
            empleado.sueldo = decimal.Parse(txtSueldo.Text);
            empleado.sd = decimal.Parse(txtSalarioDiario.Text);
            empleado.sdi = decimal.Parse(txtSDI.Text);
            empleado.idusuario = GLOBALES.IDUSUARIO;
            empleado.estatus = GLOBALES.ACTIVO;
            empleado.cuenta = mtxtCuentaBancaria.Text;
            empleado.clabe = mtxtCuentaClabe.Text;
            empleado.idbancario = mtxtIdBancario.Text;
            empleado.metodopago = cmbMetodoPago.Text;

            if (chkObraCivil.Checked)
                empleado.obracivil = true;
            else
                empleado.obracivil = false;

            ee.idtrabajador = _idempleado;
            ee.idempresa = GLOBALES.IDEMPRESA;
            ee.estatus = GLOBALES.REINGRESO;

            historia.idtrabajador = _idempleado;
            historia.idempresa = lstEmpleado[0].idempresa;
            historia.valor = decimal.Parse(txtSDI.Text);
            historia.fecha_imss = dtpFechaReingreso.Value;
            historia.fecha_sistema = DateTime.Now;
            historia.motivobaja = 0;
            historia.tipomovimiento = GLOBALES.mREINGRESO;
            historia.iddepartamento = int.Parse(cmbDepartamento.SelectedValue.ToString());
            historia.idpuesto = int.Parse(cmbPuesto.SelectedValue.ToString());

            empresa.idempresa = lstEmpleado[0].idempresa;

            reingreso.idtrabajador = _idempleado;
            reingreso.idempresa = lstEmpleado[0].idempresa;
            reingreso.fechaingreso = dtpFechaReingreso.Value;
            reingreso.sdi = decimal.Parse(txtSDI.Text);
            reingreso.registro = DateTime.Now;

            Periodos.Core.PeriodosHelper pdh = new Periodos.Core.PeriodosHelper();
            pdh.Command = cmd;

            Periodos.Core.Periodos p = new Periodos.Core.Periodos();
            p.idperiodo = int.Parse(cmbPeriodo.SelectedValue.ToString());
            int diasPago = 0;
            try { cnx.Open(); diasPago = (int)pdh.DiasDePago(p); cnx.Close(); }
            catch { MessageBox.Show("Error: Al obtener los dias de pago.", "Error"); }

            DateTime dt = dtpFechaReingreso.Value.Date;
            DateTime periodoInicio, periodoFin;
            int diasProporcionales = 0;
            if (diasPago == 7)
            {
                while (dt.DayOfWeek != DayOfWeek.Monday) dt = dt.AddDays(-1);
                periodoInicio = dt;
                periodoFin = dt.AddDays(6);
                diasProporcionales = (int)(periodoFin.Date - dtpFechaReingreso.Value.Date).TotalDays + 1;
            }
            else
            {
                if (dt.Day <= 15)
                {
                    periodoInicio = new DateTime(dt.Year, dt.Month, 1);
                    periodoFin = new DateTime(dt.Year, dt.Month, 15);
                    diasProporcionales = (int)(periodoFin.Date - dtpFechaReingreso.Value.Date).TotalDays + 1;
                }
                else
                {
                    int diasMes = DateTime.DaysInMonth(dt.Year, dt.Month);
                    int diasNoLaborados = 0;
                    periodoInicio = new DateTime(dt.Year, dt.Month, 16);
                    periodoFin = new DateTime(dt.Year, dt.Month, DateTime.DaysInMonth(dt.Year, dt.Month));
                    diasNoLaborados = (int)(dtpFechaReingreso.Value.Date - periodoInicio).TotalDays;
                    switch (diasMes)
                    {
                        case 28:
                            diasProporcionales = 15 - diasNoLaborados;
                            break;
                        case 29:
                            diasProporcionales = 15 - diasNoLaborados;
                            break;
                        case 30:
                            diasProporcionales = (diasMes - 15) - diasNoLaborados;
                            break;
                        case 31:
                            diasProporcionales = (diasMes - 16) - diasNoLaborados;
                            break;
                    }
                }
            }

            CalculoNomina.Core.NominaHelper nh = new CalculoNomina.Core.NominaHelper();
            nh.Command = cmd;

            List<CalculoNomina.Core.tmpPagoNomina> lstFechas = new List<CalculoNomina.Core.tmpPagoNomina>();
            bool verificaFechas = false;

            try
            {
                cnx.Open();
                lstFechas = nh.obtenerUltimaNominaTrabajador(GLOBALES.IDEMPRESA, GLOBALES.NORMAL, diasPago, _idempleado);
                cnx.Close();
            }
            catch (Exception)
            {
                MessageBox.Show("Error: Al obtener la fecha de la ultima nómina calculada", "Error");
            }

            if (lstFechas.Count != 0)
            {
                if (dtpFechaReingreso.Value.Date <= lstFechas[0].fechainicio.Date || dtpFechaReingreso.Value.Date <= lstFechas[0].fechafin.Date)
                    verificaFechas = false;
                else
                    verificaFechas = true;
                if (!verificaFechas)
                {
                    MessageBox.Show("La fecha de ingreso es invalida. Fecha menor al ultimo periodo calculado, verifique.", "Error");
                    return;
                }
            }

            try {
                cnx.Open();
                empleadoh.reingreso(empleado);
                empleadoh.bajaEmpleado(ee);

                rp = (string)eh.obtenerRegistroPatronal(empresa);

                reingreso.registropatronal = rp;
                reingreso.nss = lstEmpleado[0].nss + lstEmpleado[0].digitoverificador;
                reingreso.diasproporcionales = diasProporcionales;
                reingreso.periodoinicio = periodoInicio;
                reingreso.periodofin = periodoFin;

                rh.insertaReingreso(reingreso);
                hh.insertarHistorial(historia);

                cnx.Close();
                MessageBox.Show("Empleado reingresado con éxito.", "Información");

                if (OnReingreso != null)
                    OnReingreso(GLOBALES.NUEVO);
            }
            catch (Exception error) {
                MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
            }

            int existeInfonavit = 0;
            try
            {
                cnx.Open();
                existeInfonavit = (int)ih.existeInfonavit(_idempleado);
                cnx.Close();
            }
            catch (Exception)
            {
                MessageBox.Show("Error: Al obtener la existencia del Infonavit.\r\n AVISO: INGRESAR O MODIFICAR MANUALMENTE EL CREDITO DE INFONAVIT", "Error");
                cnx.Dispose();
            }

            List<Infonavit.Core.Infonavit> lstInfonavit = new List<Infonavit.Core.Infonavit>();
            if (existeInfonavit != 0)
            {
                try
                {
                    cnx.Open();
                    lstInfonavit = ih.obtenerInfonavitTrabajador(_idempleado);
                    cnx.Close();
                }
                catch (Exception)
                {
                    MessageBox.Show("Error: Al obtener la información de infonavit.\r\n AVISO: INGRESAR O MODIFICAR MANUALMENTE EL CREDITO DE INFONAVIT", "Error");
                    cnx.Dispose();
                }

                try
                {
                    cnx.Open();
                    ih.actualizaEstatusInfonavit(lstInfonavit[0].idinfonavit, _idempleado);
                    cnx.Close();
                    MessageBox.Show("Trabajador cuenta con Infonavit. Crédito: " + lstInfonavit[0].credito, "Información");
                }
                catch (Exception)
                {
                    MessageBox.Show("Error: Al obtener al activar el crédito de infonavit.\r\n AVISO: INGRESAR O MODIFICAR MANUALMENTE EL CREDITO DE INFONAVIT", "Error");
                    cnx.Dispose();
                }
            }

            this.Dispose();
        }
Пример #36
0
        private void guardar(int tipoGuardar)
        {
            //SE VALIDA SI TODOS LOS TEXTBOX HAN SIDO LLENADOS.
            string control = GLOBALES.VALIDAR(this, typeof(TextBox));

            if (!control.Equals(""))
            {
                MessageBox.Show("Falta el campo: " + control, "Información");
                return;
            }

            cnx = new MySqlConnection();
            cnx.ConnectionString = cdn;
            cmd            = new MySqlCommand();
            cmd.Connection = cnx;
            ph             = new Periodos.Core.PeriodosHelper();
            ph.Command     = cmd;

            Periodos.Core.Periodos periodo = new Periodos.Core.Periodos();
            periodo.idcliente = int.Parse(cmbCliente.SelectedValue.ToString());
            periodo.pago      = cmbPago.SelectedText;
            periodo.dias      = cmbPago.SelectedText.Equals("SEMANAL") ? 7 : 15;
            periodo.inicio    = cmbDiaInicio.SelectedText;
            periodo.termino   = cmbDiaTermino.SelectedText;
            periodo.estatus   = 1;

            switch (_tipoOperacion)
            {
            case 0:
                try
                {
                    cnx.Open();
                    ph.insertaPeriodo(periodo);
                    cnx.Close();
                    cnx.Dispose();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error al ingresar el periodo. \r\n \r\n Error: " + error.Message);
                }
                break;

            case 2:
                try
                {
                    periodo.idperiodo = _idperiodo;
                    cnx.Open();
                    ph.actualizaPeriodo(periodo);
                    cnx.Close();
                    cnx.Dispose();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error al actualizar el periodo. \r\n \r\n Error: " + error.Message);
                }
                break;
            }

            switch (tipoGuardar)
            {
            case 0:
                GLOBALES.LIMPIAR(this, typeof(TextBox));
                GLOBALES.REFRESCAR(this, typeof(ComboBox));
                break;

            case 1:
                if (OnNuevoPeriodo != null)
                {
                    OnNuevoPeriodo(_tipoOperacion);
                }
                this.Dispose();
                break;
            }
        }