Exemple #1
0
        private void toolBaja_Click(object sender, EventArgs e)
        {
            DialogResult respuesta = MessageBox.Show("¿Quiere eliminar la empresa?", "Confirmación", MessageBoxButtons.YesNo);

            if (respuesta == DialogResult.Yes)
            {
                string cdn       = ConfigurationManager.ConnectionStrings["cdnNomina"].ConnectionString;
                int    fila      = dgvEmpresas.CurrentCell.RowIndex;
                int    idempresa = int.Parse(dgvEmpresas.Rows[fila].Cells[0].Value.ToString());
                cnx            = new MySqlConnection(cdn);
                cmd            = new MySqlCommand();
                cmd.Connection = cnx;
                Empresas.Core.EmpresasHelper eh = new Empresas.Core.EmpresasHelper();
                eh.Command = cmd;
                Empresas.Core.Empresas em = new Empresas.Core.Empresas();
                em.idempresa = idempresa;
                try
                {
                    cnx.Open();
                    eh.bajaEmpresa(em);
                    cnx.Close();
                    cnx.Dispose();
                    ListaEmpresas();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
                }
            }
        }
Exemple #2
0
        private void ListaEmpresas()
        {
            string cdn = ConfigurationManager.ConnectionStrings["cdnNomina"].ConnectionString;

            cnx            = new MySqlConnection(cdn);
            cmd            = new MySqlCommand();
            cmd.Connection = cnx;
            Empresas.Core.EmpresasHelper eh = new Empresas.Core.EmpresasHelper();
            eh.Command = cmd;
            try
            {
                cnx.Open();
                lstEmpresas = eh.obtenerEmpresas();
                cnx.Close();
                cnx.Dispose();

                var em = from e in lstEmpresas
                         select new
                { IdEmpresa = e.idempresa, Nombre = e.nombre, RFC = e.rfc, Registro = e.registro + e.digitoverificador,
                  Representante = e.representante };
                dgvEmpresas.DataSource = em.ToList();

                for (int i = 0; i < dgvEmpresas.Columns.Count; i++)
                {
                    dgvEmpresas.AutoResizeColumn(i);
                }
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
            }
        }
        private void ListaEmpresas()
        {
            string cdn = ConfigurationManager.ConnectionStrings["cdnNomina"].ConnectionString;
            cnx = new SqlConnection(cdn);
            cmd = new SqlCommand();
            cmd.Connection = cnx;
            Empresas.Core.EmpresasHelper eh = new Empresas.Core.EmpresasHelper();
            eh.Command = cmd;
            try
            {
                cnx.Open();
                lstEmpresas = eh.obtenerEmpresas();
                cnx.Close();
                cnx.Dispose();

                var em = from e in lstEmpresas
                         select new
                         { IdEmpresa = e.idempresa, Nombre = e.nombre, RFC = e.rfc, Registro = e.registro + e.digitoverificador,
                         Representante = e.representante };
                dgvEmpresas.DataSource = em.ToList();

                for (int i = 0; i < dgvEmpresas.Columns.Count; i++)
                {
                    dgvEmpresas.AutoResizeColumn(i);
                }
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
            }
        }
Exemple #4
0
        private void Listas()
        {
            cnx            = new MySqlConnection(cdn);
            cmd            = new MySqlCommand();
            cmd.Connection = cnx;

            if (_EmpresaEmpleado == GLOBALES.EMPRESAS)
            {
                Empresas.Core.EmpresasHelper empresah = new Empresas.Core.EmpresasHelper();
                empresah.Command = cmd;

                try
                {
                    cnx.Open();
                    lstEmpresas = empresah.obtenerEmpresas();
                    cnx.Close();
                    cnx.Dispose();

                    var empresa = from a in lstEmpresas select new { IdEmpresa = a.idempresa, Nombre = a.nombre };
                    dgvImagenes.DataSource = empresa.ToList();

                    for (int i = 0; i < dgvImagenes.Columns.Count; i++)
                    {
                        dgvImagenes.AutoResizeColumn(i);
                    }
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
                }
            }
            else if (_EmpresaEmpleado == GLOBALES.EMPLEADOS)
            {
                Empleados.Core.EmpleadosHelper empleadoh = new Empleados.Core.EmpleadosHelper();
                empleadoh.Command = cmd;
                Empleados.Core.Empleados empleado = new Empleados.Core.Empleados();
                empleado.idplaza   = GLOBALES.IDPLAZA;
                empleado.idempresa = GLOBALES.IDEMPRESA;

                try
                {
                    cnx.Open();
                    lstEmpleados = empleadoh.obtenerEmpleados(empleado);
                    cnx.Close();
                    cnx.Dispose();

                    var trabajador = from b in lstEmpleados select new { IdEmpleado = b.idtrabajador, Nombre = b.nombrecompleto };
                    dgvImagenes.DataSource = trabajador.ToList();

                    for (int i = 0; i < dgvImagenes.Columns.Count; i++)
                    {
                        dgvImagenes.AutoResizeColumn(i);
                    }
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
                }
            }
        }
Exemple #5
0
        private void cargaGridEmpresa()
        {
            string          cdn = ConfigurationManager.ConnectionStrings["cdnNomina"].ConnectionString;
            MySqlConnection cnx = new MySqlConnection();
            MySqlCommand    cmd = new MySqlCommand();

            cnx.ConnectionString = cdn;
            cmd.Connection       = cnx;

            Empresas.Core.EmpresasHelper eh = new Empresas.Core.EmpresasHelper();
            eh.Command = cmd;

            try
            {
                cnx.Open();

                lstEmpresa = eh.InicioEmpresa();

                cnx.Close();
                cnx.Dispose();

                var e = from em in lstEmpresa
                        select new
                {
                    IdEmpresa = em.idempresa,
                    Nombre    = em.nombre,
                    Registro  = em.registro + em.digitoverificador
                };
                dgvEmpresas.DataSource        = e.ToList();
                dgvEmpresas.Columns[1].Width  = 200;
                dgvEmpresas.RowHeadersVisible = false;
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
            }
        }
        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();
        }
Exemple #7
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;
            }

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

            int idempresa;

            cnx = new MySqlConnection();
            cnx.ConnectionString = cdn;
            cmd            = new MySqlCommand();
            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.sindicato         = Convert.ToInt32(chkEsSindicato.Checked);
            em.representante     = txtRepresentante.Text;
            em.activo            = 1;

            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;

            switch (_tipoOperacion)
            {
            case 0:
                try
                {
                    cnx.Open();
                    MySqlCommand lastId = eh.insertaEmpresa(em);
                    long         Id     = lastId.LastInsertedId;
                    idempresa   = (int)eh.obtenerIdEmpresa(em);
                    d.idpersona = idempresa;
                    dh.insertaDireccion(d);
                    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);
                    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;
            }
        }
Exemple #8
0
        private void frmEmpresas_Load(object sender, EventArgs e)
        {
            /// _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 Empresas.Core.EmpresasHelper();
                eh.Command     = cmd;

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

                Direccion.Core.Direcciones d = new Direccion.Core.Direcciones();
                d.idpersona   = _idempresa;
                d.tipopersona = 0; ///TIPO PERSONA 0 - Empresas
                List <Empresas.Core.Empresas>     lstEmpresa;
                List <Direccion.Core.Direcciones> lstDireccion;

                try
                {
                    cnx.Open();
                    lstEmpresa   = eh.obtenerEmpresa(_idempresa);
                    lstDireccion = dh.obtenerDireccion(d);
                    cnx.Close();
                    cnx.Dispose();

                    for (int i = 0; i < lstEmpresa.Count; i++)
                    {
                        txtNombre.Text            = lstEmpresa[i].nombre;
                        txtRepresentante.Text     = lstEmpresa[i].representante;
                        txtRfc.Text               = lstEmpresa[i].rfc;
                        txtRegistroPatronal.Text  = lstEmpresa[i].registro;
                        txtDigitoVerificador.Text = lstEmpresa[i].digitoverificador.ToString();
                        chkEsSindicato.Checked    = Convert.ToBoolean(lstEmpresa[i].sindicato);
                    }

                    for (int i = 0; i < lstDireccion.Count; i++)
                    {
                        _iddireccion      = lstDireccion[i].iddireccion;
                        txtCalle.Text     = lstDireccion[i].calle;
                        txtExterior.Text  = lstDireccion[i].exterior;
                        txtInterior.Text  = lstDireccion[i].interior;
                        txtColonia.Text   = lstDireccion[i].colonia;
                        txtCP.Text        = lstDireccion[i].cp;
                        txtMunicipio.Text = lstDireccion[i].ciudad;
                        txtEstado.Text    = lstDireccion[i].estado;
                        txtPais.Text      = lstDireccion[i].pais;
                    }
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
                }

                if (_tipoOperacion == GLOBALES.CONSULTAR)
                {
                    toolTitulo.Text = "Consulta Empresa";
                    GLOBALES.INHABILITAR(this, typeof(TextBox));
                    GLOBALES.INHABILITAR(this, typeof(MaskedTextBox));
                    GLOBALES.INHABILITAR(this, typeof(CheckBox));
                }
                else
                {
                    toolTitulo.Text = "Edición Empresa";
                }
            }
        }
        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;
            }
        }
Exemple #10
0
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            int existeVacaciones = 0, existeIncapacidad = 0;
            int diasProporcionales = 0;
            int existeBaja = 0;
            DialogResult respuesta = MessageBox.Show("¿Desea dar de baja al empleado?","Confirmación",MessageBoxButtons.YesNo);
            if (respuesta == DialogResult.Yes)
            {
                //if (ausentismo)
                //{
                //    frmDiasAusentismo da = new frmDiasAusentismo();
                //    da.OnDiasAusentismo += da_OnDiasAusentismo;
                //    da.ShowDialog();
                //}

                //if (diasAusentismo == 0 && ausentismo)
                //{
                //    MessageBox.Show("El número de dias es 0 o se presionó el boton cancelar. Por favor revisar.", "Error");
                //    return;
                //}

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

                PeriodoFechaAplicacion();

                #region EXISTENCIA DE INCAPACIDAD
                Incidencias.Core.IncidenciasHelper ih = new Incidencias.Core.IncidenciasHelper();
                ih.Command = cmd;

                Incidencias.Core.Incidencias incidencia = new Incidencias.Core.Incidencias();
                incidencia.idtrabajador = _idempleado;
                incidencia.fechainicio = periodoInicio.Date;
                incidencia.fechafin = periodoFin.Date;

                try
                {
                    cnx.Open();
                    existeIncapacidad = (int)ih.existeIncidenciaBaja(incidencia);
                    cnx.Close();
                }
                catch
                {
                    MessageBox.Show("Error: Al obtener existencia de Incapacidad.","Error");
                    cnx.Dispose();
                    return;
                }
                #endregion

                #region EXISTENCIA DE VACACIONES
                Vacaciones.Core.VacacionesHelper vh = new Vacaciones.Core.VacacionesHelper();
                vh.Command = cmd;

                Vacaciones.Core.VacacionesPrima vp = new Vacaciones.Core.VacacionesPrima();
                vp.idtrabajador = _idempleado;
                vp.periodoinicio = periodoInicio;
                vp.periodofin = periodoFin;
                vp.vacacionesprima = "V";

                try
                {
                    cnx.Open();
                    existeVacaciones = (int)vh.existeVacacionesPrima(vp);
                    cnx.Close();
                }
                catch
                {
                    MessageBox.Show("Error: Al obtener existencia de Vacaciones.", "Error");
                    cnx.Dispose();
                    return;
                }
                #endregion

                #region VALIDACION DE INCAPACIDAD
                if (existeIncapacidad != 0)
                {
                    DateTime fechaInicioIncidencia;
                    DateTime fechaFinIncidencia;
                    try
                    {
                        cnx.Open();
                        fechaInicioIncidencia = DateTime.Parse(ih.fechaInicio(incidencia).ToString());
                        fechaFinIncidencia = DateTime.Parse(ih.fechaFin(incidencia).ToString());
                        cnx.Close();
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Error: Al obtener las fechas de incapacidad.", "Error");
                        cnx.Dispose();
                        return;
                    }

                    if (dtpFechaBaja.Value.Date >= fechaInicioIncidencia.Date && dtpFechaBaja.Value.Date <= fechaFinIncidencia.Date)
                    {
                        MessageBox.Show("No se puede dar de baja. La fecha de baja esta entre una incapacidad.", "Error");
                        return;
                    }
                    if (dtpFechaBaja.Value.Date <= fechaInicioIncidencia.Date)
                    {
                        MessageBox.Show("No se puede dar de baja. Existe una incapacidad.", "Error");
                        return;
                    }
                }
                #endregion

                #region VALIDACION DE VACACIONES
                if (existeVacaciones != 0)
                {
                    DateTime fechaInicioVac;
                    DateTime fechaFinVac;

                    try
                    {
                        cnx.Open();
                        fechaInicioVac = DateTime.Parse(vh.fechaInicio(vp).ToString());
                        fechaFinVac = DateTime.Parse(vh.fechaFin(vp).ToString());
                        cnx.Close();
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Error: Al obtener las fechas de las vacaciones.", "Error");
                        cnx.Dispose();
                        return;
                    }

                    if (dtpFechaBaja.Value.Date >= fechaInicioVac.Date && dtpFechaBaja.Value.Date <= fechaFinVac.Date)
                    {
                        MessageBox.Show("No se puede dar de baja. La fecha de baja coninciden con vacaciones.", "Error");
                        return;
                    }
                    if (dtpFechaBaja.Value.Date <= fechaInicioVac.Date)
                    {
                        MessageBox.Show("No se puede dar de baja. El trabajador tiene vacaciones.", "Error");
                        return;
                    }
                }
                #endregion

                Empresas.Core.EmpresasHelper ep = new Empresas.Core.EmpresasHelper();
                ep.Command = cmd;

                Empresas.Core.Empresas empresa = new Empresas.Core.Empresas();
                empresa.idempresa = GLOBALES.IDEMPRESA;

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

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

                Empleados.Core.EmpleadosEstatus ee = new Empleados.Core.EmpleadosEstatus();
                ee.idtrabajador = _idempleado;
                ee.idempresa = GLOBALES.IDEMPRESA;
                ee.estatus = GLOBALES.INACTIVO;

                Historial.Core.HistorialHelper hp = new Historial.Core.HistorialHelper();
                hp.Command = cmd;

                Historial.Core.Historial h = new Historial.Core.Historial();
                h.idtrabajador = _idempleado;
                h.tipomovimiento = GLOBALES.mBAJA;
                h.fecha_imss = dtpFechaBaja.Value;
                h.fecha_sistema = DateTime.Now;
                h.idempresa = GLOBALES.IDEMPRESA;
                h.motivobaja = int.Parse(cmbMotivoBaja.SelectedValue.ToString());
                h.iddepartamento = 0;
                h.idpuesto = 0;

                //Ausentismo.Core.AusentismoHelper ah = new Ausentismo.Core.AusentismoHelper();
                //ah.Command = cmd;

                //Ausentismo.Core.Ausentismo a = new Ausentismo.Core.Ausentismo();
                //a.idtrabajador = _idempleado;
                //a.idempresa = GLOBALES.IDEMPRESA;
                //a.fecha_imss = dtpFechaBaja.Value;
                //a.dias = diasAusentismo;

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

                Bajas.Core.Bajas baja = new Bajas.Core.Bajas();
                baja.idtrabajador = _idempleado;
                baja.idempresa = GLOBALES.IDEMPRESA;
                baja.motivo = int.Parse(cmbMotivoBaja.SelectedValue.ToString());
                baja.fecha = dtpFechaBaja.Value.Date;
                //baja.diasproporcionales = (int)(dtpFechaBaja.Value.Date - periodoInicio.Date).TotalDays + 1;
                baja.periodoinicio = periodoInicio.Date;
                baja.periodofin = periodoFin.Date;
                baja.observaciones = txtObservaciones.Text;
                baja.registro = DateTime.Now;

                diasProporcionales = (int)(dtpFechaBaja.Value.Date - periodoInicio.Date).TotalDays + 1;
                if (diasProporcionales == 16)
                    baja.diasproporcionales = diasProporcionales - 1;
                else
                    baja.diasproporcionales = (int)(dtpFechaBaja.Value.Date - periodoInicio.Date).TotalDays + 1;

                try
                {
                    cnx.Open();
                    existeBaja = (int)bh.existeBaja(baja);
                    cnx.Close();
                }
                catch (Exception)
                {
                    MessageBox.Show("Error: Al verificar la existencia de la baja.", "Error");
                    cnx.Dispose();
                    return;
                }

                if (existeBaja != 0)
                {
                    MessageBox.Show(
                        string.Format("El trabajador ya cuenta con una baja en el periodo del: \r\n \r\n {0} al {1}",
                        periodoInicio.Date.ToShortDateString(), periodoFin.Date.ToShortDateString()),
                        "Información");
                    return;
                }

                bool obraCivil = false;
                try
                {
                    cnx.Open();
                    obraCivil = bool.Parse(eh.esObraCivil(GLOBALES.IDEMPRESA, _idempleado).ToString());
                    cnx.Close();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error: Al obtener dato de obra civil. \r\n \r\n" + error.Message, "Error");
                    return;
                }

                if (obraCivil)
                {
                    nh = new CalculoNomina.Core.NominaHelper();
                    nh.Command = cmd;
                    List<CalculoNomina.Core.tmpPagoNomina> lstPreNominaGuardada = new List<CalculoNomina.Core.tmpPagoNomina>();
                    List<CalculoNomina.Core.tmpPagoNomina> lstUltimaNomina = new List<CalculoNomina.Core.tmpPagoNomina>();
                    try
                    {
                        cnx.Open();
                        lstUltimaNomina = nh.obtenerUltimaNominaTrabajador(GLOBALES.IDEMPRESA, _idempleado, periodo);
                        lstPreNominaGuardada = nh.fechaPreNominaObraCivil(GLOBALES.IDEMPRESA, _idempleado, periodoInicio, periodoFin);
                        cnx.Close();
                    }
                    catch (Exception error)
                    {
                        MessageBox.Show("Error: Al obtener las fechas de pago. \r\n \r\n" + error.Message, "Error");
                        return;
                    }

                    if (lstUltimaNomina.Count != 0)
                    {
                        if (dtpFechaBaja.Value.Date >= lstUltimaNomina[0].fechainicio || dtpFechaBaja.Value.Date <= lstUltimaNomina[0].fechafin)
                        {
                            MessageBox.Show("La baja corresponde a un periodo cerrado.", "Información");
                            return;
                        }
                    }

                    if (lstPreNominaGuardada.Count != 0)
                    {
                        if (dtpFechaBaja.Value.Date <= lstPreNominaGuardada[0].fechafin)
                        {
                            try
                            {
                                Bajas.Core.Bajas bajaTrabajador = new Bajas.Core.Bajas();
                                bajaTrabajador.idtrabajador = _idempleado;
                                cnx.Open();
                                bh.bajaEmpleado(bajaTrabajador);
                                nh.eliminaPreNomina(_idempleado, periodo);
                                cnx.Close();
                            }
                            catch (Exception error)
                            {
                                MessageBox.Show("Error: Al dar baja del empleado. \r\n \r\n" + error.Message, "Error");
                                return;
                            }
                        }
                    }
                }
                else {
                    nh = new CalculoNomina.Core.NominaHelper();
                    nh.Command = cmd;
                    List<CalculoNomina.Core.tmpPagoNomina> lstNomina = new List<CalculoNomina.Core.tmpPagoNomina>();
                    try
                    {
                        cnx.Open();
                        lstNomina = nh.obtenerUltimaNominaTrabajador(GLOBALES.IDEMPRESA, _idempleado, periodo);
                        cnx.Close();
                    }
                    catch (Exception error)
                    {
                        MessageBox.Show("Error: Al obtener las fechas de pago. \r\n \r\n" + error.Message, "Error");
                        return;
                    }

                    if (lstNomina.Count != 0)
                    {
                        if (dtpFechaBaja.Value.Date <= lstNomina[0].fechainicio || dtpFechaBaja.Value.Date <= lstNomina[0].fechafin)
                        {
                            try
                            {
                                Bajas.Core.Bajas bajaTrabajador = new Bajas.Core.Bajas();
                                bajaTrabajador.idtrabajador = _idempleado;
                                cnx.Open();
                                bh.bajaEmpleado(bajaTrabajador);
                                nh.eliminaPreNomina(_idempleado, periodo);
                                cnx.Close();
                                baja.fecha = lstNomina[0].fechafin;
                                baja.diasproporcionales = 1;
                                MessageBox.Show("La baja corresponde a un periodo cerrado. \r\n\r\n Se dará con la fecha de termino del periodo cerrado: " +
                                    lstNomina[0].fechafin.ToShortDateString(), "Información");
                            }
                            catch (Exception error)
                            {
                                MessageBox.Show("Error: Al dar baja del empleado. \r\n \r\n" + error.Message, "Error");
                                return;
                            }
                        }
                    }
                }

                try
                {
                    cnx.Open();
                    h.valor = (decimal)eh.obtenerSalarioDiarioIntegrado(emp);
                    hp.insertarHistorial(h);
                    //ACTUALIZA TABLA trabajadoresestatus
                    eh.bajaEmpleado(ee);

                    baja.registropatronal = (string)ep.obtenerRegistroPatronal(empresa);
                    baja.nss = (string)eh.obtenerNss(emp);
                    bh.insertaBaja(baja);

                    //if (ausentismo)
                    //{
                    //    a.registropatronal = (string)ep.obtenerRegistroPatronal(empresa);
                    //    a.nss = (string)eh.obtenerNss(emp);
                    //    ah.insertaAusentismo(a);
                    //}

                    cnx.Close();
                    cnx.Dispose();

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

                MessageBox.Show("Baja exitosa.", "Información");
                btnAceptar.Enabled = false;
                this.Dispose();
            }
        }
Exemple #11
0
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            cnx = new MySqlConnection();
            cnx.ConnectionString = cdn;
            cmd            = new MySqlCommand();
            cmd.Connection = cnx;

            LayoutMovimientos.Core.LayoutHelper lh = new LayoutMovimientos.Core.LayoutHelper();
            Empresas.Core.EmpresasHelper        eh = new Empresas.Core.EmpresasHelper();
            lh.Command = cmd;
            eh.Command = cmd;

            LayoutMovimientos.Core.LayoutMovimientos lm = new LayoutMovimientos.Core.LayoutMovimientos();

            List <Empresas.Core.Empresas> lstEmpresa = new List <Empresas.Core.Empresas>();


            for (int i = 0; i < lstEmpleado.Count; i++)
            {
                lm.idtrabajador  = lstEmpleado[i].idtrabajador;
                lm.idempresa     = lstEmpleado[i].idempresa;
                lm.idcliente     = lstEmpleado[i].idcliente;
                lm.movimiento    = 2;
                lm.nombres       = lstEmpleado[i].nombres;
                lm.paterno       = lstEmpleado[i].paterno;
                lm.materno       = lstEmpleado[i].materno;
                lm.sdi           = lstEmpleado[i].sdi;
                lm.sdinuevo      = decimal.Parse(txtSDI.Text);
                lm.nss           = lstEmpleado[i].nss;
                lm.digitonss     = lstEmpleado[i].digitoverificador;
                lm.fecha_ingreso = lstEmpleado[i].fechaingreso;
                lm.fecha_sistema = DateTime.Now;
                lm.curp          = lstEmpleado[i].curp;
                lm.generado      = 0;

                try
                {
                    cnx.Open();
                    lstEmpresa = eh.obtenerEmpresa(lm.idempresa);
                    cnx.Close();
                    cnx.Dispose();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
                }

                for (int j = 0; j < lstEmpresa.Count; j++)
                {
                    lm.registro       = lstEmpresa[j].registro;
                    lm.digitoregistro = lstEmpresa[j].digitoverificador;
                }
            }

            try
            {
                cnx.Open();
                lh.insertaLayoutMovimiento(lm);
                cnx.Close();
                cnx.Dispose();
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
            }
        }
Exemple #12
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;
            }
        }
Exemple #13
0
        private void frmEmpresas_Load(object sender, EventArgs e)
        {
            /// _tipoOperacion CONSULTA = 1, EDICION = 2
            if (_tipoOperacion == GLOBALES.CONSULTAR || _tipoOperacion == GLOBALES.MODIFICAR)
            {
                cmbPago.Visible = false;
                txtDias.Visible = false;

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

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

                Direccion.Core.Direcciones d = new Direccion.Core.Direcciones();
                d.idpersona = _idempresa;
                d.tipopersona = GLOBALES.pEMPRESA; ///TIPO PERSONA 0 - Empresas
                List<Empresas.Core.Empresas> lstEmpresa;
                List<Direccion.Core.Direcciones> lstDireccion;

                try
                {
                    cnx.Open();
                    lstEmpresa = eh.obtenerEmpresa(_idempresa);
                    lstDireccion = dh.obtenerDireccion(d);
                    cnx.Close();
                    cnx.Dispose();

                    for (int i = 0; i < lstEmpresa.Count; i++)
                    {
                        txtNombre.Text = lstEmpresa[i].nombre;
                        txtRepresentante.Text = lstEmpresa[i].representante;
                        txtRfc.Text = lstEmpresa[i].rfc;
                        txtRegistroPatronal.Text = lstEmpresa[i].registro;
                        txtObservacion.Text = lstEmpresa[i].observacion;
                        txtDigitoVerificador.Text = lstEmpresa[i].digitoverificador.ToString();
                        txtRegimen.Text = lstEmpresa[i].regimen.ToString();
                        txtCertificado.Text = lstEmpresa[i].certificado;
                        txtLlave.Text = lstEmpresa[i].llave;
                        txtPassword.Text = lstEmpresa[i].password;
                        txtNoCertificado.Text = lstEmpresa[i].nocertificado;
                        dtpVigencia.Value = lstEmpresa[i].vigenciacertificado;
                    }

                    for (int i = 0; i < lstDireccion.Count; i++)
                    {
                        _iddireccion = lstDireccion[i].iddireccion;
                        txtCalle.Text = lstDireccion[i].calle;
                        txtExterior.Text = lstDireccion[i].exterior;
                        txtInterior.Text = lstDireccion[i].interior;
                        txtColonia.Text = lstDireccion[i].colonia;
                        txtCP.Text = lstDireccion[i].cp;
                        txtMunicipio.Text = lstDireccion[i].ciudad;
                        txtEstado.Text = lstDireccion[i].estado;
                        txtPais.Text = lstDireccion[i].pais;
                    }

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

                if (_tipoOperacion == GLOBALES.CONSULTAR)
                {
                    toolTitulo.Text = "Consulta Empresa";
                    ((Control)this.tabEmpresa).Enabled = false;
                    ((Control)this.tabPeriodo).Enabled = false;
                    ((Control)this.tabDomicilio).Enabled = false;
                    ((Control)this.tabTimbrado).Enabled = false;
                    btnAsignar.Enabled = false;
                    toolGuardarCerrar.Enabled = false;
                    toolGuardarNuevo.Enabled = false;

                }
                else
                    toolTitulo.Text = "Edición Empresa";
            }

            cmbPago.SelectedIndex = 0;
        }
 private void toolBaja_Click(object sender, EventArgs e)
 {
     DialogResult respuesta = MessageBox.Show("¿Quiere eliminar la empresa?", "Confirmación", MessageBoxButtons.YesNo);
     if (respuesta == DialogResult.Yes)
     {
         string cdn = ConfigurationManager.ConnectionStrings["cdnNomina"].ConnectionString;
         int fila = dgvEmpresas.CurrentCell.RowIndex;
         int idempresa = int.Parse(dgvEmpresas.Rows[fila].Cells[0].Value.ToString());
         cnx = new SqlConnection(cdn);
         cmd = new SqlCommand();
         cmd.Connection = cnx;
         Empresas.Core.EmpresasHelper eh = new Empresas.Core.EmpresasHelper();
         eh.Command = cmd;
         Empresas.Core.Empresas em = new Empresas.Core.Empresas();
         em.idempresa = idempresa;
         try
         {
             cnx.Open();
             eh.bajaEmpresa(em);
             cnx.Close();
             cnx.Dispose();
             ListaEmpresas();
         }
         catch (Exception error)
         {
             MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
         }
     }
 }
        private void ListaEmpleados()
        {
            string cdn = ConfigurationManager.ConnectionStrings["cdnNomina"].ConnectionString;
            cnx = new SqlConnection(cdn);
            cmd = new SqlCommand();
            cmd.Connection = cnx;
            fh = new Faltas.Core.FaltasHelper();
            eh = new Empleados.Core.EmpleadosHelper();
            empresah = new Empresas.Core.EmpresasHelper();
            fh.Command = cmd;
            eh.Command = cmd;
            empresah.Command = cmd;

            Empleados.Core.Empleados empleado = new Empleados.Core.Empleados();
            empleado.idempresa = GLOBALES.IDEMPRESA;

            Empresas.Core.Empresas empresa = new Empresas.Core.Empresas();
            empresa.idempresa = GLOBALES.IDEMPRESA;

            try
            {
                cnx.Open();
                lstAusentismo = fh.obtenerFaltas(GLOBALES.IDEMPRESA);
                lstEmpleados = eh.obtenerEmpleadosAusentismo(empleado);
                registroPatronal = empresah.obtenerRegistroPatronal(empresa).ToString();
                cnx.Close();
                cnx.Dispose();

                var au = from a in lstAusentismo
                          join t in lstEmpleados on a.idtrabajador equals t.idtrabajador
                          select new
                          {
                              NoEmpleado = t.noempleado,
                              Nss = t.nss + t.digitoverificador.ToString(),
                              Nombre = t.nombrecompleto,
                              Fecha = a.fecha,
                              Dias = a.faltas,
                              Sbc = t.sdi
                          };
                dgvAusentismoSua.DataSource = au.ToList();

                for (int i = 0; i < dgvAusentismoSua.Columns.Count; i++)
                {
                    dgvAusentismoSua.AutoResizeColumn(i);
                }
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
            }
        }