예제 #1
0
        private void frmModificaSalarioImss_Load(object sender, EventArgs e)
        {
            lblEmpleado.Text = _nombreCompleto;

            cnx = new MySqlConnection();
            cnx.ConnectionString = cdn;
            cmd            = new MySqlCommand();
            cmd.Connection = cnx;

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

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

            try
            {
                cnx.Open();
                lstEmpleado = eh.obtenerEmpleado(em);
                cnx.Close();
                cnx.Dispose();

                for (int i = 0; i < lstEmpleado.Count; i++)
                {
                    idperiodo  = lstEmpleado[i].idperiodo;
                    antiguedad = lstEmpleado[i].antiguedad;
                }
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
            }
        }
예제 #2
0
        private void frmInfonavit_Load(object sender, EventArgs e)
        {
            cargaCombo();
            if (_tipoOperacion == GLOBALES.CONSULTAR || _tipoOperacion == GLOBALES.MODIFICAR)
            {
                cnx = new SqlConnection();
                cnx.ConnectionString = cdn;
                cmd = new SqlCommand();
                cmd.Connection = cnx;
                ih = new Infonavit.Core.InfonavitHelper();
                ih.Command = cmd;

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

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

                List<Infonavit.Core.Infonavit> lstInfonavit;
                List<Departamento.Core.Depto> lstDepartamento = new List<Departamento.Core.Depto>();
                List<Empleados.Core.Empleados> lstEmpleado = new List<Empleados.Core.Empleados>();

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

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

                Infonavit.Core.Infonavit i = new Infonavit.Core.Infonavit();
                i.idtrabajador = _idEmpleado;
                i.activo = _estatusInfonavit;

                try
                {
                    cnx.Open();
                    Periodo = (int)eh.obtenerDiasPeriodo(_idEmpleado);
                    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();
                }

                var dato = from emp in lstEmpleado
                           join d in lstDepartamento on emp.iddepartamento equals d.id
                           select new
                           {
                               emp.noempleado,
                               emp.nombrecompleto,
                               d.descripcion
                           };
                foreach (var inf in dato)
                {
                    mtxtNoEmpleado.Text = inf.noempleado;
                    txtDepartamento.Text = inf.descripcion;
                }

                try
                {
                    cnx.Open();
                    lstInfonavit = ih.obtenerInfonavit(i);
                    Periodo = (int)eh.obtenerDiasPeriodo(_idEmpleado);
                    cnx.Close();
                    cnx.Dispose();

                    for (int j = 0; j < lstInfonavit.Count; j++)
                    {
                        IdInfonavit = int.Parse(lstInfonavit[j].idinfonavit.ToString());
                        txtNumeroCredito.Text = lstInfonavit[j].credito;
                        txtValor.Text = lstInfonavit[j].valordescuento.ToString();
                        if (lstInfonavit[j].activo)
                            chkInactivo.Checked = false;
                        else
                            chkInactivo.Checked = true;
                        txtDescripcion.Text = lstInfonavit[j].descripcion;
                        dtpFechaAplicacion.Value = lstInfonavit[j].fecha;
                        cmbEstatusInfonavit.SelectedValue = lstInfonavit[j].estatus;
                        //dtpInicioPeriodo.Value = lstInfonavit[j].inicio.AddDays(1);
                        //dtpFinPeriodo.Value = lstInfonavit[j].fin;

                        switch (lstInfonavit[j].descuento)
                        {
                                //Porcentaje
                            case 1:
                                rbtnPorcentaje.Checked = true;
                                break;
                            case 2:
                                rbtnPesos.Checked = true;
                                if (Periodo == 7)
                                    txtValor.Text = ((lstInfonavit[j].valordescuento * decimal.Parse((30.4).ToString())) / Periodo).ToString();
                                else
                                    txtValor.Text = (lstInfonavit[j].valordescuento * 2).ToString();
                                break;
                            case 3:
                                rbtnVsmdf.Checked = true;
                                txtValor.Text = lstInfonavit[j].valordescuento.ToString();
                                break;
                        }
                    }
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
                }

                if (_tipoOperacion == GLOBALES.CONSULTAR)
                {
                    toolVentana.Text = "Consulta del Crédito";
                    GLOBALES.INHABILITAR(this, typeof(TextBox));
                    GLOBALES.INHABILITAR(this, typeof(RadioButton));
                    GLOBALES.INHABILITAR(this, typeof(CheckBox));
                    GLOBALES.INHABILITAR(this, typeof(DateTimePicker));
                    GLOBALES.INHABILITAR(this, typeof(MaskedTextBox));
                    GLOBALES.INHABILITAR(this, typeof(ComboBox));
                    toolGuardar.Enabled = false;
                    toolBuscar.Enabled = false;
                }
                else
                {
                    toolVentana.Text = "Edición del Crédito";
                    lblEmpleado.Text = _nombreEmpleado;
                    toolBuscar.Enabled = false;
                    //obtenerPeriodoActual();
                }

                if (_modificar == 1)
                {
                    //dtpInicioPeriodo.Enabled = true;
                }
            }
        }
예제 #3
0
        void b_OnBuscar(int id, string nombre)
        {
            idTrabajador = id;

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

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

            Puestos.Core.PuestosHelper ph = new Puestos.Core.PuestosHelper();
            ph.Command = cmd;

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

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

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

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

            Puestos.Core.Puestos puesto = new Puestos.Core.Puestos();
            puesto.idempresa = GLOBALES.IDEMPRESA;

            try {
                cnx.Open();
                lstEmpleado = eh.obtenerEmpleado(empleado);
                lstDepartamento = dh.obtenerDepartamentos(dpto);
                lstPuesto = ph.obtenerPuestos(puesto);
                cnx.Close();
                cnx.Dispose();
            }
            catch
            {
                MessageBox.Show("Error al obtener el empleado.","Error");
            }

            var dato = from emp in lstEmpleado
                       join d in lstDepartamento on emp.iddepartamento equals d.id
                       join p in lstPuesto on emp.idpuesto equals p.idpuesto
                       select new {
                           emp.noempleado,
                           emp.nombrecompleto,
                           emp.sd,
                           d.descripcion,
                           p.nombre,
                           emp.fechaingreso
                       };
            foreach (var i in dato)
            {
                mtxtNoEmpleado.Text = i.noempleado;
                txtNombreCompleto.Text = i.nombrecompleto;
                txtDepartamento.Text = i.descripcion;
                txtPuesto.Text = i.nombre;
                txtSueldo.Text = "$ " + i.sd.ToString("#,##0.00");
                txtFechaIngreso.Text = i.fechaingreso.ToString("dd-MM-yyyy");
            }

            dgvPercepciones.DataSource = null;
            dgvDeducciones.DataSource = null;
            txtPercepciones.Text = "$ 0.00";
            txtDeducciones.Text = "$ 0.00";
            txtNeto.Text = "$ 0.00";

            muestraDatos();
            muestraFaltas();
            muestraIncidencias();
            muestraProgramacion();
            muestraMovimientos();
            muestraInfonavit();
            muestraVacaciones();
        }
예제 #4
0
        private void muestraProgramacion()
        {
            cnx = new SqlConnection(cdn);
            cmd = new SqlCommand();
            cmd.Connection = cnx;

            ProgramacionConcepto.Core.ProgramacionHelper pch = new ProgramacionConcepto.Core.ProgramacionHelper();
            pch.Command = cmd;

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

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

            ProgramacionConcepto.Core.ProgramacionConcepto pc = new ProgramacionConcepto.Core.ProgramacionConcepto();
            pc.idtrabajador = idTrabajador;

            Conceptos.Core.Conceptos c = new Conceptos.Core.Conceptos();
            c.idempresa = GLOBALES.IDEMPRESA;

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

            List<ProgramacionConcepto.Core.ProgramacionConcepto> lstProgramacionConcepto = new List<ProgramacionConcepto.Core.ProgramacionConcepto>();
            List<Conceptos.Core.Conceptos> lstConceptos = new List<Conceptos.Core.Conceptos>();
            List<Empleados.Core.Empleados> lstEmpleado = new List<Empleados.Core.Empleados>();

            try
            {
                cnx.Open();
                lstProgramacionConcepto = pch.obtenerProgramacion(pc);
                lstConceptos = ch.obtenerConceptos(c, _periodo);
                lstEmpleado = emph.obtenerEmpleado(empleado);
                cnx.Close();
                cnx.Dispose();
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: Al obtener las Programaciones. (Función Muestra Programación.)\r\n \r\n" + error.Message, "Error");
            }

            var prog = from p in lstProgramacionConcepto
                       join co in lstConceptos on p.idconcepto equals co.id
                       join em in lstEmpleado on p.idtrabajador equals em.idtrabajador
                       select new {
                           p.idprogramacion,
                           p.idtrabajador,
                           co.id,
                           em.noempleado,
                           em.nombrecompleto,
                           co.concepto,
                           p.cantidad,
                           p.fechafin
                       };

            dgvProgramacion.Columns["idpc"].DataPropertyName = "idprogramacion";
            dgvProgramacion.Columns["idtrabajadorpc"].DataPropertyName = "idtrabajador";
            dgvProgramacion.Columns["idconceptopc"].DataPropertyName = "id";
            dgvProgramacion.Columns["noempleadopc"].DataPropertyName = "noempleado";
            dgvProgramacion.Columns["nombrepc"].DataPropertyName = "nombrecompleto";
            dgvProgramacion.Columns["conceptopc"].DataPropertyName = "concepto";
            dgvProgramacion.Columns["cantidadpc"].DataPropertyName = "cantidad";
            dgvProgramacion.Columns["fechafinpc"].DataPropertyName = "fechafin";
            dgvProgramacion.DataSource = prog.ToList();

            DataGridViewCellStyle estilo = new DataGridViewCellStyle();
            estilo.Alignment = DataGridViewContentAlignment.MiddleRight;
            estilo.Format = "C2";

            dgvProgramacion.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            dgvProgramacion.Columns[5].DefaultCellStyle = estilo;
        }
예제 #5
0
        private void muestraMovimientos()
        {
            cnx = new SqlConnection(cdn);
            cmd = new SqlCommand();
            cmd.Connection = cnx;

            Movimientos.Core.MovimientosHelper mh = new Movimientos.Core.MovimientosHelper();
            mh.Command = cmd;

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

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

            Movimientos.Core.Movimientos m = new Movimientos.Core.Movimientos();
            m.idtrabajador = idTrabajador;

            Conceptos.Core.Conceptos c = new Conceptos.Core.Conceptos();
            c.idempresa = GLOBALES.IDEMPRESA;

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

            List<Movimientos.Core.Movimientos> lstMovimientos = new List<Movimientos.Core.Movimientos>();
            List<Conceptos.Core.Conceptos> lstConceptos = new List<Conceptos.Core.Conceptos>();
            List<Empleados.Core.Empleados> lstEmpleado = new List<Empleados.Core.Empleados>();

            try
            {
                cnx.Open();
                lstMovimientos = mh.obtenerMovimientosTrabajador(m);
                lstConceptos = ch.obtenerConceptos(c, _periodo);
                lstEmpleado = emph.obtenerEmpleado(empleado);
                cnx.Close();
                cnx.Dispose();
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: Al obtener los Movimientos. (Función Muestra Movimientos.) \r\n \r\n" + error.Message, "Error");
            }

            var prog = from mov in lstMovimientos
                       join co in lstConceptos on mov.idconcepto equals co.id
                       join em in lstEmpleado on mov.idtrabajador equals em.idtrabajador
                       select new
                       {
                           mov.id,
                           mov.idtrabajador,
                           em.noempleado,
                           em.nombrecompleto,
                           co.concepto,
                           mov.cantidad,
                           mov.fechainicio,
                           mov.fechafin
                       };

            dgvMovimientos.Columns["idm"].DataPropertyName = "id";
            dgvMovimientos.Columns["idtrabajadorm"].DataPropertyName = "idtrabajador";
            dgvMovimientos.Columns["noempleadom"].DataPropertyName = "noempleado";
            dgvMovimientos.Columns["nombrem"].DataPropertyName = "nombrecompleto";
            dgvMovimientos.Columns["conceptom"].DataPropertyName = "concepto";
            dgvMovimientos.Columns["cantidadm"].DataPropertyName = "cantidad";
            dgvMovimientos.Columns["periodoiniciom"].DataPropertyName = "fechainicio";
            dgvMovimientos.Columns["periodofinm"].DataPropertyName = "fechafin";
            dgvMovimientos.DataSource = prog.ToList();

            DataGridViewCellStyle estilo = new DataGridViewCellStyle();
            estilo.Alignment = DataGridViewContentAlignment.MiddleRight;
            estilo.Format = "C2";

            dgvProgramacion.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            dgvProgramacion.Columns[5].DefaultCellStyle = estilo;
        }
예제 #6
0
        private void btnGuardarVP_Click(object sender, EventArgs e)
        {
            cnx = new SqlConnection(cdn);
            cmd = new SqlCommand();
            cmd.Connection = cnx;

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

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

            Complementos.Core.ComplementoHelper ch = new Complementos.Core.ComplementoHelper();
            ch.Command = cmd;

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

            Complementos.Core.Complemento c = new Complementos.Core.Complemento();
            c.idtrabajador = idTrabajador;
            c.observaciones = txtObservaciones.Text;

            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();
                return;
            }

            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;
            }

            int existePrima = 0;
            int existeVacacion = 0;

            if (cmbConceptoVacaciones.SelectedIndex == 0) // PRIMA VACACIONAL Y VACACIONES
            {
                Vacaciones.Core.VacacionesPrima vp = new Vacaciones.Core.VacacionesPrima();
                vp.idtrabajador = idTrabajador;
                vp.periodoinicio = _inicioPeriodo;
                vp.periodofin = _finPeriodo;
                vp.vacacionesprima = "P";

                try
                {
                    cnx.Open();
                    existePrima = (int)vh.existeVacacionesPrima(vp);
                    cnx.Close();
                }
                catch
                {
                    MessageBox.Show("Error: Al obtener la existencia de prima vacacional del empleado.", "Error");
                    cnx.Dispose();
                    return;
                }

                vp = new Vacaciones.Core.VacacionesPrima();
                vp.idtrabajador = idTrabajador;
                vp.periodoinicio = _inicioPeriodo;
                vp.periodofin = _finPeriodo;
                vp.vacacionesprima = "V";

                try
                {
                    cnx.Open();
                    existeVacacion = (int)vh.existeVacacionesPrima(vp);
                    cnx.Close();
                }
                catch
                {
                    MessageBox.Show("Error: Al obtener la existencia de vacaciones del empleado.", "Error");
                    cnx.Dispose();
                    return;
                }

                //VALIDACION DE EXISTENCIA DE PRIMA VACACIONAL Y VACACIONES
                if (existePrima != 0 || existeVacacion != 0)
                {
                    MessageBox.Show("Error: Los datos a ingresar ya existen y/o existe la Prima Vacaciona o Vacaciones.", "Error");
                    cnx.Dispose();
                    return;
                }
                else
                {
                    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 = idTrabajador;
                    falta.fechainicio = _inicioPeriodo.Date;
                    falta.fechafin = _finPeriodo.Date;

                    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 diasPagoReales = int.Parse(txtDiasPagoPV.Text) + existeFaltas;
                    if (diasPagoReales > _periodo)
                    {
                        diasPagoReales = _periodo - existeFaltas;
                        MessageBox.Show("Existen faltas del trabajador, se ajustaron las vacaciones a: " + diasPagoReales.ToString() + " dia(s).", "Información");
                    }
                    else
                    {
                        diasPagoReales = int.Parse(txtDiasPagoPV.Text);
                    }

                    vp = new Vacaciones.Core.VacacionesPrima();
                    vp.idtrabajador = idTrabajador;
                    vp.idempresa = GLOBALES.IDEMPRESA;
                    vp.periodoinicio = _inicioPeriodo;
                    vp.periodofin = _finPeriodo;
                    vp.diasderecho = dias;
                    vp.diaspago = diasPagoReales;
                    vp.diaspendientes = dias - diasPagoReales;
                    vp.fechapago = DateTime.Now.Date;
                    vp.fechainicio = DateTime.Now.Date;
                    vp.fechafin = DateTime.Now.Date;
                    vp.vacacionesprima = "P";

                    try
                    {
                        cnx.Open();
                        vh.insertaVacacion(vp);
                        cnx.Close();
                    }
                    catch
                    {
                        MessageBox.Show("Error: Al ingresar el registro de prima vacacional.", "Error");
                        cnx.Dispose();
                        return;
                    }

                    diasPagoReales = int.Parse(txtDiasPagoV.Text) + existeFaltas;
                    if (diasPagoReales > _periodo)
                    {
                        diasPagoReales = _periodo - existeFaltas;
                        MessageBox.Show("Existen faltas del trabajador, se ajustaron las vacaciones a: " + diasPagoReales.ToString() + " dia(s).", "Información");
                    }
                    else
                    {
                        diasPagoReales = int.Parse(txtDiasPagoV.Text);
                    }

                    vp = new Vacaciones.Core.VacacionesPrima();
                    vp.idtrabajador = idTrabajador;
                    vp.idempresa = GLOBALES.IDEMPRESA;
                    vp.periodoinicio = _inicioPeriodo;
                    vp.periodofin = _finPeriodo;
                    vp.diasderecho = dias;
                    vp.diaspago = diasPagoReales;
                    vp.diaspendientes = dias - diasPagoReales;
                    vp.fechapago = DateTime.Now.Date;
                    vp.fechainicio = dtpFechaInicioVacaciones.Value.Date;
                    vp.fechafin = dtpFechaInicioVacaciones.Value.AddDays(diasPagoReales - 1);
                    vp.vacacionesprima = "V";

                    try
                    {
                        cnx.Open();
                        vh.insertaVacacion(vp);
                        cnx.Close();
                        cnx.Dispose();
                        muestraVacaciones();
                    }
                    catch
                    {
                        MessageBox.Show("Error: Al ingresar el registro de prima vacacional.", "Error");
                        cnx.Dispose();
                        return;
                    }
                }
            }
            else // SOLO PRIMA VACACIONAL
            {
                Vacaciones.Core.VacacionesPrima vp = new Vacaciones.Core.VacacionesPrima();
                vp.idtrabajador = idTrabajador;
                vp.periodoinicio = _inicioPeriodo;
                vp.periodofin = _finPeriodo;
                vp.vacacionesprima = "P";

                try
                {
                    cnx.Open();
                    existePrima = (int)vh.existeVacacionesPrima(vp);
                    cnx.Close();
                }
                catch
                {
                    MessageBox.Show("Error: Al obtener la existencia de vacaciones del empleado.", "Error");
                    cnx.Dispose();
                    return;
                }

                //VALIDACION DE EXISTENCIA DE PRIMA VACACIONAL
                if (existePrima != 0)
                {
                    MessageBox.Show("Error: Los datos a ingresar ya existen.", "Error");
                    cnx.Dispose();
                    return;
                }
                else
                {
                    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 = idTrabajador;
                    falta.fechainicio = _inicioPeriodo.Date;
                    falta.fechafin = _finPeriodo.Date;

                    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 diasPagoReales = int.Parse(txtDiasPagoPV.Text) + existeFaltas;
                    if (diasPagoReales > _periodo)
                    {
                        diasPagoReales = _periodo - existeFaltas;
                        MessageBox.Show("Existen faltas del trabajador, se ajustaron las vacaciones a: " + diasPagoReales.ToString() + " dia(s).", "Información");
                    }
                    else
                    {
                        diasPagoReales = int.Parse(txtDiasPagoPV.Text);
                    }

                    vp = new Vacaciones.Core.VacacionesPrima();
                    vp.idtrabajador = idTrabajador;
                    vp.idempresa = GLOBALES.IDEMPRESA;
                    vp.periodoinicio = _inicioPeriodo;
                    vp.periodofin = _finPeriodo;
                    vp.diasderecho = dias;
                    vp.diaspago = diasPagoReales;
                    vp.diaspendientes = dias - diasPagoReales;
                    vp.fechapago = DateTime.Now.Date;
                    vp.fechainicio = DateTime.Now.Date;
                    vp.fechafin = DateTime.Now.Date;
                    vp.vacacionesprima = "P";

                    try
                    {
                        cnx.Open();
                        vh.insertaVacacion(vp);
                        cnx.Close();
                        cnx.Dispose();
                        muestraVacaciones();
                    }
                    catch
                    {
                        MessageBox.Show("Error: Al ingresar el registro de prima vacacional.", "Error");
                        cnx.Dispose();
                        return;
                    }
                }
            }
        }
예제 #7
0
        private void frmEmpleados_Load(object sender, EventArgs e)
        {
            CargaComboBox();

            if (GLOBALES.OBRACIVIL)
                chkObraCivil.Visible = true;
            else
                chkObraCivil.Visible = false;

            if (_tipoOperacion == GLOBALES.CONSULTAR || _tipoOperacion == GLOBALES.MODIFICAR)
            {
                object fechaBaja;
                cnx = new SqlConnection();
                cnx.ConnectionString = cdn;
                cmd = new SqlCommand();
                cmd.Connection = cnx;
                eh = new Empleados.Core.EmpleadosHelper();
                eh.Command = cmd;

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

                Bajas.Core.Bajas b = new Bajas.Core.Bajas();
                b.idempresa = GLOBALES.IDEMPRESA;
                b.idtrabajador = _idempleado;

                List<Empleados.Core.Empleados> lstEmpleado;

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

                try
                {
                    cnx.Open();
                    lstEmpleado = eh.obtenerEmpleado(em);
                    fechaBaja = bh.obtenerFechaBaja(b);
                    cnx.Close();
                    cnx.Dispose();

                    if (fechaBaja != null)
                    {
                        dtpFechaBaja.Value = DateTime.Parse(fechaBaja.ToString());
                    }
                    else
                        dtpFechaBaja.Value = new DateTime(1900, 1, 1);

                    for (int i = 0; i < lstEmpleado.Count; i++)
                    {
                        txtNombre.Text = lstEmpleado[i].nombres;
                        txtApPaterno.Text = lstEmpleado[i].paterno;
                        txtApMaterno.Text = lstEmpleado[i].materno;
                        mtxtNoEmpleado.Text = lstEmpleado[i].noempleado;
                        dtpFechaIngreso.Value = DateTime.Parse(lstEmpleado[i].fechaingreso.ToString());
                        dtpFechaAntiguedad.Value = DateTime.Parse(lstEmpleado[i].fechaantiguedad.ToString());
                        dtpFechaNacimiento.Value = DateTime.Parse(lstEmpleado[i].fechanacimiento.ToString());
                        txtAntiguedad.Text = lstEmpleado[i].antiguedad.ToString();
                        txtEdad.Text = lstEmpleado[i].edad.ToString();
                        txtAntiguedadMod.Text = lstEmpleado[i].antiguedadmod.ToString();
                        txtRFC.Text = lstEmpleado[i].rfc;
                        txtCURP.Text = lstEmpleado[i].curp;
                        txtNSS.Text = lstEmpleado[i].nss + lstEmpleado[i].digitoverificador.ToString();

                        cmbDepartamento.SelectedValue = int.Parse(lstEmpleado[i].iddepartamento.ToString());
                        cmbPuesto.SelectedValue = int.Parse(lstEmpleado[i].idpuesto.ToString());
                        cmbPeriodo.SelectedValue = int.Parse(lstEmpleado[i].idperiodo.ToString());
                        cmbZona.SelectedValue = int.Parse(lstEmpleado[i].idsalario.ToString());
                        cmbTipoSalario.SelectedValue = int.Parse(lstEmpleado[i].tiposalario.ToString());
                        cmbTipoRegimen.SelectedValue = int.Parse(lstEmpleado[i].tiporegimen.ToString());

                        txtSueldo.Text = lstEmpleado[i].sueldo.ToString("F6");
                        txtSD.Text = lstEmpleado[i].sd.ToString("F6");
                        txtSDI.Text = lstEmpleado[i].sdi.ToString("F6");

                        mtxtCuentaBancaria.Text = lstEmpleado[i].cuenta.ToString();
                        mtxtCuentaClabe.Text = lstEmpleado[i].clabe.ToString();
                        mtxtIdBancario.Text = lstEmpleado[i].idbancario.ToString();

                        if (lstEmpleado[i].metodopago == "EFECTIVO")
                            cmbMetodoPago.SelectedIndex = 0;
                        if (lstEmpleado[i].metodopago == "CHEQUE")
                            cmbMetodoPago.SelectedIndex = 1;
                        if (lstEmpleado[i].metodopago == "TRANSFERENCIA")
                            cmbMetodoPago.SelectedIndex = 2;

                        departamento = cmbDepartamento.Text;
                        puesto = cmbPuesto.Text;
                        idDepto = int.Parse(lstEmpleado[i].iddepartamento.ToString());
                        idPuesto = int.Parse(lstEmpleado[i].idpuesto.ToString());

                        if (lstEmpleado[i].obracivil)
                            chkObraCivil.Checked = true;
                        else
                            chkObraCivil.Checked = false;
                    }
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
                }

                if (_tipoOperacion == GLOBALES.CONSULTAR)
                {
                    toolTitulo.Text = "Consulta Empleado";
                    GLOBALES.INHABILITAR(this, typeof(TextBox));
                    GLOBALES.INHABILITAR(this, typeof(MaskedTextBox));
                    GLOBALES.INHABILITAR(this, typeof(Button));
                    GLOBALES.INHABILITAR(this, typeof(DateTimePicker));
                    GLOBALES.INHABILITAR(this, typeof(ComboBox));
                    GLOBALES.INHABILITAR(this, typeof(RadioButton));
                    GLOBALES.INHABILITAR(this, typeof(CheckBox));
                    toolGuardarCerrar.Enabled = false;
                    toolGuardarNuevo.Enabled = false;
                }
                else
                {
                    toolTitulo.Text = "Edición Empleado";
                    cmbPeriodo.Enabled = false;
                }
            }
            else
                toolHistorial.Enabled = false;
        }
예제 #8
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();
                }
            }
        }
예제 #9
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;
            }
        }
예제 #10
0
        private void frmIncrementoSalarial_Load(object sender, EventArgs e)
        {
            cmbDepartamento.Enabled = false;
            cmbPuesto.Enabled = false;

            lblEmpleado.Text = _nombreEmpleado;
            cnx = new SqlConnection();
            cnx.ConnectionString = cdn;
            cmd = new SqlCommand();
            cmd.Connection = cnx;

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

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

            puestoh = new Puestos.Core.PuestosHelper();
            puestoh.Command = cmd;

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

            List<Departamento.Core.Depto> lstDepartamento = new List<Departamento.Core.Depto>();
            List<Puestos.Core.Puestos> lstPuesto = new List<Puestos.Core.Puestos>();

            ph = new Empresas.Core.EmpresasHelper();
            ph.Command = cmd;
            Empresas.Core.Empresas p = new Empresas.Core.Empresas();
            p.idempresa = GLOBALES.IDEMPRESA;

            Puestos.Core.Puestos puesto = new Puestos.Core.Puestos();
            puesto.idempresa = GLOBALES.IDEMPRESA;

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

            try {
                cnx.Open();
                lstEmpleado = eh.obtenerEmpleado(empleado);
                rp = (string)ph.obtenerRegistroPatronal(p);
                lstDepartamento = dh.obtenerDepartamentos(d);
                lstPuesto = puestoh.obtenerPuestos(puesto);
                cnx.Close();
                cnx.Dispose();

                for (int i = 0; i < lstEmpleado.Count; i++)
                {
                    idperiodo = lstEmpleado[i].idperiodo;
                    antiguedad = lstEmpleado[i].antiguedad;
                    nss = lstEmpleado[i].nss + lstEmpleado[i].digitoverificador;
                }
            }
            catch (Exception error) {
                MessageBox.Show("Error: \r\n \r\n" + error.Message, "Error");
            }

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

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

            var dato = from emp in lstEmpleado
                       join depto in lstDepartamento on emp.iddepartamento equals depto.id
                       join pto in lstPuesto on emp.idpuesto equals pto.idpuesto
                       select new
                       {
                           emp.noempleado,
                           emp.nombrecompleto,
                           depto.id,
                           depto.descripcion,
                           pto.idpuesto,
                           pto.nombre
                       };
            foreach (var inf in dato)
            {
                iddepto = inf.id;
                idpuesto = inf.id;
                cmbDepartamento.SelectedValue = inf.id;
                cmbPuesto.SelectedValue = inf.idpuesto;
                mtxtNoEmpleado.Text = inf.noempleado;
                txtDepartamento.Text = inf.descripcion;
                txtPuesto.Text = inf.nombre;
            }
        }
예제 #11
0
        private void frmEmpleados_Load(object sender, EventArgs e)
        {
            CargaComboBox();
            /// _tipoOperacion CONSULTA = 1, EDICION = 2
            if (_tipoOperacion == GLOBALES.CONSULTAR || _tipoOperacion == GLOBALES.MODIFICAR)
            {
                cnx = new MySqlConnection();
                cnx.ConnectionString = cdn;
                cmd            = new MySqlCommand();
                cmd.Connection = cnx;
                eh             = new Empleados.Core.EmpleadosHelper();
                eh.Command     = cmd;

                List <Empleados.Core.Empleados> lstEmpleado;

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

                try
                {
                    cnx.Open();
                    lstEmpleado = eh.obtenerEmpleado(em);
                    cnx.Close();
                    cnx.Dispose();

                    for (int i = 0; i < lstEmpleado.Count; i++)
                    {
                        txtNombre.Text                = lstEmpleado[i].nombres;
                        txtApPaterno.Text             = lstEmpleado[i].paterno;
                        txtApMaterno.Text             = lstEmpleado[i].materno;
                        dtpFechaNacimiento.Value      = DateTime.Parse(lstEmpleado[i].fechanacimiento.ToString());
                        txtEdad.Text                  = lstEmpleado[i].edad.ToString();
                        dtpFechaIngreso.Value         = lstEmpleado[i].fechaingreso;
                        cmbLocalForaneo.SelectedValue = lstEmpleado[i].localforaneo;
                        cmbSua.SelectedValue          = lstEmpleado[i].sua;
                        txtRFC.Text    = lstEmpleado[i].rfc;
                        txtCURP.Text   = lstEmpleado[i].curp;
                        txtNSS.Text    = lstEmpleado[i].nss;
                        txtDigito.Text = lstEmpleado[i].digitoverificador.ToString();

                        lblCliente.Visible = false;
                        lblPeriodo.Visible = false;
                        cmbCliente.Visible = false;
                        cmbPeriodo.Visible = false;

                        lblSalario.Visible     = false;
                        lblTipoSalario.Visible = false;
                        lblSueldo.Visible      = false;
                        lblSD.Visible          = false;
                        lblSDI.Visible         = false;
                        cmbTipoSalario.Visible = false;
                        txtSueldo.Visible      = false;
                        txtSD.Visible          = false;
                        txtSDI.Visible         = false;
                        btnCalcular.Visible    = false;
                    }
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
                }

                if (_tipoOperacion == GLOBALES.CONSULTAR)
                {
                    toolTitulo.Text = "Consulta Empleado";
                    GLOBALES.INHABILITAR(this, typeof(TextBox));
                    GLOBALES.INHABILITAR(this, typeof(MaskedTextBox));
                    GLOBALES.INHABILITAR(this, typeof(Button));
                    GLOBALES.INHABILITAR(this, typeof(DateTimePicker));
                    GLOBALES.INHABILITAR(this, typeof(ComboBox));
                }
                else
                {
                    toolTitulo.Text = "Edición Empleado";
                }
            }
        }
예제 #12
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();
        }
예제 #13
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");
            }
        }
예제 #15
0
        void b_OnBuscar(int id, string nombre)
        {
            _idEmpleado = id;
            lblEmpleado.Text = nombre;

            cnx = new SqlConnection(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>();

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

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

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

            var dato = from emp in lstEmpleado
                       join d in lstDepartamento on emp.iddepartamento equals d.id
                       select new
                       {
                           emp.noempleado,
                           emp.nombrecompleto,
                           d.descripcion
                       };
            foreach (var inf in dato)
            {
                mtxtNoEmpleado.Text = inf.noempleado;
                txtDepartamento.Text = inf.descripcion;
            }

            try
            {
                cnx.Open();
                Periodo = (int)eh.obtenerDiasPeriodo(_idEmpleado);
                cnx.Close();
                //obtenerPeriodoActual();
            }
            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();
            }
        }
예제 #16
0
        private void frmListaHistorial_Load(object sender, EventArgs e)
        {
            cnx = new SqlConnection(cdn);
            cmd = new SqlCommand();
            cmd.Connection = cnx;

            eh = new Empleados.Core.EmpleadosHelper();
            hh = new Historial.Core.HistorialHelper();
            dh = new Departamento.Core.DeptoHelper();
            ph = new Puestos.Core.PuestosHelper();

            eh.Command = cmd;
            hh.Command = cmd;
            dh.Command = cmd;
            ph.Command = cmd;

            Empleados.Core.Empleados empleado = new Empleados.Core.Empleados();
            empleado.idtrabajador = _idempleado;
            Historial.Core.Historial historial = new Historial.Core.Historial();
            historial.idtrabajador = _idempleado;
            Departamento.Core.Depto depto = new Departamento.Core.Depto();
            depto.idempresa = GLOBALES.IDEMPRESA;
            Puestos.Core.Puestos puesto = new Puestos.Core.Puestos();
            puesto.idempresa = GLOBALES.IDEMPRESA;

            try
            {
                cnx.Open();
                lstEmpleados = eh.obtenerEmpleado(empleado);
                lstHistorial = hh.obtenerHistoriales(historial);
                lstDepto = dh.obtenerDepartamentos(depto);
                lstPuesto = ph.obtenerPuestos(puesto);
                cnx.Close();
                cnx.Dispose();

                var lista = from emp in lstEmpleados join his in lstHistorial on emp.idtrabajador equals his.idtrabajador
                            join d in lstDepto on his.iddepartamento equals d.id
                            join p in lstPuesto on his.idpuesto equals p.idpuesto orderby his.fecha_imss ascending
                         select new
                         {
                             IdTrabajador = emp.idtrabajador,
                             NoEmpleado = emp.noempleado,
                             Nombre = emp.nombrecompleto,
                             Movimiento =
                                his.tipomovimiento == GLOBALES.mALTA ? "ALTA" :
                                his.tipomovimiento == GLOBALES.mMODIFICACIONSALARIO ? "MODIFICACION" :
                                his.tipomovimiento == GLOBALES.mREINGRESO ? "REINGRESO" :
                                his.tipomovimiento == GLOBALES.mBAJA ? "BAJA" :
                                his.tipomovimiento == GLOBALES.mCAMBIODEPARTAMENTO ? "CAMBIO DE DEPARTAMENTO" : "CAMBIO DE PUESTO",
                             SDI = his.valor,
                             FechaAplicacion = his.fecha_imss,
                             FechaSistema = his.fecha_sistema,
                             Depto = d.descripcion,
                             Puesto = p.nombre
                         };
                dgvHistorial.DataSource = lista.ToList();

                for (int i = 0; i < dgvHistorial.Columns.Count; i++)
                {
                    dgvHistorial.AutoResizeColumn(i);
                }
                dgvHistorial.Columns["IdTrabajador"].Visible = false;
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
            }
        }
예제 #17
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;
        }
예제 #18
0
        private void frmDeptoPuesto_Load(object sender, EventArgs e)
        {
            cmbDeptoPuesto.DataSource = null;

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

            Empleados.Core.EmpleadosHelper eh = new Empleados.Core.EmpleadosHelper();
            eh.Command = cmd;
            Empleados.Core.Empleados emp = new Empleados.Core.Empleados();
            emp.idtrabajador = _idempleado;
            List<Empleados.Core.Empleados> lstEmpleado = new List<Empleados.Core.Empleados>();
            try
            {
                cnx.Open();
                lstEmpleado = eh.obtenerEmpleado(emp);
                cnx.Close();
            }
            catch (Exception)
            {

                throw;
            }

            lblEmpleado.Text = lstEmpleado[0].nombrecompleto;
            mtxtNoEmpleado.Text = lstEmpleado[0].noempleado;
            idperiodo = lstEmpleado[0].idperiodo;
            sdi = lstEmpleado[0].sdi;
            iddepto = lstEmpleado[0].iddepartamento;
            idpuesto = lstEmpleado[0].idpuesto;

            if (_deptopuesto == 0)
            {
                Departamento.Core.DeptoHelper dh = new Departamento.Core.DeptoHelper();
                dh.Command = cmd;

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

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

                try
                {
                    cnx.Open();
                    lstDeptos = dh.obtenerDepartamentos(d);
                    cnx.Close();
                    cnx.Dispose();
                }
                catch (Exception)
                {

                    throw;
                }

                cmbDeptoPuesto.DataSource = lstDeptos.ToList();
                cmbDeptoPuesto.DisplayMember = "descripcion";
                cmbDeptoPuesto.ValueMember = "id";
            }
            else {
                Puestos.Core.PuestosHelper ph = new Puestos.Core.PuestosHelper();
                ph.Command = cmd;

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

                List<Puestos.Core.Puestos> lstPuestos = new List<Puestos.Core.Puestos>();

                try
                {
                    cnx.Open();
                    lstPuestos = ph.obtenerPuestos(p);
                    cnx.Close();
                    cnx.Dispose();
                }
                catch (Exception)
                {

                    throw;
                }
                cmbDeptoPuesto.DataSource = lstPuestos.ToList();
                cmbDeptoPuesto.DisplayMember = "nombre";
                cmbDeptoPuesto.ValueMember = "idpuesto";
            }
        }