diff --git a/App_Code/ClsClientes.vb b/App_Code/ClsClientes.vb index 018752561..8163a318d 100644 --- a/App_Code/ClsClientes.vb +++ b/App_Code/ClsClientes.vb @@ -87,7 +87,7 @@ Public Class ClsClientes Public Property Codigo As String Public Property LimiteCredito As Double 'Public Property NumCtaPago As String - 'Public Property CveMetodoPago As Integer + Public Property CveMetodoPago As Integer Public Property AplicaFEMSA As Boolean Public Property FEMSA_NumSociedad As String Public Property FEMSA_NumProveedor As String diff --git a/App_Code/ClsGenerales.vb b/App_Code/ClsGenerales.vb index 353146e49..8009b4b60 100644 --- a/App_Code/ClsGenerales.vb +++ b/App_Code/ClsGenerales.vb @@ -2619,13 +2619,12 @@ Public Class ClsGenerales #End Region #Region "SAT PRODUCTOS SERVICIOS Y UNIDAD DE MEDIDA" - Public Function GetSATProductosServicios() As Boolean + Public Function GetSATProductosServicios(Optional SATClaveProductoServicio As String = "-1") As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Gral_SAT_ProductosServiciosGet") - With SqlAdapter.SelectCommand.Parameters - - + With SqlAdapter.SelectCommand.Parameters + .Add("@SATClaveProductoServicio", SqlDbType.Int).Value = SATClaveProductoServicio End With 'SqlTypes.SqlDateTime.Null Try diff --git a/App_Code/ClsNominas.vb b/App_Code/ClsNominas.vb index 8dc140ab6..593e54e06 100644 --- a/App_Code/ClsNominas.vb +++ b/App_Code/ClsNominas.vb @@ -130,7 +130,8 @@ Public Class ClsNominas .CommandText = pStrSQL .CommandType = TipoComando End With - Data = New DataTable + Data = New DataTable() + DTSet = New DataSet() If SqlTransacc IsNot Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc End Sub #Region "Conexiones" @@ -311,7 +312,7 @@ Public Class ClsNominas End Function Public Function GetCalculoAguinaldo(ejercicio As Int32, cveEmpresa As Int32, importe As Double, CveTipoPeriodo As Integer, CvePeriodo As Integer) As Boolean Dim retorno As Boolean = False - DataAdapter("PA_NomCalcularAguinaldo", CommandType.StoredProcedure) + DataAdapter("PA_Nom_CalcularAguinaldo", CommandType.StoredProcedure) With SqlAdapter.SelectCommand.Parameters .Add("@CveEmpresa", SqlDbType.Int).Value = cveEmpresa .Add("@Ejercicio", SqlDbType.Int).Value = ejercicio @@ -327,24 +328,28 @@ Public Class ClsNominas End Try Return retorno End Function - Public Function Autorizaperiodoconta(CvePeriodo As Int32, CveEmpresa As Int32) As Boolean + Public Function RegistraProvision(CvePeriodo As Int32, CveEmpresa As Int32) As Boolean Dim retorno As Boolean = False - DataAdapter("PA_Nom_Autorizaperiodoconta", CommandType.StoredProcedure) + DataAdapter("PA_Nom_RegistraProvision", CommandType.StoredProcedure) With SqlAdapter.SelectCommand.Parameters .Add("@CvePeriodo", SqlDbType.Int).Value = CvePeriodo .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa End With Try - SqlAdapter.Fill(Data) + SqlAdapter.Fill(DTSet) + Data = New DataTable + If DTSet.Tables.Count > 0 Then + Data = DTSet.Tables(0) + End If retorno = True Catch ex As Exception - OnError("Ocurrió un error al autorizar periodo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + OnError("Ocurrió un error al registrar la provisión de nomina.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) End Try Return retorno End Function - Public Function GetDispersiondenomina(CvePeriodo As Int32, CveEmpresa As Int32) As Boolean + Public Function GetDispersionnomina(CvePeriodo As Int32, CveEmpresa As Int32) As Boolean Dim retorno As Boolean = False - DataAdapter("PA_PA_NomDispersiondenomina", CommandType.StoredProcedure) + DataAdapter("PA_Nom_Dispersionnomina", CommandType.StoredProcedure) With SqlAdapter.SelectCommand.Parameters .Add("@CvePeriodo", SqlDbType.Int).Value = CvePeriodo .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa @@ -359,7 +364,7 @@ Public Class ClsNominas End Function Public Function GetCalculoUtilidades(ejercicio As Int32, cveEmpresa As Int32, importe As Double, importeA As Double) As Boolean Dim retorno As Boolean = False - DataAdapter("PA_NomCalcularUtilidades", CommandType.StoredProcedure) + DataAdapter("PA_Nom_CalcularUtilidades", CommandType.StoredProcedure) With SqlAdapter.SelectCommand.Parameters .Add("@CveEmpresa", SqlDbType.Int).Value = cveEmpresa .Add("@Ejercicio", SqlDbType.Int).Value = ejercicio @@ -2549,7 +2554,7 @@ Public Class ClsNominas End Try Return retorno End Function - Public Function AddMovtoPermanente(cveConcepto As Int32, cvePersonal As Int32, descripcion As String, tipoDescuento As Int32, valor As Double, vecesAplicar As Int32, montoLimite As Decimal, fechaInicioAplicacion As String, estatus As Boolean) As Boolean + Public Function AddMovtoPermanente(cveConcepto As Int32, cvePersonal As Int32, descripcion As String, tipoDescuento As Int32, valor As Double, vecesAplicar As Int32, montoLimite As Decimal, fechaInicioAplicacion As String, estatus As Boolean, CveCuenta As Integer) As Boolean Dim retorno As Boolean = False DataAdapter("PA_AddMovtoPermanente", CommandType.StoredProcedure) @@ -2563,20 +2568,21 @@ Public Class ClsNominas .Add("@montoLimite", SqlDbType.Decimal).Value = (montoLimite) .Add("@fechaInicioAplicacion", SqlDbType.VarChar).Value = (fechaInicioAplicacion) .Add("@estatus", SqlDbType.Bit).Value = (estatus) + .Add("@CveCuenta", SqlDbType.Int).Value = (CveCuenta) End With Try SqlAdapter.Fill(Data) retorno = True Catch sqEx As SqlException retorno = False - OnError("Ocurrió un error al agregar los Movtos Permanentes.", sqEx, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + OnError("Ocurrió un error al agregar los movimientos permanentes.", sqEx, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) Catch ex As Exception retorno = False - OnError("Ocurrió un error al agregar los Movtos Permanentes.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + OnError("Ocurrió un error al agregar los movimientos permanentes.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) End Try Return retorno End Function - Public Function UpMovtoPermanente(cveMovtoPermanente As Int32, cveConcepto As Int32, cvePersonal As Int32, descripcion As String, tipoDescuento As Int32, valor As Double, vecesAplicar As Int32, montoLimite As Decimal, fechaInicioAplicacion As String, estatus As Boolean) As Boolean + Public Function UpMovtoPermanente(cveMovtoPermanente As Int32, cveConcepto As Int32, cvePersonal As Int32, descripcion As String, tipoDescuento As Int32, valor As Double, vecesAplicar As Int32, montoLimite As Decimal, fechaInicioAplicacion As String, estatus As Boolean, CveCuenta As Integer) As Boolean Dim retorno As Boolean = False DataAdapter("PA_UpMovtoPermanente", CommandType.StoredProcedure) With SqlAdapter.SelectCommand.Parameters @@ -2590,16 +2596,21 @@ Public Class ClsNominas .Add("@montoLimite", SqlDbType.Decimal).Value = (montoLimite) .Add("@fechaInicioAplicacion", SqlDbType.VarChar).Value = (fechaInicioAplicacion) .Add("@estatus", SqlDbType.Bit).Value = (estatus) + .Add("@CveCuenta", SqlDbType.Int).Value = (CveCuenta) End With Try SqlAdapter.Fill(Data) retorno = True Catch sqEx As SqlException retorno = False - OnError("Ocurrió un error al agregar los Movtos Permanentes.", sqEx, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + If (sqEx.Message.Contains("FK_Conta_CuentasAsignaciones_Conta_ConceptosContables")) Then + OnError("Es necesario asignar el concepto contable al concepto de nomina para poder realizar la vinculacion de la cuenta.", sqEx, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + Else + OnError("Ocurrió un error al actualizar los movimientos permanentes.", sqEx, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If Catch ex As Exception retorno = False - OnError("Ocurrió un error al agregar los Movtos Permanentes.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + OnError("Ocurrió un error al actualizar los movimientos permanentes.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) End Try Return retorno End Function diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 06ea7a8d6..65369f14c 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -293,19 +293,28 @@ Public Class ClsPaginas Application("Directorio") = value End Set End Property - Property GlobalDTPSATPS() As DataTable + Public Shared ReadOnly Property GlobalDTPSATPS(SATClaveProductoServicio As String) As DataTable Get - If Application("GlobalDTPSATPS") Is Nothing Then - Dim ObjGrales As New ClsGenerales - If ObjGrales.GetSATProductosServicios Then Application("GlobalDTPSATPS") = ObjGrales.DtResultados.AsEnumerable() Else Application("GlobalDTPSATPS") = Nothing - ObjGrales.Dispose() + 'If Application("GlobalDTPSATPS") Is Nothing Then + ' Dim ObjGrales As New ClsGenerales + ' If ObjGrales.GetSATProductosServicios Then Application("GlobalDTPSATPS") = ObjGrales.DtResultados.AsEnumerable() Else Application("GlobalDTPSATPS") = Nothing + ' ObjGrales.Dispose() + 'End If + + 'GlobalDTPSATPS = DirectCast(Application("GlobalDTPSATPS"), EnumerableRowCollection(Of DataRow)).CopyToDataTable + + Dim ObjGrales As New ClsGenerales + If ObjGrales.GetSATProductosServicios(SATClaveProductoServicio) Then + GlobalDTPSATPS = ObjGrales.DtResultados + Else + GlobalDTPSATPS = Nothing End If + ObjGrales.Dispose() - GlobalDTPSATPS = DirectCast(Application("GlobalDTPSATPS"), EnumerableRowCollection(Of DataRow)).CopyToDataTable End Get - Set(value As DataTable) - Application("GlobalDTPSATPS") = value - End Set + 'Set(value As DataTable) + ' Application("GlobalDTPSATPS") = value + 'End Set End Property #Region "GLOBALES DE SAT COMERCIO EXTERIOR" @@ -638,7 +647,7 @@ Public Class ClsPaginas End Property - Property GlobalDTClasificaciones(Optional CveEmpresa As Integer = -1, Optional CveCategoria As Integer = -1, Optional UsoClasificacion As Integer = -1, Optional CveClasificacion As Integer = -1) As DataTable + Property GlobalDTClasificaciones(Optional CveEmpresa As Integer = -1, Optional CveCategoria As Integer = -1, Optional UsoClasificacion As Integer = -1, Optional CveClasificacion As Integer = -1, Optional Estatus As Integer = 1) As DataTable Get Dim AppNombre As String = String.Format("GlobalDTClasificaciones-{0}", CveEmpresa) 'sino existe, recarga los datos @@ -653,6 +662,7 @@ Public Class ClsPaginas If CveCategoria <> -1 Then Str.AppendFormat(" AND CveCategoria = {0}", CveCategoria) If UsoClasificacion <> -1 Then Str.AppendFormat(" AND UsoClasificacion IN ({0},3) ", UsoClasificacion) If CveClasificacion <> -1 Then Str.AppendFormat(" AND CveClasificacion = {0}", CveClasificacion) + If Estatus <> -1 Then Str.AppendFormat(" AND Estatus = '{0}'", If(Estatus = 1, "Activo", "Inactivo")) Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), Str.ToString(), "", DataViewRowState.CurrentRows) GlobalDTClasificaciones = Dv.ToTable Dv.Dispose() @@ -3066,8 +3076,6 @@ Public Class ClsPaginas End Set End Property - - Property GlobalDTContaConceptosContables(CvePlantillaPoliza As Integer) As DataTable Get If CvePlantillaPoliza <> -1 Then @@ -3840,6 +3848,7 @@ Public Class ClsPaginas If Application("GlobalSIGAppPaginas") Is Nothing Then PaginaDict = New System.Collections.Hashtable + PaginaDict.Add("/Nomina/ISRCalculoAnual.aspx".ToUpper(), 918) PaginaDict.Add("/Nomina/Acumulados.aspx".ToUpper(), 916) PaginaDict.Add("/RH/CalculoSBC.aspx".ToUpper(), 915) @@ -4610,6 +4619,7 @@ Public Class ClsPaginas PaginaDict.Add("/GPS/RepGastos.aspx".ToUpper(), 685) PaginaDict.Add("/GPS/RecursoConfiableTracking.aspx".ToUpper(), 692) PaginaDict.Add("/GPS/KimberlyClarkTracking.aspx".ToUpper(), -1) + PaginaDict.Add("/GPS/RepUnidades.aspx".ToUpper(), 780) #End Region 'INVENTARIOS #Region "Inventarios" @@ -5943,6 +5953,19 @@ Public Class ClsPaginas Dim TipoDocumentoRef As String = "" Dim AplicaPagare As String = "1" + Dim RFCReceptor As String = "" + + If String.IsNullOrEmpty(Vta.RFCReceptor) Then + RFCReceptor = Vta.Cliente.RFC + If Vta.FacturarSucursal Then + If Vta.ClienteSucursal IsNot Nothing Then + RFCReceptor = Vta.ClienteSucursal.RFC + End If + End If + Else + RFCReceptor = Vta.RFCReceptor + End If + Dim RutaCBB As String = String.Format("{0}CBB\{1}.jpg", Ruta, Vta.SerieFolio) Dim ImagenCBB As New System.IO.FileInfo(RutaCBB) Dim ImgCBB As String '= String.Format("{0}://{1}:{2}/Empresas/{3}/CBB/{4}.jpg", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa, Vta.SerieFolio) @@ -6072,7 +6095,7 @@ Public Class ClsPaginas 'Si no tiene CBB, SE GENERA If Not ImagenCBB.Exists Then Dim CBB As New ClbNegBICFDv3_2.ClsNegCBBGenerar() - CBB.GenerarCBB(UsuarioActual.Empresa.RFC, Vta.Cliente.RFC, Vta.Total.ToString.ToDecimal, Vta.FolioFiscal, RutaCBB) + CBB.GenerarCBB(UsuarioActual.Empresa.RFC, RFCReceptor, Vta.Total.ToString.ToDecimal, Vta.FolioFiscal, RutaCBB) End If ImgCBB = String.Format("{0}://{1}:{2}/Empresas/{3}/CBB/{4}.jpg", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa, Vta.SerieFolio) @@ -6087,7 +6110,7 @@ Public Class ClsPaginas 'CLIENTE params.Add(New CrystalParametro("ClienteCodigo", Vta.Cliente.Codigo)) - params.Add(New CrystalParametro("ClienteNombre", If(Vta.ClienteSucursal.ImprimeNombreSucursal = "True", If(Vta.CveClienteSucursal > 0, Vta.ClienteSucursal.Sucursal, Vta.Cliente.Nombre), If(Vta.AtencionA <> "" AndAlso Vta.TipoDocto.Contiene("Ing", "Rem") AndAlso Vta.Cliente.RFC = "XAXX010101000", $"{Vta.Cliente.Nombre}({Vta.AtencionA})", Vta.Cliente.Nombre)))) + params.Add(New CrystalParametro("ClienteNombre", If(Vta.ClienteSucursal.ImprimeNombreSucursal = "True", If(Vta.CveClienteSucursal > 0, Vta.ClienteSucursal.Sucursal, Vta.Cliente.Nombre), If(Vta.AtencionA <> "" AndAlso Vta.TipoDocto.Contiene("Ing", "Rem") AndAlso RFCReceptor = "XAXX010101000", $"{Vta.Cliente.Nombre}({Vta.AtencionA})", Vta.Cliente.Nombre)))) params.Add(New CrystalParametro("ClienteDireccion", ClienteDireccion)) params.Add(New CrystalParametro("ClienteLugar", ClienteLugar)) @@ -6119,7 +6142,7 @@ Public Class ClsPaginas params.Add(New CrystalParametro("SelloSAT", Vta.SelloSAT)) params.Add(New CrystalParametro("QR", ImgCBB)) - params.Add(New CrystalParametro("ClienteRFC", Vta.Cliente.RFC)) + params.Add(New CrystalParametro("ClienteRFC", RFCReceptor)) params.Add(New CrystalParametro("FormaPago", Vta.FormaPagoText)) params.Add(New CrystalParametro("Moneda", Vta.Moneda)) params.Add(New CrystalParametro("TipoCambio", Vta.TipoCambio.ToString)) @@ -6454,7 +6477,18 @@ Public Class ClsPaginas Dim NombreArchivoDescarga As String = "" Dim TipoDocumento As String = "" Dim TipoDocumentoRef As String = "" + Dim RFCReceptor As String = "" + If String.IsNullOrEmpty(Vta.RFCReceptor) Then + RFCReceptor = Vta.Cliente.RFC + If Vta.FacturarSucursal Then + If Vta.ClienteSucursal IsNot Nothing Then + RFCReceptor = Vta.ClienteSucursal.RFC + End If + End If + Else + RFCReceptor = Vta.RFCReceptor + End If Dim RutaCBB As String = String.Format("{0}CBB\{1}.jpg", Ruta, Vta.SerieFolio) Dim ImagenCBB As New System.IO.FileInfo(RutaCBB) @@ -6609,7 +6643,7 @@ Public Class ClsPaginas 'Si no tiene CBB, SE GENERA If Not ImagenCBB.Exists AndAlso Vta.CveCliente.ToEntero > 0 Then Dim CBB As New ClbNegBICFDv3_2.ClsNegCBBGenerar() - CBB.GenerarCBB(UsuarioActual.Empresa.RFC, Vta.Cliente.RFC, Vta.Total.ToString.ToDecimal, Vta.FolioFiscal, RutaCBB) + CBB.GenerarCBB(UsuarioActual.Empresa.RFC, RFCReceptor, Vta.Total.ToString.ToDecimal, Vta.FolioFiscal, RutaCBB) End If ImgCBB = String.Format("{0}://{1}:{2}/Empresas/{3}/CBB/{4}.jpg", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa, Vta.SerieFolio) @@ -6630,14 +6664,14 @@ Public Class ClsPaginas params.Add(New ReportParameter("ClienteNombre", If(Vta.ClienteSucursal.ImprimeNombreSucursal = "True", If(Vta.CveClienteSucursal > 0, Vta.ClienteSucursal.Sucursal, Vta.Cliente.Nombre), If(Vta.AtencionA <> "" AndAlso Vta.TipoDocto.Contiene("Ing", "Rem") AndAlso Vta.Cliente.RFC = "XAXX010101000", $"{Vta.Cliente.Nombre}({Vta.AtencionA})", Vta.Cliente.Nombre)))) params.Add(New ReportParameter("ClienteDireccion", ClienteDireccion)) params.Add(New ReportParameter("ClienteLugar", ClienteLugar)) - params.Add(New ReportParameter("ClienteRFC", Vta.Cliente.RFC)) + params.Add(New ReportParameter("ClienteRFC", RFCReceptor)) End If If Vta.CveEmpresaCRM.ToEntero > 0 Then params.Add(New ReportParameter("ClienteCodigo", Vta.Cliente.Codigo)) params.Add(New ReportParameter("ClienteNombre", Vta.Cliente.Nombre)) params.Add(New ReportParameter("ClienteDireccion", ClienteDireccion)) params.Add(New ReportParameter("ClienteLugar", ClienteLugar)) - params.Add(New ReportParameter("ClienteRFC", Vta.Cliente.RFC)) + params.Add(New ReportParameter("ClienteRFC", RFCReceptor)) End If 'TOTALES diff --git a/Ashx/SIGWeb.ashx b/Ashx/SIGWeb.ashx index 43e27b789..d59b4c02d 100644 --- a/Ashx/SIGWeb.ashx +++ b/Ashx/SIGWeb.ashx @@ -35,11 +35,33 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState context.Response.Close() context.Response.End() Else - context.Response.ContentType = "text/plain" + If context.Request("metodo").Contiene("Contabilizapoliza", "RevisaConexion") Then + context.Response.ContentType = "text/json" + Else + context.Response.ContentType = "text/plain" + + End If End If Try Select Case context.Request("metodo") + Case "Contabilizapoliza" + Dim CvePrePoliza As Integer = context.Request("CvePrePoliza").ToString().ToEntero() + Dim CveUsuario As Integer = context.Request("CveUsuario").ToString().ToEntero() + Dim CveEmpresa As Integer = context.Request("CveEmpresa").ToString().ToEntero() + GuardaLog(String.Format("?metodo=Contabilizapoliza&CvePrePoliza={0}&CveUsuario={1}&CveEmpresa ={2}", CvePrePoliza, CveUsuario, CveEmpresa)) + ActualizaPrePoliza(context) + Dim obj As New ADSNetLibrary.SIGAPI.Models.ResponseModel(Of Object)() + obj.Result = DateTime.Now.ToString() + Dim retorno = JsonConvert.SerializeObject(obj).ToString() + context.Response.Write(retorno) + context.Response.StatusCode = 200 + Case "RevisaConexion" + Dim obj As New ADSNetLibrary.SIGAPI.Models.ResponseModel(Of Object)() + obj.Result = DateTime.Now.ToString() + Dim retorno = JsonConvert.SerializeObject(obj).ToString() + context.Response.Write(retorno) + context.Response.StatusCode = 200 Case "getps" GETPS(context) Case "getps2" diff --git a/BinJLC.zip b/BinJLC.zip new file mode 100644 index 000000000..3ae709130 Binary files /dev/null and b/BinJLC.zip differ diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index 509fa9327..2eda03230 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -18225,12 +18225,12 @@ Partial Class Compras_Compras If Version = "3.3" And CveSATPS > 0 Then Dim DrPSSAT As DataRow = Nothing If CargaXml Then - DrPSSAT = GlobalDTPSATPS().FiltroPrimero(String.Format("SATClavePS={0}", CveSATPS)) + DrPSSAT = GlobalDTPSATPS("-1").FiltroPrimero(String.Format("SATClavePS={0}", CveSATPS)) 'If GlobalDTPSATPS().FiltraParametros(String.Format("SATClavePS={0}", CveSATPS)).Rows.Count > 0 Then ' DrPSSAT = GlobalDTPSATPS().FiltraParametros(String.Format("SATClavePS={0}", CveSATPS)).Rows(0) 'End If Else - DrPSSAT = GlobalDTPSATPS().FiltroPrimero(String.Format("SATClavePS={0}", CveSATPS)) + DrPSSAT = GlobalDTPSATPS("-1").FiltroPrimero(String.Format("SATClavePS={0}", CveSATPS)) 'If GlobalDTPSATPS().FiltraParametros(String.Format("CveSATPS={0}", CveSATPS)).Rows.Count > 0 Then ' DrPSSAT = GlobalDTPSATPS().FiltraParametros(String.Format("CveSATPS={0}", CveSATPS)).Rows(0) 'End If diff --git a/Contabilidad/RegPrePoliza1.aspx.vb b/Contabilidad/RegPrePoliza1.aspx.vb index 24a9d6da5..2dbc8e945 100644 --- a/Contabilidad/RegPrePoliza1.aspx.vb +++ b/Contabilidad/RegPrePoliza1.aspx.vb @@ -857,9 +857,9 @@ Partial Class ContabilidadC_RegPrePoliza Next If CvePeriodo > 0 Then - If Not ObjNom.UpdateProvisionNomina(CvePeriodo, CvePrePoliza, UsuarioActual.CveEmpresa) Then - MsgError = "No se pudo actualizar el periodo de la nómina" - End If + 'If Not ObjNom.UpdateProvisionNomina(CvePeriodo, CvePrePoliza, UsuarioActual.CveEmpresa) Then + ' MsgError = "No se pudo actualizar el periodo de la nómina" + 'End If End If If ObjMov.ValidacionPrePolizaCuadre(CvePrePoliza, 1) Then diff --git a/Nomina/Nomina.aspx b/Nomina/Nomina.aspx index c04e8e10c..72004b2fa 100644 --- a/Nomina/Nomina.aspx +++ b/Nomina/Nomina.aspx @@ -156,7 +156,7 @@ - +
  • Autorizar
  • @@ -220,13 +220,13 @@
  • Recibos timbrados
  • -
    - +
    + - +
    @@ -234,7 +234,7 @@ - +
    @@ -335,10 +335,10 @@
    -
    +
    - + @@ -552,14 +552,14 @@ - + @@ -626,7 +626,7 @@
    Fecha Fin - - + + - +
    @@ -2452,7 +2453,7 @@ @@ -2884,13 +2885,13 @@ - + - +
    diff --git a/Nomina/Nomina.aspx.cs b/Nomina/Nomina.aspx.cs index 60b362b2b..94242dff5 100644 --- a/Nomina/Nomina.aspx.cs +++ b/Nomina/Nomina.aspx.cs @@ -396,7 +396,7 @@ public partial class Nomina_Nomina2 : ClsPaginas int CvePrePolizaProvision = drow["CvePrePolizaProvision"].ToString().ToEntero(); int CvePrePolizaProvisionAsimilados = drow["CvePrePolizaAsimilables"].ToString().ToEntero(); LnkConceptoEmpleado.Visible = (Estatus == 1); - LnkRegistrarProvision.Visible = (Estatus >= 2) && CvePrePolizaProvision <= 0; + LnkRegistrarProvision.Visible = (Estatus >= 2);// && CvePrePolizaProvision <= 0; LnkConceptoEmpleado.Visible = (Estatus < 2); LnkCargaAsistenciaMasiva.Visible = (Estatus < 2); LnkModalPlantillaNomina.Visible = (Estatus < 2); @@ -1101,12 +1101,12 @@ public partial class Nomina_Nomina2 : ClsPaginas { Nom.IniciaTransacSQL(); //AutorizaNom_Nominas - if (continuar && (continuar=Nom.RemoveNom_Nominas(Cve))) + if (continuar && (continuar = Nom.RemoveNom_Nominas(Cve))) { Alert("Los movimientos de la nómina fueron eliminados", TipoMensaje.MsgInformacion); cargaDatos(); Nom.Commit(); } - } + } } protected void LnkCancelar_Click(object sender, EventArgs e) @@ -1634,7 +1634,7 @@ public partial class Nomina_Nomina2 : ClsPaginas { using (ClsNominas onom = new ClsNominas()) { - if (continuar=onom.DeleteNom_NominasDetalles(SRCveConcepto, SRCvePersonal, CvePeriodoSeleccionado)) + if (continuar = onom.DeleteNom_NominasDetalles(SRCveConcepto, SRCvePersonal, CvePeriodoSeleccionado)) { } } @@ -2404,7 +2404,7 @@ public partial class Nomina_Nomina2 : ClsPaginas bool isEditedD = e.Row.DataKey("isEditedD").ToEntero() > 0; bool isSavedP = e.Row.DataKey("isSavedP").ToEntero() > 0; bool isSavedD = e.Row.DataKey("isSavedD").ToEntero() > 0; - + //isEditedD // Controles Label LtlConcepto = e.Row.FCLabel("LtlConcepto"); @@ -4509,10 +4509,11 @@ public partial class Nomina_Nomina2 : ClsPaginas decimal montoLimite = TxtMontoLimite.Text.ToDecimal(); string fechaInicioAplicacion = TxtFechaAplicacion.Text.ToDate().ToString("yyyy/MM/dd"); bool estatus = ChkEstatus.Checked; + int CveCuenta =DdlCtaContable.SelectedValue.ToEntero(); bool Continuar; using (ClsNominas ObjMovt = new ClsNominas()) { - Continuar = ObjMovt.AddMovtoPermanente(cveConcepto, SRCvePersonal, descripcion, tipoDescuento, valor, vecesAplicar, montoLimite, fechaInicioAplicacion, estatus); + Continuar = ObjMovt.AddMovtoPermanente(cveConcepto, SRCvePersonal, descripcion, tipoDescuento, valor, vecesAplicar, montoLimite, fechaInicioAplicacion, estatus, CveCuenta); } if (Continuar) @@ -4520,7 +4521,7 @@ public partial class Nomina_Nomina2 : ClsPaginas this.RegistraScript("$('#DModalMovtoPermanente').modal('hide');"); CargaMovtoPermanente(); UpMovtosPermanentes.Update(); - this.Alert("El Movto_Permanente Se ha agregado"); + this.Alert("Se ha agregado el movimiento permanente"); } } @@ -4535,10 +4536,11 @@ public partial class Nomina_Nomina2 : ClsPaginas decimal montoLimite = TxtMontoLimite.Text.ToDecimal(); string fechaInicioAplicacion = TxtFechaAplicacion.Text.ToDate().ToString("yyyy/MM/dd"); bool estatus = ChkEstatus.Checked; + int CveCuenta = DdlCtaContable.SelectedValue.ToEntero(); bool Continuar; using (ClsNominas ObjMovt = new ClsNominas()) { - Continuar = ObjMovt.UpMovtoPermanente(CcveMovtoPermanente, cveConcepto, SRCvePersonal, descripcion, tipoDescuento, valor, vecesAplicar, montoLimite, fechaInicioAplicacion, estatus); + Continuar = ObjMovt.UpMovtoPermanente(CcveMovtoPermanente, cveConcepto, SRCvePersonal, descripcion, tipoDescuento, valor, vecesAplicar, montoLimite, fechaInicioAplicacion, estatus, CveCuenta); } if (Continuar) @@ -4546,7 +4548,7 @@ public partial class Nomina_Nomina2 : ClsPaginas this.RegistraScript("$('#DModalMovtoPermanente').modal('hide');"); CargaMovtoPermanente(); UpMovtosPermanentes.Update(); - this.Alert("El Movto_Permanente Se ha agregado"); + this.Alert("Se ha actualizado el movimiento permanente"); } } @@ -4564,6 +4566,7 @@ public partial class Nomina_Nomina2 : ClsPaginas CcveMovtoPermanente = gvRow.DataKey("CveMovtoPermanente").ToEntero(); int cveConcepto = gvRow.DataKey("CveConcepto").ToEntero(); int cvePersonal = gvRow.DataKey("CvePersonal").ToEntero(); + int CveCuenta = gvRow.DataKey("CveCuenta").ToEntero(); string descripcion = gvRow.DataKey("Descripcion"); int tipoDescuento = gvRow.DataKey("TipoDescuento").ToEntero(); double valor = gvRow.DataKey("Valor").ToDouble(); @@ -4590,6 +4593,8 @@ public partial class Nomina_Nomina2 : ClsPaginas TxtVecesAplicar.Text = vecesAplicar.ToString(); TxtMontoLimite.Text = montoLimite.ToString(); TxtFechaAplicacion.Text = $"{fechaInicioAplicacion:dd/MM/yyyy}"; + DdlCtaContable.SelectedValueExist("-1"); + DdlCtaContable.SelectedValueExist(CveCuenta); ChkEstatus.Checked = estatus; this.RegistraScript("$('#DModalMovtoPermanente').modal();"); @@ -6183,16 +6188,65 @@ public partial class Nomina_Nomina2 : ClsPaginas { using (ClsNominas objnom = new ClsNominas()) { - if (objnom.Autorizaperiodoconta(CvePeriodoSeleccionado, UsuarioActual.CveEmpresa)) + if (objnom.RegistraProvision(CvePeriodoSeleccionado, UsuarioActual.CveEmpresa)) { int CvePrePolizaProvision = 0; int CvePrePolizaasmilidos = 0; - if (objnom.DtResultados.Rows.Count > 0) + if (objnom.DTSetResultados.Tables.Count > 1 && objnom.DTSetResultados.Tables[1].Rows.Count == 0) { - CvePrePolizaProvision = objnom.DtResultados.Rows[0]["CvePrePoliza"].ToString().ToEntero(); - CvePrePolizaasmilidos = objnom.DtResultados.Rows[0]["CvePrePolizaAsimilables"].ToString().ToEntero(); + + if (objnom.DtResultados.Rows.Count > 0) + { + CvePrePolizaProvision = objnom.DtResultados.Rows[0]["CvePrePoliza"].ToString().ToEntero(); + CvePrePolizaasmilidos = objnom.DtResultados.Rows[0]["CvePrePolizaAsimilables"].ToString().ToEntero(); + } + string mensaje = string.Format("La provision a sido autorizada.
    Provision
    ", CvePrePolizaProvision ); + if (CvePrePolizaasmilidos>0) + { + mensaje = string.Format("{0} Asimilados", mensaje, CvePrePolizaasmilidos); + + } + Alert(mensaje); + } + else + { + if (objnom.DTSetResultados.Tables.Count > 1) + { + StringBuilder str = new StringBuilder(); + str.Append(""); + str.Append(""); + //ConceptoContable ConceptoNomina CodigoNombreCompleto + + str.Append(""); + str.Append(""); + str.Append(""); + str.Append(""); + str.Append(""); + foreach (DataRow item in objnom.DTSetResultados.Tables[1].Rows) + { + + str.Append(""); + str.Append(""); + str.Append(""); + str.Append(""); + str.Append(""); + } + str.Append(""); + str.Append("
    "); + str.Append("Concepto Contable"); + str.Append(""); + str.Append("Concepto Nomina"); + str.Append(""); + str.Append("Personal"); + str.Append("
    "); + str.Append(item["ConceptoContable"]); + str.Append(""); + str.Append(item["ConceptoNomina"]); + str.Append(""); + str.Append(item["CodigoNombreCompleto"]); + str.Append("
    "); + Alert(string.Format("
    no se pudo registrar la provisión, existen cuentas sin vincular.
    {0}", str)); + } } - string mensaje = string.Format("La provision a sido autorizada.
    Provision
    Asimilados", CvePrePolizaProvision, CvePrePolizaasmilidos); - Alert(mensaje); } } } @@ -6306,7 +6360,7 @@ public partial class Nomina_Nomina2 : ClsPaginas using (ClsNominas objnom = new ClsNominas()) { - if (objnom.GetDispersiondenomina(CvePeriodoSeleccionado, UsuarioActual.CveEmpresa)) + if (objnom.GetDispersionnomina(CvePeriodoSeleccionado, UsuarioActual.CveEmpresa)) { CrearLayout(objnom.DtResultados); } diff --git a/Nomina/Nomina.aspx.vb b/Nomina/Nomina.aspx.vb deleted file mode 100644 index 435f425a8..000000000 --- a/Nomina/Nomina.aspx.vb +++ /dev/null @@ -1,2545 +0,0 @@ -Imports Extensiones -Imports System.Data -Imports System.Drawing -Imports Microsoft.Reporting.WebForms -Imports System.IO -Imports System.Xml - -Partial Class Nomina_Nomina - Inherits ClsPaginas - -#Region "Propiedades" - - Private Shared CveNominaT As Integer - - 'Local - Private Property DTConceptos As Data.DataTable - Get - Return CType(ViewState("DTConceptos"), Data.DataTable) - End Get - Set(value As Data.DataTable) - ViewState("DTConceptos") = value - End Set - End Property - - Private Property DTResultados As Data.DataTable - Get - Return CType(ViewState("DTResultados"), Data.DataTable) - End Get - Set(value As Data.DataTable) - ViewState("DTResultados") = value - End Set - End Property - - Private ReadOnly Property DTPeriodos As Data.DataTable - Get - Return DirectCast(ViewState("DTPeriodos"), Data.DataTable) - End Get - End Property - - Private Property PermisoAutorizar As Boolean - Get - Return CType(ViewState("PermisoAutorizar"), Boolean) - End Get - Set(value As Boolean) - ViewState("PermisoAutorizar") = value - End Set - End Property - - Private Property PermisoEmitir As Boolean - Get - Return CType(ViewState("PermisoEmitir"), Boolean) - End Get - Set(value As Boolean) - ViewState("PermisoEmitir") = value - End Set - End Property - - Public Property PermisoCancelarEmitido As Boolean - Get - Return CType(ViewState("PermisoCancelarEmitido"), Boolean) - End Get - Set(value As Boolean) - ViewState("PermisoCancelarEmitido") = value - End Set - End Property - - Private ReadOnly Property CvePersonal As Integer - Get - If ViewState("CvePersonal") Is Nothing Then - Return -1 - Else - Return ViewState("CvePersonal").ToString.ToEntero - End If - End Get - End Property - - - 'Private ReadOnly Property CveNomina As Integer - ' Get - ' Return ViewState("CveNomina").ToString.ToEntero - ' End Get - 'End Property - 'Private ReadOnly Property NominaFolio As String - ' Get - ' Return ViewState("NominaFolio").ToString - ' End Get - 'End Property - Private ReadOnly Property FolioFiscal As String - Get - Return ViewState("FolioFiscal").ToString - End Get - End Property - Private ReadOnly Property Ruta As String - Get - Return ModExtensiones.DirectorioBaseEmpresas & "Empresas\" & UsuarioActual.CveEmpresa & "\" - End Get - End Property - Private ReadOnly Property RutaPruebas As String - Get - Return ModExtensiones.DirectorioBaseEmpresas & "Empresas\1\" - End Get - End Property - - Private ReadOnly Property SucCalle As String - Get - Return ViewState("SucCalle").ToString - End Get - End Property - Private ReadOnly Property SucNoExt As String - Get - Return ViewState("SucNoExt").ToString - End Get - End Property - Private ReadOnly Property SucNoInt As String - Get - Return ViewState("SucNoInt").ToString - End Get - End Property - Private ReadOnly Property SucColonia As String - Get - Return ViewState("SucColonia").ToString - End Get - End Property - Private ReadOnly Property SucLocalidad As String - Get - Return ViewState("SucLocalidad").ToString - End Get - End Property - Private ReadOnly Property SucMunicipio As String - Get - Return ViewState("SucMunicipio").ToString - End Get - End Property - Private ReadOnly Property SucEstado As String - Get - Return ViewState("SucEstado").ToString - End Get - End Property - Private ReadOnly Property SucPais As String - Get - Return ViewState("SucPais").ToString - End Get - End Property - Private ReadOnly Property SucCP As String - Get - Return ViewState("SucCP").ToString - End Get - End Property - - Private ReadOnly Property MatCalle As String - Get - Return ViewState("MatCalle").ToString - End Get - End Property - Private ReadOnly Property MatNoExt As String - Get - Return ViewState("MatNoExt").ToString - End Get - End Property - Private ReadOnly Property MatNoInt As String - Get - Return ViewState("MatNoInt").ToString - End Get - End Property - Private ReadOnly Property MatColonia As String - Get - Return ViewState("MatColonia").ToString - End Get - End Property - Private ReadOnly Property MatLocalidad As String - Get - Return ViewState("MatLocalidad").ToString - End Get - End Property - Private ReadOnly Property MatMunicipio As String - Get - Return ViewState("MatMunicipio").ToString - End Get - End Property - Private ReadOnly Property MatEstado As String - Get - Return ViewState("MatEstado").ToString - End Get - End Property - Private ReadOnly Property MatPais As String - Get - Return ViewState("MatPais").ToString - End Get - End Property - Private ReadOnly Property MatCP As String - Get - Return ViewState("MatCP").ToString - End Get - End Property - - 'Private ReadOnly Property DiasPeriodo As Integer - ' Get - ' Return ViewState("DiasPeriodo").ToString.ToEntero - ' End Get - 'End Property - 'Private ReadOnly Property CvePeriodo As Integer - ' Get - ' Return ViewState("CvePeriodo").ToString.ToEntero - ' End Get - 'End Property - - Private ReadOnly Property CvePeriodoSeleccionado As Integer - Get - Return ViewState("CvePeriodoSeleccionado").ToString.ToEntero - End Get - End Property - 'Private ReadOnly Property FechaI As Date - ' Get - ' Return ViewState("FechaI").ToString.ToDate - ' End Get - 'End Property - 'Private ReadOnly Property FechaF As Date - ' Get - ' Return ViewState("FechaF").ToString.ToDate - ' End Get - 'End Property -#End Region - - Partial Public Class ActualizaTimbre - Public Property Estatus As Boolean - Public Property CveNomina As Integer - Public Property CvePAC As Integer - End Class - - Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load - If Not IsPostBack Then - If UsuarioActual.CveEmpresa.Contiene(1, 48, 80, 72, 119, 153, 154, 158) Then - Response.Redirect("/Nomina/Nomina2.aspx") - End If - CargaTiposPeriodo() - CargaProyecto() - CargaTurnos() - CargaEmpresa() - CargaFolios() - LnkCorreos.Visible = False - TxtFechaPago.Text = Now.ToShortDateString - Dim EjercicioActual As Integer = UsuarioActual.Empresa.EjercicioActual - If EjercicioActual = 0 Then - EjercicioActual = DateTime.Now.Year - End If - DdlEjercicios.Items.Add(New ListItem(EjercicioActual.ToString(), EjercicioActual.ToString())) - DdlEjercicios.Items.Add(New ListItem((EjercicioActual - 1).ToString(), (EjercicioActual - 1).ToString())) - - 'Verifica Permisos de Autorizar - If UsuarioActual.TienePermisoProceso(82) Then PermisoAutorizar = True Else PermisoAutorizar = False - 'Verifica Permisos de Timbrar - If UsuarioActual.TienePermisoProceso(83) Then - PermisoEmitir = True - PermisoCancelarEmitido = True - Else - PermisoEmitir = False - PermisoCancelarEmitido = False - End If - - 'If UsuarioActual.Rol = "Administrador AD" Then - ' BtnGeneraPDF.Visible = True - ' BtnActualizaNomina.Visible = True - 'End If - End If - End Sub - -#Region "Carga Datos,Combos, Etc..." - - Private Sub CargaTiposPeriodo() - DdlTipoPeriodo.DataSource = GlobalDTTipoPeriodo.FiltraParametros("Estatus = 'Activo'") - DdlTipoPeriodo.DataBind() - End Sub - - Private Sub CargaPeriodos() - - - If DdlTipoPeriodo.SelectedValue.ToEntero > 0 Then - - Dim ObjPeriodos As New ClsNominas - If ObjPeriodos.GetPeriodos(DdlTipoPeriodo.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, DdlEjercicios.SelectedValue.ToEntero, -1, -1) Then - ViewState("DTPeriodos") = ObjPeriodos.DtResultados.FiltraParametros("Estatus IN (1,2,3,4,5)") - DdlPeriodo.DataSource = DTPeriodos - Else - DdlPeriodo.DataSource = Nothing - End If - ObjPeriodos.Dispose() - - End If - - DdlPeriodo.Items.Clear() - DdlPeriodo.DataBind() - DdlPeriodo.Items.Insert(0, New ListItem("Seleccione", "-1")) - End Sub - - Private Sub CargaProyecto() - DdlProyecto.DataSource = GlobalDTProyectos(UsuarioActual.Empresa.CveEmpresa) - DdlProyecto.DataBind() - End Sub - - Private Sub CargaSubProyecto() - DdlSubProyecto.Items.Clear() - DdlSubProyecto.DataSource = GlobalDTSubProyectos(DdlProyecto.SelectedValue.ToEntero) - DdlSubProyecto.DataBind() - DdlSubProyecto.Items.Insert(0, New ListItem("Todos", "-1")) - End Sub - - Private Sub CargaTurnos() - DdlTurno.DataSource = GlobalDTTurno.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) - DdlTurno.DataBind() - End Sub - - Private Sub CargaEmpresa() - Dim dr As DataRow = Nothing - dr = GlobalDTSubProyectos(-1).FiltroPrimero("SubProyecto = 'MATRIZ' AND Estatus = 'Activo' AND CveEmpresa = " & UsuarioActual.CveEmpresa) - If dr IsNot Nothing Then - - - ViewState("MatCalle") = dr("Calle") - ViewState("MatNoExt") = dr("NoExt") - ViewState("MatNoInt") = dr("NoInt") - ViewState("MatColonia") = dr("Colonia") - ViewState("MatLocalidad") = dr("Localidad") - ViewState("MatMunicipio") = dr("Municipio") - ViewState("MatEstado") = dr("Estado") - ViewState("MatPais") = dr("Pais") - ViewState("MatCP") = dr("CP") - - 'dr = GlobalDTSucursales.FiltroPrimero("CveSucursal = " & ObjCliente.CveSucursal) - ViewState("SucCalle") = dr("Calle") - ViewState("SucNoExt") = dr("NoExt") - ViewState("SucNoInt") = dr("NoInt") - ViewState("SucColonia") = dr("Colonia") - ViewState("SucLocalidad") = dr("Localidad") - ViewState("SucMunicipio") = dr("Municipio") - ViewState("SucEstado") = dr("Estado") - ViewState("SucPais") = dr("Pais") - ViewState("SucCP") = dr("CP") - End If - - End Sub - - Private Sub CargaFolios() - Dim ObjFolios As New ClsGralFolios() - If ObjFolios.GetFolios(TipoDocto:="Nom", CveEmpresa:=UsuarioActual.CveEmpresa) Then - Dim DT As DataTable = ObjFolios.DtResultados.FiltraParametros("Estado = 'Activo'") - If DT.Rows.Count = 1 Then - ViewState("CveFolio") = DT.Rows(0)("CveFolio").ToString.ToEntero - 'ViewState("NumAprobacion") = CLng(DT.Rows(0)("Aprobacion").ToString) - 'ViewState("FechaAprobacion") = DT.Rows(0)("FechaAprobacion").ToString.ToDate - ViewState("FolioActual") = DT.Rows(0)("FActual").ToString - 'BtnAutorizar.Visible = True - 'BtnEmitir.Visible = True - Else - Alert("No tiene registrados Folios para Nómina en esta sucursal.", TipoMensaje.MsgAdvertencia) - 'BtnAutorizar.Visible = False - 'BtnEmitir.Visible = False - End If - DT.Dispose() - End If - ObjFolios.Dispose() - End Sub - - Private Sub CargaDatos() - - VerificaPermisos() - - Dim ObjNomina As New ClsRH - - If ObjNomina.GetNomina2(DdlProyecto.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, DdlTurno.SelectedValue.ToEntero, DdlPeriodo.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, DdlAgrupador.SelectedValue) Then - LnkCorreos.Visible = True - 'Ocultar todas las columnas del grid y prenderlas con forme se vayan llenando - For i As Integer = 1 To GVDatos.Columns.Count - If (i >= 2 And i <= 16) Or (i >= 18 And i <= 32) Or (i >= 35 And i <= 51) Then - GVDatos.Columns(i).Visible = False - End If - Next - - DTConceptos = ObjNomina.DSResultados().Tables(0) - DTResultados = ObjNomina.DSResultados().Tables(1) - ViewState("CvePeriodoSeleccionado") = DdlPeriodo.SelectedValue - Dim P As Integer = 2 - Dim D As Integer = 2 - Dim O As Integer = 2 - - For Each RowConceptos As DataRow In DTConceptos.FiltraParametros("Tipo IN ('P','D','O') AND EsPadre = 1 ").Rows - If RowConceptos("Tipo").ToString = "P" Then - - GVDatos.Columns(P).Visible = True - Dim field As BoundField = DirectCast(GVDatos.Columns(P), BoundField) - GVDatos.Columns(P).Visible = True - field.DataField = RowConceptos("CveConcepto").ToString - field.HeaderText = RowConceptos("Concepto").ToString - - P = P + 1 - ElseIf RowConceptos("Tipo").ToString = "D" Then - - GVDatos.Columns(D + 17).Visible = True - Dim field As BoundField = DirectCast(GVDatos.Columns(D + 17), BoundField) - GVDatos.Columns(D).Visible = True - field.DataField = RowConceptos("CveConcepto").ToString - field.HeaderText = RowConceptos("Concepto").ToString - D = D + 1 - - ElseIf RowConceptos("Tipo").ToString = "O" AndAlso UsuarioActual.CveRol = 1 Then - - GVDatos.Columns(O + 34).Visible = True - Dim field As BoundField = DirectCast(GVDatos.Columns(O + 34), BoundField) - GVDatos.Columns(O).Visible = True - field.DataField = RowConceptos("CveConcepto").ToString - field.HeaderText = If(RowConceptos("Concepto").ToString.Length > 15, RowConceptos("Concepto").ToString.Substring(0, 15), RowConceptos("Concepto").ToString) - O = O + 1 - End If - - Next - If DTResultados.Rows.Count > 0 And DTResultados.Rows(0)("FechaPago").ToString.ToDate > MinFecha Then - TxtFechaPago.Text = DTResultados.Rows(0)("FechaPago").ToString.ToDate.ToShortDateString - End If - If O > 1 AndAlso UsuarioActual.CveRol = 1 Then ' si tiene activadas las obligaciones, que muestre el total - GVDatos.Columns(GVDatos.Columns.Count - 3).Visible = True - End If - - GVDatos.DataSource = DTResultados - Else - GVDatos.DataSource = Nothing - End If - - ObjNomina.Dispose() - - GVDatos.DataBind() - - If GVDatos.Rows.Count > 0 Then - 'Ocultar las columnas donde el total sea cero - Dim tContador As Integer = 0 - For i As Integer = 1 To GVDatos.Columns.Count - If (i >= 1 And i <= 15) Or (i >= 17 And i <= 31) Or (i >= 34 And i <= 49) Then - If GVDatos.Rows(0).Cells(i).Text.ToDecimal = 0 Then - GVDatos.Columns(i).Visible = False - Else - tContador += 1 - End If - End If - Next - GVDatos.Width = Unit.Pixel(350 + 240 + (80 * (tContador)) + 55) - End If - - GVDatos.Columns(1).Visible = True - - UPDatos.Update() - End Sub - - Private Sub VerificaPermisos() - 'verifico los permisos de cada periodo - If DdlPeriodo.SelectedValue.ToEntero > 0 Then - Dim Per As New ClsNominas - - If Per.GetPeriodos(-1, UsuarioActual.CveEmpresa, -1, -1, DdlPeriodo.SelectedValue.ToEntero) Then - Dim dr As DataRow = Per.DtResultados.FiltroPrimero("") - If dr IsNot Nothing Then - Select Case dr("Estatus").ToString().ToEntero() - Case 0 - BtnAutorizar.Visible = False - BtnEmitir.Visible = False - LnkPagoNomina.Visible = False - LnkProvisionNomina.Visible = False - LblFechaPago.Visible = False - DivFechaPago.Visible = False - Case 1 - BtnAutorizar.Visible = True - BtnEmitir.Visible = False - LnkPagoNomina.Visible = False - LnkProvisionNomina.Visible = False - LblFechaPago.Visible = True - DivFechaPago.Visible = True - TxtFechaPago.Text = Now.ToShortDateString - TxtFechaPago.Enabled = True - Case 2 - BtnAutorizar.Visible = True - BtnEmitir.Visible = True - LblFechaPago.Visible = True - DivFechaPago.Visible = True - TxtFechaPago.Text = Now.ToShortDateString - TxtFechaPago.Enabled = True - If dr("CveIE").ToString <> "" Then - LnkPagoNomina.Visible = True - LnkPagoNomina.Text = "Ver Pago" - LnkPagoNomina.Attributes.Add("href", $"../Bancos/IE.aspx?CveIE={dr("CveIE").ToString}") - Else - LnkPagoNomina.Visible = True - LnkPagoNomina.Attributes.Add("href", $"../Bancos/PolizaCheque.aspx?CvePeriodo={DdlPeriodo.SelectedValue.ToEntero}&CveProyecto={DdlProyecto.SelectedValue.ToEntero}&CveSubProyecto={DdlProyecto.SelectedValue.ToEntero}&CveTurno={DdlTurno.SelectedValue.ToEntero}") - End If - - If dr("CvePrePolizaProvision").ToString <> "" Then - LnkProvisionNomina.Visible = True - LnkProvisionNomina.Text = "Ver Provisón" - LnkProvisionNomina.Attributes.Add("href", $"../Contabilidad/RegPrePoliza.aspx?CvePrePoliza={dr("CvePrePolizaProvision").ToString}&Tipo=NOMPROV") - Else - LnkProvisionNomina.Visible = True - LnkProvisionNomina.Attributes.Add("href", $"../Contabilidad/RegPrePoliza.aspx?CvePeriodo={DdlPeriodo.SelectedValue.ToEntero}&CveProyecto={DdlProyecto.SelectedValue.ToEntero}&CveSubProyecto={DdlProyecto.SelectedValue.ToEntero}&CveTurno={DdlTurno.SelectedValue.ToEntero}&Tipo=NOMPROV") - End If - UpnTools.Update() - Case 3 - BtnAutorizar.Visible = True - BtnEmitir.Visible = False - LblFechaPago.Visible = True - DivFechaPago.Visible = True - TxtFechaPago.Text = dr("FechaPago").ToString.ToDate.ToShortDateString - TxtFechaPago.Enabled = False - If dr("CveIE").ToString <> "" Then - LnkPagoNomina.Visible = True - LnkPagoNomina.Text = "Ver Pago" - LnkPagoNomina.Attributes.Add("href", $"../Bancos/IE.aspx?CveIE={dr("CveIE").ToString}") - Else - LnkPagoNomina.Visible = True - LnkPagoNomina.Attributes.Add("href", $"../Bancos/PolizaCheque.aspx?CvePeriodo={DdlPeriodo.SelectedValue.ToEntero}&CveProyecto={DdlProyecto.SelectedValue.ToEntero}&CveSubProyecto={DdlProyecto.SelectedValue.ToEntero}&CveTurno={DdlTurno.SelectedValue.ToEntero}") - End If - - If dr("CvePrePolizaProvision").ToString <> "" Then - LnkProvisionNomina.Visible = True - LnkProvisionNomina.Text = "Ver Provisón" - LnkProvisionNomina.Attributes.Add("href", $"../Contabilidad/RegPrePoliza.aspx?CvePrePoliza={dr("CvePrePolizaProvision").ToString}&Tipo=NOMPROV") - Else - LnkProvisionNomina.Visible = True - LnkProvisionNomina.Attributes.Add("href", $"../Contabilidad/RegPrePoliza.aspx?CvePeriodo={DdlPeriodo.SelectedValue.ToEntero}&CveProyecto={DdlProyecto.SelectedValue.ToEntero}&CveSubProyecto={DdlProyecto.SelectedValue.ToEntero}&CveTurno={DdlTurno.SelectedValue.ToEntero}&Tipo=NOMPROV") - End If - - UpnTools.Update() - Case 4 - - BtnAutorizar.Visible = True - BtnEmitir.Visible = False - LblFechaPago.Visible = True - DivFechaPago.Visible = True - TxtFechaPago.Text = Now.ToShortDateString - TxtFechaPago.Enabled = True - If dr("CveIE").ToString <> "" Then - LnkPagoNomina.Visible = True - LnkPagoNomina.Text = "Ver Pago" - LnkPagoNomina.Attributes.Add("href", $"../Bancos/IE.aspx?CveIE={dr("CveIE").ToString}") - Else - LnkPagoNomina.Visible = True - LnkPagoNomina.Attributes.Add("href", $"../Bancos/PolizaCheque.aspx?CvePeriodo={DdlPeriodo.SelectedValue.ToEntero}&CveProyecto={DdlProyecto.SelectedValue.ToEntero}&CveSubProyecto={DdlProyecto.SelectedValue.ToEntero}&CveTurno={DdlTurno.SelectedValue.ToEntero}") - End If - - If dr("CvePrePolizaProvision").ToString <> "" Then - LnkProvisionNomina.Visible = True - LnkProvisionNomina.Text = "Ver Provisón" - LnkProvisionNomina.Attributes.Add("href", $"../Contabilidad/RegPrePoliza.aspx?CvePrePoliza={dr("CvePrePolizaProvision").ToString}&Tipo=NOMPROV") - Else - LnkProvisionNomina.Visible = True - LnkProvisionNomina.Attributes.Add("href", $"../Contabilidad/RegPrePoliza.aspx?CvePeriodo={DdlPeriodo.SelectedValue.ToEntero}&CveProyecto={DdlProyecto.SelectedValue.ToEntero}&CveSubProyecto={DdlProyecto.SelectedValue.ToEntero}&CveTurno={DdlTurno.SelectedValue.ToEntero}&Tipo=NOMPROV") - End If - UpnTools.Update() - Case 5 - - BtnAutorizar.Visible = True - End Select - - End If - End If - Per.Dispose() - - If PermisoAutorizar And BtnAutorizar.Visible Then BtnAutorizar.Visible = True Else BtnAutorizar.Visible = False - If PermisoEmitir And BtnEmitir.Visible Then BtnEmitir.Visible = True Else BtnEmitir.Visible = False - End If - End Sub -#End Region - -#Region "DDL'S SELECT INDEX CHANGED" - Protected Sub DdlProyecto_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlProyecto.SelectedIndexChanged - CargaSubProyecto() - CargaFolios() - End Sub - - Protected Sub DdlTipoPeriodo_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlTipoPeriodo.SelectedIndexChanged - CargaPeriodos() - CargaFolios() - End Sub - - Protected Sub DdlPeriodo_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlPeriodo.SelectedIndexChanged - If DdlPeriodo.SelectedValue.ToEntero > 0 Then - BtnConsultar.Visible = True - Else - BtnConsultar.Visible = False - End If - End Sub -#End Region - -#Region "BTN'S CLICK" - Protected Sub BtnConsultar_Click(sender As Object, e As System.EventArgs) Handles BtnConsultar.Click - If DdlPeriodo.SelectedValue <> "-1" Then - CargaDatos() - Else - Alert("Debe de seleccionar el Período con el que se desea trabajar", TipoMensaje.MsgAdvertencia) - End If - End Sub - - Protected Sub LnkTimbrar_Click(sender As Object, e As EventArgs) - Dim lnk As LinkButton = DirectCast(sender, LinkButton) - Dim gvRow As GridViewRow = DirectCast(lnk.NamingContainer, GridViewRow) - Dim CvePeriodo As Integer = gvRow.DataKey("CvePeriodo").ToEntero() - Dim CvePersonal As Integer = gvRow.DataKey("CvePersonal").ToEntero() - Dim CveNomina As Integer = gvRow.DataKey("CveNomina").ToEntero() - - Dim lognom As New LogicNominas - - Dim Msg As String = lognom.TimbrarNomina(CveNomina, CvePersonal, CvePeriodo, UsuarioActual) - If Not IsNothing(Msg) AndAlso Msg.Length > 0 Then - Alert(Msg, TipoMensaje.MsgAdvertencia) - - Else - Dim ObjPeriodo As New ClsNominas() - ObjPeriodo.CambiaEstatusPeriodo(CvePeriodo, enumNominasEstatus.Timbrada, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - ObjPeriodo.Dispose() - Alert("Se ha timbrado correctamente") - gvRow.FindControl("ImgDelete").Visible = False - gvRow.FindControl("LnkCancelar").Visible = False - - gvRow.FCImage("ImgBandera").ImageUrl = "/Imagenes/flag_green.png" - gvRow.ForeColor = Color.Green - lnk.Visible = False - End If - End Sub - Protected Sub ImgDelete_Click(sender As Object, e As EventArgs) - Dim Cve As Integer = DirectCast(sender, LinkButton).CommandArgument.ToEntero - - Dim Nom As New ClsNominas - If Nom.RemoveNom_Nominas(Cve) Then - Alert("Los Movimientos de la Nómina fueron eliminados", TipoMensaje.MsgInformacion) - CargaDatos() - End If - Nom.Dispose() - - End Sub - - - Protected Sub ImgCancelar_Click(sender As Object, e As EventArgs) - Dim CveNomina As Integer = DirectCast(sender, LinkButton).CommandArgument.ToEntero - - - If CveNomina > 0 Then - Dim Nom As New ClsNominas - If Nom.GetNom_Nominas(CveNomina, -1, -1, -1, UsuarioActual.CveEmpresa) Then - Dim ObjTimbrado As New Timbrado - - Dim FolioFiscal As String = Nom.FolioFiscal - Dim Total As Decimal = Nom.Total - Dim RFCReceptor As String = Nom.RFC - Dim RFCEmisor As String = UsuarioActual.Empresa.RFC - - - If ObjTimbrado.CFDICancelar(UsuarioActual.Empresa, FolioFiscal, Total, RFCReceptor, RFCEmisor) Then - Nom.UpdateEstatusNomNominas(2, UsuarioActual.Empresa.CvePAC, "", "", ("01/01/2000").ToDate, CveNomina, 0, 0, 0, 0, 0) - - Alert("La nómina con folio fiscal fue cancelada ante el SAT", TipoMensaje.MsgInformacion) - End If - - End If - - - Nom.Dispose() - - CargaDatos() - End If - - - End Sub - - Private Sub ImgExcel_Click(sender As Object, e As EventArgs) Handles ImgExcel.Click - - GVDatos.Columns(0).Visible = False - - GVDatos.ExportToExcel("Nomina") - - GVDatos.Columns(0).Visible = True - - - End Sub - - - Protected Sub BtnAutorizar_Click(sender As Object, e As EventArgs) Handles BtnAutorizar.Click - 'DTConceptos - 'DTResultados - ' Dim CvePeriodo As Integer - If Not (DdlAgrupador.SelectedValue = "1" AndAlso DdlProyecto.SelectedValue = "-1" AndAlso DdlSubProyecto.SelectedValue = "-1" AndAlso DdlTurno.SelectedValue = "-1") Then - Alert("Seleccione el agrupador Empresa y limpie los filtros", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - - Dim Errores As Boolean = False - - Dim objAsistencias As New ClsRH - 'Checar la existencia de este personal - If objAsistencias.GetAsistenciasPeriodo(CvePeriodoSeleccionado, UsuarioActual.CveEmpresa) Then - If objAsistencias.DtResultados.COUNT("CvePersonal", "Asistencias <> DiasPeriodo") = 0 Then - For Each Row As DataRow In DTResultados.FiltraParametros("CvePersonal > 0").Rows - Dim objNomina As New ClsNominas - Dim CveNomina As Integer = Row("CveNomina").ToString.ToEntero - Dim CvePersonal As Integer = Row("CvePersonal").ToString.ToEntero - Dim NombrePersonal As String = Row("Nombre").ToString - Dim CveMetodoPago As Integer = Row("CveMetodoPago").ToString.ToEntero - - If CveNomina = 0 Then - objNomina.IniciaTransacSQL() - Errores = False - - Dim SubTotal As Double = Row("SumaPercepciones").ToString.ToDouble - Dim Total As Double = Row("Total").ToString.ToDouble - Dim CveMoneda As Integer = 1 - 'RMF, verificar este ciclo, que no debe de ir - 'For i As Integer = 0 To GVDatos.Rows.Count - 1 - ' If GVDatos.Rows(i).FCLabel("LblCvePersonal").Text.ToEntero = CvePersonal Then - ' CveNomina = GVDatos.Rows(i).DataKey("CveNomina").ToEntero '.FCLabel("LblCveNomina").Text.ToEntero - ' SubTotal = GVDatos.Rows(i).Cells(16).Text.ToDecimal - ' Total = GVDatos.Rows(i).Cells(28).Text.ToDecimal - ' Exit For - ' End If - 'Next - - If objNomina.AddNom_Nominas(-1, 1, CvePersonal, CvePeriodoSeleccionado, SubTotal, 0, 0, Total, CveMoneda, 1, CveMetodoPago, Now, "Deducciones nómina", - "", "", "", "", 0, 0, 0, New Date, New Date, New Date, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then - - CveNomina = objNomina.CveNomina - 'recorro los conceptos y saco el valor - For Each drr As DataRow In DTConceptos.Rows - - - Dim Importe As Decimal = Row(drr("CveConcepto").ToString).ToString.ToDecimal - Dim ImporteExento As Decimal = Row(String.Format("{0}-E", drr("CveConcepto"))).ToString.ToDecimal - Dim ImporteGravado As Decimal = Row(String.Format("{0}-G", drr("CveConcepto"))).ToString.ToDecimal - - Dim CveConcepto As Integer = drr("CveConcepto").ToString.ToEntero - - 'If Importe > 0 OrElse drr("CveSATConcepto").ToString.ToEntero > 0 Then - 'JLL Se quita el OrElse, siempre que el importe sea mayor a cero debe ingresarse - If Importe > 0 OrElse drr("Obligatorio").ToString = "True" Then - Errores = Not objNomina.AddNom_NominasDetalles(objNomina.CveNomina, CvePeriodoSeleccionado, CvePersonal, CveConcepto, Importe, ImporteGravado, ImporteExento) - End If - - If Errores Then Exit For - - Next - - 'RECORRO LOS CONCEPTOS OBLIGATORIOS QUE DEBE DE HABER EN LAS AUTORIZACIONES COMO SUELDO - 'For Each drr As DataRow In GlobalDTNomConceptos(UsuarioActual.CveEmpresa).FiltraParametros("Obligatorio = True").Rows - ' Errores = Not objNomina.AddNom_NominasDetalles(objNomina.CveNomina, CvePeriodoSeleccionado, CvePersonal, drr("CveConcepto").ToString.ToEntero, 0, 0, 0) - 'Next - - ''Inicia del 9, porque anteriores a esa son columnas fijas, y apartir de alli inician las columnas variables - 'For i As Integer = 9 To DTResultados.Columns.Count - 1 - ' Dim Importe As Decimal = Row(i).ToString.ToDecimal - ' Dim ImporteExento As Decimal = Row(i + 1).ToString.ToDecimal - ' Dim ImporteGravado As Decimal = Row(i + 2).ToString.ToDecimal - - ' Dim CveConcepto As Integer = DTResultados.Columns(i).ColumnName.ToEntero - - ' If Importe > 0 Then - ' Errores = Not objNomina.AddNom_NominasDetalles(objNomina.CveNomina, CvePeriodo, CvePersonal, CveConcepto, Importe, ImporteGravado, ImporteExento) - ' End If - - - ' If Errores = True Then - ' Exit For - ' End If - - ' i = i + 2 - 'Next - Else - Errores = True - End If - - If Errores = False Then - objNomina.Commit() - - Else - objNomina.RollBack() - End If - End If - - - objNomina.Dispose() - Next - - 'ACTUALIZO EL PERIODO, COMO AUTORIZADO, RMF, QUE ME REGRESE SI EST[A COMPLETA LA NOMINA AUTORIZADA O FALTAN EMPLEADOS - - If Errores = False Then - Dim ObjPeriodo As New ClsNominas - If ObjPeriodo.CambiaEstatusPeriodo(CvePeriodoSeleccionado, enumNominasEstatus.Autorizada, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) And ObjPeriodo.UpdatePeriodoFechaPago(CvePeriodoSeleccionado, TxtFechaPago.Text.ToDate) Then - BtnEmitir.Visible = True - Dim temp As String = DdlPeriodo.SelectedValue - CargaPeriodos() - DdlPeriodo.SelectedValue = temp - End If - ObjPeriodo.Dispose() - - End If - - BtnConsultar_Click(New Object, New EventArgs) - Else - Dim Msg As String = String.Empty - Dim StrErrores As New StringBuilder - - For Each Row As DataRow In objAsistencias.DtResultados.FiltraParametros("Asistencias <> DiasPeriodo").Rows - StrErrores.AppendFormat("- {0}, {1} de {2}
    ", Row("Nombre"), Row("Asistencias"), Row("DiasPeriodo")) - Next - - Alert("No se pudo autorizar el siguiente personal por no tener completas las asistencias:

    " & StrErrores.ToString, TipoMensaje.MsgAdvertencia) - End If - End If - objAsistencias.Dispose() - - End Sub - - Protected Sub BtnEmitir_Click(sender As Object, e As EventArgs) Handles BtnEmitir.Click - If False Then 'UsuarioActual.CveUsuario <> 100 AndAlso (Now.Hour > 7 And Now.Hour <18) Then - Alert("Los servicios de timbrado de nómina del PAC no están disponibles. Favor de intentarlo más tarde.", TipoMensaje.MsgError) - Else - - If Not (DdlAgrupador.SelectedValue = "1" AndAlso DdlProyecto.SelectedValue = "-1" AndAlso DdlSubProyecto.SelectedValue = "-1") Then - Alert("Seleccione el agrupador Empresa y limpie los filtros", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - 'Dim StrErrores As New StringBuilder - Dim Msg As String = String.Empty - 'Dim CvePeriodo As Integer - - Dim noCiclos As Integer = 0 - Dim noTotal As Integer = DTResultados.FiltraParametros("CvePersonal > 0 and SeTimbro = False AND SerieFolio <> ''").Rows.Count - - 'For Each Row As DataRow In DTResultados.FiltraParametros("CvePersonal > 0 and SeTimbro = False AND SerieFolio <> ''").Rows - ' If noCiclos < 4 Then - ' noCiclos = noCiclos + 1 - ' Dim CveNomina As Integer = Row("CveNomina").ToString.ToEntero - ' Dim CvePersonal As Integer = Row("CvePersonal").ToString.ToEntero - - ' Dim SerieFolio As String = Row("SerieFolio").ToString - - ' CvePeriodo = Row("CvePeriodo").ToString.ToEntero - - ' If CveNomina > 0 Then - - ' If DdlEjercicios.SelectedValue.ToEntero < 2017 Then - ' Msg = "No se puede timbrar del 2017" - ' ' Msg = TimbrarNomina11(CveNomina, CvePersonal, CvePeriodo) - ' Else - ' Msg = TimbrarNomina12(CveNomina, CvePersonal, CvePeriodo) - ' End If - - ' 'If Msg = "" Then - ' ' Dim NombreComercial As String = UsuarioActual.Empresa.Empresa - ' ' Dim Destinatario As String = Row("Mail").ToString - ' ' Dim Personal As String = Row("Nombre").ToString - - ' ' Dim objNommina As New ClsNominas - ' ' objNommina.GetPeriodos(-1, UsuarioActual.Empresa.CveEmpresa, -1, -1, Periodo) - ' ' Dim DT As DataTable = objNommina.DtResultados - - ' ' Dim FechaI = DT.Rows(0)("FechaInicio").ToString.ToDate.ToShortDateString - ' ' Dim FechaF = DT.Rows(0)("FechaFin").ToString.ToDate.ToShortDateString - - - ' ' MandaCorreo(NombreComercial, SerieFolio, Destinatario, Personal, FechaI, FechaF) - ' 'End If - - ' If Msg.Trim <> String.Empty Then StrErrores.Append(Msg & "
    ") - ' End If - ' Else - ' Exit For - ' End If - 'Next - 'GC.Collect() - 'StrErrores.ToString().GuardaLog() - - - 'If StrErrores.ToString <> "" Then - ' Alert($" Ocurrieron los siguientes errores al timbrar:
    {StrErrores.ToString()}
    {noCiclos} timbres de {noTotal}", TipoMensaje.MsgError) - 'Else - Alert($" Se ha generado su solicitud de timbre un vez procesada se le enviara un correo con los resultados.
    ", TipoMensaje.MsgInformacion) - If DdlTurno.SelectedValue = "-1" Then - Dim ObjPeriodo As New ClsNominas() - ObjPeriodo.CambiaEstatusPeriodo(CvePeriodoSeleccionado, enumNominasEstatus.PorAutorizar, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - ObjPeriodo.Dispose() - 'EnvioMasivoCorreo() - Dim temp As String = DdlPeriodo.SelectedValue - CargaPeriodos() - BtnEmitir.Visible = False - DdlPeriodo.SelectedValue = temp - End If - 'End If - - - 'If StrErrores.ToString <> "" Then - ' Alert($"Ocurrieron los siguientes errores al timbrar:
    {StrErrores.ToString}", TipoMensaje.MsgError) - 'Else - ' Alert("La Nómina Se Timbró correctamente.", TipoMensaje.MsgInformacion) - ' 'RMF. se debe de actualizar el estatus de la nomina y activar el siguiente periodo al estatus activo - - ' 'condicion temporal, para filtrar por filtro y timbrar por partes y no marque timeout - ' If DdlTurno.SelectedValue = "-1" Then - ' Dim ObjPeriodo As New ClsNominas - ' ObjPeriodo.CambiaEstatusPeriodo(CvePeriodoSeleccionado, 3, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - ' ObjPeriodo.Dispose() - ' EnvioMasivoCorreo() - ' Dim temp As String = DdlPeriodo.SelectedValue - ' CargaPeriodos() - ' DdlPeriodo.SelectedValue = temp - ' End If - - 'End If - - CargaDatos() - UPDatos.Update() - End If - - End Sub - - Private Sub MandaCorreo(NombreComercial As String, SerieFolio As String, Destinatario As String, Optional Personal As String = "", Optional FechaI As String = "", Optional FechaF As String = "", Optional CvePeriodo As Integer = -1, Optional CvePersonal As Integer = -1) - - Dim RutaXml As String = String.Format("{0}\XML\Nomina\{1}.xml", UsuarioActual.Empresa.Ruta, SerieFolio) - Dim RutaPdf As String = String.Format("{0}\PDF\Nomina\{1}.pdf", UsuarioActual.Empresa.Ruta, SerieFolio) - - If Destinatario.Length > 0 Then - - Dim Correo As New ClsSisMail() - Dim Asunto As String = "Comprobante de Nómina" - Dim Cuerpo As New StringBuilder - - Cuerpo.AppendFormat("Estimado {0}
    Por este medio le hacemos llegar los comprobantes fiscales de su nomina, correspondiente al periodo del {1} al {2}

    ", Personal, FechaI, FechaF) - Cuerpo.AppendFormat("
    {0}", NombreComercial) - - Dim Xml As New ClsSisMail.ArchivoMail - Dim Pdf As New ClsSisMail.ArchivoMail - Dim ListaAdjuntos As New List(Of ClsSisMail.ArchivoMail) - - If File.Exists(RutaXml) Then - Xml.ArchivoBinario() = File.ReadAllBytes(RutaXml) - Xml.Ruta = "" - - Xml.NombreArchivo = New FileInfo(SerieFolio + ".Xml").Name - - ListaAdjuntos.Add(Xml) - End If - - If Not File.Exists(RutaPdf) Then - GeneraPDFNomina(CvePersonal, CvePeriodo, UsuarioActual.CveEmpresa, UsuarioActual.Empresa.Ruta) - End If - - If File.Exists(RutaPdf) Then - Pdf.ArchivoBinario() = File.ReadAllBytes(RutaPdf) - Pdf.Ruta = "" - - Pdf.NombreArchivo = New FileInfo(SerieFolio + ".Pdf").Name - - ListaAdjuntos.Add(Pdf) - End If - - - If ListaAdjuntos.Count > 0 Then - If Correo.SendMail(UsuarioActual.Empresa, Destinatario, Asunto, Cuerpo.ToString, Archivos:=ListaAdjuntos) Then - ' Alert("Correo enviado existosamente a " & Destinatario) - Else - ' Alert("Se presento un error al enviar el correo a " & Destinatario) - End If - Else - If Correo.SendMail(UsuarioActual.Empresa, Destinatario, Asunto, Cuerpo.ToString) Then - ' Alert("Correo enviado existosamente a " & Destinatario) - Else - ' Alert("Se presento un error al enviar el correo a " & Destinatario) - End If - End If - Else - - End If - - End Sub - - Protected Sub BtnGeneraPDF_Click(sender As Object, e As EventArgs) Handles BtnGeneraPDF.Click - - Dim objPersonal As New ClsRH - Dim objNomina As New ClsNominas - - For Each Row As DataRow In DTResultados.FiltraParametros("CvePersonal > 0 AND SeTimbro = True ").Rows - 'Dim CveNomina As Integer = Row("CveNomina").ToString.ToEntero - 'Dim CvePersonal As Integer = Row("CvePersonal").ToString.ToEntero - 'Dim CvePeriodo As Integer = Row("CvePeriodo").ToString.ToEntero - - If Row("CveNomina").ToString.ToEntero > 0 Then - - - objPersonal.GetPersonal(Row("CvePersonal").ToString.ToEntero, UsuarioActual.CveEmpresa) - objNomina.GetNom_Nominas(Row("CveNomina").ToString.ToEntero, Row("CvePersonal").ToString.ToEntero, Row("CvePeriodo").ToString.ToEntero, -1, UsuarioActual.CveEmpresa) - - If objNomina.Folio > 0 Then - 'GeneraPDF(String.Format("{0}XML\Nomina\{1}-{2}.xml", Ruta, objNomina.Serie, objNomina.Folio), Row("CvePersonal").ToString.ToEntero, Row("CvePeriodo").ToString.ToEntero, objPersonal.FormatoReciboCFDi) - Else - Alert("Error", TipoMensaje.MsgError) - End If - - - End If - Next - - objNomina.Dispose() - objPersonal.Dispose() - objNomina = Nothing - objPersonal = Nothing - - End Sub - - Protected Sub BtnActualizaNomina_Click(sender As Object, e As EventArgs) Handles BtnActualizaNomina.Click - Dim objNomina As New ClsNominas - 'saco el nombre de la columna ISR, - Dim SubTotal, Deducciones, ISR As Double - Dim Total As Double - Dim ColISR As String = "" - - Dim dr As DataRow = DTConceptos.FiltroPrimero("CveSATConcepto = 3") 'saco los tipo ISR - If dr IsNot Nothing Then - ColISR = dr("CveConcepto").ToString - End If - For Each Row As DataRow In DTResultados.FiltraParametros("CvePersonal > 0 AND CveNomina > 0").Rows - - - SubTotal = Row("SumaPercepciones").ToString.ToDouble - Total = Row("Total").ToString.ToDouble - Deducciones = Row("SumaDeducciones").ToString.ToDouble - ISR = Row(String.Format("{0}", ColISR)).ToString.ToDouble - Deducciones = Deducciones - ISR - - If objNomina.UpdateTotalesNominas(SubTotal, Deducciones, ISR, Total, Row("CveNomina").ToString.ToEntero) Then - - End If - - - Next - objNomina.Dispose() - End Sub - -#End Region - -#Region "GvDatos" - Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVDatos.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - If e.Row.DBCampo("Turno") = "" AndAlso e.Row.DBCampo("Nombre") = "" AndAlso e.Row.DBCampo("SubProyecto") <> "" Then - e.Row.FCLiteral("LtlNombre").Text = String.Format("Sub Proyecto: {0}", e.Row.DBCampo("SubProyecto")) - - e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left - - ElseIf e.Row.DBCampo("Turno") <> "" AndAlso e.Row.DBCampo("Nombre") = "" Then - e.Row.FCLiteral("LtlNombre").Text = String.Format("Turno: {0}", e.Row.DBCampo("Turno")) - - e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left - - Else - e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left - e.Row.FCLiteral("LtlNombre").Text = String.Format("{1}", e.Row.DBCampo("CvePersonal"), e.Row.DBCampo("Nombre")) - End If - - If e.Row.DBCampo("Turno") = "" AndAlso e.Row.DBCampo("Nombre") = "" AndAlso e.Row.DBCampo("SubProyecto") = "" Then - e.Row.FCLiteral("LtlNombre").Text = "Total General" - e.Row.CssClass = "SubTotales" - e.Row.Cells(0).Text = "" - End If - e.Row.FindControl("LnkTimbrar").Visible = (e.Row.DBCampo("CveNomina").ToEntero > 0 AndAlso e.Row.DBCampo("SeTimbro").ToString = "False") - 'Visible='<%# If(Eval("CveNomina").ToString <> "" And Eval("SeTimbro").ToString = "False", True, False)%>' - If e.Row.DBCampo("CveNomina").ToEntero > 0 And e.Row.DBCampo("CvePersonal").ToEntero > 0 Then - e.Row.FCImage("ImgBandera").Visible = True - If e.Row.DBCampo("SeTimbro").ToString = "True" Then - e.Row.FCImage("ImgBandera").ImageUrl = "/Imagenes/flag_green.png" - e.Row.ForeColor = Color.Green - Else - e.Row.FCImage("ImgBandera").ImageUrl = "/Imagenes/flag_red.png" - e.Row.ForeColor = Color.Blue - End If - End If - End If - - - End Sub - -#End Region - -#Region "P D F" - Private Sub GeneraPDF(CveNomina As Integer, CvePersonal As Integer, CvePeriodo As Integer, FechaCFDi As DateTime, FolioFiscal As String, NoSerieCertificado As String, FechaCertificacion As DateTime, NoSerieCertificadoContribuyente As String, - SelloCFDi As String, SelloSAT As String, CBB As String, RutaXML As String, EsVistaPrevia As Boolean, CadenaOriginalCFD As String, FormatoReciboCFDi As String) - End Sub - - Private Sub GeneraPDFNuevo(PathXML As String, CvePersonal As Integer, CvePeriodo As Integer) - - Dim ObjNomina As New ClsNominas - Dim objPersonal As New ClsRH - Dim TieneError = False - - - - If Not ObjNomina.GetNom_Nominas(-1, CvePersonal, CvePeriodo, -1, UsuarioActual.CveEmpresa) Then - Alert("Ocurrio un erro al obtener datos de la nomina", TipoMensaje.MsgError) - objPersonal.Dispose() - ObjNomina.Dispose() - Exit Sub - End If - - - Dim CveNomina = ObjNomina.CveNomina - Dim dtPercepciones As Data.DataTable - Dim dtDeducciones As Data.DataTable - - Dim FechaEmision, FechaCertificacion As DateTime - Dim FolioFiscal, NoSerieCertificado, NoSerieCertificadoContribuyente, SelloCFDi, SelloSAT As String - FolioFiscal = "" - NoSerieCertificado = "" - SelloCFDi = "" - SelloSAT = "" - NoSerieCertificadoContribuyente = "" - - Dim SerieFolio = String.Format("{0}-{1}", ObjNomina.Serie, ObjNomina.Folio) - Dim RutaCBB As String = Ruta & "CBB\" & SerieFolio & ".jpg" - - Dim ImagenCBB As New System.IO.FileInfo(RutaCBB) - - Dim ImgCBB = String.Format("{0}://{1}:{2}/Empresas/{3}/CBB/Nomina/{4}.jpg", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa, SerieFolio) - Dim RutaFormato As String = String.Format("{0}Formatos\Nomina.rdlc", UsuarioActual.Empresa.Ruta) - Dim RutaFormatoDefault As String = String.Format("Empresas\Grales\Formatos\Nomina.rdlc") - - - 'SI ESTA TIMBRADA - CON XML - If System.IO.File.Exists(PathXML) Then - Dim XmlDoc As New System.Xml.XmlDocument - 'XmlDoc.Load(Ruta & "XML\\Nomina\NOM A-3845.xml") - XmlDoc.Load(PathXML) - - FechaEmision = XmlDoc.DocumentElement.Attributes("fecha").InnerText.ToDate - NoSerieCertificadoContribuyente = XmlDoc.DocumentElement.Attributes("noCertificado").InnerText - - For i As Integer = 0 To XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes.Count - 1 - If XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Name = "tfd:TimbreFiscalDigital" Then - FolioFiscal = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("UUID").InnerText - NoSerieCertificado = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("noCertificadoSAT").InnerText - FechaCertificacion = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("FechaTimbrado").InnerText.ToDate - SelloCFDi = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("selloCFD").InnerText - SelloSAT = XmlDoc.DocumentElement("cfdi:Complemento").ChildNodes(i).Attributes("selloSAT").InnerText - - End If - Next - - 'SIN TIMBRAR - SIN XML - Else - FolioFiscal = "Sin Timbrar" - NoSerieCertificado = "Sin Timbrar" - SelloCFDi = "Sin Timbrar" - SelloSAT = "Sin Timbrar" - End If - - Dim CadenaOriginalCFD As String = "||1.0|" + FolioFiscal + "|" + FechaCertificacion.ToString("yyyy-MM-dd") + "T" + FechaCertificacion.ToString("HH:mm:ss") + "|" + SelloCFDi + "|" + NoSerieCertificado + "||" - - Dim params As New List(Of ReportParameter) - - - 'DATOS DEL EMPLEADO - If objPersonal.GetPersonal(CvePersonal, UsuarioActual.CveEmpresa) Then - Dim Departamento As DataRow = GlobalDTDepartamentos().FiltraParametros("CveDepartamento = " & objPersonal.CveDepartamento)(0) - Dim Puesto As DataRow = GlobalDTRHPuestos(UsuarioActual.CveEmpresa).FiltraParametros($"CvePuesto = {objPersonal.CvePuesto}")(0) - Dim TipoContrato As DataRow = GlobalDTTiposContrato().FiltraParametros("CveTipoContrato = " & objPersonal.CveTipoContrato.ToString)(0) - - params.Add(New ReportParameter("NoEmpleado", objPersonal.Codigo)) - params.Add(New ReportParameter("RFC", objPersonal.RFC)) - params.Add(New ReportParameter("CURP", objPersonal.CURP)) - - params.Add(New ReportParameter("NombreCompleto", objPersonal.NombreCompleto)) - params.Add(New ReportParameter("Regimen", objPersonal.RegimenContratacion)) - params.Add(New ReportParameter("RiesgoPuesto", objPersonal.RiesgoPuesto)) - - params.Add(New ReportParameter("NSS", objPersonal.NumeroSS)) - params.Add(New ReportParameter("Departamento", Departamento("Departamento").ToString)) - params.Add(New ReportParameter("Puesto", Puesto("Puesto").ToString)) - - params.Add(New ReportParameter("Contrato", TipoContrato("TipoContrato").ToString)) - - params.Add(New ReportParameter("Jornada", objPersonal.Jornada)) - params.Add(New ReportParameter("Periodo", ObjNomina.TipoPeriodo)) - params.Add(New ReportParameter("SalarioBase", objPersonal.SalarioDiario)) - params.Add(New ReportParameter("SalarioDiarioInt", objPersonal.SDI)) - - params.Add(New ReportParameter("Banco", objPersonal.Banco)) - params.Add(New ReportParameter("CLABE", objPersonal.CLABE)) - Else - TieneError = True - End If - - - 'DATOS NOMINA - If Not TieneError Then - If ObjNomina.GetNom_Nominas(CveNomina, CvePersonal, CvePeriodo, -1, UsuarioActual.CveEmpresa) Then - params.Add(New ReportParameter("ReciboNomina", ObjNomina.Folio.ToString)) - params.Add(New ReportParameter("Serie", ObjNomina.Serie)) - params.Add(New ReportParameter("Fecha", ObjNomina.Fecha)) - params.Add(New ReportParameter("Periodo", ObjNomina.TipoPeriodo)) - - params.Add(New ReportParameter("DiasPagados", ObjNomina.DiasPagados.ToString)) - params.Add(New ReportParameter("MetodoPago", ObjNomina.MetodoPago)) - params.Add(New ReportParameter("FormaPago", ObjNomina.FormaPago)) - - params.Add(New ReportParameter("Cantidad", "1")) - params.Add(New ReportParameter("Unidad", "SERVICIO")) - params.Add(New ReportParameter("Descripcion", "Pago de nómina")) - params.Add(New ReportParameter("PU", ObjNomina.SubTotal)) - params.Add(New ReportParameter("Importe", ObjNomina.SubTotal)) - - params.Add(New ReportParameter("SubTotal", ObjNomina.SubTotal)) - params.Add(New ReportParameter("Descuentos", ObjNomina.Descuento)) - params.Add(New ReportParameter("ISR", ObjNomina.RetISR)) - params.Add(New ReportParameter("Total", ObjNomina.Total)) - - - params.Add(New ReportParameter("ImporteLetra", ObjNomina.Total.ToString.ToDouble.Texto2Letras)) - params.Add(New ReportParameter("Clave", "")) - Else - TieneError = True - End If - End If - - - If Not TieneError Then - If ObjNomina.GetPeriodos(-1, UsuarioActual.CveEmpresa, -1, -1, CvePeriodo) Then - params.Add(New ReportParameter("FechaInicio", ObjNomina.FechaInicio.ToString("dd/MM/yyyy"))) - params.Add(New ReportParameter("FechaFin", ObjNomina.FechaFin.ToString("dd/MM/yyyy"))) - Else - TieneError = True - End If - End If - - - 'Timbrado - params.Add(New ReportParameter("FolioFiscal", FolioFiscal)) - params.Add(New ReportParameter("CertificadoSAT", NoSerieCertificado)) - params.Add(New ReportParameter("FechaCertificacion", FechaCertificacion)) - params.Add(New ReportParameter("SelloDigitalEmisor", SelloCFDi)) - params.Add(New ReportParameter("SelloDigitalSAT", SelloSAT)) - params.Add(New ReportParameter("CadenaOriginal", CadenaOriginalCFD)) - params.Add(New ReportParameter("QR", ImgCBB)) - - 'PERCECIONES - DEDUCCIONES - If ObjNomina.GetNom_NominasDetalles(CveNomina, CvePersonal, CvePeriodo, "-1") Then - dtPercepciones = ObjNomina.DtResultados.FiltraParametros("Tipo = 'P' AND EsPadre = 1") - dtDeducciones = ObjNomina.DtResultados.FiltraParametros("Tipo = 'D' AND EsPadre = 1 ") - Else - dtPercepciones = Nothing - dtDeducciones = Nothing - End If - - - - Dim lrds As New List(Of ReportDataSource) - Dim rds As New ReportDataSource - rds.Name = "DsOC" - rds.Value = dtPercepciones - lrds.Add(rds) - - Dim rds1 As New ReportDataSource - rds1.Name = "DataSet1" - rds1.Value = dtDeducciones - lrds.Add(rds1) - Dim Archivo As New System.IO.FileInfo(RutaFormato) - - If Not TieneError Then - If Archivo.Exists Then - 'ImprimirPDF(String.Format("{0}Formatos\Nomina.rdlc", UsuarioActual.Empresa.Ruta), lrds, params, String.Format("Nomina {0}-{1}", ObjNomina.Serie.ToString, ObjNomina.Folio.ToString)) - StreamPDF(String.Format("{0}Formatos\Nomina.rdlc", UsuarioActual.Empresa.Ruta), lrds, params, String.Format("Nomina {0}-{1}", ObjNomina.Serie.ToString, ObjNomina.Folio.ToString)) - End If - Else - Alert("Ocurrio un error al obtener los datos de la Nomina") - End If - - - - ObjNomina.Dispose() - objPersonal.Dispose() - End Sub - -#End Region - -#Region "TIMBRADO" - - Private Function TimbrarNomina12(CveNomina As Integer, CvePersonal As Integer, CvePeriodo As Integer) As String - Dim Retorno As String = "" - UsuarioActual.Empresa.CvePAC = 2 - Dim sw As New Diagnostics.Stopwatch - sw.Start() - Select Case UsuarioActual.Empresa.CvePAC - Case 1 - Retorno = False 'TimbrarBIInformNomina12(CveNomina, CvePersonal, CvePeriodo) - Case 2 - Dim cfdi As CFDITimbre = PreTimbrar(CveNomina, CvePersonal, CvePeriodo) - If cfdi IsNot Nothing AndAlso cfdi.Mensaje = "" Then - Dim ObjTimbrado As New Timbrado - Dim ObjFactura As New Modelos.Factura - ObjFactura.TipoDocto = "Nomina" - ObjFactura.Folio = cfdi.Comprobante.Folio - ObjFactura.Serie = cfdi.Comprobante.Serie - ObjFactura.Timbre = cfdi - If Not ObjTimbrado.TimbrarFactura(UsuarioActual, ObjFactura, 4) Then - Retorno = ObjTimbrado.MensajeErrorCFDI - End If - - 'Retorno = TimbrarFacturaRealVirtual(cfdi, UsuarioActual) - If Retorno <> "" Then - Retorno = $"{Retorno} - {cfdi.Receptor.Nombre}" - Else - 'Genero la addenda Ford - ' GeneraPDFNuevo(String.Format("{0}XML\Nomina\{1}.xml", Ruta, NominaFolio), CvePersonal, CvePeriodo) - End If - Else - Retorno = $"No se pudo generar el pretimbre:
    {cfdi.Mensaje}" - End If - End Select - sw.Stop() - GuardaLogTimbrado(sw.ElapsedMilliseconds.ToString, UsuarioActual.Empresa.CvePAC, "Nomina") - - Return Retorno - - End Function - 'Private Function TimbrarBIInformNomina12(CveNomina As Integer, CvePersonal As Integer, CvePeriodo As Integer) As String - - ' If UsuarioActual.CveEmpresa = 8 Then - ' UsuarioActual.Empresa.FacturaProduccion = True - ' End If - ' 'UsuarioActual.Empresa.FacturaProduccion = False - - ' Dim MsgError As String = String.Empty - - ' Dim CFDi As New ClbNegBICFDv3_2.ClsNegEDI - ' CFDi.ObjCompNomina12 = New ClbNegBICFDv3_2.ClsNegComplementoNomina12() - ' 'CFDi.ObjCompNomina = New ClbNegBICFDv3_2.ClsNegCompNomina - - ' Dim objPersonal As New ClsRH - ' Dim objNomina As New ClsNominas - ' objPersonal.GetPersonal(CvePersonal, UsuarioActual.CveEmpresa) - ' objNomina.GetNom_Nominas(CveNomina, CvePersonal, CvePeriodo, -1, UsuarioActual.CveEmpresa) - - ' Dim Total As Decimal = 0 - ' Dim SubTotal As Decimal = 0 - ' Dim Descuentos As Decimal = 0 - ' Dim RetISR As Decimal = 0 - ' Dim TotalExcento As Decimal = 0 - ' Dim TotalGravado As Decimal = 0 - ' Dim TotalPercepciones As Decimal = 0 - ' Dim TotalDeducciones As Decimal = 0 - ' Dim TotalOtrosPagos As Decimal = 0 - - ' Dim Serie As String = objNomina.Serie - ' Dim Folio As String = objNomina.Folio.ToString - ' Dim NominaFolio As String = Serie & "-" & Folio - ' Dim RFC As String = objPersonal.RFC.Trim - ' Dim Nombre As String = objPersonal.NombreCompleto.Trim - ' Dim Direccion As String = String.Format("{0} {1} {2}", objPersonal.Calle.Trim, objPersonal.NumExt.Trim, objPersonal.NumInt.Trim).Trim - ' Dim Ciudad As String = objPersonal.Ciudad.Trim - ' Dim Estado As String = objPersonal.Estado.Trim - ' Dim CP As String = objPersonal.CP.Trim - - ' 'Dim TipoContrato As String = GlobalDTTiposContrato.FiltraParametros("CveTipoContrato = " + objPersonal.CveTipoContrato.ToString)(0)("TipoContrato").ToString - ' 'Dim TipoPeriodo As String = GlobalDTTipoPeriodo.FiltraParametros("CveTipoPeriodo = " + objPersonal.CveTipoPeriodo.ToString)(0)("TipoPeriodo").ToString - ' Dim AntiguedadSemanas As Integer = DateDiff(DateInterval.Weekday, objPersonal.FechaIngreso, Now).ToEntero - ' Dim FormatoReciboCFDi As String = objPersonal.FormatoReciboCFDi - - ' Dim FechaInicio, FechaFin, FechaPago As Date - ' Dim DiasPagados As Integer = 0 - ' Dim Msg As String = String.Empty - ' Dim DiasIncapacitados As Integer = 0 - ' Dim DrPeriodo As DataRow = Nothing - ' If objNomina.GetPeriodos(-1, UsuarioActual.CveEmpresa, -1, -1, CvePeriodo) Then - ' If objNomina.DtResultados.Rows().Count > 0 Then - ' DrPeriodo = objNomina.DtResultados.Rows(0) - ' End If - ' End If - ' 'Dim DrPeriodo As DataRow = GlobalDTNominasPeriodos(-1, CvePeriodo, -1).FiltroPrimero("") - ' If DrPeriodo IsNot Nothing Then - ' FechaInicio = DrPeriodo("FechaInicio").ToString.ToDate - ' FechaFin = DrPeriodo("FechaFin").ToString.ToDate - ' FechaPago = DrPeriodo("FechaPago").ToString.ToDate - ' If objPersonal.GetAsistencias(CvePersonal, -1, -1, -1, -1, -1, FechaInicio, FechaFin, UsuarioActual.CveEmpresa) Then - - ' Dim Asistencias As Integer = objPersonal.DtResultados.SUM("AplicaAsistencia").ToEntero - ' Dim Vacaciones As Integer = objPersonal.DtResultados.SUM("AplicaVacacion").ToEntero - ' DiasIncapacitados = objPersonal.DtResultados.SUM("AplicaIncapacidad").ToEntero - ' DiasPagados = Asistencias - Vacaciones - ' If DiasPagados < 0 Then DiasPagados = 0 - - ' End If - - ' End If - - ' Dim DtPercepciones As Data.DataTable = Nothing - ' Dim DtDeducciones As Data.DataTable = Nothing - ' Dim DtOtrosPagos As Data.DataTable = Nothing - ' If objNomina.GetNom_NominasDetalles(CveNomina, CvePersonal, CvePeriodo, "-1") Then - ' If objNomina.DtResultados.Rows.Count > 0 Then - ' DtPercepciones = objNomina.DtResultados.FiltraParametros("Tipo = 'P' AND EsPadre = 1 ") - ' DtDeducciones = objNomina.DtResultados.FiltraParametros("Tipo = 'D' AND EsPadre = 1 ") - ' TotalPercepciones = DtPercepciones.SUM("Importe") - ' TotalDeducciones = DtDeducciones.SUM("Importe") - ' Total = CType((Total + DtPercepciones.SUM("Importe")), Decimal) - ' End If - ' End If - - ' 'Tipo Nomina O de Ordinaria o E de extraordinaria - ' 'Dim FechaPago As Date = Now - ' Dim TotalSueldos As Decimal = 0 - ' Dim TotalIndemnizacion As Decimal = 0 - ' Dim TotalJubilacion As Decimal = 0 - ' Msg = CFDi.ObjCompNomina12.Cargar("O", FechaPago, FechaInicio, FechaFin, DiasPagados, TotalPercepciones, TotalDeducciones, 0) - - - - ' If Msg = String.Empty Then - ' If DtPercepciones IsNot Nothing Then - ' If DtPercepciones.Rows.Count > 0 Then - ' TotalSueldos = DtPercepciones.SUM("Importe", "SATCveConcepto = '001'") - ' TotalIndemnizacion = DtPercepciones.SUM("Importe", "SATCveConcepto IN ('022','023','025')") ' https://www.ccpm.org.mx/avisos/nuevo-complemento-de-nomina-version-1.2-puntos-finos-diciembre-2016.pdf - ' TotalJubilacion = DtPercepciones.SUM("Importe", "SATCveConcepto IN ('039','044')") 'https://www.ccpm.org.mx/avisos/nuevo-complemento-de-nomina-version-1.2-puntos-finos-diciembre-2016.pdf - ' Msg = CFDi.ObjCompNomina12.CargarPercepciones(TotalSueldos, TotalIndemnizacion, TotalJubilacion, DtPercepciones.SUM("ImporteGravado").ToDecimal, DtPercepciones.SUM("ImporteExento").ToDecimal) - ' End If - ' For Each Row As DataRow In DtPercepciones.Rows - ' If Row("Importe").ToString.ToDecimal > 0 Then - ' If Row("CveSATConcepto").ToString = "" Then - ' Msg = String.Format("Concepto No registrado ({0})", Row("Concepto").ToString) - ' Else - ' Msg = CFDi.ObjCompNomina12.AgregarPercepcion(Row("SATCveConcepto").ToString, Row("Codigo").ToString, Row("Concepto").ToString, Row("ImporteGravado").ToString.ToDecimal, Row("ImporteExento").ToString.ToDecimal) - ' TotalExcento = TotalExcento + Row("ImporteExento").ToString.ToDecimal - ' TotalGravado = TotalGravado + Row("ImporteGravado").ToString.ToDecimal - ' SubTotal = SubTotal + Row("Importe").ToString.ToDecimal - ' End If - - ' If Msg <> String.Empty Then - ' Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: Percepcion", New Exception) - ' Exit For - ' End If - ' End If - ' 'RMF, falta poner el numero de horas pagadas - ' If Row("CveSATConcepto").ToString.ToEntero = 19 Then 'cuando son horas extras - - ' 'Obtengo el desglose de horas extras - - ' If objNomina.GetHorasExtras(CvePersonal, CvePeriodo, UsuarioActual.CveEmpresa) Then - - ' Dim dr As DataRow = objNomina.DtResultados.FiltroPrimero("") - ' If dr IsNot Nothing Then - - ' If dr("HorasDobles").ToString.ToDouble > 0 Then CFDi.ObjCompNomina12.AgregarHorasExtra(dr("DiasHorasDobles").ToString.ToEntero, ClbNegBICFDv3_2.TipoHoras.Dobles, dr("HorasDobles").ToString.ToEntero, Row("Importe").ToString.ToDecimal) - ' If dr("HorasTriples").ToString.ToDouble > 0 Then CFDi.ObjCompNomina12.AgregarHorasExtra(dr("DiasHorasTriples").ToString.ToEntero, ClbNegBICFDv3_2.TipoHoras.Triples, dr("HorasTriples").ToString.ToEntero, Row("Importe").ToString.ToDecimal) - - - ' End If - - - ' End If - - ' End If - ' Next - ' If Msg = "" Then - ' CFDi.ObjCompNomina12.ObjPercepciones.TotalExento = TotalExcento - ' CFDi.ObjCompNomina12.ObjPercepciones.TotalGravado = TotalGravado - ' End If - - ' End If - - ' 'cargo las incapacidades - ' If DiasIncapacitados > 0 Then - - ' If objNomina.GetIncapacidades(CvePersonal, CvePeriodo, UsuarioActual.CveEmpresa) Then - - ' CFDi.ObjCompNomina12.CargarIncapacidades() - ' For Each dr As DataRow In objNomina.DtResultados.Rows - ' CFDi.ObjCompNomina12.AgregarIncapacidad(dr("Dias").ToString.ToDecimal, dr("ClaveTipoIncapacidad").ToString.ToEntero, dr("Descuento").ToString.ToDecimal) - ' Next - - ' End If - - ' End If - - - - ' TotalExcento = 0 - ' TotalGravado = 0 - - ' If Msg = String.Empty Then - ' If DtDeducciones IsNot Nothing Then - ' If DtDeducciones.Rows.Count > 0 Then - ' Total = CType((Total - DtDeducciones.SUM("Importe")), Decimal) - ' CFDi.ObjCompNomina12.CargarDeducciones(CType(DtDeducciones.SUM("ImporteGravado"), Decimal), CType(DtDeducciones.SUM("ImporteExento"), Decimal)) - ' End If - ' For Each Row As DataRow In DtDeducciones.Rows - - ' If Row("Importe").ToString.ToDecimal > 0 Then - ' If Row("CveSATConcepto").ToString = "" Then - ' Msg = String.Format("Concepto No registrado ({0})", Row("Concepto").ToString) - ' Else - - ' Msg = CFDi.ObjCompNomina12.AgregarDeduccion(Row("SATCveConcepto").ToString, Row("Codigo").ToString, Row("Concepto").ToString, 0) - ' TotalExcento = TotalExcento + Row("ImporteExento").ToString.ToDecimal - ' TotalGravado = TotalGravado + Row("ImporteGravado").ToString.ToDecimal - - ' If Row("CveSATConcepto").ToString.ToEntero = 3 Then - ' RetISR = RetISR + Row("Importe").ToString.ToDecimal - ' Else - ' Descuentos = Descuentos + Row("Importe").ToString.ToDecimal - ' End If - ' End If - - ' If Msg <> String.Empty Then - ' Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: Deduccion", New Exception) - ' Exit For - ' End If - ' End If - ' Next - ' If Msg = "" Then - ' If CFDi.ObjCompNomina12.ObjDeducciones IsNot Nothing Then - ' CFDi.ObjCompNomina12.ObjDeducciones.TotalOtrasDeducciones = Descuentos - ' CFDi.ObjCompNomina12.ObjDeducciones.TotalImpuestosRetenidos = RetISR - ' End If - - ' End If - ' End If - - ' If Msg = String.Empty Then - ' If DtOtrosPagos IsNot Nothing Then - ' If DtOtrosPagos.Rows.Count > 0 Then - ' Total = CType((Total - DtOtrosPagos.SUM("Importe")), Decimal) - ' CFDi.ObjCompNomina12.CargarOtrosPagos() - ' End If - - ' For Each Row As DataRow In DtOtrosPagos.Rows - ' If Row("Importe").ToString.ToDecimal > 0 Then - ' If Row("CveSATConcepto").ToString = "" Then - ' Msg = String.Format("Concepto No registrado ({0})", Row("Concepto").ToString) - ' Else - ' Msg = CFDi.ObjCompNomina12.AgregarOtroPago(Row("SATCveConcepto").ToString, Row("Codigo").ToString, Row("Concepto").ToString, 0) - ' 'Msg = CFDi.ObjCompNomina12.CargarSubsidioAlEmpleo(0) - ' 'Msg = CFDi.ObjCompNomina12.CargarCompensacionSaldosAFavor(0, 0, 0) - ' End If - - ' If Msg <> String.Empty Then - ' Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: Otros Pagos", New Exception) - ' Exit For - ' End If - ' End If - ' Next - - ' End If - - ' If Msg = String.Empty Then - ' Dim x As Integer = 0 - - ' Dim Moneda As String = "MXN" - ' Dim LugarExp As String = String.Format("{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8} ", SucCalle, SucNoExt, SucNoInt, SucColonia, SucLocalidad, SucMunicipio, SucEstado, SucPais, SucCP) - ' Dim FechaFactura As DateTime = Now - ' 'Nodo Comprobante - - ' Dim TipoComprobante As ClbNegBICFDv3_2.TipoDeComprobante = ClbNegBICFDv3_2.TipoDeComprobante.egreso - ' Msg = CFDi.comprobantecfd(0, 0, Serie, Folio, FechaFactura, "PAGO EN UNA SOLA EXHIBICION", "CONTADO", SubTotal, Descuentos, "Deducciones nómina", "1", Moneda, Total, objPersonal.MetodoPagoSAT, ClbNegBICFDv3_2.TipoDeComprobante.egreso, LugarExp, "", "", "", New Date(1900, 1, 1), 0) - - ' If Msg = String.Empty Then - ' 'Nodo emisor - ' Msg = CFDi.ObjCompNomina12.CargarEmisor("", UsuarioActual.Empresa.RegistroPatronal, UsuarioActual.Empresa.RFC) - ' 'If Msg = String.Empty Then Msg = CFDi.EmisorRegimen(UsuarioActual.Empresa.CodigoRegimenFiscal) - ' If Msg = String.Empty Then - ' 'Nodo Entidad SNCF - ' If 1 = 2 Then 'cuando es gobierno - ' Msg = CFDi.ObjCompNomina12.CargarEntidadSNCF("", 0) - ' End If - - ' If Msg = String.Empty Then - ' 'Nodo Receptor - ' Msg = CFDi.ObjCompNomina12.CargarReceptor(objPersonal.CURP, objPersonal.NumeroSS, objPersonal.FechaInicioContrato, AntiguedadSemanas, objPersonal.TipoContrato, "", objPersonal.ClaveTipoJornada, objPersonal.CveRegimenContratacion, objPersonal.Codigo.ToString, - ' objPersonal.Departamento, objPersonal.Puesto, objPersonal.CveRiesgoPuesto, objPersonal.TipoPeriodo, objPersonal.ClaveBanco, objPersonal.BancoNumCuenta, Total, objPersonal.SDI.ToString.ToDecimal, objPersonal.ClaveEstado) - ' If Msg = String.Empty Then - ' 'Nodo SubContratacion - ' If 1 = 2 Then Msg = CFDi.ObjCompNomina12.AgregarSubContratacion("", 0) - ' If Msg = String.Empty Then - - ' CFDi.LstCompNomina12.Add(CFDi.ObjCompNomina12) - - ' Dim HasErrorConceptos As Boolean = False - ' 'Dim Importe As Decimal = 0 - - - ' Msg = CFDi.ConceptosCfd(1, "ACT", "", "Pago de nómina", SubTotal, SubTotal) - - ' 'Timbrado - - ' 'Web Services de producción: http://biinform.com.mx/srvCFDi/service1.asmx - ' 'Web Services de pruebasd: http://biinform.com.mx/srvCFDiPrueba/service1.asmx - - - ' Dim WS As String = String.Empty - ' If UsuarioActual.Empresa.FacturaProduccion Then - ' WS = "http://portalbiinform.com.mx/srvCFDiPrueba/service1.asmx" - ' Else - ' WS = "http://portalbiinform.com.mx/srvCFDiPrueba/service1.asmx" - ' End If - - ' If Not System.IO.Directory.Exists(Ruta & "XML\") Then System.IO.Directory.CreateDirectory(Ruta & "XML\") - ' If Not System.IO.Directory.Exists(Ruta & "XML\Nomina\") Then System.IO.Directory.CreateDirectory(Ruta & "XML\Nomina\") - - ' 'Generar Timbre - ' 'If UsuarioActual.Empresa.FacturaProduccion Then - ' If 1 = 2 Then - ' CFDi.Generar(String.Format("{0}Certificados\{1}", Ruta, UsuarioActual.Empresa.ArchivoPfx), - ' UsuarioActual.Empresa.ContraseñaKey, - ' String.Format("{0}Certificados\{1}", Ruta, UsuarioActual.Empresa.ArchivoCer), - ' String.Format("{0}XML\Nomina\{1}.xml", Ruta, NominaFolio), - ' String.Format("{0}Certificados\", Ruta), - ' UsuarioActual.Empresa.BIUsuario, - ' UsuarioActual.Empresa.BIContraseña, - ' WS, - ' True) - ' Else - ' If Not System.IO.Directory.Exists(Ruta & "XML\Nomina\Demo\") Then System.IO.Directory.CreateDirectory(Ruta & "XML\Nomina\Demo\") - ' 'RutaPruebas & "XML\Demo\" & NominaFolio & ".xml", - ' CFDi.Generar(String.Format("{0}Certificados\aaa010101aaa__csd_01.pfx", RutaPruebas), - ' "12345678a", - ' String.Format("{0}Certificados\aaa010101aaa__csd_01.cer", RutaPruebas), - ' String.Format("{0}XML\Nomina\Demo\{1}.xml", Ruta, NominaFolio), - ' String.Format("{0}Certificados\", RutaPruebas), - ' "prueba", - ' "123", - ' WS, - ' True) - ' End If - - - ' If CFDi.MsgError <> String.Empty Then - - ' 'OnError("Ocurrió un error al generar el timbre: " & CFDi.MsgError, New Exception) - - ' Dim params As New ActualizaTimbre - ' params.Estatus = False - ' params.CveNomina = CveNomina - ' params.CvePAC = 1 - - ' 'Dim Hilo As New System.Threading.Thread(AddressOf ActualizaTimbrado) - ' 'Hilo.Start(params) - ' BtnAutorizar.Enabled = False - ' MsgError = "Nombre: " & Nombre & ". Error: " & CFDi.MsgError - ' Else - ' 'Actualiza Estatus Timbrado - ' Dim params As New ActualizaTimbre - ' params.Estatus = True - ' params.CveNomina = CveNomina - ' params.CvePAC = 1 - - ' 'Dim Hilo As New System.Threading.Thread(AddressOf ActualizaTimbrado) - ' 'Hilo.Start(params) - - ' Dim CBB As New ClbNegBICFDv3_2.ClsNegCBBGenerar() - ' Dim FechaCertificacion As DateTime - ' Dim FolioFiscal, NoSerieCertificado, NoSerieCertificadoContribuyente, SelloCFDi, SelloSAT As String - - ' FolioFiscal = CFDi.Timbrado.UUDI 'XmlDoc.DocumentElement("cfdi:Complemento").FirstChild.Attributes("UUID").InnerText - ' NoSerieCertificado = CFDi.Timbrado.NoCertificadoSAT - ' FechaCertificacion = CFDi.Timbrado.FechaTimbrado - ' SelloCFDi = CFDi.Timbrado.SelloCFD - ' SelloSAT = CFDi.Timbrado.SelloSAT - ' NoSerieCertificadoContribuyente = CFDi.Timbrado.NoCertificado - ' ViewState("FolioFiscal") = FolioFiscal - - ' 'Actualiza Estatus Factura - ' CveNominaT = CveNomina - - ' Dim Rastro As String = String.Format("Nomina: CvePeriodo:{0}, CvePersonal:{1}, UUID: {2}, RFC:{3}", CvePeriodo, CvePersonal, FolioFiscal, objPersonal.RFC) - ' Rastro.GuardaLog() - - ' If FolioFiscal <> "" Then - - ' 'If UsuarioActual.Empresa.FacturaProduccion Then - ' ' Dim ObjNomina2 As New ClsNominas() - ' ' ObjNomina2.UpdateEstatusNomNominas(3, UsuarioActual.Empresa.CvePAC, FolioFiscal, "", ("01/01/2000").ToDate, CveNomina, SubTotal, Descuentos, RetISR, Total, DiasPagados) - ' ' ObjNomina2.Dispose() - ' 'End If - ' Rastro = "--Estatus" & Rastro - ' Rastro.GuardaLog() - ' 'Dim Hilo1 As New System.Threading.Thread(AddressOf ActualizaEstatus) - ' 'Hilo1.Start(3) - ' End If - - - ' Dim RutaCBB As String = String.Empty - ' If Not System.IO.Directory.Exists(Ruta & "CBB\") Then System.IO.Directory.CreateDirectory(Ruta & "CBB\") - ' If Not System.IO.Directory.Exists(Ruta & "CBB\Nomina\") Then System.IO.Directory.CreateDirectory(Ruta & "CBB\Nomina\") - - ' If UsuarioActual.Empresa.FacturaProduccion Then - ' RutaCBB = Ruta & "CBB\Nomina\" & NominaFolio & ".jpg" - ' Else - ' If Not System.IO.Directory.Exists(Ruta & "CBB\Nomina\Demo\") Then System.IO.Directory.CreateDirectory(Ruta & "CBB\Nomina\Demo\") - ' RutaCBB = Ruta & "CBB\Nomina\Demo\" & NominaFolio & ".jpg" - ' End If - ' CBB.GenerarCBB(UsuarioActual.Empresa.RFC, RFC, Total, FolioFiscal, RutaCBB) - - - ' 'GeneraPDF(FechaFactura, FolioFiscal, NoSerieCertificado, FechaCertificacion, NoSerieCertificadoContribuyente, TmpDT, SelloCFDi, SelloSAT, RutaCBB, VentaFolio, Ruta & "XML\" & VentaFolio & ".xml", False, CFDi.CadenaOriginal) - ' 'GeneraPDF(CveNomina, CvePersonal, CvePeriodo, FechaFactura, FolioFiscal, NoSerieCertificado, FechaCertificacion, NoSerieCertificadoContribuyente, SelloCFDi, SelloSAT, RutaCBB, Ruta & "Nomina\XML\" & NominaFolio & ".xml", False, CFDi.Timbrado.CadenaOriginal, FormatoReciboCFDi) - ' GeneraPDFNuevo(String.Format("{0}XML\Nomina\{1}.xml", Ruta, NominaFolio), CvePersonal, CvePeriodo) - ' End If - ' Else - ' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: EmisorRegimen", Msg, Nombre), New Exception) - ' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: EmisorRegimen", Msg, Nombre) - ' End If - ' Else - ' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: EmisorDomicilioExpedidoEn", Msg, Nombre), New Exception) - ' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: EmisorDomicilioExpedidoEn", Msg, Nombre) - ' End If - ' Else - ' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: EmisorDomicilioFiscalCfd", Msg, Nombre), New Exception) - ' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: EmisorDomicilioFiscalCfd", Msg, Nombre) - ' End If - ' Else - ' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: EmisorCfd", Msg, Nombre), New Exception) - ' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: EmisorCfd", Msg, Nombre) - ' End If - ' Else - ' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre), New Exception) - ' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre) - ' End If - ' Else - ' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre), New Exception) - ' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre) - ' End If - ' Else - ' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre), New Exception) - ' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre) - ' End If - ' Else - ' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre), New Exception) - ' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre) - ' End If - ' Else - ' 'Me.OnError(String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre), New Exception) - ' MsgError = String.Format("El SAT regresó el siguiente mensaje: {0} Nombre: {1}. Objeto: Comprobante", Msg, Nombre) - ' End If - ' objPersonal.Dispose() - ' objNomina.Dispose() - - ' Return MsgError - 'End Function - - - Private Function PreTimbrar(CveNomina As Integer, CvePersonal As Integer, CvePeriodo As Integer) As CFDITimbre - - Dim cfdi As New CFDITimbre - Dim objPersonal As New ClsRH - Dim objNomina As New ClsNominas - objPersonal.GetPersonal(CvePersonal, UsuarioActual.CveEmpresa) - objNomina.GetNom_Nominas(CveNomina, CvePersonal, CvePeriodo, -1, UsuarioActual.CveEmpresa) - Dim DtPercepciones As Data.DataTable = Nothing - Dim DtDeducciones As Data.DataTable = Nothing - Dim DtOtrosPagos As Data.DataTable = Nothing - Dim TotalPercepciones As Decimal = 0 - Dim TotalDeducciones As Decimal = 0 - Dim TotalOtrosPagos As Decimal = 0 - Dim Total As Decimal = 0 - If objNomina.GetNom_NominasDetalles(CveNomina, CvePersonal, CvePeriodo, "-1") Then - If objNomina.DtResultados.Rows.Count > 0 Then - DtPercepciones = objNomina.DtResultados.FiltraParametros("Tipo = 'P' AND EsPadre = 1 ") - DtDeducciones = objNomina.DtResultados.FiltraParametros("Tipo = 'D' AND EsPadre = 1 ") - TotalPercepciones = DtPercepciones.SUM("Importe") - TotalDeducciones = DtDeducciones.SUM("Importe") - Total = CType((Total + DtPercepciones.SUM("Importe")), Decimal) - End If - End If - 'nota. siempre y cuando halla concepto 19 - Dim DtHorasExtras As Data.DataTable = Nothing - If objNomina.GetHorasExtras(CvePersonal, CvePeriodo, UsuarioActual.CveEmpresa) Then - DtHorasExtras = objNomina.DtResultados - End If - - Dim TotalExcento As Decimal = 0 - Dim TotalGravado As Decimal = 0 - - Dim AntiguedadSemanas As Integer = DateDiff(DateInterval.Weekday, objPersonal.FechaIngreso, Now).ToEntero - Dim FormatoReciboCFDi As String = objPersonal.FormatoReciboCFDi - - Dim FechaInicio, FechaFin, FechaPago As Date - Dim DiasPagados As Integer = 0 - Dim Msg As String = String.Empty - Dim DiasIncapacitados As Integer = 0 - Dim DrPeriodo As DataRow = Nothing - If objNomina.GetPeriodos(-1, UsuarioActual.CveEmpresa, -1, -1, CvePeriodo) Then - If objNomina.DtResultados.Rows().Count > 0 Then - DrPeriodo = objNomina.DtResultados.Rows(0) - End If - End If - - 'Dim DrPeriodo As DataRow = GlobalDTNominasPeriodos(-1, CvePeriodo, -1).FiltroPrimero("") - If DrPeriodo IsNot Nothing Then - FechaInicio = DrPeriodo("FechaInicio").ToString.ToDate - FechaFin = DrPeriodo("FechaFin").ToString.ToDate - FechaPago = DrPeriodo("FechaPago").ToString.ToDate - If objPersonal.GetAsistencias(CvePersonal, -1, -1, -1, -1, -1, FechaInicio, FechaFin, UsuarioActual.CveEmpresa) Then - - Dim Asistencias As Integer = objPersonal.DtResultados.SUM("AplicaAsistencia").ToEntero - Dim Vacaciones As Integer = objPersonal.DtResultados.SUM("AplicaVacacion").ToEntero - DiasIncapacitados = objPersonal.DtResultados.SUM("AplicaIncapacidad").ToEntero - DiasPagados = Asistencias - Vacaciones - If DiasPagados < 0 Then DiasPagados = 0 - - End If - - End If - - 'Tipo Nomina O de Ordinaria o E de extraordinaria - 'Dim FechaPago As Date = Now - Dim TotalSueldos As Decimal = 0 - Dim TotalIndemnizacion As Decimal = 0 - Dim TotalJubilacion As Decimal = 0 - - cfdi.Nomina = New CFDINomina - cfdi.Nomina.Version = "1.2" - cfdi.Nomina.TipoNomina = If(objNomina.CveTipoPeriodo = 6, "E", "O") - cfdi.Nomina.FechaPago = FechaPago - cfdi.Nomina.FechaInicio = FechaInicio - cfdi.Nomina.FechaFin = FechaFin - cfdi.Nomina.NumDiasPagados = DiasPagados - cfdi.Emisor.Nombre = UsuarioActual.Empresa.Empresa - cfdi.Emisor.RFC = UsuarioActual.Empresa.RFC - cfdi.Emisor.RegistroPatronal = UsuarioActual.Empresa.RegistroPatronal - cfdi.Emisor.RegimenFiscal = UsuarioActual.Empresa.CodigoRegimenFiscal - 'aplica persona fisica debe de tener CURP - If cfdi.Emisor.RegimenFiscal.Contiene("605", "606", "608", "611", "612", "614", "616", "621", "622", "629", "630", "615") Then - cfdi.Emisor.CURP = UsuarioActual.Empresa.CURP - End If - cfdi.Nomina.CveNomina = CveNomina - - cfdi.Receptor.UsoCFDI = "P01" - cfdi.Receptor.RFC = objPersonal.RFC - cfdi.Receptor.Nombre = objPersonal.NombreCompleto - - If DtPercepciones IsNot Nothing Then - If DtPercepciones.Rows.Count > 0 Then - Dim ObjPercepciones As New List(Of CFDINominaPercepciones) - Dim ObjHorasExtras As New List(Of CFDINominaHorasExtras) - Dim ObjOtrosPagos As New List(Of CFDINominaOtrosPagos) - - For Each Row As DataRow In DtPercepciones.Rows - If Row("Importe").ToString.ToDecimal > 0 AndAlso Row("SATCveConcepto").ToString.ToEntero <> 17 Then - If Row("CveSATConcepto").ToString = "" Then cfdi.AddMsg(String.Format("Concepto No registrado ({0})", Row("Concepto").ToString)) : Exit For - - ObjPercepciones.Add(New CFDINominaPercepciones With {.TipoPercepcion = Row("SATCveConcepto").ToString, - .Clave = Row("Codigo").ToString, - .Concepto = Row("Concepto").ToString, - .ImporteGravado = Row("ImporteGravado").ToString.ToDecimal, - .ImporteExento = Row("ImporteExento").ToString.ToDecimal} - ) - - End If - 'RMF, falta poner el numero de horas pagadas - If Row("CveSATConcepto").ToString.ToEntero = 19 Then 'cuando son horas extras - - 'Obtengo el desglose de horas extras - - If DtHorasExtras IsNot Nothing Then - - Dim dr As DataRow = DtHorasExtras.FiltroPrimero("") - If dr IsNot Nothing Then - - If dr("HorasDobles").ToString.ToDouble > 0 Then ObjHorasExtras.Add(New CFDINominaHorasExtras With {.Dias = dr("DiasHorasDobles").ToString.ToEntero, .TipoHoras = "01", .HorasExtra = dr("HorasDobles").ToString.ToEntero, .ImportePagado = Row("Importe").ToString.ToDecimal}) - If dr("HorasTriples").ToString.ToDouble > 0 Then ObjHorasExtras.Add(New CFDINominaHorasExtras With {.Dias = dr("DiasHorasTriples").ToString.ToEntero, .TipoHoras = "02", .HorasExtra = dr("HorasTriples").ToString.ToEntero, .ImportePagado = Row("Importe").ToString.ToDecimal}) - - End If - - End If - End If - 'subsidio al empleo - If Row("SATCveConcepto").ToString.ToEntero.ToEntero = 17 AndAlso Row("Importe").ToString.ToDecimal > 0 Then 'Subsidio - - ObjOtrosPagos.Add(New CFDINominaOtrosPagos With {.TipoOtroPago = "002", ' codigo fijo, por ser refernte a subsidio al empleo - .Clave = Row("Codigo").ToString, - .Concepto = Row("Concepto").ToString, - .Importe = Row("Importe").ToString.ToDecimal} - ) - - End If - - Next - If ObjPercepciones IsNot Nothing AndAlso ObjPercepciones.Count > 0 Then cfdi.Nomina.Percepciones = ObjPercepciones - If ObjHorasExtras IsNot Nothing AndAlso ObjHorasExtras.Count > 0 Then cfdi.Nomina.HorasExtras = ObjHorasExtras - If ObjOtrosPagos IsNot Nothing AndAlso ObjOtrosPagos.Count > 0 Then cfdi.Nomina.OtrosPagos = ObjOtrosPagos - - End If - - End If - - 'cargo las incapacidades - If DiasIncapacitados > 0 Then - - If objNomina.GetIncapacidades(CvePersonal, CvePeriodo, UsuarioActual.CveEmpresa) Then - - If objNomina.DtResultados IsNot Nothing AndAlso objNomina.DtResultados.Rows.Count > 0 Then - Dim ObjIncapacidades As New List(Of CFDINominaIncapacidades) - For Each dr As DataRow In objNomina.DtResultados.Rows - ObjIncapacidades.Add(New CFDINominaIncapacidades With {.DiasIncapacidad = dr("Dias").ToString.ToEntero, .TipoIncapacidad = dr("ClaveTipoIncapacidad").ToString, .Importe = dr("Descuento").ToString.ToDecimal}) - Next - If ObjIncapacidades IsNot Nothing AndAlso ObjIncapacidades.Count > 0 Then cfdi.Nomina.Incapacidades = ObjIncapacidades - End If - End If - End If - - TotalExcento = 0 - TotalGravado = 0 - - If DtDeducciones IsNot Nothing Then - If DtDeducciones.Rows.Count > 0 Then - - Dim ObjDeducciones As New List(Of CFDINominaDeducciones) - For Each Row As DataRow In DtDeducciones.Rows - - If Row("Importe").ToString.ToDecimal > 0 Then - - If Row("CveSATConcepto").ToString = "" Then cfdi.AddMsg(String.Format("Concepto No registrado ({0})", Row("Concepto").ToString)) : Exit For - - ObjDeducciones.Add(New CFDINominaDeducciones With {.TipoDeduccion = Row("SATCveConcepto").ToString, - .Clave = Row("Codigo").ToString, - .Concepto = Row("Concepto").ToString, - .Importe = Row("Importe").ToString.ToDecimal} - ) - - End If - Next - If ObjDeducciones IsNot Nothing AndAlso ObjDeducciones.Count > 0 Then cfdi.Nomina.Deducciones = ObjDeducciones - End If - - End If - - - 'If DtOtrosPagos IsNot Nothing Then - ' If DtOtrosPagos.Rows.Count > 0 Then - ' ' Total = CType((Total - DtOtrosPagos.SUM("Importe")), Decimal) - ' Dim ObjOtrosPagos As New List(Of CFDINominaOtrosPagos) - ' ' End If - - ' ' For Each Row As DataRow In DtOtrosPagos.Rows - ' ' If Row("Importe").ToString.ToDecimal > 0 Then - ' ' If Row("CveSATConcepto").ToString = "" Then - ' ' Msg = String.Format("Concepto No registrado ({0})", Row("Concepto").ToString) - ' ' Else - ' ' Msg = cfdi.ObjCompNomina12.AgregarOtroPago(Row("SATCveConcepto").ToString, Row("Codigo").ToString, Row("Concepto").ToString, 0) - ' ' 'Msg = CFDi.ObjCompNomina12.CargarSubsidioAlEmpleo(0) - ' ' 'Msg = CFDi.ObjCompNomina12.CargarCompensacionSaldosAFavor(0, 0, 0) - ' ' End If - - ' ' If Msg <> String.Empty Then - ' ' Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: Otros Pagos", New Exception) - ' ' Exit For - ' ' End If - ' ' End If - ' ' Next - ' If ObjOtrosPagos IsNot Nothing AndAlso ObjOtrosPagos.Count > 0 Then cfdi.Nomina.OtrosPagos = ObjOtrosPagos - ' End If - 'End If - - cfdi.Comprobante.Version = "3.3" - cfdi.Comprobante.Serie = objNomina.Serie - cfdi.Comprobante.Folio = objNomina.Folio - cfdi.Comprobante.Fecha = Now - cfdi.Comprobante.Subtotal = cfdi.Nomina.TotalPercepciones + cfdi.Nomina.TotalOtrosPagos - cfdi.Comprobante.Descuentos = cfdi.Nomina.TotalDeducciones - cfdi.Comprobante.Total = cfdi.Comprobante.Subtotal - cfdi.Comprobante.Descuentos 'cfdi.Nomina.TotalPercepciones + cfdi.Nomina.TotalOtrosPagos - cfdi.Nomina.TotalDeducciones - cfdi.Comprobante.MotivoDescuento = "" '"Deducciones nómina" - cfdi.Comprobante.Moneda = "MXN" - cfdi.Comprobante.TipoComprobante = "N" - cfdi.Comprobante.TipoDocto = "Egs" - cfdi.Comprobante.MetodoPago = "PUE" - cfdi.Comprobante.CondicionesdePago = "" '"CONTADO" - cfdi.Comprobante.FormadePago = "99" - cfdi.Comprobante.LugarExpedicion = UsuarioActual.Empresa.CP ' AHORITA SOLO SE REQUIERE ESPECIFICAR EL CODIGO POSTAL - cfdi.Comprobante.NumCuentaPago = "" 'objPersonal.BancoNumCuenta - - cfdi.Nomina.Receptor.CURP = objPersonal.CURP - cfdi.Nomina.Receptor.NSS = objPersonal.NumeroSS - cfdi.Nomina.Receptor.FechaInicioContrato = objPersonal.FechaInicioContrato - cfdi.Nomina.Receptor.Antiguedad = $"P{AntiguedadSemanas}W" - cfdi.Nomina.Receptor.TipoContrato = objPersonal.CodigoTipoContrato - cfdi.Nomina.Receptor.CodigoTipoJornada = objPersonal.ClaveTipoJornada - cfdi.Nomina.Receptor.CodigoRegimenContratacion = objPersonal.CveRegimenContratacion - cfdi.Nomina.Receptor.CodigoEmpleado = objPersonal.Codigo - cfdi.Nomina.Receptor.Departamento = objPersonal.Departamento - cfdi.Nomina.Receptor.Puesto = objPersonal.Puesto - cfdi.Nomina.Receptor.CodigoRiesgoPuesto = objPersonal.CveSATRiesgoPuesto - cfdi.Nomina.Receptor.TipoPeriodo = objPersonal.TipoPeriodoPago - cfdi.Nomina.Receptor.CodigoBanco = objPersonal.ClaveBanco - cfdi.Nomina.Receptor.NumeroCuenta = objPersonal.BancoNumCuenta - cfdi.Nomina.Receptor.SDI = objPersonal.SDI - cfdi.Nomina.Receptor.SBC = objPersonal.SDI - cfdi.Nomina.Receptor.Sindicalizado = "" - cfdi.Nomina.Receptor.CodigoEntidadFederativa = objPersonal.ClaveEstado - - cfdi.Conceptos.Add(New CFDIConceptos With {.Cantidad = 1, .ClaveUnidad = "ACT", .ClaveProdServ = "84111505", .Descripcion = "Pago de nómina", .ValorUnitario = cfdi.Comprobante.Subtotal, .Importe = cfdi.Comprobante.Subtotal, .Descuento = cfdi.Nomina.TotalDeducciones}) - - objPersonal.Dispose() - objNomina.Dispose() - - Return cfdi - End Function - - ' Private Function TimbrarFacturaRealVirtual(ObjCFDITimbre As CFDITimbre, UsuarioActual As Usuario) As String - ' Dim Retorno As String = "" - - ' ' 'Sucursal matriz de la empresa - ' Dim ArchivoLLave As String = $"{UsuarioActual.Empresa.Ruta}Certificados\{UsuarioActual.Empresa.ArchivoKey}" - ' Dim ArchivoCertificado As String = $"{UsuarioActual.Empresa.Ruta}Certificados\{UsuarioActual.Empresa.ArchivoCer}" - ' Dim UsuarioServicio As String = UsuarioActual.Empresa.RFC - ' Dim ClaveServicio As String = UsuarioActual.Empresa.RFC.ToLower - ' Dim Clave As String = UsuarioActual.Empresa.ContraseñaKey - ' Dim RFCPrueba As String = "AAA010101AAA" - ' Dim UrlServicio As String = "http://generacfdi.com.mx/rvltimbrado/service1.asmx?WSDL" ' Produccion - ' Dim RutaArchivo As String = $"{UsuarioActual.Empresa.Ruta}XML\Nomina\" - ' Dim NombreArchivoXML As String = $"{ObjCFDITimbre.Comprobante.SerieFolio}" - ' Dim SubTotal As Decimal = 0 - - ' If Not UsuarioActual.Empresa.FacturaProduccion Then - ' UsuarioServicio = "fgomez" - ' ClaveServicio = "12121212" - ' Clave = "12345678a" - ' ArchivoLLave = $"{UsuarioActual.Empresa.Ruta}Certificados\aad990814bp7_1210261233s.key" - ' ArchivoCertificado = $"{UsuarioActual.Empresa.Ruta}Certificados\aad990814bp7_1210261233s.cer" - ' UrlServicio = "http://108.60.211.43/rvltimbrado/service1.asmx" - ' End If - - - '#Region "Valida" - ' If Not File.Exists(ArchivoCertificado) Then - ' Alert("El archivo de certificado no existe", TipoMensaje.MsgError) - ' Return False - ' End If - ' If Not File.Exists(ArchivoLLave) Then - ' Alert("El archivo de llave privada no existe", TipoMensaje.MsgError) - ' Return False - ' End If - ' If UsuarioActual.Empresa.ContraseñaKey = "" Then - ' Alert("La clave no puede ser vacía", TipoMensaje.MsgError) - ' Return False - ' End If - '#End Region - - '#Region "Variables" - ' Dim llaveByte As Byte(), certByte As Byte() - ' Dim llaveBase64 As String, certBase64 As String - ' Dim cfdi As New RVCFDI.GeneraCFDI() - ' Dim complemento As String = "" - ' Dim complementoConcepto As String = "" - - '#End Region - - '#Region "Verifica" - ' Try - ' llaveByte = System.IO.File.ReadAllBytes(ArchivoLLave) - ' llaveBase64 = Convert.ToBase64String(llaveByte) - ' Catch ex As Exception - ' Alert($"Error al leer la llave privada: {ex.Message}", TipoMensaje.MsgError) - ' Return False - ' End Try - - - ' Try - ' certByte = System.IO.File.ReadAllBytes(ArchivoCertificado) - ' certBase64 = Convert.ToBase64String(certByte) - ' Catch ex As Exception - ' Alert($"Error al leer el certificado: {ex.Message}", TipoMensaje.MsgError) - ' Return False - - ' End Try - '#End Region - - ' cfdi.saltarValidacion("bNtMuvZockPVhEjaPj0E") - - '#Region "Certificado" - ' cfdi.agregarCertificado(ArchivoCertificado) - '#End Region - - - - '#Region "Comprobante" - - ' cfdi.agregarComprobante(ObjCFDITimbre.Comprobante.Version, - ' ObjCFDITimbre.Comprobante.Serie, - ' ObjCFDITimbre.Comprobante.Folio, - ' ObjCFDITimbre.Comprobante.Fecha.ToString("yyyy-MM-ddTHH:mm:ss"), - ' ObjCFDITimbre.Comprobante.FormadePago, - ' ObjCFDITimbre.Comprobante.CondicionesdePago, - ' ObjCFDITimbre.Comprobante.Subtotal, - ' ObjCFDITimbre.Comprobante.Descuentos, - ' ObjCFDITimbre.Comprobante.MotivoDescuento, - ' ObjCFDITimbre.Comprobante.TipoCambio, - ' ObjCFDITimbre.Comprobante.Moneda, - ' ObjCFDITimbre.Comprobante.Total, - ' ObjCFDITimbre.Comprobante.TipoComprobante, - ' ObjCFDITimbre.Comprobante.MetodoPago, - ' ObjCFDITimbre.Comprobante.LugarExpedicion, - ' ObjCFDITimbre.Comprobante.NumCuentaPago) - - '#Region "Emisor" - - ' cfdi.agregarEmisor(If(UsuarioActual.Empresa.FacturaProduccion, UsuarioActual.Empresa.RFC, RFCPrueba), UsuarioActual.Empresa.Empresa) - ' cfdi.agregarRegimenFiscal(UsuarioActual.Empresa.CodigoRegimenFiscal) - - '#End Region - - '#Region "Receptor" - - ' cfdi.agregarReceptor(ObjCFDITimbre.Receptor.RFC, ObjCFDITimbre.Receptor.Nombre) - - '#End Region - - '#Region "Conceptos" - - ' 'Nodo conceptos, se agregan los PS - - ' If ObjCFDITimbre.Conceptos IsNot Nothing AndAlso ObjCFDITimbre.Conceptos.Count > 0 Then - ' For Each concep As CFDIConceptos In ObjCFDITimbre.Conceptos - ' cfdi.agregarConcepto(concep.Cantidad, concep.Unidad, concep.Noidentificacion, concep.Descripcion, concep.ValorUnitario, concep.Importe) - ' Next - ' End If - - '#End Region - - - '#Region "Impuestos" - - ' cfdi.agregarImpuestos(0, 0) - '#End Region - ' '#Region "Retenciones" - ' 'cfdi.agregarRetencion("IVA", 0) - ' ' If Ventas.RetISRTC > 0 Then cfdi.agregarRetencion("ISR", Ventas.RetISRTC) - ' '#End Region - - - ' '#Region "Traslados" - ' ' cfdi.agregarTraslado("IVA", CDec(16.0), Ventas.IVATC) - ' ' If Ventas.IEPS > 0 Then cfdi.agregarTraslado("IEPS", 10, Ventas.IEPS) - ' '#End Region - - - - '#Region "Nomina12" - ' Try - - - - ' cfdi._agregadoNomina12 = True - ' cfdi.Esquema.AgregarEsquema("http://www.sat.gob.mx/nomina12 http://www.sat.gob.mx/sitio_internet/cfd/nomina/nomina12.xsd") - ' cfdi.agregarNomina12(ObjCFDITimbre.Nomina.Version, ObjCFDITimbre.Nomina.TipoNomina, ObjCFDITimbre.Nomina.FechaPago, ObjCFDITimbre.Nomina.FechaInicio, ObjCFDITimbre.Nomina.FechaFin, ObjCFDITimbre.Nomina.NumDiasPagados, ObjCFDITimbre.Nomina.TotalPercepciones, ObjCFDITimbre.Nomina.TotalDeducciones, ObjCFDITimbre.Nomina.TotalOtrosPagos) - - ' cfdi.agregarNominaEmisor12(ObjCFDITimbre.Emisor.CURP, ObjCFDITimbre.Emisor.RegistroPatronal, ObjCFDITimbre.Emisor.RFC) - - ' If UsuarioActual.Empresa.UsaAC Then cfdi.agregarNominaEmisorEntidadSNCF12("IF", "90") - - ' If ObjCFDITimbre.Nomina.Percepciones IsNot Nothing AndAlso ObjCFDITimbre.Nomina.Percepciones.Count > 0 Then - ' Dim TotalIndemnizacion As String = If(ObjCFDITimbre.Nomina.TotalIndemnizacion > 0, ObjCFDITimbre.Nomina.TotalIndemnizacion.ToString, "") - ' Dim TotalJubilacion As String = If(ObjCFDITimbre.Nomina.TotalJubilacion > 0, ObjCFDITimbre.Nomina.TotalJubilacion.ToString, "") - ' cfdi.agregarNominaPercepciones12(ObjCFDITimbre.Nomina.TotalSueldos, TotalIndemnizacion, TotalJubilacion, ObjCFDITimbre.Nomina.TotalPercepcionesGravado, ObjCFDITimbre.Nomina.TotalPercepcionesExento) - ' For Each percep As CFDINominaPercepciones In ObjCFDITimbre.Nomina.Percepciones - ' cfdi.agregarNominaPercepcionesPercepcion12(percep.TipoPercepcion, percep.Clave, percep.Concepto, Math.Round(percep.ImporteGravado, 2), Math.Round(percep.ImporteExento, 2)) - ' Next - ' End If - ' 'cfdi.agregarNominaReceptorSubContratacion12("AAD990814BP6", "50") - ' 'cfdi.agregarNominaPercepcionesPercepcionAccionesOTitulos12("100", "200"); - ' 'cfdi.agregarNominaPercepcionesSeparacionIndemnizacion12("100", "10", "1000", "100", "50"); - ' 'cfdi.agregarNominaPercepcionesJubilacionPensionRetiro12("50", "100", "10", "100", "0"); - - ' If ObjCFDITimbre.Nomina.HorasExtras IsNot Nothing AndAlso ObjCFDITimbre.Nomina.HorasExtras.Count > 0 Then - ' For Each HoraExtra As CFDINominaHorasExtras In ObjCFDITimbre.Nomina.HorasExtras - ' cfdi.agregarNominaPercepcionesPercepcionHorasExtra12(HoraExtra.Dias, HoraExtra.TipoHoras, HoraExtra.HorasExtra, HoraExtra.ImportePagado) - ' Next - ' End If - - ' If ObjCFDITimbre.Nomina.Incapacidades IsNot Nothing AndAlso ObjCFDITimbre.Nomina.Incapacidades.Count > 0 Then - ' For Each Incap As CFDINominaIncapacidades In ObjCFDITimbre.Nomina.Incapacidades - ' cfdi.agregarNominaIncapacidadesIncapacidad12(Incap.DiasIncapacidad, Incap.TipoIncapacidad, Incap.Importe) - ' Next - ' End If - - ' If ObjCFDITimbre.Nomina.Deducciones IsNot Nothing AndAlso ObjCFDITimbre.Nomina.Deducciones.Count > 0 Then - ' cfdi.agregarNominaDeducciones12(ObjCFDITimbre.Nomina.TotalDeduccionesOtras, Math.Round(ObjCFDITimbre.Nomina.TotalDeduccionesImpuestosRetenidos, 2)) - ' For Each deduc As CFDINominaDeducciones In ObjCFDITimbre.Nomina.Deducciones - ' cfdi.agregarNominaDeduccionesDeduccion12(deduc.TipoDeduccion, deduc.Clave, deduc.Concepto, Math.Round(deduc.Importe, 2)) - ' Next - ' End If - - ' If ObjCFDITimbre.Nomina.OtrosPagos IsNot Nothing Then - ' ' cfdi.agregarNominaOtrosPagosOtroPago12("002", "002", "Subsidio", "10.00"); - ' ' cfdi.agregarNominaOtrosPagosOtroPagoSubsidioAlEmpleo12("10.00"); - ' If ObjCFDITimbre.Nomina.OtrosPagos IsNot Nothing AndAlso ObjCFDITimbre.Nomina.OtrosPagos.Count > 0 Then - ' For Each otpag As CFDINominaOtrosPagos In ObjCFDITimbre.Nomina.OtrosPagos - ' cfdi.agregarNominaOtrosPagosOtroPago12(otpag.TipoOtroPago, otpag.Clave, otpag.Concepto, otpag.Importe) - ' If otpag.TipoOtroPago = "002" Then - ' cfdi.agregarNominaOtrosPagosOtroPagoSubsidioAlEmpleo12(otpag.Importe) - ' End If - - ' Next - ' End If - ' End If - - - '#Region "Receptor" - - ' cfdi.agregarNominaReceptor12(ObjCFDITimbre.Nomina.Receptor.CURP, - ' ObjCFDITimbre.Nomina.Receptor.NSS, - ' ObjCFDITimbre.Nomina.Receptor.FechaInicioContrato, - ' ObjCFDITimbre.Nomina.Receptor.Antiguedad, - ' ObjCFDITimbre.Nomina.Receptor.TipoContrato, - ' ObjCFDITimbre.Nomina.Receptor.Sindicalizado, - ' ObjCFDITimbre.Nomina.Receptor.CodigoTipoJornada, - ' ObjCFDITimbre.Nomina.Receptor.CodigoRegimenContratacion, - ' ObjCFDITimbre.Nomina.Receptor.CodigoEmpleado, - ' ObjCFDITimbre.Nomina.Receptor.Departamento, - ' ObjCFDITimbre.Nomina.Receptor.Puesto, - ' ObjCFDITimbre.Nomina.Receptor.CodigoRiesgoPuesto, - ' ObjCFDITimbre.Nomina.Receptor.TipoPeriodo, - ' ObjCFDITimbre.Nomina.Receptor.CodigoBanco, - ' ObjCFDITimbre.Nomina.Receptor.NumeroCuenta, - ' ObjCFDITimbre.Nomina.Receptor.SBC, - ' ObjCFDITimbre.Nomina.Receptor.SDI, - ' ObjCFDITimbre.Nomina.Receptor.CodigoEntidadFederativa) - - - '#End Region - - - '#End Region - - ' 'String banco = cfdi.buscarClaveCatalogo("c_Banco", "BANAMEX"); - - - '#End Region - - - - '#Region "Genera XML" - ' Try - ' cfdi.generaXMLBase64(llaveBase64, Clave) - ' cfdi.escribirXML(cfdi.Xml, RutaArchivo, NombreArchivoXML) - ' Catch ex As Exception - - ' End Try - - '#End Region - - '#Region "Timbra" - ' cfdi.timbrar(UsuarioServicio, ClaveServicio, UrlServicio, RutaArchivo, NombreArchivoXML) - '#End Region - ' 'Verifica el error - ' If cfdi.CodigoError = 0 Then - - ' Dim FechaCertificacion As DateTime - ' Dim FolioFiscal, NoSerieCertificado, NoSerieCertificadoContribuyente, SelloCFDi, SelloSAT As String - - ' FolioFiscal = obtenerAtributo(cfdi.Xml, "TimbreFiscalDigital", "UUID") 'XmlDoc.DocumentElement("cfdi:Complemento").FirstChild.Attributes("UUID").InnerText - ' NoSerieCertificado = obtenerAtributo(cfdi.Xml, "Comprobante", "noCertificado") ''++Pendiente - ' FechaCertificacion = obtenerAtributo(cfdi.Xml, "TimbreFiscalDigital", "FechaTimbrado").ToDate - ' SelloCFDi = cfdi.SelloEmisor - ' SelloSAT = cfdi.SelloSat - ' NoSerieCertificadoContribuyente = obtenerAtributo(cfdi.Xml, "TimbreFiscalDigital", "noCertificadoSAT") ''++Pendiente - - ' If FolioFiscal <> "" Then - ' ''Actualiza Estatus Factura - ' If UsuarioActual.Empresa.FacturaProduccion Then - ' Dim ObjNomina2 As New ClsNominas() - ' ObjNomina2.UpdateEstatusNomNominas(3, UsuarioActual.Empresa.CvePAC, FolioFiscal, "", ("01/01/2000").ToDate, ObjCFDITimbre.Nomina.CveNomina, 0, 0, 0, 0, 0) - ' ObjNomina2.Dispose() - ' End If - - ' 'Dim ObjVentas As New ClsVentas() - ' 'Retorno = ObjVentas.UpdateEstatusFactura(3, FolioFiscal, "", Now, Ventas.CveVenta, CvePAC:=UsuarioActual.Empresa.CvePAC) - ' 'ObjVentas.Dispose() - ' If Not Directory.Exists(Ruta & "CBB\") Then Directory.CreateDirectory(Ruta & "CBB\") - ' If Not Directory.Exists(Ruta & "CBB\Nomina\") Then Directory.CreateDirectory(Ruta & "CBB\Nomina\") - - - ' Dim RutaCBB As String = $"{Ruta}CBB\Nomina\{ObjCFDITimbre.Comprobante.SerieFolio}.jpg" - ' Dim b As Byte() = cfdi.ConvertirQrCode($"?re={UsuarioActual.Empresa.RFC}&rr={ObjCFDITimbre.Receptor.RFC}&tt={String.Format("{0,12:F6}", ObjCFDITimbre.Comprobante.Total).Trim()}&id={FolioFiscal}") - ' File.WriteAllBytes(RutaCBB, b) - - - ' Retorno = "" - ' Else - ' Retorno = "No se pudo timbrar ante el SAT. UUID no generado." - ' End If - - - ' Else - ' Retorno = cfdi.MensajeError - ' End If - - ' Catch ex As Exception - ' Retorno = "Error al registrar nómina" - ' End Try - - ' Return Retorno - ' End Function - - 'Private Function obtenerAtributo(cadena_xml As String, nodo As String, nombre_atributo As String) As String - ' Try - ' 'Variables - ' Dim valor As String - ' Dim inicio As Integer = 0 - ' Dim fin As Integer = 0 - ' Dim inicionodo As Integer = cadena_xml.IndexOf(nodo) - ' If inicionodo = -1 Then - ' Return "" - ' End If - ' 'Buscamos inicio - ' inicio = cadena_xml.IndexOf((Convert.ToString(" ") & nombre_atributo) + "=""", inicionodo) + nombre_atributo.Length + 3 - ' 'Buscamos el final - ' fin = cadena_xml.IndexOf("""", inicio) - ' 'Cortamos la cadena - ' valor = cadena_xml.Substring(inicio, fin - inicio) - ' 'Retorna el valor - ' Return valor - ' Catch - ' Return "" - ' End Try - 'End Function - - - Private Sub ActualizaTimbrado(Data As Object) - Dim Parametros As ActualizaTimbre = CType(Data, ActualizaTimbre) - Dim ObjNomina As New ClsNominas() - ObjNomina.UpdateNom_NominasTimbre(Parametros.Estatus, Parametros.CveNomina) - ObjNomina.Dispose() - End Sub - - Private Sub ActualizaCadenaOriginal(CadenaOriginal As Object) - Dim ObjNomina As New ClsNominas() - ObjNomina.UpdateNom_NominaCadenaOriginal(CadenaOriginal.ToString, CveNominaT) - ObjNomina.Dispose() - End Sub - - Private Sub ActualizaEstatus(CveEstatus As Object) - - 'If UsuarioActual.Empresa.FacturaProduccion Then - ' Dim ObjNomina As New ClsNominas() - ' ObjNomina.UpdateEstatusNom_Nominas(CInt(CveEstatus), FolioFiscal, "", Now, CveNominaT) - ' ObjNomina.Dispose() - 'End If - - End Sub - - - -#End Region - -#Region " DESCARGAR ZIP PDF, XML" - Private Sub ImgDownZip_Click(sender As Object, e As EventArgs) Handles ImgDownZip.Click - - Dim pathXML As String - Dim pathPDF As String - - 'Using archive As ZipArchive = Compression.ZipFile.Open(String.Format("{0}nomina.zip", UsuarioActual.Empresa.Ruta), ZipArchiveMode.Create) - ' For Each gvr As GridViewRow In GVDatos.Rows - ' If gvr.DataKey("CvePersonal").ToEntero > 0 Then - ' pathXML = Server.MapPath(String.Format("~/Empresas/{0}/XML/Nomina/{1}.xml", UsuarioActual.CveEmpresa, gvr.DataKey("SerieFolio").ToString)) - ' pathPDF = Server.MapPath(String.Format("~/Empresas/{0}/PDF/Nomina/{1}.pdf", UsuarioActual.CveEmpresa, gvr.DataKey("SerieFolio").ToString)) - - - ' If IO.File.Exists(pathXML) Then - ' archive.CreateEntryFromFile(pathXML, String.Format("{0}.xml", gvr.DataKey("SerieFolio").ToString)) - ' End If - - ' If IO.File.Exists(pathPDF) Then - ' archive.CreateEntryFromFile(pathPDF, String.Format("{0}.pdf", gvr.DataKey("SerieFolio").ToString)) - ' End If - ' End If - ' Next - 'End Using - - - 'D E S C A R G A I O N I C ! - Dim DescargaZIP As Ionic.Zip.ZipFile = New Ionic.Zip.ZipFile() - Using DescargaZIP - For Each gvr As GridViewRow In GVDatos.Rows - If gvr.DataKey("CvePersonal").ToEntero > 0 Then - pathXML = Server.MapPath(String.Format("~/Empresas/{0}/XML/Nomina/{1}.xml", UsuarioActual.CveEmpresa, gvr.DataKey("SerieFolio").ToString)) - pathPDF = Server.MapPath(String.Format("~/Empresas/{0}/PDF/Nomina/{1}.pdf", UsuarioActual.CveEmpresa, gvr.DataKey("SerieFolio").ToString)) - - - If IO.File.Exists(pathXML) Then - DescargaZIP.AddFile(pathXML, "") - End If - - If IO.File.Exists(pathPDF) Then - DescargaZIP.AddFile(pathPDF, "") - End If - - End If - Next - DescargaZIP.Save(Response.OutputStream) - End Using - - Response.AddHeader("content-Disposition", "attachment; filename=NominaTimbrado.zip") - Response.ContentType = "application/zip" - Response.End() - - End Sub -#End Region - - Protected Sub LnkCorreos_Click(sender As Object, e As EventArgs) - - EnvioMasivoCorreo() - - End Sub - - Private Sub CrearLayout(DTNomina As DataTable) - - Dim sb As New StringBuilder - Dim SbErrores As New StringBuilder - Dim ErroresValidaciones As Boolean = False - - - SbErrores.AppendLine("Se detectaron los siguientes errores en la generación del layout") - - For Each dRow As DataRow In DTNomina.Rows - - Dim RFC As String = dRow("RFC").ToString() - Dim Nombre As String = dRow("Nombre").ToString() - Dim BancoNumCuenta As String = dRow("BancoNumCuenta").ToString() - Dim Importe As Decimal = dRow("Importe").ToString().ToDecimal - - - - If RFC.Trim().Length = 0 Then - SbErrores.AppendLine($"El RFC es requerido del empleado {Nombre}
    ") - End If - - Dim Coincidencia As Match = System.Text.RegularExpressions.Regex.Match(RFC, "/^([A-Z,Ñ,&]{3,4}([0-9]{2})(0[1-9]|1[0-2])(0[1-9]|1[0-9]|2[0-9]|3[0-1])[A-Z|\d]{3})$/") - If Not Coincidencia.Success Then - SbErrores.AppendLine($"El RFC {RFC} del empleado {Nombre} no es valido
    ") - ErroresValidaciones = True - End If - - If BancoNumCuenta.Trim().Length <> 10 Then - SbErrores.AppendLine($"Empleado {Nombre} numero de cuenta incorrecto, la cuenta debe de tener 10 caracteres
    ") 'Bancomer 10 caracteres - ErroresValidaciones = True - End If - - - If Importe <= 0 Then - SbErrores.AppendLine($"Empleado {Nombre} el importe debe de ser mayor a 0 importe {Importe}") 'importe mayot a 0 - ErroresValidaciones = True - End If - - Next - - ErroresValidaciones = False - - If Not ErroresValidaciones Then - - Dim Count As Integer = 1 - For Each dRow As DataRow In DTNomina.Rows - - Dim SbLinea As New StringBuilder - - Dim RFC As String = dRow("RFC").ToString() - Dim Nombre As String = dRow("Nombre").ToString() - Dim BancoNumCuenta As String = dRow("BancoNumCuenta").ToString() - Dim Importe As Decimal = dRow("Importe").ToString().ToDecimal.RoundSQL(2) - - SbLinea.Append(Count.ToString("000000000")) - SbLinea.Append(RFC.Trim().PadRight(16)) - SbLinea.Append("03") - SbLinea.Append(BancoNumCuenta.Trim().PadRight(20)) - SbLinea.Append(Importe.ToString("0000000000000.00").Replace(".", "")) - - - If Nombre.Trim().Length > 40 Then - Nombre = Nombre.Substring(0, 40) - End If - - SbLinea.Append(Nombre.Trim().PadRight(40)) - - SbLinea.Append("012") - SbLinea.Append("000") - - sb.AppendLine(SbLinea.ToString()) - - - Count = Count + 1 - Next - - - Response.Clear() - Response.ClearHeaders() - Response.AppendHeader("Content-Length", sb.ToString()) - Response.ContentType = "text/plain" - Response.AppendHeader("Content-Disposition", $"attachment;filename=""Nomina{Now.ToString("yyyyMMddhhmmss").ToString()}.txt""") - Response.Write(sb.ToString()) - Response.End() - - - Else - Alert(SbErrores.ToString(), TipoMensaje.MsgAdvertencia) - End If - - - - - End Sub - - Private Sub EnvioMasivoCorreo() - - If GVDatos.Rows.Count > 0 Then - - Dim Periodo As Integer = DdlPeriodo.SelectedValue.ToEntero - - Dim objNommina As New ClsNominas - objNommina.GetPeriodos(-1, UsuarioActual.Empresa.CveEmpresa, -1, -1, Periodo) - Dim DT As DataTable = objNommina.DtResultados - - Dim FechaI = DT.Rows(0)("FechaInicio").ToString.ToDate.ToShortDateString - Dim FechaF = DT.Rows(0)("FechaFin").ToString.ToDate.ToShortDateString - - objNommina.Dispose() - - For Each gvr As GridViewRow In GVDatos.Rows - If gvr.DataKey("SeTimbro") = "True" Then - - Dim NombreComercial As String = UsuarioActual.Empresa.Empresa - Dim SerieFolio As String = gvr.DataKey("SerieFolio") - Dim Personal As String = gvr.DataKey("Nombre") - Dim Destinatario As String = gvr.DataKey("Correo") - Dim cvePeriodo = gvr.DataKey("CvePeriodo").ToString.ToEntero - Dim CvePersonal = gvr.DataKey("CvePersonal").ToString.ToEntero - - MandaCorreo(NombreComercial, SerieFolio, Destinatario, Personal, FechaI, FechaF, cvePeriodo, CvePersonal) - End If - Next - - Alert("Envio de Correos exitoso", TipoMensaje.MsgInformacion) - Else - Alert("Favor de Carga un Periodo", TipoMensaje.MsgError) - End If - End Sub - -End Class - -#Region "Nomina" -#End Region diff --git a/Nomina/Nomina2.aspx b/Nomina/Nomina2.aspx deleted file mode 100644 index 20c87ea82..000000000 --- a/Nomina/Nomina2.aspx +++ /dev/null @@ -1,2859 +0,0 @@ -<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Nomina2.aspx.cs" Inherits="Nomina_Nomina2" %> - - - - - - - - Nominas - - - - - - - -
  • - Autorizar -
  • -
  • - Registrar provisión -
  • -
  • - Layout banco -
  • -
  • - Ver provisión -
  • -
  • - Ver provisión Asimilados -
  • -
  • - Timbrar todos -
  • -
  • - Incidencias asistencia -
  • -
  • - Reporte percepciones y deducciones -
  • -
  • - Reporte acumulados -
  • -
  • - Empleado concepto -
  • -
  • - Carga masiva de asistencia -
  • -
  • - Lista de raya -
  • -
  • - Cargar masiva de conceptos -
  • -
  • - Tablas de cálculo -
  • -
  • - Cálculo ISR -
  • -
  • - Ir a asistencia -
  • -
  • - Nómina tabular -
  • -
  • - Simulador -
  • -
  • - Procesar archivo SUA -
  • -
  • - Descargar archivos SUA -
  • -
  • - Recibos timbrados -
  • -
    - - - - - - -
    - -
    - - - - - - -
    -
    -
    -
    - -
    - -
    - - -
    - - - -
    - - -
    - - - -
    -
    - - <%----%> - <%----%> - - - - - Recibos -
    -
    -
    -
    - -
    -
    - -
    -
    -
    - - - - - - - -
    -
    -
    - - Nomina -
    - -
    - - -
    -
    -
    -
    -
    -
    - - -
    -
    -
    - - - - - - - - - - - - Nombre - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
    -
    -
    - -
    - - - -
    -
    -
    -
    -
    - - - - -
    -
    -
    - - Asistencia -
    - -
    - - -
    -
    -
    -
    -
    -
    - - -
    -
    - -
    -
    -
    -
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - diff --git a/Nomina/Nomina2.aspx.cs b/Nomina/Nomina2.aspx.cs deleted file mode 100644 index dde8ba866..000000000 --- a/Nomina/Nomina2.aspx.cs +++ /dev/null @@ -1,6186 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.UI; -using System.Web.UI.WebControls; -using Extensiones; -using System.Data; -using System.Text; -using static Extensiones.ModExtensiones; -using System.Drawing; -using iTextSharp.text.pdf; -using System.IO; -using System.Data.SqlClient; -using System.Configuration; - -public partial class Nomina_Nomina2 : ClsPaginas -{ - #region Propiedades - private int FilaConceptos - { - get { return 5; } - } - - private DataTable dtPeriodos - { - get - { - if (ViewState["dtPeriodos"] == null) { return null; } - else { return (DataTable)ViewState["dtPeriodos"]; } - } - - set { ViewState["dtPeriodos"] = value; } - } - private DataTable dtConceptos - { - get - { - if (ViewState["dtConceptos"] == null) { return null; } - else { return (DataTable)ViewState["dtConceptos"]; } - } - - set { ViewState["dtConceptos"] = value; } - } - - private DataTable dtempleadosConceptos - { - get - { - if (ViewState["dtempleadosConceptos"] == null) { return null; } - else { return (DataTable)ViewState["dtempleadosConceptos"]; } - } - - set { ViewState["dtempleadosConceptos"] = value; } - } - private DataTable dtempleados - { - get - { - if (ViewState["dtempleados"] == null) { return null; } - else { return (DataTable)ViewState["dtempleados"]; } - } - - set { ViewState["dtempleados"] = value; } - } - private DataTable DtSuaProcesado - { - get - { - if (ViewState["dtempleados"] == null) { return null; } - else { return (DataTable)ViewState["dtempleados"]; } - } - - set { ViewState["dtempleados"] = value; } - } - - protected bool PermisoCancelarEmitido - { - get - { - if (ViewState["PermisoCancelarEmitido"] == null) { return false; } - else { return (bool)ViewState["PermisoCancelarEmitido"]; } - } - - set { ViewState["PermisoCancelarEmitido"] = value; } - } - protected bool PermisoAutorizar - { - get - { - if (ViewState["PermisoAutorizar"] == null) { return false; } - else { return (bool)ViewState["PermisoAutorizar"]; } - } - - set { ViewState["PermisoAutorizar"] = value; } - } - protected bool PermisoEmitir - { - get - { - if (ViewState["PermisoEmitir"] == null) { return false; } - else { return (bool)ViewState["PermisoEmitir"]; } - } - - set { ViewState["PermisoEmitir"] = value; } - } - protected int CvePeriodoSeleccionado - { - get - { - if (ViewState["CvePeriodoSeleccionado"] == null) { return 0; } - else { return ViewState["CvePeriodoSeleccionado"].ToString().ToEntero(); } - } - - set { ViewState["CvePeriodoSeleccionado"] = value; } - } - - protected int CcveMovtoPermanente - { - get - { - if (ViewState["CcveMovtoPermanente"] == null) { return 0; } - else { return ViewState["CcveMovtoPermanente"].ToString().ToEntero(); } - } - - set { ViewState["CcveMovtoPermanente"] = value; } - } - - protected int FiltCveProyecto - { - get - { - if (ViewState["FiltCveProyecto"] == null) { return 0; } - else { return ViewState["FiltCveProyecto"].ToString().ToEntero(); } - } - - set { ViewState["FiltCveProyecto"] = value; } - } - protected int FiltCveSubProyecto - { - get - { - if (ViewState["FiltCveSubProyecto"] == null) { return 0; } - else { return ViewState["FiltCveSubProyecto"].ToString().ToEntero(); } - } - - set { ViewState["FiltCveSubProyecto"] = value; } - } - protected int FiltCveTurno - { - get - { - if (ViewState["FiltCveTurno"] == null) { return 0; } - else { return ViewState["FiltCveTurno"].ToString().ToEntero(); } - } - - set { ViewState["FiltCveTurno"] = value; } - } - protected int FiltCvePeriodo - { - get - { - if (ViewState["FiltCvePeriodo"] == null) { return 0; } - else { return ViewState["FiltCvePeriodo"].ToString().ToEntero(); } - } - - set { ViewState["FiltCvePeriodo"] = value; } - } - protected int FiltAgrupador - { - get - { - if (ViewState["FiltAgrupador"] == null) { return 0; } - else { return ViewState["FiltAgrupador"].ToString().ToEntero(); } - } - - set { ViewState["FiltAgrupador"] = value; } - } - #endregion - protected void Page_Load(object sender, EventArgs e) - { - if (!IsPostBack) - { - LnkVerCalculoISR.Visible = (UsuarioActual.CveUsuario == 100); - TxtPeriodo.Text = $"{DateTime.Now:yyyyMM}"; - CargarCentrosDeCosto(DdlProyecto, DdlSubProyecto, LblProyecto, LblSubProyeccto); - cargaEjercicios(); - CargaTiposPeriodo(); - cargaPeriodos(); - DdlTurno.DataSource = GlobalDTTurno.FiltraParametros($"CveEmpresa = { UsuarioActual.CveEmpresa}"); - DdlTurno.DataBind(); - //Permisos - if (UsuarioActual.TienePermisoProceso(82)) - { - PermisoAutorizar = true; - } - else - { - PermisoAutorizar = false; - } - if (UsuarioActual.TienePermisoProceso(83)) - { - PermisoEmitir = true; - PermisoCancelarEmitido = true; - } - else - { - PermisoEmitir = false; - PermisoCancelarEmitido = false; - } - DataTable dtperinc = null; - using (ClsNominas onom = new ClsNominas()) - { - if (onom.PersonalIncapacidadCatalogos()) - { - dtperinc = onom.DtResultados; - } - } - if (dtperinc != null) - { - DdlSRINCcveTipodeIncidencia.DataSource = dtperinc.FiltraParametros("Tipo = -1 OR Tipo =1 "); - DdlSRINCcveRamoSeguro.DataSource = dtperinc.FiltraParametros("Tipo = -1 OR Tipo =2 "); - DdlSRINCcveTipoRiesgo.DataSource = dtperinc.FiltraParametros("Tipo = -1 OR Tipo =3 "); - DdlSRINCcveSecuelaConsecuencia.DataSource = dtperinc.FiltraParametros("Tipo = -1 OR Tipo =4 "); - DdlSRINCcveControlIncapacidad.DataSource = dtperinc.FiltraParametros("Tipo = -1 OR Tipo =5 "); - - DdlSRINCcveTipodeIncidencia.DataBind(); - DdlSRINCcveRamoSeguro.DataBind(); - DdlSRINCcveTipoRiesgo.DataBind(); - DdlSRINCcveSecuelaConsecuencia.DataBind(); - DdlSRINCcveControlIncapacidad.DataBind(); - } - } - - } - #region Filtros - private void cargaEjercicios() - { - int EjercicioActual = UsuarioActual.Empresa.EjercicioActual; - if (EjercicioActual == 0) - { - EjercicioActual = DateTime.Now.Year; - } - DataTable dtejercicio = null; - using (ClsNominas objnom = new ClsNominas()) - { - if (objnom.GetEjercicios(UsuarioActual.CveEmpresa)) - { - dtejercicio = objnom.DtResultados; - } - } - DdlEjercicios.DataSource = dtejercicio; - DdlEjerciciosCM.DataSource = dtejercicio; - DdlEjercicios.DataBind(); - DdlEjerciciosCM.DataBind(); - ListItem litem = null; - if ((dtejercicio != null) && dtejercicio.Rows.Count > 0) - { - if (dtejercicio.COUNT("Ejercicio", string.Format("Ejercicio={0}", EjercicioActual)) == 0) - { - litem = new ListItem(EjercicioActual.ToString(), EjercicioActual.ToString()); - DdlEjercicios.Items.Insert(0, litem); - DdlEjerciciosCM.Items.Insert(0, litem); - } - if (dtejercicio.COUNT("Ejercicio", string.Format("Ejercicio={0}", (EjercicioActual - 1))) == 0) - { - litem = new ListItem((EjercicioActual - 1).ToString(), (EjercicioActual - 1).ToString()); - DdlEjercicios.Items.Insert(1, litem); - DdlEjerciciosCM.Items.Insert(1, litem); - } - } - else - { - litem = new ListItem(EjercicioActual.ToString(), EjercicioActual.ToString()); - DdlEjercicios.Items.Insert(0, litem); - DdlEjerciciosCM.Items.Insert(0, litem); - litem = new ListItem((EjercicioActual - 1).ToString(), (EjercicioActual - 1).ToString()); - DdlEjercicios.Items.Insert(0, litem); - DdlEjerciciosCM.Items.Insert(0, litem); - - } - if (DdlEjercicios.Items.Count > 0) - { - DdlEjercicios.SelectedIndex = 0; - } - DdlEjercicios.SelectedValueExist(DateTime.Now.Year.ToString()); - } - private void CargaTiposPeriodo() - { - DdlTipoPeriodo.DataSource = GlobalDTTipoPeriodo.FiltraParametros("Estatus = 'Activo'"); - DdlTipoPeriodoCM.DataSource = DdlTipoPeriodo.DataSource; - DdlTipoPeriodoSim.DataSource = DdlTipoPeriodo.DataSource; - DdlTipoPeriodoSim.DataBind(); - DdlTipoPeriodoCM.DataBind(); - DdlTipoPeriodo.DataBind(); - DdlTipoPeriodo.Items.Insert(0, new ListItem("Seleccione", "-1")); - if (DdlTipoPeriodo.Items.Count > 0) - { - DdlTipoPeriodo.SelectedIndex = 0; - } - } - private void cargaPeriodos() - { - int tipoPeriodo = DdlTipoPeriodo.SelectedValue.ToEntero(); - int ejercicio = DdlEjercicios.SelectedValue.ToEntero(); - dtPeriodos = null; - if (DdlTipoPeriodo.SelectedValue.ToEntero() > 0) - { - using (ClsNominas objperiodos = new ClsNominas()) - { - if (objperiodos.GetPeriodos(tipoPeriodo, UsuarioActual.CveEmpresa, ejercicio, -1, -1)) - { - dtPeriodos = objperiodos.DtResultados.FiltraParametros("Estatus IN (1,2,3,4,5)"); - } - } - } - DdlPeriodo.DataSource = dtPeriodos; - DdlPeriodo.DataBind(); - DdlPeriodo.Items.Insert(0, new ListItem("Seleccione", "-1")); - muestraPeriodo(); - } - - protected void DdlEjercicios_SelectedIndexChanged(object sender, EventArgs e) - { - cargaPeriodos(); - } - - protected void DdlTipoPeriodo_SelectedIndexChanged(object sender, EventArgs e) - { - cargaPeriodos(); - DdlEjercicios.AutoPostBack = true; - } - - protected void DdlPeriodo_SelectedIndexChanged(object sender, EventArgs e) - { - muestraPeriodo(); - } - private void muestraPeriodo() - { - int CvePeriodo = DdlPeriodo.SelectedValue.ToEntero(); - LnkConsultar.Visible = (CvePeriodo > 0); - UPFiltros.Update(); - UpDatos.Update(); - } - #endregion - #region Datos - - protected void LnkConsultar_Click(object sender, EventArgs e) - { - FiltCveProyecto = DdlProyecto.SelectedValue.ToEntero(); - FiltCveSubProyecto = DdlSubProyecto.SelectedValue.ToEntero(); - FiltCveTurno = DdlTurno.SelectedValue.ToEntero(); - FiltCvePeriodo = DdlPeriodo.SelectedValue.ToEntero(); - LtlPeriodoseleccionado.Text = DdlPeriodo.SelectedItem.Text; - FiltAgrupador = 1; - HypPDFSTimbrados.Attributes.Add("onclick", string.Format("GETPDF({0},{1})", -1, FiltCvePeriodo)); - cargaDatos(); - - } - public void cargaDatos(bool cargaasistencia = true) - { - int CveEmpresa = UsuarioActual.CveEmpresa; - - bool continuar = false; - CvePeriodoSeleccionado = 0; - dtempleados = null; - dtConceptos = null; - DataTable dtPeriodo = new DataTable(); - DataTable dtasistencia = new DataTable(); - LnkAutorizar.Visible = false; - if (FiltCvePeriodo > 0) - { - - int Estatus = 0; - using (ClsNominas objnom = new ClsNominas()) - { - if (objnom.GetPeriodos(-1, UsuarioActual.CveEmpresa, -1, -1, FiltCvePeriodo)) - { - DataRow drow = objnom.DtResultados.Rows[0]; - Estatus = drow["Estatus"].ToString().ToEntero(); - int CvePrePolizaProvision = drow["CvePrePolizaProvision"].ToString().ToEntero(); - int CvePrePolizaProvisionAsimilados = drow["CvePrePolizaAsimilables"].ToString().ToEntero(); - LnkConceptoEmpleado.Visible = (Estatus == 1); - LnkRegistrarProvision.Visible = (Estatus >= 2) && CvePrePolizaProvision <= 0; - LnkConceptoEmpleado.Visible = (Estatus < 2); - LnkCargaAsistenciaMasiva.Visible = (Estatus < 2); - LnkModalPlantillaNomina.Visible = (Estatus < 2); - LnkTimbrarTodos.Visible = (Estatus > 2); - - LnkLayoutContable.Visible = (Estatus > 2); - LnkProvisionNomina.Visible = CvePrePolizaProvision > 0; - LnkProvisionNomina.NavigateUrl = $"../Contabilidad/RegPrePoliza.aspx?CvePrePoliza={CvePrePolizaProvision}"; - LnkProvisionNominaAsimilados.Visible = CvePrePolizaProvision > 0; - LnkProvisionNominaAsimilados.NavigateUrl = $"../Contabilidad/RegPrePoliza.aspx?CvePrePoliza={CvePrePolizaProvisionAsimilados}"; - UpAccciones.Update(); - } - LnkListaRaya.Visible = true; - LnkAsistenciaIncidencias.Visible = true; - - LnkFormatoTabular.Visible = true; - HypPDFSTimbrados.Visible = true; - if (objnom.GetNominaEmpleado(FiltCveProyecto, FiltCveSubProyecto, FiltCveTurno, FiltCvePeriodo, CveEmpresa, FiltAgrupador, DdlRegimenContratacion.SelectedValue.ToEntero()) && objnom.DTSetResultados.Tables.Count > 1) - { - dtempleados = objnom.DTSetResultados.Tables[3]; - dtempleadosConceptos = objnom.DTSetResultados.Tables[4]; - dtConceptos = objnom.DTSetResultados.Tables[0]; - dtPeriodo = objnom.DTSetResultados.Tables[1]; - dtasistencia = objnom.DTSetResultados.Tables[2]; - CvePeriodoSeleccionado = FiltCvePeriodo; - continuar = true; - } - - LnkTimbrarTodos.Visible = dtempleados.Rows.Count > 0 && dtempleados.COUNT("CvePersonal", "SeTimbro=0 AND CvePersonal >0") > 0; - } - - } - #region CargaGrid - if (continuar) - { - - //string ctipo = "P"; - /* - while (GvNominas.Columns.Count > 3) - { - GvNominas.Columns.RemoveAt(2); - //GvNominas.Columns.sa(); - }*/ - - int CurrentColumn = 2; - BoundField bf; - foreach (DataRow row in dtConceptos.FiltraParametros("Tipo IN ('P') AND EsPadre = 1 ").Rows) - { - int CveConcepto = row["CveConcepto"].ToString().ToEntero(); - int SoloVisible = row["SoloVisible"].ToString().ToEntero(); - string Concepto = row["Concepto"].ToString(); - GvNominas.Columns[CurrentColumn].ItemStyle.BackColor = System.Drawing.Color.Transparent; - GvNominas.Columns[CurrentColumn].ItemStyle.CssClass = " "; - GvNominas.Columns[CurrentColumn].HeaderStyle.CssClass = " "; - if (SoloVisible == 1) - { - - GvNominas.Columns[CurrentColumn].HeaderStyle.CssClass = "isOnlyVisible "; - } - GvNominas.Columns[CurrentColumn].Visible = (dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) != 0); - bf = (BoundField)GvNominas.Columns[CurrentColumn]; - bf.DataField = string.Format("V_{0}", CveConcepto); - bf.HeaderText = Concepto; - if (GvNominas.Columns[CurrentColumn].Visible) - { - CurrentColumn++; - } - } - if (true) - { - BoundField field = (BoundField)GvNominas.Columns[CurrentColumn]; - - field.HeaderText = "Percepciones"; - field.DataField = "SumaPercepciones"; - field.ItemStyle.BackColor = System.Drawing.Color.LightGray; - GvNominas.Columns[CurrentColumn].Visible = true; - CurrentColumn++; - } - - foreach (DataRow row in dtConceptos.FiltraParametros("Tipo IN ('D') AND EsPadre = 1 ").Rows) - { - int CveConcepto = row["CveConcepto"].ToString().ToEntero(); - int SoloVisible = row["SoloVisible"].ToString().ToEntero(); - string Concepto = row["Concepto"].ToString(); - GvNominas.Columns[CurrentColumn].ItemStyle.BackColor = System.Drawing.Color.Transparent; - GvNominas.Columns[CurrentColumn].ItemStyle.CssClass = " "; - GvNominas.Columns[CurrentColumn].HeaderStyle.CssClass = " "; - if (SoloVisible == 1) - { - GvNominas.Columns[CurrentColumn].HeaderStyle.CssClass = "isOnlyVisible "; - } - GvNominas.Columns[CurrentColumn].Visible = (dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) != 0); - bf = (BoundField)GvNominas.Columns[CurrentColumn]; - bf.DataField = string.Format("V_{0}", CveConcepto); - bf.HeaderText = Concepto; - if (GvNominas.Columns[CurrentColumn].Visible) - { - CurrentColumn++; - } - } - - if (true) - { - BoundField field = (BoundField)GvNominas.Columns[CurrentColumn]; - field.HeaderText = "Deducciones"; - field.DataField = "SumaDeducciones"; - field.ItemStyle.BackColor = System.Drawing.Color.LightGray; - GvNominas.Columns[CurrentColumn].ItemStyle.CssClass = " "; - GvNominas.Columns[CurrentColumn].HeaderStyle.CssClass = " "; - GvNominas.Columns[CurrentColumn].Visible = true; - CurrentColumn++; - - field = (BoundField)GvNominas.Columns[CurrentColumn]; - field.HeaderText = "Total"; - field.DataField = "Total"; - field.ItemStyle.BackColor = System.Drawing.Color.DarkGray; - field.ItemStyle.CssClass = "TotalWhite"; - field.HeaderStyle.CssClass = "TotalWhite"; - - GvNominas.Columns[CurrentColumn].Visible = true; - CurrentColumn++; - } - - foreach (DataRow row in dtConceptos.FiltraParametros("Tipo IN ('O') AND EsPadre = 1 ").Rows) - { - int CveConcepto = row["CveConcepto"].ToString().ToEntero(); - int SoloVisible = row["SoloVisible"].ToString().ToEntero(); - string Concepto = row["Concepto"].ToString(); - GvNominas.Columns[CurrentColumn].ItemStyle.BackColor = System.Drawing.Color.Transparent; - GvNominas.Columns[CurrentColumn].ItemStyle.CssClass = " "; - GvNominas.Columns[CurrentColumn].HeaderStyle.CssClass = " "; - if (SoloVisible == 1) - { - GvNominas.Columns[CurrentColumn].HeaderStyle.CssClass = "isOnlyVisible "; - } - GvNominas.Columns[CurrentColumn].Visible = (dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) != 0); - bf = (BoundField)GvNominas.Columns[CurrentColumn]; - bf.DataField = string.Format("V_{0}", CveConcepto); - bf.HeaderText = Concepto; - - if (GvNominas.Columns[CurrentColumn].Visible) - { - CurrentColumn++; - } - } - if (true) - { - BoundField field = (BoundField)GvNominas.Columns[CurrentColumn]; - field.HeaderText = "Obligaciones"; - field.DataField = "SumaObligaciones"; - field.ItemStyle.BackColor = System.Drawing.Color.LightGray; - GvNominas.Columns[CurrentColumn].ItemStyle.CssClass = " "; - GvNominas.Columns[CurrentColumn].HeaderStyle.CssClass = " "; - GvNominas.Columns[CurrentColumn].Visible = true; - CurrentColumn++; - } - for (int i = CurrentColumn; i < 102; i++) - { - bf = (BoundField)GvNominas.Columns[i]; - bf.DataField = ""; - bf.HeaderText = ""; - GvNominas.Columns[i].ItemStyle.BackColor = System.Drawing.Color.Transparent; - GvNominas.Columns[CurrentColumn].ItemStyle.CssClass = " "; - GvNominas.Columns[CurrentColumn].HeaderStyle.CssClass = " "; - GvNominas.Columns[i].Visible = false; - - } - bool tr = false; - if (tr) - { - /* - bool sumaPercepciones = false; - bool sumaDeducciones = false; - if (GvNominas.Columns.Count > 3) - { - - foreach (DataRow row in dtConceptos.FiltraParametros("Tipo IN ('P','D','O') AND EsPadre = 1 ").Rows) - { - int CveConcepto = row["CveConcepto"].ToString().ToEntero(); - string Concepto = row["Concepto"].ToString(); - string Tipo = row["Tipo"].ToString(); - - if (Tipo != ctipo) - { - if (ctipo == "P") - { - CurrentColumn++; - if (Tipo != "D") - { - CurrentColumn++; - CurrentColumn++; - } - } - else if (ctipo == "D") - { - - CurrentColumn++; - CurrentColumn++; - } - ctipo = Tipo; - } - CurrentColumn++; - } - } - else - { - - foreach (DataRow row in dtConceptos.FiltraParametros("Tipo IN ('P','D','O') AND EsPadre = 1 ").Rows) - { - int CveConcepto = row["CveConcepto"].ToString().ToEntero(); - string Concepto = row["Concepto"].ToString(); - string Tipo = row["Tipo"].ToString(); - - if (Tipo != ctipo) - { - if (ctipo == "P") - { - - BoundField field = new BoundField(); - field.HeaderText = "Percepciones"; - field.DataField = "SumaPercepciones"; - field.DataFormatString = "{0:N2}"; - field.ItemStyle.Width = Unit.Pixel(120); - field.ItemStyle.HorizontalAlign = HorizontalAlign.Right; - field.ItemStyle.BackColor = System.Drawing.Color.LightGray; - GvNominas.Columns.Insert(CurrentColumn++, field); - sumaPercepciones = true; - if (Tipo != "D") - { - field = new BoundField(); - field.HeaderText = "Deducciones"; - field.DataField = "SumaDeducciones"; - field.DataFormatString = "{0:N2}"; - field.ItemStyle.Width = Unit.Pixel(120); - field.ItemStyle.HorizontalAlign = HorizontalAlign.Right; - field.ItemStyle.BackColor = System.Drawing.Color.LightGray; - field.ItemStyle.CssClass = " "; - field.HeaderStyle.CssClass = " "; - GvNominas.Columns.Insert(CurrentColumn++, field); - field = new BoundField(); - field.HeaderText = "Total"; - field.DataField = "Total"; - field.DataFormatString = "{0:N2}"; - field.ItemStyle.Width = Unit.Pixel(120); - field.ItemStyle.HorizontalAlign = HorizontalAlign.Right; - field.ItemStyle.BackColor = System.Drawing.Color.LightGray; - field.ItemStyle.CssClass = " "; - field.HeaderStyle.CssClass = " "; - GvNominas.Columns.Insert(CurrentColumn++, field); - sumaDeducciones = true; - } - } - else if (ctipo == "D") - { - - BoundField field = new BoundField(); - if (!sumaPercepciones) - { - - field.HeaderText = "Percepciones"; - field.DataField = "SumaPercepciones"; - field.DataFormatString = "{0:N2}"; - field.ItemStyle.Width = Unit.Pixel(120); - field.ItemStyle.HorizontalAlign = HorizontalAlign.Right; - field.ItemStyle.BackColor = System.Drawing.Color.LightGray; - field.ItemStyle.CssClass = " "; - field.HeaderStyle.CssClass = " "; - GvNominas.Columns.Insert(CurrentColumn++, field); - field = new BoundField(); - sumaPercepciones = true; - } - field.HeaderText = "Deducciones"; - field.DataField = "SumaDeducciones"; - field.DataFormatString = "{0:N2}"; - field.ItemStyle.Width = Unit.Pixel(120); - field.ItemStyle.HorizontalAlign = HorizontalAlign.Right; - field.ItemStyle.BackColor = System.Drawing.Color.LightGray; - field.ItemStyle.CssClass = " "; - field.HeaderStyle.CssClass = " "; - GvNominas.Columns.Insert(CurrentColumn++, field); - - field = new BoundField(); - field.HeaderText = "Total"; - field.DataField = "Total"; - field.DataFormatString = "{0:N2}"; - field.ItemStyle.Width = Unit.Pixel(120); - field.ItemStyle.HorizontalAlign = HorizontalAlign.Right; - field.ItemStyle.BackColor = System.Drawing.Color.LightGray; - field.ItemStyle.CssClass = "TotalWhite "; - field.HeaderStyle.CssClass = "TotalWhite "; - GvNominas.Columns.Insert(CurrentColumn++, field); - sumaDeducciones = true; - } - ctipo = Tipo; - } - if (true) - { - BoundField field = new BoundField(); - field.Visible = (dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) > 0); - field.HeaderText = Concepto; - field.DataField = string.Format("V_{0}", CveConcepto); - field.DataFormatString = "{0:N2}"; - field.ItemStyle.Width = Unit.Pixel(80); - GvNominas.Columns.Insert(CurrentColumn++, field); - } - } - - if (true) - { - - BoundField field = new BoundField(); - if (!sumaPercepciones) - { - - field.HeaderText = "Percepciones"; - field.DataField = "SumaPercepciones"; - field.DataFormatString = "{0:N2}"; - field.ItemStyle.Width = Unit.Pixel(120); - field.ItemStyle.HorizontalAlign = HorizontalAlign.Right; - field.ItemStyle.BackColor = System.Drawing.Color.LightGray; - field.ItemStyle.CssClass = " "; - field.HeaderStyle.CssClass = " "; - GvNominas.Columns.Insert(CurrentColumn++, field); - field = new BoundField(); - sumaPercepciones = true; - } - if (!sumaDeducciones) - { - field.HeaderText = "Deducciones"; - field.DataField = "SumaDeducciones"; - field.DataFormatString = "{0:N2}"; - field.ItemStyle.Width = Unit.Pixel(120); - field.ItemStyle.HorizontalAlign = HorizontalAlign.Right; - field.ItemStyle.BackColor = System.Drawing.Color.LightGray; - field.ItemStyle.CssClass = " "; - field.HeaderStyle.CssClass = " "; - GvNominas.Columns.Insert(CurrentColumn++, field); - - field = new BoundField(); - field.HeaderText = "Total"; - field.DataField = "Total"; - field.DataFormatString = "{0:N2}"; - field.ItemStyle.Width = Unit.Pixel(120); - field.ItemStyle.HorizontalAlign = HorizontalAlign.Right; - field.ItemStyle.BackColor = System.Drawing.Color.LightGray; - field.ItemStyle.CssClass = " "; - field.HeaderStyle.CssClass = " "; - GvNominas.Columns.Insert(CurrentColumn++, field); - sumaDeducciones = true; - field = new BoundField(); - } - field.HeaderText = "Obligaciones"; - field.DataField = "SumaObligaciones"; - field.DataFormatString = "{0:N2}"; - field.ItemStyle.Width = Unit.Pixel(120); - field.ItemStyle.HorizontalAlign = HorizontalAlign.Right; - field.ItemStyle.BackColor = System.Drawing.Color.LightGray; - field.ItemStyle.CssClass = " "; - field.HeaderStyle.CssClass = " "; - GvNominas.Columns.Insert(CurrentColumn++, field); - } - - - } - */ - } - setGVNominas(); - } - else - { - - GvNominas.DataSource = null; - GvNominas.DataBind(); - } - if (cargaasistencia) - { - if (dtPeriodo != null && dtPeriodo.Rows.Count > 0) - { - - DateTime FechaInicio = (DateTime)dtPeriodo.Rows[0]["FechaInicio"]; - DateTime FechaFin = (DateTime)dtPeriodo.Rows[0]["FechaFin"]; - StringBuilder gvasistencia = new StringBuilder(); - gvasistencia.Append("
    "); - if (true) - { - DateTime fecha = FechaInicio; - - gvasistencia.Append(""); - gvasistencia.Append(""); - while (fecha <= FechaFin) - { - gvasistencia.AppendFormat("", fecha); - fecha = fecha.AddDays(1); - } - gvasistencia.Append(""); - } - string tipo = ""; - foreach (DataRow rempl in dtempleados.FiltraParametros("CvePersonal>0").Rows) - { - int CvePersonal = rempl["CvePersonal"].ToString().ToEntero(); - string nombre = rempl["Nombre"].ToString(); - string Codigo = rempl["Codigo"].ToString(); - DateTime fecha = FechaInicio; int HorasDobles, HorasTriples; - gvasistencia.Append(""); - gvasistencia.AppendFormat("", CvePersonal, nombre, Codigo); - while (fecha <= FechaFin) - { - DataRow drow = dtasistencia.FiltroPrimero(string.Format("Fecha='{0:yyyy/MM/dd}' AND CvePersonal={1}", fecha, CvePersonal)); - tipo = "-"; - if (drow != null) - { - tipo = string.Format("{0} ({1}%)", drow["Tipo"], drow["PorcentajePago"]); - HorasDobles = drow["HorasDobles"].ToString().ToEntero(); - HorasTriples = drow["HorasTriples"].ToString().ToEntero(); - if (HorasDobles > 0) - { - - tipo = string.Format("{0}
    {1} horas dobles", tipo, HorasDobles); - } - if (HorasTriples > 0) - { - - tipo = string.Format("{0}
    {1} horas triple", tipo, HorasTriples); - } - drow.Delete(); - } - gvasistencia.AppendFormat("", tipo, CvePersonal, fecha); - fecha = fecha.AddDays(1); - } - gvasistencia.Append(""); - } - gvasistencia.Append("
    Nombre{0:dd/MM/yyyy}
    {2} {1} {0}
    "); - ltlGvAsistencia.Text = gvasistencia.ToString(); - } - } - #endregion - UpDatos.Update(); - LnkAutorizar.Visible = dtempleados.COUNT("CvePersonal", " CvePersonal > 0 AND NomAutorizado =0")>0 ; - } - private void setGVNominas() - { - string filtrogrupo = ""; - DataTable dt = dtempleados.Copy(); - if (DdlAgrupadorB.SelectedValue == "1") - { - foreach (DataRow drow in dtempleados.FiltraParametros("CvePersonal > 0", "", new string[] { "CveSubProyecto", "SubProyecto" }).Rows) - { - DataRow dr = dt.NewRow(); - filtrogrupo = (drow["CveSubProyecto"] == DBNull.Value ? "CveSubProyecto IS NULL AND CvePersonal>0 " : string.Format("CveSubProyecto = {0} AND CvePersonal>0", drow["CveSubProyecto"])); - foreach (DataRow row in dtConceptos.FiltraParametros("EsPadre = 1 ").Rows) - { - int CveConcepto = row["CveConcepto"].ToString().ToEntero(); - dr[string.Format("V_{0}", CveConcepto)] = dtempleados.SUM(string.Format("[V_{0}]", CveConcepto), filtrogrupo); - } - dr["CveSubProyecto"] = drow["CveSubProyecto"]; - dr["SubProyecto"] = drow["SubProyecto"]; - dr["SumaPercepciones"] = dtempleados.SUM("SumaPercepciones", filtrogrupo); - dr["SumaDeducciones"] = dtempleados.SUM("SumaDeducciones", filtrogrupo); - dr["Total"] = dtempleados.SUM("Total", filtrogrupo); - dr["SumaObligaciones"] = dtempleados.SUM("SumaObligaciones", filtrogrupo); - - dt.Rows.Add(dr); - } - dt.AcceptChanges(); - dt = dt.FiltraParametros("", "CveSubProyecto,SubProyecto,Codigo,Nombre"); - } - if (DdlAgrupadorB.SelectedValue == "2") - { - - foreach (DataRow drow in dtempleados.FiltraParametros("CvePersonal > 0", "", new string[] { "CveDepartamento", "Departamento" }).Rows) - { - DataRow dr = dt.NewRow(); - filtrogrupo = (drow["CveDepartamento"] == DBNull.Value ? "CveDepartamento IS NULL AND CvePersonal>0 " : string.Format("CveDepartamento = {0} AND CvePersonal>0", drow["CveDepartamento"])); - foreach (DataRow row in dtConceptos.FiltraParametros("EsPadre = 1 ").Rows) - { - int CveConcepto = row["CveConcepto"].ToString().ToEntero(); - dr[string.Format("V_{0}", CveConcepto)] = dtempleados.SUM(string.Format("[V_{0}]", CveConcepto), filtrogrupo); - } - dr["CveDepartamento"] = drow["CveDepartamento"]; - dr["Departamento"] = drow["Departamento"]; - dr["SumaPercepciones"] = dtempleados.SUM("SumaPercepciones", filtrogrupo); - dr["SumaDeducciones"] = dtempleados.SUM("SumaDeducciones", filtrogrupo); - dr["Total"] = dtempleados.SUM("Total", filtrogrupo); - dr["SumaObligaciones"] = dtempleados.SUM("SumaObligaciones", filtrogrupo); - - dt.Rows.Add(dr); - } - dt.AcceptChanges(); - dt = dt.FiltraParametros("", "CveDepartamento,Departamento,Codigo,Nombre"); - } - if (DdlAgrupadorB.SelectedValue == "3") - { - - foreach (DataRow drow in dtempleados.FiltraParametros("CvePersonal > 0", "", new string[] { "CveTurno", "Turno" }).Rows) - { - DataRow dr = dt.NewRow(); - filtrogrupo = (drow["CveTurno"] == DBNull.Value ? "CveTurno IS NULL AND CvePersonal>0 " : string.Format("CveTurno = {0} AND CvePersonal>0", drow["CveTurno"])); - foreach (DataRow row in dtConceptos.FiltraParametros("EsPadre = 1 ").Rows) - { - int CveConcepto = row["CveConcepto"].ToString().ToEntero(); - dr[string.Format("V_{0}", CveConcepto)] = dtempleados.SUM(string.Format("[V_{0}]", CveConcepto), filtrogrupo); - } - dr["CveTurno"] = drow["CveTurno"]; - dr["Turno"] = drow["Turno"]; - dr["SumaPercepciones"] = dtempleados.SUM("SumaPercepciones", filtrogrupo); - dr["SumaDeducciones"] = dtempleados.SUM("SumaDeducciones", filtrogrupo); - dr["Total"] = dtempleados.SUM("Total", filtrogrupo); - dr["SumaObligaciones"] = dtempleados.SUM("SumaObligaciones", filtrogrupo); - - dt.Rows.Add(dr); - } - dt.AcceptChanges(); - dt = dt.FiltraParametros("", "CveDepartamento,Departamento,Codigo,Nombre"); - } - GvNominas.DataSource = dt; - GvNominas.DataBind(); - } - protected void GvNominas_RowDataBound(object sender, GridViewRowEventArgs e) - { - if (e.Row.RowType == DataControlRowType.DataRow) - { - Literal LtlNombre = e.Row.FCLiteral("LtlNombre"); - LinkButton LnkTimbrar = (LinkButton)e.Row.FindControl("LnkTimbrar"); - int cvePersonal = e.Row.DataKey("CvePersonal").ToEntero(); - int CvePeriodo = e.Row.DataKey("CvePeriodo").ToEntero(); - int CveNomina = e.Row.DataKey("CveNomina").ToEntero(); - string SeTimbro = e.Row.DataKey("SeTimbro").ToString(); - string SeTimbroFiniquito = e.Row.DataKey("SeTimbroFiniquito").ToString(); - string EsRenuncia = e.Row.DataKey("EsRenuncia").ToString(); - string NomAutorizado = e.Row.DataKey("NomAutorizado").ToString(); - string Nombre = e.Row.DataKey("Nombre").ToString(); - string Codigo = e.Row.DataKey("Codigo").ToString(); - string Turno = e.Row.DataKey("Turno").ToString(); - string Departamento = e.Row.DataKey("Departamento").ToString(); - string SubProyecto = e.Row.DataKey("SubProyecto").ToString(); - LnkTimbrar.Visible = false; - if (cvePersonal > 0) - { - LtlNombre.Text = String.Format("{2} {1}", cvePersonal, Nombre, Codigo); - if (CveNomina > 0) - { - if (NomAutorizado == "False") - { - - - } - else - { - if (!SeTimbro.ToUpper().Contiene("TRUE", "1")) - { - LnkTimbrar.Visible = true; - e.Row.CssClass = "info"; - - } - else - { - //onclick() - e.Row.FCHyperLink("HypPDF").Attributes.Add("onclick", string.Format("GETPDF({0},{1})", cvePersonal, CvePeriodo)); - e.Row.FCHyperLink("HypXml").Attributes.Add("onclick", string.Format("GETXML({0},{1})", cvePersonal, CvePeriodo)); - e.Row.FindControl("HypPDF").Visible = true; - e.Row.FindControl("HypXml").Visible = true; - e.Row.CssClass = "success"; - if (EsRenuncia.ToUpper().Contiene("TRUE", "1") && !SeTimbroFiniquito.ToUpper().Contiene("TRUE", "1")) - { - LnkTimbrar.Visible = true; - e.Row.CssClass = "danger"; - e.Row.ToolTip = "sin timbrar conceptos de indemnización"; - } - } - - } - - } - } - else - { - LtlNombre.Text = "Total General"; - e.Row.FindControl("LnkTimbrar").Visible = false; - if (Turno.Length == 0 && SubProyecto.Length > 0) - { - LtlNombre.Text = String.Format("Centro de costos: {0}", SubProyecto); - } - else if (Turno.Length > 0) - { - LtlNombre.Text = String.Format("Turno: {0}", SubProyecto); - } - else if (Departamento.Length > 0) - { - LtlNombre.Text = String.Format("Departamento: {0}", Departamento); - } - else - { - - e.Row.FCHyperLink("HypPDF").Attributes.Add("onclick", string.Format("GETPDF({0},{1})", -1, CvePeriodoSeleccionado)); - e.Row.FindControl("HypPDF").Visible = false; - e.Row.CssClass = "SubTotales"; - } - e.Row.FindControl("LnkSobreRecibo").Visible = false; - - } - - } - - } - #endregion - - protected void LnkTimbrarTodos_Click(object sender, EventArgs e) - { - string msggral = ""; - foreach (GridViewRow gvRow in GvNominas.Rows) - { - int CvePeriodo = gvRow.DataKey("CvePeriodo").ToEntero(); - int CvePersonal = gvRow.DataKey("CvePersonal").ToEntero(); - int CveNomina = gvRow.DataKey("CveNomina").ToEntero(); - LinkButton LnkTimbrar = gvRow.FCLinkButton("LnkTimbrar"); - if (CvePersonal > 0 && LnkTimbrar.Visible) - { - LogicNominas lognom = new LogicNominas(); - - string Msg = lognom.TimbrarNomina(CveNomina, CvePersonal, CvePeriodo, UsuarioActual); - if (Msg != null && Msg.Length > 0) - { - msggral = string.Format("{0}{3}{2}
    {1}
    ", msggral, Msg, gvRow.DataKey("Nombre"), gvRow.DataKey("Codigo")); - } - else - { - ClsNominas ObjPeriodo = new ClsNominas(); - ObjPeriodo.CambiaEstatusPeriodo(CvePeriodo, (int)enumNominasEstatus.Timbrada, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa); - ObjPeriodo.Dispose(); - LnkTimbrar.Visible = false; - gvRow.FindControl("ImgDelete").Visible = false; - gvRow.FindControl("LnkCancelar").Visible = false; - gvRow.FindControl("HypXml").Visible = true; - gvRow.FindControl("HypPDF").Visible = true; - - gvRow.ForeColor = Color.Green; - } - - - } - } - if (msggral.Length > 0) - { - - Alert(string.Format("Ocurrieron los siguientes errores {0}
    CódigoNombreError
    ", msggral), TipoMensaje.MsgAdvertencia); - } - UpDatos.Update(); - } - - protected void LnkTimbrar_Click(object sender, EventArgs e) - { - LinkButton lnk = (LinkButton)sender; - GridViewRow gvRow = (GridViewRow)lnk.NamingContainer; - int CvePeriodo = gvRow.DataKey("CvePeriodo").ToEntero(); - int CvePersonal = gvRow.DataKey("CvePersonal").ToEntero(); - int CveNomina = gvRow.DataKey("CveNomina").ToEntero(); - LogicNominas lognom = new LogicNominas(); - - string Msg = lognom.TimbrarNomina(CveNomina, CvePersonal, CvePeriodo, UsuarioActual); - if (Msg != null && Msg.Length > 0) - { Alert(Msg, TipoMensaje.MsgAdvertencia); } - else - { - ClsNominas ObjPeriodo = new ClsNominas(); - ObjPeriodo.CambiaEstatusPeriodo(CvePeriodo, (int)enumNominasEstatus.Timbrada, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa); - ObjPeriodo.Dispose(); - Alert("Se ha timbrado correctamente"); - gvRow.FindControl("ImgDelete").Visible = false; - gvRow.FindControl("LnkCancelar").Visible = false; - gvRow.FindControl("HypXml").Visible = true; - gvRow.FindControl("HypPDF").Visible = true; - gvRow.ForeColor = Color.Green; - lnk.Visible = false; UpDatos.Update(); - } - } - - protected void ImgDelete_Click(object sender, EventArgs e) - { - int Cve = ((LinkButton)sender).CommandArgument.ToEntero(); - - ClsNominas Nom = new ClsNominas(); - if (Nom.RemoveNom_Nominas(Cve)) - { - Alert("Los movimientos de la nómina fueron eliminados", TipoMensaje.MsgInformacion); cargaDatos(); - - } - Nom.Dispose(); - } - - protected void LnkCancelar_Click(object sender, EventArgs e) - { - int CveNomina = ((LinkButton)sender).CommandArgument.ToEntero(); - - - if (CveNomina > 0) - { - ClsNominas Nom = new ClsNominas(); - if (Nom.GetNom_Nominas(CveNomina, -1, -1, -1, UsuarioActual.CveEmpresa)) - { - Timbrado ObjTimbrado = new Timbrado(); - - string FolioFiscal = Nom.FolioFiscal; - decimal Total = Nom.Total.ToString().ToDecimal(); - string RFCReceptor = Nom.RFC; - string RFCEmisor = UsuarioActual.Empresa.RFC; - - - if (ObjTimbrado.CFDICancelar(UsuarioActual.Empresa, FolioFiscal, Total, RFCReceptor, RFCEmisor, 4)) - { - Nom.UpdateEstatusNomNominas(2, UsuarioActual.Empresa.CvePAC, "", "", ("01/01/2000").ToDate(), CveNomina, 0, 0, 0, 0, 0); - - Alert($"La nómina con folio fiscal '{FolioFiscal}' fue cancelada ante el SAT", TipoMensaje.MsgInformacion); - } - else - { - - ObjTimbrado.MensajeErrorCFDI.GuardaLog(); - Alert($"no se pudo cancelar el folio fiscal
    {ObjTimbrado.MensajeErrorCFDI}", TipoMensaje.MsgAdvertencia); - } - } - - - Nom.Dispose(); - - cargaDatos(); - } - } - - - protected void LnkModalPlantillaNomina_Click(object sender, EventArgs e) - { - RegistraScript("$('#DModalNominas').modal();"); - - using (ClsNominas ObjNomina = new ClsNominas()) - { - if (ObjNomina.GetConceptos(UsuarioActual.CveEmpresa)) - { - GVConceptosPlantilla.DataSource = ObjNomina.DtResultados.FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa}"); - GVConceptosPlantilla.DataBind(); - } - } - - UpCargarNomina.Update(); - } - protected void LnkFormato_Click(object sender, EventArgs e) - { - try - { - StringBuilder str = new StringBuilder("0"); - bool continuar = false; - foreach (GridViewRow gvrow in GVConceptosPlantilla.Rows) - { - if (gvrow.DataKey("CveConcepto").ToEntero() > 0 && gvrow.FCCheckBox("chkCon").Checked) - { - str.AppendFormat(",{0}", gvrow.DataKey("CveConcepto")); - continuar = true; - } - } - if (continuar) - { - - ClosedXML.Excel.XLWorkbook wb = new ClosedXML.Excel.XLWorkbook(); - var libro = wb.AddWorksheet("Nomina"); - int column = 1; - libro.Row(1).Hide(); - libro.Cell(1, column).Value = "Codigo"; - libro.Cell(3, column).Value = "Codigo"; - column++; - libro.Cell(1, column).Value = "Empleado"; - libro.Cell(3, column).Value = "Empleado"; - libro.Column(column).Width = 35; - DataTable dtcP = dtConceptos.FiltraParametros(string.Format("Tipo = 'P' AND EsPadre = 1 AND CveConcepto in({0})", str)); - DataTable dtcD = dtConceptos.FiltraParametros(string.Format("Tipo = 'D' AND EsPadre = 1 AND CveConcepto in({0})", str)); - DataTable dtcO = dtConceptos.FiltraParametros(string.Format("Tipo = 'O' AND EsPadre = 1 AND CveConcepto in({0})", str)); - int iniciotipe = column; - foreach (DataRow row in dtcP.Rows) - { - column++; - libro.Cell(1, column).Value = row["CveConcepto"].ToString(); - libro.Cell(FilaConceptos, column).Value = "N"; - libro.Cell(3, column).Value = row["Concepto"].ToString(); - libro.Cell(4, column).Value = row["Codigo"].ToString(); - libro.Column(column).Width = 15; - } - if (iniciotipe < column) - { - libro.Range(2, iniciotipe + 1, 2, column).Style.Alignment.Horizontal = ClosedXML.Excel.XLAlignmentHorizontalValues.Center; - libro.Range(2, iniciotipe + 1, 2, column).Merge().Value = "Percepciones"; - } - iniciotipe = column; - foreach (DataRow row in dtcD.Rows) - { - column++; - libro.Cell(1, column).Value = row["CveConcepto"].ToString(); - libro.Cell(FilaConceptos, column).Value = "N"; - libro.Cell(3, column).Value = row["Concepto"].ToString(); - libro.Cell(4, column).Value = row["Codigo"].ToString(); - libro.Column(column).Width = 15; - } - if (iniciotipe < column) - { - libro.Range(2, iniciotipe + 1, 2, column).Style.Alignment.Horizontal = ClosedXML.Excel.XLAlignmentHorizontalValues.Center; - libro.Range(2, iniciotipe + 1, 2, column).Merge().Value = "Deducciones"; - } - iniciotipe = column; - foreach (DataRow row in dtcO.Rows) - { - column++; - libro.Cell(1, column).Value = row["CveConcepto"].ToString(); - libro.Cell(FilaConceptos, column).Value = "N"; - libro.Cell(3, column).Value = row["Concepto"].ToString(); - libro.Cell(4, column).Value = row["Codigo"].ToString(); - libro.Column(column).Width = 15; - } - if (iniciotipe < column) - { - libro.Range(2, iniciotipe + 1, 2, column).Style.Alignment.Horizontal = ClosedXML.Excel.XLAlignmentHorizontalValues.Center; - libro.Range(2, iniciotipe + 1, 2, column).Merge().Value = "Obligaciones"; - } - libro.Range(2, 1, 2, 2).Merge().Value = ""; - libro.Range(4, 1, 4, 2).Merge().Value = ""; - libro.Range(2, 1, 2, 2).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(79, 129, 189)); - libro.Range(4, 1, 4, 2).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(79, 129, 189)); - - libro.Row(1).CellsUsed().Style.Font.FontColor = ClosedXML.Excel.XLColor.White; - libro.Row(2).CellsUsed().Style.Font.FontColor = ClosedXML.Excel.XLColor.White; - libro.Row(3).CellsUsed().Style.Font.FontColor = ClosedXML.Excel.XLColor.White; - libro.Row(4).CellsUsed().Style.Font.FontColor = ClosedXML.Excel.XLColor.White; - libro.Row(FilaConceptos).CellsUsed().Style.Font.FontColor = ClosedXML.Excel.XLColor.White; - libro.Row(1).CellsUsed().Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(79, 129, 189)); - libro.Row(2).CellsUsed().Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(79, 129, 189)); - libro.Row(3).CellsUsed().Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(79, 129, 189)); - libro.Row(4).CellsUsed().Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(79, 129, 189)); - //libro.Row(FilaConceptos).CellsUsed().Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(79, 129, 189)); - libro.Cell(FilaConceptos, 1).Value = "'-------"; - libro.Cell(FilaConceptos, 1).Style.Font.FontColor = ClosedXML.Excel.XLColor.FromArgb(177, 160, 199); - libro.Cell(FilaConceptos, 2).Value = "¿Modificar SI(S)/NO(N)?"; - libro.Cell(FilaConceptos, 1).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(177, 160, 199)); - libro.Row(FilaConceptos).CellsUsed().Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(177, 160, 199)); - - int Fila = 5; - foreach (DataRow erow in dtempleados.FiltraParametros("CvePersonal>0 AND NomAutorizado=0").Rows) - { - Fila++; - column = 1; - libro.Cell(Fila, column).Value = string.Format("'{0}", erow["Codigo"]); - column++; - libro.Cell(Fila, column).Value = erow["Nombre"]; - foreach (DataRow row in dtcP.Rows) - { - column++; - string Concepto = string.Format("V_{0}", row["CveConcepto"]); - libro.Cell(Fila, column).Value = erow[Concepto]; - } - foreach (DataRow row in dtcD.Rows) - { - column++; - string Concepto = string.Format("V_{0}", row["CveConcepto"]); - libro.Cell(Fila, column).Value = erow[Concepto]; - } - foreach (DataRow row in dtcO.Rows) - { - column++; - string Concepto = string.Format("V_{0}", row["CveConcepto"]); - libro.Cell(Fila, column).Value = erow[Concepto]; - } - } - System.IO.Stream fs = new System.IO.MemoryStream(); - wb.SaveAs(fs); - fs.Position = 0; - System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(); - using (System.IO.Stream input = fs) - - { - input.CopyTo(memoryStream); - } - memoryStream.Position = 0; - - Response.Clear(); - Response.Buffer = true; - - Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; - Response.AddHeader("content-disposition", string.Format("attachment;filename={0}.xlsx", "Plantilla conceptos nómina ")); - Response.BinaryWrite(memoryStream.ToArray()); - Response.End(); - } - else - { - Alert("Debe seleccionar los conceptos a cargar.", TipoMensaje.MsgAdvertencia); - } - } - catch (Exception ex) - { - Alert("Ocurrio un error al generar el Formato de nominas" + ex.ToString()); - } - } - - protected void LnkCargarNomina_Click(object sender, EventArgs e) - { - - List Filesgral = TxtArchivoNomina.getfiles().Archivos; - bool continuar = Filesgral.Count > 0; - string stringError = ""; - Archivo fileItem = continuar ? Filesgral[0] : null; - if (continuar) - { - string FileExtension = fileItem.Extencion.ToUpper(); - if (FileExtension == "XLS" | FileExtension == "XLSX" | FileExtension == "CSV") - { - } - else - { - continuar = false; - stringError = "No se inserto un archivo de tipo Excel"; - } - - } - DataTable DTEXcel = new DataTable(); - if (continuar) - { - try - { - DTEXcel = Extensiones.ModExtensiones.ReadExcelFile(fileItem.FileUrl, true).FiltraParametros(" LEN(Codigo)>0 AND Codigo <> 'Codigo'"); - - } - catch (Exception ex) - { - - continuar = false; - stringError = "Ocurrio un Error al procesar el excel "; - string.Format("{0} \r\n{0}", stringError, ex.ToString()).GuardaLog(); - } - } - if (continuar && DTEXcel.Rows.Count == 0) - { - - continuar = false; - stringError = "No se encontraron cambios"; - } - StringBuilder str = new StringBuilder(); - bool rollback = false; - if (continuar) - { - - int CveMoneda = 1; - //List lConceptos = new List(); - //foreach (DataColumn item in DTEXcel.Columns) - //{ - // if (item.ColumnName.ToEntero() > 0) - // { - // lConceptos.Add(item.ColumnName.ToEntero()); - // } - - //} - using (ClsRH objpersonal = new ClsRH()) - { - using (ClsNominas objNomina = new ClsNominas(objpersonal.IniciaTransacSQL())) - { - foreach (DataRow row in DTEXcel.FiltraParametros("LEN(Codigo)>0 ").Rows) - { - if (!rollback) - { - - string Codigo = row["Codigo"].ToString(); - int CvePersonal = -1; // row["CvePersonal"].ToString().ToEntero(); - int CveNomina = 0; - double SubTotal = 0; - double Total = 0; - int CveMetodoPago = 0; - if (Codigo != "-1" && objpersonal.GetPersonal(CvePersonal, Codigo, "-1", "-1", "-1", -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "-1", -1, -1, -1, -1, -1, -1, "-1", "-1", "-1", "-1", UsuarioActual.CveEmpresa) && - objpersonal.DtResultados.Rows.Count == 1) - { - CvePersonal = objpersonal.CvePersonal; - CveMetodoPago = objpersonal.CveMetodoPago; - } - else - { - CvePersonal = 0; - str.AppendLine(string.Format("No se encontro el codigo {0}
    ", Codigo)); - } - if (CvePersonal > 0) - { - if (objNomina.GetNom_Nominas(-1, CvePersonal, CvePeriodoSeleccionado, -1, UsuarioActual.CveEmpresa)) - { - if (objNomina.DtResultados.Rows.Count > 0) - { - CveNomina = objNomina.CveNomina; - } - else - { - if (objNomina.AddNom_Nominas(-1, 1, CvePersonal, CvePeriodoSeleccionado, SubTotal, 0, 0, Total, CveMoneda, 1, CveMetodoPago, DateTime.Now, "Deducciones nómina", - "", "", "", "", 0, 0, 0, new DateTime(), new DateTime(), new DateTime(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, false)) - { - CveNomina = objNomina.CveNomina; - } - else - { - rollback = true; - } - } - } - else - { - rollback = true; - } - } - if (CveNomina > 0) - { - for (int i = 1; i < DTEXcel.Columns.Count; i++) - { - int CveConcepto = DTEXcel.Columns[i].ColumnName.ToEntero(); - decimal Importe = 0; - decimal ImporteGravado = 0; - decimal ImporteExento = 0; - decimal ImporteValor = 0; - bool dontsaveconcepto = ((row[i].ToString().ToUpper() == "N") || (DTEXcel.Rows[0][i].ToString().ToUpper() == "N")); - Importe = row[i].ToString().ToDecimal(); - ImporteGravado = Importe - ImporteExento; - ImporteValor = 0; - if (CveConcepto > 0) - { - if (!dontsaveconcepto)//el usuario definira si desea actualizar o no el concepto en el periodo - { - if (!objNomina.AddUPNom_NominasDetalles(objNomina.CveNomina, CvePeriodoSeleccionado, CvePersonal, CveConcepto, Importe, ImporteGravado, ImporteExento, ImporteValor, UsuarioActual.CveUsuario, true)) - { - rollback = true; - } - } - } - else - { - rollback = false; - stringError = "ocurrio un error al procesar el archivo favor de intentar de nuevo volviendo a descargar la plantilla.
    si el problema Persiste Contacte a soporte."; - } - - } - - } - } - } - if (rollback) - { - objpersonal.RollBack(); - continuar = false; - } - else - { - objpersonal.Commit(); - } - } - } - - } - if (!continuar) - { - Alert(stringError, ModExtensiones.TipoMensaje.MsgAdvertencia); - } - else - { - Alert("La información se a actualizado satisfactoriamente"); - } - } - - protected void LnkFormatoEmpleados_Click(object sender, EventArgs e) - { - - } - - - #region SobreRecibo - #region SobreRecibo propiedades - - protected int SRCvePersonal - { - get - { - if (ViewState["SRCvePersonal"] == null) { return 0; } - else { return ViewState["SRCvePersonal"].ToString().ToEntero(); } - } - - set { ViewState["SRCvePersonal"] = value; } - } - - protected int SRCvePeriodo - { - get - { - if (ViewState["SRCvePeriodo"] == null) { return 0; } - else { return ViewState["SRCvePeriodo"].ToString().ToEntero(); } - } - - set { ViewState["SRCvePeriodo"] = value; } - } - protected int SRCveConcepto - { - get - { - if (ViewState["SRCveConcepto"] == null) { return 0; } - else { return ViewState["SRCveConcepto"].ToString().ToEntero(); } - } - - set { ViewState["SRCveConcepto"] = value; } - } - protected string SRTipoConcepto - { - get - { - if (ViewState["SRTipoConcepto"] == null) { return ""; } - else { return ViewState["SRTipoConcepto"].ToString(); } - } - - set { ViewState["SRTipoConcepto"] = value; } - } - #endregion - - protected void LnkSobreRecibo_Click(object sender, EventArgs e) - { - GridViewRow gvrow = (GridViewRow)(((LinkButton)sender).NamingContainer); - LnkSRVacacionesADD.Visible = false; - if (DdlCtaContable.Items.Count == 0) - { - - using (ClsContPAQi ObjConta = new ClsContPAQi(UsuarioActual.Empresa)) - { - - if (ObjConta.Conectado && ObjConta.GetCuentas(-1, "-1", 1)) - { - DdlCtaContable.DataSource = ObjConta.DtResultados; - DdlCtaContable.DataBind(); - } - } - - DdlCtaContable.Items.Insert(0, new ListItem("Seleccione", "-1")); - DdlCtaContable.SelectedValueExist("-1"); - } - string Nombre = gvrow.DataKey("Nombre").ToString(); - SRCvePersonal = gvrow.DataKey("CvePersonal").ToEntero(); - SRCvePeriodo = gvrow.DataKey("CvePeriodo").ToEntero(); - int CveNomina = gvrow.DataKey("CveNomina").ToEntero(); - LblEmpleado.Text = Nombre; - TabPersonal.ActiveTabIndex = 0; - mostrarConceptos(); - CargaVacaciones(); - pnlAddupMovto.Visible = false; - CargaMovtoPermanente(); - CargaPersonalIncapacidad(); - RegistraScript("$('#ModalConceptos').modal();"); - } - - private void CargaVacaciones() - { - ClsRH objRH = new ClsRH(); - - if (objRH.VacacionesGet(SRCvePersonal, UsuarioActual.Empresa.CveEmpresa)) - { - GvVacaciones.DataSource = objRH.DtResultados; - - } - else { GvVacaciones.DataSource = null; } - - objRH.Dispose(); - GvVacaciones.DataBind(); - UpGvVacaciones.Update(); - } - - protected void LnkImportexCalculo_Click(object sender, EventArgs e) - { - - SRCveConcepto = ((LinkButton)sender).CommandArgument.ToEntero(); - //CvePeriodoSeleccionado - //SRCvePersonal - if (SRCveConcepto > 0) - { - using (ClsNominas onom = new ClsNominas()) - { - if (onom.DeleteNom_NominasDetalles(SRCveConcepto, SRCvePersonal, CvePeriodoSeleccionado)) - { - Alert("el importe sera tomado del calculo y no del valor fijo"); - } - } - } - } - protected void LnkConcepto_Click(object sender, EventArgs e) - { - SRCveConcepto = ((LinkButton)sender).CommandArgument.ToEntero(); - SRTipoConcepto = ((LinkButton)sender).CommandArgument; - #region carga conceptos - DataTable dtCon; - if (SRCveConcepto > 0) - { - DataRow drow = dtConceptos.FiltroPrimero(string.Format("CveConcepto={0}", SRCveConcepto)); - if (drow != null) - { - SRTipoConcepto = drow["Tipo"].ToString(); - } - else - { - SRCveConcepto = 0; - SRTipoConcepto = "D"; - } - } - - - if (SRTipoConcepto == "P") - { - dtCon = dtConceptos.FiltraParametros("Tipo ='P' AND EsPadre = 1 ").Copy(); //AND CveSistema <>12' - } - else - { - dtCon = dtConceptos.FiltraParametros("Tipo ='D' AND EsPadre = 1 ").Copy(); - SRTipoConcepto = "D"; - } - dtCon.Columns.Add(new DataColumn("CodigoConcepto")); - foreach (DataRow trow in dtCon.Rows) - { - trow["CodigoConcepto"] = string.Format("{0} - {1}", trow["Codigo"], trow["Concepto"]); - } - dtCon.AcceptChanges(); - DataRow row = dtCon.NewRow(); - row["CveConcepto"] = "-1"; - row["CodigoConcepto"] = "Seleccione"; - dtCon.Rows.InsertAt(row, 0); - #endregion - DdlmcConceptos.DataSource = dtCon; - DdlmcConceptos.DataBind(); - if (SRCveConcepto > 0) - { - DdlmcConceptos.SelectedValueExist(SRCveConcepto); - } - - PnlConceptoPersonal.Visible = false; - DdlmcConceptos_SelectedIndexChanged(DdlmcConceptos, null); - RegistraScript(string.Format("$('#ModalUpConcepto').on('shown.bs.modal', function () {{$('#{0}').trigger('focus')}});$('#ModalUpConcepto').modal();", TxtmcImporte.ClientID)); - UPpanelModalUpConcepto.Update(); - } - - protected void LnkConceptoEmpleado_Click(object sender, EventArgs e) - { - - SRCveConcepto = -1; - SRTipoConcepto = "P"; - SRCvePersonal = -1; - - using (ClsRH ObjPersonal = new ClsRH()) - { - if (ObjPersonal.GetPersonal(-1, UsuarioActual.CveEmpresa)) - { - DdlmcPersonal.DataSource = ObjPersonal.DtResultados; - DdlmcPersonal.DataBind(); - } - } - #region carga conceptos - DataTable dtCon; - - dtCon = dtConceptos.FiltraParametros("Tipo IN('P','D') AND EsPadre = 1 ").Copy(); - dtCon.Columns.Add(new DataColumn("CodigoConcepto")); - foreach (DataRow trow in dtCon.Rows) - { - trow["CodigoConcepto"] = string.Format("{0} - {1}", trow["Codigo"], trow["Concepto"]); - } - dtCon.AcceptChanges(); - #endregion - DdlmcConceptos.DataSource = dtCon; - DdlmcConceptos.DataBind(); - if (SRCveConcepto > 0) - { - DdlmcConceptos.SelectedValueExist(SRCveConcepto); - } - PnlConceptoPersonal.Visible = true; - DdlmcConceptos_SelectedIndexChanged(DdlmcConceptos, null); - RegistraScript(string.Format("$('#ModalUpConcepto').on('shown.bs.modal', function () {{$('#{0}').trigger('focus')}});$('#ModalUpConcepto').modal();", TxtmcImporte.ClientID)); - UPpanelModalUpConcepto.Update(); - } - protected void DdlmcConceptos_SelectedIndexChanged(object sender, EventArgs e) - { - int CvePersonal = SRCvePersonal; - int CveConcepto = DdlmcConceptos.SelectedValue.ToEntero(); - TxtmcImporte.Text = ""; - TxtmcImporteGrabado.Text = ""; - Txtmcvalor.Text = ""; - if (CveConcepto > 0) - { - DataRow drow = dtempleadosConceptos.FiltroPrimero(string.Format("CveConcepto={0} AND CvePersonal ={1}", CveConcepto, CvePersonal)); - if (drow != null) - { - TxtmcImporte.Text = string.Format("{0:N2}", drow["Importe"]); - TxtmcImporteGrabado.Text = string.Format("{0:N2}", drow["ImporteGravado"]); - Txtmcvalor.Text = string.Format("{0:N2}", drow["Valor"]); - } - } - else - { - if (e != null) - { - Alert("Seleccione un concepto.", TipoMensaje.MsgAdvertencia); - } - } - UPpanelModalUpConcepto.Update(); - } - protected void BtnAceptarMC_Click(object sender, EventArgs e) - { - bool continuar = true; - int CveNomina = 0; - double Total = 0; - int CveMoneda = 1; - int CveMetodoPago = 0; - int CvePersonal = SRCvePersonal; - if (CvePersonal <= 0) - { - CvePersonal = DdlmcPersonal.SelectedValue.ToEntero(); - } - int CveConcepto = DdlmcConceptos.SelectedValue.ToEntero(); - if (CveConcepto > 0 && CvePersonal > 0) - { - decimal ImporteConcepto = TxtmcImporte.Text.Replace("$", "").Replace(",", "").ToDecimal(); - decimal ImporteGravadoConcepto = TxtmcImporteGrabado.Text.Replace("$", "").Replace(",", "").ToDecimal(); - decimal ImporteExentoConcepto = ImporteConcepto - ImporteGravadoConcepto; - decimal ImporteValor = Txtmcvalor.Text.Replace("$", "").Replace(",", "").ToDecimal(); - using (ClsNominas objNomina = new ClsNominas()) - { - - if (continuar) - { - if (objNomina.GetNom_Nominas(-1, CvePersonal, CvePeriodoSeleccionado, -1, UsuarioActual.CveEmpresa)) - { - if (objNomina.DtResultados.Rows.Count > 0) - { - CveNomina = objNomina.CveNomina; - } - else - { - if (objNomina.AddNom_Nominas(-1, 1, CvePersonal, CvePeriodoSeleccionado, Total, 0, 0, Total, CveMoneda, 1, CveMetodoPago, DateTime.Now, "Deducciones nómina", - "", "", "", "", 0, 0, 0, new DateTime(), new DateTime(), new DateTime(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, false)) - { - CveNomina = objNomina.CveNomina; - } - else - { - continuar = false; - } - } - } - } - if (CveNomina == 0) - { - continuar = false; - } - - - - if (continuar) - { - - if (continuar) - { - - if (!objNomina.AddUPNom_NominasDetalles(CveNomina, CvePeriodoSeleccionado, CvePersonal, CveConcepto, ImporteConcepto, ImporteGravadoConcepto, ImporteExentoConcepto, ImporteValor, UsuarioActual.CveUsuario, true)) - { - continuar = false; - } - } - } - } - - if (continuar) - { - cargaDatos(); - - cargasobrericiboconceptos(); - UpModalConceptos.Update(); - - RegistraScript("$('#ModalUpConcepto').modal('hide');"); - Alert("El cambio se ha guardado correctamente."); - - } - - } - else - { - if (CveConcepto > 0) - { - Alert("Debe seleccionar un empleado.", TipoMensaje.MsgAdvertencia); - } - else - { - Alert("Debe seleccionar un concepto.", TipoMensaje.MsgAdvertencia); - } - } - - } - private void mostrarConceptos() - { - #region "Llenado de datos empleado" - string CodigoEmpleado = ""; - string NombreCompleto = ""; - string RFC = ""; - string CURP = ""; - string TipoPeriodo = ""; - string NSS = ""; - string DiasLaborados = ""; - string DiasFaltados = ""; - string DiasVacaciones = ""; - string FechaInicio = ""; - string FechaFin = ""; - string DiasRetardos = ""; - string DiasIncapacidad = ""; - string Puesto = ""; - string Departamento = ""; - string SD = ""; - string SDI = ""; - string SalarioDiarioIMSS = ""; - DataRow drow = dtempleados.FiltroPrimero(string.Format("CvePersonal = {0}", SRCvePersonal)); - if (drow != null) - { - DiasLaborados = string.Format("{0}", drow["DiasLaborados"].ToString().ToEntero()); - DiasFaltados = string.Format("{0}", drow["DiasFaltados"].ToString().ToEntero()); - DiasVacaciones = string.Format("{0}", drow["DiasVacaciones"].ToString().ToEntero()); - FechaInicio = string.Format("{0:dd/MM/yyyy}", drow["FechaInicio"]); - FechaFin = string.Format("{0:dd/MM/yyyy}", drow["FechaFin"]); - DiasRetardos = string.Format("{0}", drow["DiasRetardos"].ToString().ToEntero()); - DiasIncapacidad = string.Format("{0}", drow["DiasIncapacidad"].ToString().ToEntero()); - SD = string.Format("{0:####.####}", drow["SalarioDiario"]); - SDI = string.Format("{0:####.####}", drow["SalarioDiarioIntegrado"]); - SalarioDiarioIMSS = string.Format("{0:####.####}", drow["SalarioDiarioIMSS"]); - } - - using (ClsRH objrh = new ClsRH()) - { - if (objrh.GetPersonal(SRCvePersonal, UsuarioActual.CveEmpresa) && objrh.DtResultados.Rows.Count > 0) - { - DataRow erow = objrh.DtResultados.Rows[0]; - CodigoEmpleado = erow["Codigo"].ToString(); - NombreCompleto = erow["NombreCompleto"].ToString(); - RFC = erow["RFC"].ToString(); - CURP = erow["CURP"].ToString(); - TipoPeriodo = erow["TipoPeriodo"].ToString(); - NSS = erow["NSS"].ToString(); - Puesto = erow["Puesto"].ToString(); - Departamento = erow["Departamento"].ToString(); - } - } - LblCodigoEmpleado.Text = CodigoEmpleado; - //LblNombreCompleto.Text = NombreCompleto; - LblRFC.Text = RFC; - LblCURP.Text = CURP; - LblTipoPeriodo.Text = TipoPeriodo; - LblNSS.Text = NSS; - LblDiasLaborados.Text = DiasLaborados; - LblDiasFaltados.Text = DiasFaltados; - LblDiasVacaciones.Text = DiasVacaciones; - LblFecha.Text = string.Format("{0} al {1}", FechaInicio, FechaFin); - LblDiasRetardos.Text = DiasRetardos; - LblDiasIncapacidad.Text = DiasIncapacidad; - LblSRPuesto.Text = Puesto; - LblSRDepartamento.Text = Departamento; - LblSRSalarioDiario.Text = SD; - LblSRSalarioDiarioIntegrado.Text = SDI; - LblSRSbc.Text = SalarioDiarioIMSS; - - #endregion - #region "Sobre Recibo" - cargasobrericiboconceptos(); - #endregion - #region "Infonavit" - { - using (ClsRH objper = new ClsRH()) - { - objper.GetPersonalConceptos(SRCvePersonal, UsuarioActual.CveEmpresa); - DataRow frow = objper.DtResultados.FiltroPrimero("CveSistema =3"); - TxtInfoValor.Text = ""; - DdlInfoTipoAplicacion.SelectedValueExist("-1"); - TxtInfoDescripcion.Text = ""; - TxtInfoNumCredito.Text = ""; - TxtInfoFechaInicio.Text = ""; - ChkInfo.Checked = false; - if (frow != null) - { - - TxtInfoValor.Text = String.Format("{0:###,###.##}", frow["Importe"]); - DdlInfoTipoAplicacion.SelectedValueExist(frow["TipoAplicacion"].ToString()); - - TxtInfoDescripcion.Text = String.Format("{0}", frow["Descripcion02"]); - TxtInfoNumCredito.Text = String.Format("{0}", frow["Descripcion01"]); - TxtInfoFechaInicio.Text = String.Format("{0:dd/MM/yyyy}", frow["FInicioAplicacion"]); - ChkInfo.Checked = frow["estatus"].ToString().ToUpper().Contiene("1", "TRUE"); - } - - - - - frow = objper.DtResultados.FiltroPrimero("CveSistema =4"); - TxtFonValor.Text = ""; - DdlFonTipoAplicacion.SelectedValueExist("-1"); - TxtFonDescripcion.Text = ""; - TxtFonNumCredito.Text = ""; - TxtFonFechaInicio.Text = ""; - ChkFonacot.Checked = false; - if (frow != null) - { - - TxtFonValor.Text = String.Format("{0:###,###.##}", frow["Importe"]); - DdlFonTipoAplicacion.SelectedValueExist(frow["TipoAplicacion"].ToString()); - - TxtFonDescripcion.Text = String.Format("{0}", frow["Descripcion02"]); - TxtFonNumCredito.Text = String.Format("{0}", frow["Descripcion01"]); - TxtFonFechaInicio.Text = String.Format("{0:dd/MM/yyyy}", frow["FInicioAplicacion"]); - ChkFonacot.Checked = frow["estatus"].ToString().ToUpper().Contiene("1", "TRUE"); - } - - } - } - #endregion - - UpModalConceptos.Update(); - } - public void cargasobrericiboconceptos() - { - - { - DataTable dtper = dtConceptos.FiltraParametros("Tipo IN ('P') AND EsPadre = 1 "); - DataTable dtded = dtConceptos.FiltraParametros("Tipo IN ('D') AND EsPadre = 1 "); - dtper.Columns.Add("BorradoLogico", typeof(int)); - dtded.Columns.Add("BorradoLogico", typeof(int)); - - foreach (DataRow row in dtper.Rows) - { - int BorradoLogico = 0; - int CveConcepto = row["CveConcepto"].ToString().ToEntero(); - if (!(dtempleados.SUM(string.Format("[V_{0}]", CveConcepto), string.Format("CvePersonal = {0}", SRCvePersonal)) != 0) - && (dtempleadosConceptos.COUNT("CveConcepto", string.Format("CveConcepto={0} AND CvePersonal ={1} AND Estatus =2", CveConcepto, SRCvePersonal)) == 0) - ) - { - BorradoLogico = 1; - } - row["BorradoLogico"] = BorradoLogico; - } - dtper.AcceptChanges(); - foreach (DataRow row in dtded.Rows) - { - int BorradoLogico = 0; - int CveConcepto = row["CveConcepto"].ToString().ToEntero(); - if (!(dtempleados.SUM(string.Format("[V_{0}]", CveConcepto), string.Format("CvePersonal = {0}", SRCvePersonal)) != 0) - && (dtempleadosConceptos.COUNT("CveConcepto", string.Format("CveConcepto={0} AND CvePersonal ={1} AND Estatus =2", CveConcepto, SRCvePersonal)) == 0) - ) - { - BorradoLogico = 1; - } - row["BorradoLogico"] = BorradoLogico; - } - dtded.AcceptChanges(); - dtper = dtper.FiltraParametros("BorradoLogico=0"); - dtded = dtded.FiltraParametros("BorradoLogico=0"); - int maxper = dtper.Rows.Count; - int maxded = dtded.Rows.Count; - int i = 0; - List lconc = new List(); - for (i = 0; i < maxper || i < maxded; i++) - { - NConcepto nConcepto = new NConcepto(); - DataRow row; - if (maxper > i) - { - row = dtper.Rows[i]; - int CveConcepto = row["CveConcepto"].ToString().ToEntero(); - string Concepto = row["Concepto"].ToString(); - string Codigo = row["Codigo"].ToString(); - //bool visible = (dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) > 0); - double Importe = dtempleados.SUM(string.Format("[V_{0}]", CveConcepto), string.Format("CvePersonal = {0}", SRCvePersonal)); - nConcepto.CveConceptoP = CveConcepto; - nConcepto.ConceptoP = Concepto; - nConcepto.NoConceptoP = Codigo; - nConcepto.ImporteP = Importe; - nConcepto.ValorP = dtempleados.SUM(string.Format("[VAL_{0}]", CveConcepto), string.Format("CvePersonal = {0}", SRCvePersonal)); - nConcepto.isOnlyBisibleP = row["SoloVisible"].ToString().ToEntero(); - - nConcepto.isEditedP = dtempleadosConceptos.COUNT("CveConcepto", string.Format("CveConcepto={0} AND CvePersonal ={1} AND Estatus =2", CveConcepto, SRCvePersonal)); - } - if (maxded > i) - { - row = dtded.Rows[i]; - int CveConcepto = row["CveConcepto"].ToString().ToEntero(); - string Concepto = row["Concepto"].ToString(); - string Codigo = row["Codigo"].ToString(); - //bool visible = (dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) > 0); - double Importe = dtempleados.SUM(string.Format("[V_{0}]", CveConcepto), string.Format("CvePersonal = {0}", SRCvePersonal)); - nConcepto.CveConceptoD = CveConcepto; - nConcepto.ConceptoD = Concepto; - nConcepto.NoConceptoD = Codigo; - nConcepto.ImporteD = Importe; - nConcepto.ValorD = dtempleados.SUM(string.Format("[VAL_{0}]", CveConcepto), string.Format("CvePersonal = {0}", SRCvePersonal)); - nConcepto.isOnlyBisibleD = row["SoloVisible"].ToString().ToEntero(); - nConcepto.isEditedD = dtempleadosConceptos.COUNT("CveConcepto", string.Format("CveConcepto={0} AND CvePersonal ={1} AND Estatus =2", CveConcepto, SRCvePersonal)); - } - lconc.Add(nConcepto); - } - - lconc.Add(new NConcepto()); - - NConcepto SubTotales = new NConcepto(); - SubTotales.CveConceptoP = 0; - SubTotales.ConceptoP = "Total Percepciones"; - SubTotales.EstatusP = -2; - SubTotales.ImporteP = dtempleados.SUM("SumaPercepciones", string.Format("CvePersonal = {0}", SRCvePersonal)); - ///Alert(SubTotales.ImporteP.ToString()); - - SubTotales.CveConceptoD = 0; - SubTotales.ConceptoD = "Total Deducciones"; - SubTotales.EstatusD = -2; - SubTotales.ImporteD = dtempleados.SUM("SumaDeducciones", string.Format("CvePersonal = {0}", SRCvePersonal)); - - NConcepto Totales = new NConcepto(); - Totales.CveConceptoD = 0; - Totales.ConceptoD = "Total"; - Totales.EstatusD = -3; - Totales.ImporteD = dtempleados.SUM("Total", string.Format("CvePersonal = {0}", SRCvePersonal)); - - lconc.Add(SubTotales); - lconc.Add(Totales); - GvConceptos.DataSource = lconc; - GvConceptos.DataBind(); - } - } - - protected void BtnImprimirsobrerecibo_Click(object sender, EventArgs e) - { - - DataTable dtper = dtConceptos.FiltraParametros("Tipo IN ('P') AND EsPadre = 1 AND SoloVisible =0"); - DataTable dtded = dtConceptos.FiltraParametros("Tipo IN ('D') AND EsPadre = 1 AND SoloVisible =0"); - dtper.Columns.Add("BorradoLogico", typeof(int)); - dtded.Columns.Add("BorradoLogico", typeof(int)); - - foreach (DataRow row in dtper.Rows) - { - int BorradoLogico = 0; - int CveConcepto = row["CveConcepto"].ToString().ToEntero(); - if (!(dtempleados.SUM(string.Format("[V_{0}]", CveConcepto), string.Format("CvePersonal = {0}", SRCvePersonal)) != 0)) - { - BorradoLogico = 1; - } - row["BorradoLogico"] = BorradoLogico; - } - dtper.AcceptChanges(); - foreach (DataRow row in dtded.Rows) - { - int BorradoLogico = 0; - int CveConcepto = row["CveConcepto"].ToString().ToEntero(); - if (!(dtempleados.SUM(string.Format("[V_{0}]", CveConcepto), string.Format("CvePersonal = {0}", SRCvePersonal)) != 0)) - { - BorradoLogico = 1; - } - row["BorradoLogico"] = BorradoLogico; - } - dtded.AcceptChanges(); - dtper = dtper.FiltraParametros("BorradoLogico=0"); - dtded = dtded.FiltraParametros("BorradoLogico=0"); - int maxper = dtper.Rows.Count; - int maxded = dtded.Rows.Count; - int i = 0; - List lconc = new List(); - for (i = 0; i < maxper || i < maxded; i++) - { - NConcepto nConcepto = new NConcepto(); - DataRow row; - if (maxper > i) - { - row = dtper.Rows[i]; - int CveConcepto = row["CveConcepto"].ToString().ToEntero(); - string Concepto = row["Concepto"].ToString(); - string Codigo = row["Codigo"].ToString(); - //bool visible = (dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) > 0); - double Importe = dtempleados.SUM(string.Format("[V_{0}]", CveConcepto), string.Format("CvePersonal = {0}", SRCvePersonal)); - nConcepto.CveConceptoP = CveConcepto; - nConcepto.ConceptoP = Concepto; - nConcepto.NoConceptoP = Codigo; - nConcepto.ImporteP = Importe; - nConcepto.ValorP = dtempleados.SUM(string.Format("[VAL_{0}]", CveConcepto), string.Format("CvePersonal = {0}", SRCvePersonal)); - } - if (maxded > i) - { - row = dtded.Rows[i]; - int CveConcepto = row["CveConcepto"].ToString().ToEntero(); - string Concepto = row["Concepto"].ToString(); - string Codigo = row["Codigo"].ToString(); - //bool visible = (dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) > 0); - double Importe = dtempleados.SUM(string.Format("[V_{0}]", CveConcepto), string.Format("CvePersonal = {0}", SRCvePersonal)); - nConcepto.CveConceptoD = CveConcepto; - nConcepto.ConceptoD = Concepto; - nConcepto.NoConceptoD = Codigo; - nConcepto.ImporteD = Importe; - nConcepto.ValorD = dtempleados.SUM(string.Format("[VAL_{0}]", CveConcepto), string.Format("CvePersonal = {0}", SRCvePersonal)); - } - lconc.Add(nConcepto); - } - - lconc.Add(new NConcepto()); - - NConcepto SubTotales = new NConcepto(); - SubTotales.CveConceptoP = 0; - SubTotales.ConceptoP = "Total Percepciones"; - SubTotales.EstatusP = -2; - SubTotales.ImporteP = dtempleados.SUM("SumaPercepciones", string.Format("CvePersonal = {0}", SRCvePersonal)); - ///Alert(SubTotales.ImporteP.ToString()); - - SubTotales.CveConceptoD = 0; - SubTotales.ConceptoD = "Total Deducciones"; - SubTotales.EstatusD = -2; - SubTotales.ImporteD = dtempleados.SUM("SumaDeducciones", string.Format("CvePersonal = {0}", SRCvePersonal)); - - NConcepto Totales = new NConcepto(); - Totales.CveConceptoD = 0; - Totales.ConceptoD = "Total"; - Totales.EstatusD = -3; - Totales.ImporteD = dtempleados.SUM("Total", string.Format("CvePersonal = {0}", SRCvePersonal)); - - lconc.Add(SubTotales); - lconc.Add(Totales); - - DataTable dtCon = new DataTable(); - dtCon.Columns.Add(new DataColumn("NoConceptoP", typeof(string))); - dtCon.Columns.Add(new DataColumn("ConceptoP", typeof(string))); - dtCon.Columns.Add(new DataColumn("LabelValorP", typeof(string))); - dtCon.Columns.Add(new DataColumn("CveConceptoP", typeof(int))); - dtCon.Columns.Add(new DataColumn("ImporteP", typeof(double))); - dtCon.Columns.Add(new DataColumn("ValorP", typeof(double))); - dtCon.Columns.Add(new DataColumn("EstatusP", typeof(int))); - dtCon.Columns.Add(new DataColumn("isEditedP", typeof(int))); - dtCon.Columns.Add(new DataColumn("isOnlyBisibleP", typeof(int))); - dtCon.Columns.Add(new DataColumn("NoConceptoD", typeof(string))); - dtCon.Columns.Add(new DataColumn("ConceptoD", typeof(string))); - dtCon.Columns.Add(new DataColumn("LabelValorD", typeof(string))); - dtCon.Columns.Add(new DataColumn("CveConceptoD", typeof(int))); - dtCon.Columns.Add(new DataColumn("ImporteD", typeof(double))); - dtCon.Columns.Add(new DataColumn("ValorD", typeof(double))); - dtCon.Columns.Add(new DataColumn("EstatusD", typeof(int))); - dtCon.Columns.Add(new DataColumn("isEditedD", typeof(int))); - dtCon.Columns.Add(new DataColumn("isOnlyBisibleD", typeof(int))); - foreach (NConcepto itc in lconc) - { - DataRow dr = dtCon.NewRow(); - dr["NoConceptoP"] = itc.NoConceptoP; - dr["ConceptoP"] = itc.ConceptoP; - dr["LabelValorP"] = itc.LabelValorP; - dr["CveConceptoP"] = itc.CveConceptoP; - dr["ImporteP"] = itc.ImporteP; - dr["ValorP"] = itc.ValorP; - dr["EstatusP"] = itc.EstatusP; - dr["isEditedP"] = itc.isEditedP; - dr["isOnlyBisibleP"] = itc.isOnlyBisibleP; - dr["NoConceptoD"] = itc.NoConceptoD; - dr["ConceptoD"] = itc.ConceptoD; - dr["LabelValorD"] = itc.LabelValorD; - dr["CveConceptoD"] = itc.CveConceptoD; - dr["ImporteD"] = itc.ImporteD; - dr["ValorD"] = itc.ValorD; - dr["EstatusD"] = itc.EstatusD; - dr["isEditedD"] = itc.isEditedD; - dr["isOnlyBisibleD"] = itc.isOnlyBisibleD; - dtCon.Rows.Add(dr); - } - dtCon.AcceptChanges(); - List lrds = new List(); - Microsoft.Reporting.WebForms.ReportDataSource rds = new Microsoft.Reporting.WebForms.ReportDataSource(); - rds.Name = "DataSet1"; - rds.Value = dtCon;// lconc; - lrds.Add(rds); - List parametros = new List(); - - string CodigoEmpleado = ""; - string NombreCompleto = ""; - string RFC = ""; - string CURP = ""; - string TipoPeriodo = ""; - string NSS = ""; - string DiasLaborados = ""; - string DiasFaltados = ""; - string DiasVacaciones = ""; - string FechaInicio = ""; - string FechaFin = ""; - string DiasRetardos = ""; - string DiasIncapacidad = ""; - string SubProyecto = ""; - { - DataRow drow = dtempleados.FiltroPrimero(string.Format("CvePersonal = {0}", SRCvePersonal)); - if (drow != null) - { - DiasLaborados = string.Format("{0}", drow["DiasLaborados"].ToString().ToEntero()); - DiasFaltados = string.Format("{0}", drow["DiasFaltados"].ToString().ToEntero()); - DiasVacaciones = string.Format("{0}", drow["DiasVacaciones"].ToString().ToEntero()); - FechaInicio = string.Format("{0:dd/MM/yyyy}", drow["FechaInicio"]); - FechaFin = string.Format("{0:dd/MM/yyyy}", drow["FechaFin"]); - DiasRetardos = string.Format("{0}", drow["DiasRetardos"].ToString().ToEntero()); - DiasIncapacidad = string.Format("{0}", drow["DiasIncapacidad"].ToString().ToEntero()); - } - } - //string Codigo = ""; - using (ClsRH objrh = new ClsRH()) - { - if (objrh.GetPersonal(SRCvePersonal, UsuarioActual.CveEmpresa) && objrh.DtResultados.Rows.Count > 0) - { - DataRow drow = objrh.DtResultados.Rows[0]; - SubProyecto = drow["SubProyecto"].ToString(); - CodigoEmpleado = drow["Codigo"].ToString(); - NombreCompleto = drow["NombreCompleto"].ToString(); - RFC = drow["RFC"].ToString(); - CURP = drow["CURP"].ToString(); - TipoPeriodo = drow["TipoPeriodo"].ToString(); - NSS = drow["NSS"].ToString(); - } - } - parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("DiasIncapacidad", DiasIncapacidad)); - parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("Codigo", CodigoEmpleado)); - parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("NombreCompleto", NombreCompleto)); - parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("RFC", RFC)); - parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("CURP", "")); - parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("TipoPeriodo", TipoPeriodo)); - parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("NSS", NSS)); - parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("DiasLaborados", DiasLaborados)); - parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("DiasFaltados", DiasFaltados)); - parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("DiasVacaciones", DiasVacaciones)); - parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("FechaInicio", FechaInicio)); - parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("FechaFin", FechaFin)); - parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("DiasRetardos", DiasRetardos)); - parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("Empresa", UsuarioActual.Empresa.Empresa)); - parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("SubProyecto", SubProyecto)); - parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("FechaPago", "")); - //parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("", "")); - //parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("", "")); - //parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("", "")); - //parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("", "")); - //parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("", "")); - string urlfile = System.IO.Path.Combine(ModExtensiones.DirectorioBaseEmpresas, string.Format("Empresas/{0}/Formatos/SobreRecibo.rdlc", UsuarioActual.CveEmpresa)); - if (!System.IO.File.Exists(urlfile)) - { - urlfile = System.IO.Path.Combine(ModExtensiones.DirectorioBaseEmpresas, "Empresas/Grales/Formatos/SobreRecibo.rdlc"); - } - - ImprimirPDF(urlfile, lrds, parametros, "SobreRecibo", "PDF", null); - } - protected void BtnGuardarInfornavit_Click(object sender, EventArgs e) - { - double importe = TxtInfoValor.Text.ToDouble(); - int TipoAplicacion = DdlInfoTipoAplicacion.SelectedValue.ToEntero(); - int NoPagos = 0; - double SaldoIni = 0; - string descripcion02 = TxtInfoDescripcion.Text; - string descripcion01 = TxtInfoNumCredito.Text; - string fecha = TxtInfoFechaInicio.Text.Replace("_", ""); - int estatus = ChkInfo.Checked ? 1 : 0; - if (fecha.Length > 8) - fecha = fecha.ToDateTime().ToString("yyyy/MM/dd"); - else - fecha = ""; - bool continuar = true; - using (ClsRH ObjPersonal = new ClsRH()) - { - if (!ObjPersonal.AddConcepto(SRCvePersonal, -1, importe, TipoAplicacion, NoPagos, SaldoIni, UsuarioActual.CveUsuario, 3, descripcion01, descripcion02, fecha, "", estatus, UsuarioActual.CveEmpresa)) - continuar = false; - } - if (continuar) - { - LnkConsultar_Click(null, null); - mostrarConceptos(); - Alert("Se actualizo el calculo de infonavit"); - } - } - - - private class NConcepto - { - public string NoConceptoP { get; set; } - public string ConceptoP { get; set; } - public string LabelValorP { get; set; } - public int CveConceptoP { get; set; } - public double ImporteP { get; set; } - public double ValorP { get; set; } - public int EstatusP { get; set; } - public int isEditedP { get; set; } - public int isOnlyBisibleP { get; set; } - - - public string NoConceptoD { get; set; } - public string ConceptoD { get; set; } - public string LabelValorD { get; set; } - public int CveConceptoD { get; set; } - public double ImporteD { get; set; } - public double ValorD { get; set; } - public int EstatusD { get; set; } - public int isEditedD { get; set; } - public int isOnlyBisibleD { get; set; } - - - - - - public string NoConceptoO { get; set; } - public string ConceptoO { get; set; } - public string LabelValorO { get; set; } - public int CveConceptoO { get; set; } - public double ImporteO { get; set; } - public double ValorO { get; set; } - public int EstatusO { get; set; } - public int isEditedO { get; set; } - public int isOnlyBisibleO { get; set; } - } - - int CveConceptoPolgvc, CveConceptoDolgvc; - protected void GvConceptos_RowDataBound(object sender, GridViewRowEventArgs e) - { - if (e.Row.RowType == DataControlRowType.DataRow) - { - if (e.Row.RowIndex == 0) - { - CveConceptoPolgvc = 1; - CveConceptoDolgvc = 1; - } - // Datakeys - // Concepto,CveConcepto,Importe,Estatus,ConceptoD,CveConceptoD,ImporteD,EstatusD - int CveConcepto = e.Row.DataKey("CveConceptoP").ToEntero(); - int CveConceptoD = e.Row.DataKey("CveConceptoD").ToEntero(); - // Dim Importe As Decimal = e.Row.DataKey("Importe").ToDecimal() - // Dim ImporteD As Decimal = e.Row.DataKey("ImporteD").ToDecimal() - int Estatus = e.Row.DataKey("EstatusP").ToEntero(); - int EstatusD = e.Row.DataKey("EstatusD").ToEntero(); - int isOnlyBisibleP = e.Row.DataKey("isOnlyBisibleP").ToEntero(); - int isOnlyBisibleD = e.Row.DataKey("isOnlyBisibleD").ToEntero(); - bool isEditedP = e.Row.DataKey("isEditedP").ToEntero() > 0; - bool isEditedD = e.Row.DataKey("isEditedD").ToEntero() > 0; - //isEditedD - // Controles - Label LtlConcepto = e.Row.FCLabel("LtlConcepto"); - LinkButton LnkConcepto = e.Row.FCLinkButton("LnkConcepto"); - Label LtlConceptoD = e.Row.FCLabel("LtlConceptoD"); - LinkButton LnkConceptoD = e.Row.FCLinkButton("LnkConceptod"); - Label LtlImporte = e.Row.FCLabel("LtlImporte"); - LinkButton LnkImporte = e.Row.FCLinkButton("LnkImporte"); - Label LtlImporteD = e.Row.FCLabel("LtlImporteD"); - LinkButton LnkImporteD = e.Row.FCLinkButton("LnkImporteD"); - - LinkButton LnkImportexCalculo = e.Row.FCLinkButton("LnkImportexCalculo"); - LinkButton LnkImporteDxCalculo = e.Row.FCLinkButton("LnkImporteDxCalculo"); - - //isEditedD - if (isOnlyBisibleP == 1) - { - e.Row.CssClass = string.Format("{0} isOnlyBisibleP", e.Row.CssClass); - } - if (isOnlyBisibleD == 1) - { - e.Row.CssClass = string.Format("{0} isOnlyBisibleD", e.Row.CssClass); - } - if (isEditedP) - { - e.Row.CssClass = string.Format("{0} isEditedP", e.Row.CssClass); - } - if (isEditedD) - { - e.Row.CssClass = string.Format("{0} isEditedD", e.Row.CssClass); - } - - if (Estatus == -1) { LtlConcepto.Visible = false; } - else if (Estatus > 0) { LtlImporte.Visible = false; } - - if (EstatusD == -1) { LtlConceptoD.Visible = false; } - else if (EstatusD > 0) { LtlImporteD.Visible = false; } - - LtlImporte.Visible = false; - LtlImporteD.Visible = false; - if (Estatus < -1 | EstatusD < -1) - { - e.Row.CssClass = "ConceptosTotales"; - LtlImporte.Visible = true; - LtlImporteD.Visible = true; - } - LnkImporte.CommandArgument = (CveConcepto > 0 ? CveConcepto.ToString() : "P"); - LnkImporteD.CommandArgument = (CveConceptoD > 0 ? CveConceptoD.ToString() : "D"); - if (LnkImportexCalculo != null) - { - LnkImportexCalculo.CommandArgument = LnkImporte.CommandArgument; - LnkImporteDxCalculo.CommandArgument = LnkImporteD.CommandArgument; - LnkImportexCalculo.Visible = isEditedP; - LnkImporteDxCalculo.Visible = isEditedD; - - } - - LnkImporte.Text = (CveConcepto > 0 ? string.Format("${0:N2}", e.Row.DataKey("ImporteP").ToDecimal()) : (CveConceptoPolgvc > 0 ? "" : "")); - LnkImporteD.Text = (CveConceptoD > 0 ? string.Format("${0:N2}", e.Row.DataKey("ImporteD").ToDecimal()) : (CveConceptoDolgvc > 0 ? "" : "")); - - - - if (CveConcepto == 0 && (Estatus == 0 || Estatus == -1 || Estatus == -3)) { LtlImporte.Text = ""; } - - if (CveConceptoD == 0 && (EstatusD == 0 || EstatusD == -1)) { LtlImporteD.Text = ""; } - - - - LnkConcepto.Visible = !LtlConcepto.Visible; - LnkConceptoD.Visible = !LtlConceptoD.Visible; - LnkImporte.Visible = !LtlImporte.Visible; - LnkImporteD.Visible = !LtlImporteD.Visible; - - LinkButton LnkConceptoO = e.Row.FCLinkButton("LnkConceptoO"); - LinkButton LnkImporteO = e.Row.FCLinkButton("LnkImporteO"); - if (LnkConceptoO != null) - { - LnkConceptoO.Visible = false; - LnkImporteO.Visible = false; - if (e.Row.DBCampo("ImporteO").ToDecimal() == 0) - { - e.Row.FCLabel("LtlConceptoO").Visible = false; - e.Row.FCLabel("LtlImporteO").Visible = false; - if (e.Row.DataKey("isOnlyBisibleO").ToEntero() == 1) - { - e.Row.CssClass = string.Format("{0} isOnlyBisibleO", e.Row.CssClass); - } - } - } - - CveConceptoPolgvc = CveConcepto; - CveConceptoDolgvc = CveConceptoD; - } - } - #endregion - - protected void LnkFormatoTabular_Click(object sender, EventArgs e) - { - try - { - ClosedXML.Excel.XLWorkbook wb = new ClosedXML.Excel.XLWorkbook(); - var libro = wb.AddWorksheet("Nomina"); - int column = 1; - int filainicio = 3; - libro.Cell(filainicio + 1, column).Value = " "; - libro.Cell(filainicio + 2, column).Value = "Codigo"; - libro.Cell(filainicio + 3, column).Value = " "; - column++; - libro.Cell(filainicio + 1, column).Value = " "; - libro.Cell(filainicio + 2, column).Value = "Empleado"; - libro.Cell(filainicio + 3, column).Value = " "; - libro.Column(column).Width = 35; - libro.Cell(1, 1).Value = "Empresa"; - libro.Range(1, 2, 1, 4).Merge().Value = UsuarioActual.Empresa.Empresa; - libro.Cell(2, 1).Value = "período"; - string periodo = DdlPeriodo.SelectedItem.Text; - periodo = periodo.Substring(0, (periodo.Length > 27 ? 27 : periodo.Length)); - libro.Range(2, 2, 2, 4).Merge().Value = periodo; - - int iniciotipe = column; - foreach (DataRow row in dtConceptos.FiltraParametros("Tipo ='P' AND EsPadre = 1 ").Rows) - { - - column++; - libro.Cell(filainicio + 2, column).Value = row["Concepto"].ToString(); - libro.Cell(filainicio + 3, column).Value = row["Codigo"].ToString(); - libro.Column(column).Width = 15; - if ((dtempleados.SUM(string.Format("[V_{0}]", row["CveConcepto"].ToString())) == 0)) - { - libro.Column(column).Hide(); - } - - } - column++; - libro.Range(filainicio + 2, column, filainicio + 3, column).Merge().Value = "Percepciones"; - libro.Column(column).Width = 15; - if (iniciotipe < column) - { - libro.Range(filainicio + 1, iniciotipe + 1, filainicio + 1, column).Style.Alignment.Horizontal = ClosedXML.Excel.XLAlignmentHorizontalValues.Center; - libro.Range(filainicio + 1, iniciotipe + 1, filainicio + 1, column).Merge().Value = "Percepciones"; - } - iniciotipe = column; - - - foreach (DataRow row in dtConceptos.FiltraParametros("Tipo = 'D' AND EsPadre = 1 ").Rows) - { - column++; - libro.Cell(filainicio + 2, column).Value = row["Concepto"].ToString(); - libro.Cell(filainicio + 3, column).Value = row["Codigo"].ToString(); - libro.Column(column).Width = 15; - if ((dtempleados.SUM(string.Format("[V_{0}]", row["CveConcepto"].ToString())) == 0)) - { - libro.Column(column).Hide(); - } - - } - - column++; - libro.Range(filainicio + 2, column, filainicio + 3, column).Merge().Value = "Deducciones"; - libro.Column(column).Width = 15; - - if (iniciotipe < column) - { - libro.Range(filainicio + 1, iniciotipe + 1, filainicio + 1, column).Style.Alignment.Horizontal = ClosedXML.Excel.XLAlignmentHorizontalValues.Center; - libro.Range(filainicio + 1, iniciotipe + 1, filainicio + 1, column).Merge().Value = "Deducciones"; - } - - column++; - libro.Cell(filainicio + 1, column).Value = " "; - libro.Range(filainicio + 2, column, filainicio + 3, column).Merge().Value = "Total"; - libro.Column(column).Width = 15; - iniciotipe = column; - - foreach (DataRow row in dtConceptos.FiltraParametros("Tipo = 'O' AND EsPadre = 1 ").Rows) - { - column++; - libro.Cell(filainicio + 2, column).Value = row["Concepto"].ToString(); - libro.Cell(filainicio + 3, column).Value = row["Codigo"].ToString(); - libro.Column(column).Width = 15; - if ((dtempleados.SUM(string.Format("[V_{0}]", row["CveConcepto"].ToString())) == 0)) - { - libro.Column(column).Hide(); - } - - } - column++; - libro.Range(filainicio + 2, column, filainicio + 3, column).Merge().Value = "Obligaciones"; - libro.Column(column).Width = 15; - - - if (iniciotipe < column) - { - libro.Range(filainicio + 1, iniciotipe + 1, filainicio + 1, column).Style.Alignment.Horizontal = ClosedXML.Excel.XLAlignmentHorizontalValues.Center; - libro.Range(filainicio + 1, iniciotipe + 1, filainicio + 1, column).Merge().Value = "Obligaciones"; - } - - //libro.Row(1).CellsUsed().Style.Font.FontColor = ClosedXML.Excel.XLColor.White; - //libro.Row(2).CellsUsed().Style.Font.FontColor = ClosedXML.Excel.XLColor.White; - //libro.Row(3).CellsUsed().Style.Font.FontColor = ClosedXML.Excel.XLColor.White; - //libro.Row(1).CellsUsed().Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(177, 160, 199)); - //libro.Row(2).CellsUsed().Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(79, 129, 189)); - //libro.Row(3).Cell(1).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(79, 129, 189)); - //libro.Row(3).CellsUsed().Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(79, 129, 189)); - int maxnocolumn = column; - - int Fila = filainicio + 3; - int cveSupProyecto = -5; - string subproyecto = ""; - int oldcveSupProyecto = -5; - bool newsubproyecto = false; - bool newsubproyectoTitulo = false; - DataTable dtsr = dtempleados.FiltraParametros("", "CveSubProyecto"); - dtsr.Rows.Add(dtsr.NewRow()); - foreach (DataRow erow in dtsr.Rows) - { - Fila++; - newsubproyecto = false; newsubproyectoTitulo = false; - if (cveSupProyecto != erow["CveSubProyecto"].ToString().ToEntero()) - { - - if (oldcveSupProyecto != -5) { Fila += 2; newsubproyecto = true; } - oldcveSupProyecto = cveSupProyecto; - cveSupProyecto = erow["CveSubProyecto"].ToString().ToEntero(); - subproyecto = erow["SubProyecto"].ToString(); - if (cveSupProyecto != -5 && oldcveSupProyecto != -5) { Fila++; newsubproyectoTitulo = true; } - } - column = 1; - libro.Cell(Fila, column).Value = string.Format("'{0}", erow["Codigo"]); - column++; - if (newsubproyectoTitulo) - { - libro.Cell(Fila - 1, column).Value = subproyecto; - libro.Range(Fila - 1, 1, Fila - 1, maxnocolumn).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(155, 194, 230)); - } - if (newsubproyecto) - { - libro.Cell(Fila - 3, column).Value = "Total"; - libro.Range(Fila - 3, 1, Fila - 3, maxnocolumn).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(155, 194, 230)); - } - libro.Cell(Fila, column).Value = erow["Nombre"]; - foreach (DataRow row in dtConceptos.FiltraParametros("Tipo = 'P' AND EsPadre = 1 ").Rows) - { - column++; - string Concepto = string.Format("V_{0}", row["CveConcepto"]); - libro.Cell(Fila, column).Value = erow[Concepto]; - - - if (newsubproyecto) - { - libro.Cell(Fila - 3, column).Value = dtempleados.SUM(Concepto, string.Format("CveSubProyecto ={0} AND CvePersonal > 0 ", oldcveSupProyecto)); - } - - } - - column++; - libro.Cell(Fila, column).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(166, 166, 166)); - libro.Cell(Fila, column).Value = erow["SumaPercepciones"]; - if (newsubproyecto) - { - libro.Cell(Fila - 3, column).Value = dtempleados.SUM("SumaPercepciones", string.Format("CveSubProyecto ={0} AND CvePersonal > 0 ", oldcveSupProyecto)); - } - - - foreach (DataRow row in dtConceptos.FiltraParametros("Tipo = 'D' AND EsPadre = 1 ").Rows) - { - column++; - string Concepto = string.Format("V_{0}", row["CveConcepto"]); - libro.Cell(Fila, column).Value = erow[Concepto]; - - if (newsubproyecto) - { - libro.Cell(Fila - 3, column).Value = dtempleados.SUM(Concepto, string.Format("CveSubProyecto ={0} AND CvePersonal > 0 ", oldcveSupProyecto)); - } - } - - column++; - libro.Cell(Fila, column).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(166, 166, 166)); - libro.Cell(Fila, column).Value = erow["SumaDeducciones"]; - if (newsubproyecto) - { - libro.Cell(Fila - 3, column).Value = dtempleados.SUM("SumaDeducciones", string.Format("CveSubProyecto ={0} AND CvePersonal > 0 ", oldcveSupProyecto)); - } - - column++; - libro.Cell(Fila, column).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(166, 166, 166)); - libro.Cell(Fila, column).Value = erow["Total"]; - if (newsubproyecto) - { - libro.Cell(Fila - 3, column).Value = dtempleados.SUM("Total", string.Format("CveSubProyecto ={0} AND CvePersonal > 0 ", oldcveSupProyecto)); - } - - foreach (DataRow row in dtConceptos.FiltraParametros("Tipo = 'O' AND EsPadre = 1 ").Rows) - { - column++; - string Concepto = string.Format("V_{0}", row["CveConcepto"]); - libro.Cell(Fila, column).Value = erow[Concepto]; - - if (newsubproyecto) - { - libro.Cell(Fila - 3, column).Value = dtempleados.SUM(Concepto, string.Format("CveSubProyecto ={0} AND CvePersonal > 0 ", oldcveSupProyecto)); - } - } - - column++; - libro.Cell(Fila, column).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(166, 166, 166)); - libro.Cell(Fila, column).Value = erow["SumaObligaciones"]; - if (newsubproyecto) - { - libro.Cell(Fila - 3, column).Value = dtempleados.SUM("SumaObligaciones", string.Format("CveSubProyecto ={0} AND CvePersonal > 0 ", oldcveSupProyecto)); - } - } - - - libro.Range(filainicio + 1, 1, filainicio + 4, maxnocolumn).Style.Font.FontColor = ClosedXML.Excel.XLColor.White; - libro.Range(filainicio + 1, 1, filainicio + 4, maxnocolumn).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(79, 129, 189)); - - System.IO.Stream fs = new System.IO.MemoryStream(); - wb.SaveAs(fs); - fs.Position = 0; - System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(); - using (System.IO.Stream input = fs) - - { - input.CopyTo(memoryStream); - } - memoryStream.Position = 0; - - Response.Clear(); - Response.Buffer = true; - - Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; - Response.AddHeader("content-disposition", string.Format("attachment;filename={0} {1}.xlsx", "Nomina tabular", periodo)); - Response.BinaryWrite(memoryStream.ToArray()); - Response.End(); - } - catch (Exception ex) - { - Alert("Ocurrio un error al generar el Formato de nominas" + ex.ToString()); - } - } - - - protected void LnkConceptoD_Click(object sender, EventArgs e) - { - - } - - public void loadtablas() - { - - using (ClsNominas objnom = new ClsNominas()) - { - if (objnom.GetTablasNomina(UsuarioActual.CveEmpresa) && objnom.DTSetResultados.Tables.Count > 1) - { - GVFactorDesctInfonavit.DataSource = objnom.DTSetResultados.Tables[0]; - GVSalariosMinimos.DataSource = objnom.DTSetResultados.Tables[1]; - GVIMMSRiesgot.DataSource = objnom.DTSetResultados.Tables[2]; - GVInfonavitSegViv.DataSource = objnom.DTSetResultados.Tables[3]; - GVVigISRMensual.DataSource = objnom.DTSetResultados.Tables[4]; - GVVigSubEmpMensual.DataSource = objnom.DTSetResultados.Tables[5]; - GVVigISRSemanal.DataSource = objnom.DTSetResultados.Tables[7]; - GVVigISRDecenal.DataSource = objnom.DTSetResultados.Tables[8]; - GVVigISRQuincenal.DataSource = objnom.DTSetResultados.Tables[9]; - - - - } - if (objnom.RH_TablasValoresGet(UsuarioActual.CveEmpresa, 1)) - { - GVUma.DataSource = objnom.DtResultados; - } - - } - GVFactorDesctInfonavit.DataBind(); - GVSalariosMinimos.DataBind(); - GVIMMSRiesgot.DataBind(); - GVInfonavitSegViv.DataBind(); - GVVigISRMensual.DataBind(); - GVVigSubEmpMensual.DataBind(); - GVVigISRSemanal.DataBind(); - GVVigISRDecenal.DataBind(); - GVVigISRQuincenal.DataBind(); - GVUma.DataBind(); - UpModalTablas.Update(); - } - - protected void LnkAddUMA_Click(object sender, EventArgs e) - { - using (ClsNominas objnom = new ClsNominas()) - { - if (objnom.RH_TablasValoresAdd(UsuarioActual.CveEmpresa, TxtFechaUma.Text.ToDateTime(), 1, TxtValorUma.Text.ToDecimal())) - { - if (objnom.RH_TablasValoresGet(UsuarioActual.CveEmpresa, 1)) - { - GVUma.DataSource = objnom.DtResultados; - GVUma.DataBind(); - } - Alert("La UMA se ha actualizado."); - } - - } - } - protected void LnkEliminarUma_Click(object sender, EventArgs e) - { - GridViewRow gvrow = (GridViewRow)((LinkButton)sender).NamingContainer; - DateTime fecha = gvrow.DataKey("Fecha").ToDateTime(); - //DateTime tipo = gvrow.DataKey("Tipo").ToDateTime(); - - using (ClsNominas objnom = new ClsNominas()) - { - - if (objnom.RH_TablasValoresRemove(UsuarioActual.CveEmpresa, TxtFechaUma.Text.ToDateTime(), 1)) - { - if (objnom.RH_TablasValoresGet(UsuarioActual.CveEmpresa, 1)) - { - GVUma.DataSource = objnom.DtResultados; - GVUma.DataBind(); - } - Alert("La UMA se ha eliminado."); - } - } - } - protected void LnkVerTablas_Click(object sender, EventArgs e) - { - loadtablas(); - RegistraScript("$('#ModalTablas').modal();"); - } - protected void LnkVerCalculoISR_Click(object sender, EventArgs e) - { - DataTable dt = dtempleados.FiltraParametros("CvePersonal >0", "", new string[] { "CvePersonal", "Nombre", "Codigo", "SumaPercepcionesG" }); - - //dt.Columns.Add("SumaPercepcionesG"); - dt.Columns.Add("LimiteInferior"); - dt.Columns.Add("ExedenteLI"); - dt.Columns.Add("PorcentajeSE"); - dt.Columns.Add("ImpuestoMarginal"); - dt.Columns.Add("cuotafija"); - - dt.Columns.Add("Impuestoantessubs"); - dt.Columns.Add("subsidio"); - dt.Columns.Add("Impuesto"); - - DataTable dtquin = null; - using (ClsNominas objnom = new ClsNominas()) - { - if (objnom.GetTablasNomina(UsuarioActual.CveEmpresa) && objnom.DTSetResultados.Tables.Count > 1) - { - //GVFactorDesctInfonavit.DataSource = objnom.DTSetResultados.Tables[0]; - //GVSalariosMinimos.DataSource = objnom.DTSetResultados.Tables[1]; - //GVIMMSRiesgot.DataSource = objnom.DTSetResultados.Tables[2]; - //GVInfonavitSegViv.DataSource = objnom.DTSetResultados.Tables[3]; - //GVVigISRMensual.DataSource = objnom.DTSetResultados.Tables[4]; - //GVVigSubEmpMensual.DataSource = objnom.DTSetResultados.Tables[5]; - //GVVigISRSemanal.DataSource = objnom.DTSetResultados.Tables[7]; - //GVVigISRDecenal.DataSource = objnom.DTSetResultados.Tables[8]; - //GVVigISRQuincenal.DataSource = objnom.DTSetResultados.Tables[9]; - dtquin = objnom.DTSetResultados.Tables[9]; - - - } - //if (objnom.RH_TablasValoresGet(UsuarioActual.CveEmpresa, 1)) - //{ - // GVUma.DataSource = objnom.DtResultados; - //} - - } - if (dtquin != null) - { - - foreach (DataRow item in dt.Rows) - { - decimal SumaPercepcionesG = item["SumaPercepcionesG"].ToString().ToDecimal(); - - decimal Limiteinferior = 0; - decimal CuotaFija = 0; - decimal Porcentaje = 0; - foreach (DataRow drow in dtquin.Rows) - { - decimal limite = drow["Limite inferior"].ToString().ToDecimal(); - if (limite > SumaPercepcionesG) { - break; - } - else - { - Limiteinferior = drow["Limite inferior"].ToString().ToDecimal(); - CuotaFija = drow["Cuota fija"].ToString().ToDecimal(); - Porcentaje = drow["Porcentaje"].ToString().ToDecimal(); - - } - - } - decimal Impuestomarginal = (SumaPercepcionesG - Limiteinferior) * (Porcentaje / 100); - decimal Impuestoantessubs= Impuestomarginal+ CuotaFija; - item["LimiteInferior"] = Limiteinferior; - item["ExedenteLI"] = SumaPercepcionesG - Limiteinferior; - item["PorcentajeSE"] = Porcentaje; - item["ImpuestoMarginal"] = Impuestomarginal; - item["cuotafija"] = CuotaFija; - item["Impuestoantessubs"] = Impuestoantessubs; - item["subsidio"] =0; - item["Impuesto"] = Impuestoantessubs; - //[Limite inferior],FORMAT(CuotaFija,'###,####,###0.00') [Cuota fija],FORMAT(Porcentaje,'###,####,###0.00') Porcentaje - } - dt.AcceptChanges(); - } - - UpCalculoISR.Update(); - GVCalculoISR.DataSource = dt; - GVCalculoISR.DataBind(); - - RegistraScript("$('#ModalCalculoISR').modal();"); - } - - private void ImprimirReporte() - { - string RutaDocumento = System.IO.Path.Combine(ModExtensiones.DirectorioBaseEmpresas, "Empresas/Grales/Lista de Raya.docx"); - DataTable dtpersonas = null; - using (ClsRH ObjRH = new ClsRH()) - { - if (ObjRH.GetPersonal(-1, UsuarioActual.CveEmpresa)) - { - dtpersonas = ObjRH.DtResultados; - } - } - if (dtempleados != null && dtempleados.Rows.Count > 0 && dtpersonas != null) - { - if (System.IO.File.Exists(RutaDocumento)) - { - try - { - clsGemBoxDocument GemDocumen = new clsGemBoxDocument(RutaDocumento); - List listaTags = new List(); - string strEmpresa = UsuarioActual.Empresa.Empresa; - string strFechaInicio = ""; - string strFechaFin = ""; - string strTipo = ""; - string strPeriodoNum = ""; - string strUbicacion = string.Format("{0}, {1}, {2}, {3}, C.P. {4}", UsuarioActual.Empresa.Direccion, UsuarioActual.Empresa.Colonia, UsuarioActual.Empresa.Ciudad, UsuarioActual.Empresa.Estado, UsuarioActual.Empresa.CP).ToLower(); - string strRegPatImss = UsuarioActual.Empresa.RegistroPatronal; - string strRFC = UsuarioActual.Empresa.RFC; - string strfecha = DateTime.Now.ToString("dd/MMM/yyyy", System.Globalization.CultureInfo.CreateSpecificCulture("es-MX")); - string strhora = DateTime.Now.ToString("HH:mm:ss", System.Globalization.CultureInfo.CreateSpecificCulture("es-MX")); - - - int CvePeriodo = DdlPeriodo.SelectedValue.ToEntero(); - DataRow rperiodo = dtPeriodos.FiltroPrimero(string.Format("CvePeriodo = {0}", CvePeriodo)); - if (rperiodo != null) - { - strFechaInicio = string.Format("{0:dd/MM/yyyy}", rperiodo["FechaInicio"]); - strFechaFin = string.Format("{0:dd/MM/yyyy}", rperiodo["FechaFin"]); - strPeriodoNum = rperiodo["Numero"].ToString(); - - strTipo = DdlTipoPeriodo.SelectedItem.Text; - } - listaTags.Add(new TagsDocumentos("[Empresa]", strEmpresa)); - listaTags.Add(new TagsDocumentos("[FechaInicio]", strFechaInicio)); - listaTags.Add(new TagsDocumentos("[FechaFin]", strFechaFin)); - listaTags.Add(new TagsDocumentos("[Tipo]", strTipo)); - listaTags.Add(new TagsDocumentos("[PeriodoNum]", strPeriodoNum)); - listaTags.Add(new TagsDocumentos("[Ubicacion]", strUbicacion)); - listaTags.Add(new TagsDocumentos("[RegPatImss]", strRegPatImss)); - listaTags.Add(new TagsDocumentos("[RFC]", strRFC)); - listaTags.Add(new TagsDocumentos("[fecha]", strfecha)); - listaTags.Add(new TagsDocumentos("[hora]", strhora)); - - GemBox.Document.DocumentModel document = GemDocumen.documento; - var section = document.Sections[0]; - GemBox.Document.Tables.TableRow row; - GemBox.Document.Tables.Table sobrereciboTable; - GemBox.Document.Tables.Table tconeptos; - GemBox.Document.Paragraph paragraphh; - int CveSubProyecto = 0; - string SubProyecto = ""; - GemBox.Document.ParagraphStyle styilo = (GemBox.Document.ParagraphStyle)document.Styles.GetOrAdd(GemBox.Document.StyleTemplateType.Normal); - GemBox.Document.ParagraphStyle styilostrong = (GemBox.Document.ParagraphStyle)document.Styles.GetOrAdd(GemBox.Document.StyleTemplateType.NoSpacing); - //GemBox.Document.Style styilonegrita = GemBox.Document.Style.CreateStyle(GemBox.Document.StyleTemplateType.Strong, document); - //document.Styles.Add(styilonegrita); - foreach (DataRow drow in dtempleados.FiltraParametros("CvePersonal > 0", "", new string[] { "CveSubProyecto", "SubProyecto" }).Rows) - { - CveSubProyecto = drow["CveSubProyecto"].ToString().ToEntero(); - SubProyecto = drow["SubProyecto"].ToString(); - paragraphh = new GemBox.Document.Paragraph(document, SubProyecto); - paragraphh.ParagraphFormat.Style = styilostrong; - section.Blocks.Add(paragraphh); - paragraphh = new GemBox.Document.Paragraph(document, "........................................................................................................................................................................"); - section.Blocks.Add(paragraphh); - foreach (DataRow drow2 in dtempleados.FiltraParametros(string.Format("CveSubProyecto={0}", CveSubProyecto)).Rows) - { - int CvePersonal = drow2["CvePersonal"].ToString().ToEntero(); - sobrereciboTable = new GemBox.Document.Tables.Table(document); - sobrereciboTable.TableFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(100, GemBox.Document.Tables.TableWidthUnit.Percentage); - section.Blocks.Add(sobrereciboTable); - - row = new GemBox.Document.Tables.TableRow(document); - sobrereciboTable.Rows.Add(row); - var cell = new GemBox.Document.Tables.TableCell(document); - row.Cells.Add(cell); - /* - string SalarioDiariop = ""; - string FechaIngreso = "", Nombre = "", DiasLaborados = "";*/ - paragraphh = new GemBox.Document.Paragraph(document, string.Format("{1} : {0}", drow2["Nombre"].ToString(), drow2["Codigo"].ToString())); cell.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilostrong; - // - DataRow drh = dtpersonas.FiltroPrimero(string.Format("CvePersonal ={0}", CvePersonal)); - if (drh != null) - { - paragraphh = new GemBox.Document.Paragraph(document, string.Format("CURP:{0} RFC:{1} Afiliación IMSS:{2}", drh["CURP"], drh["RFC"], drh["NumeroSS"])); cell.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilo; - } - paragraphh = new GemBox.Document.Paragraph(document, string.Format("Fecha Ingr:{0:dd/MM/yyyy}, S.D.:{1:N2}, S.D.I.:{2:N2}, S.B.C.:{3:N2} ", drow2["FechaIngreso"], drow2["SalarioDiario"], drow2["SalarioDiarioIntegrado"], drow2["SalarioDiarioIMSS"])); cell.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilo; - paragraphh = new GemBox.Document.Paragraph(document, string.Format("Días pagados:{0}, Retardos: {1}, Ausencias:{2},Incapacidad:{4}, Centro de costos: {3}", drow2["DiasLaborados"], drow2["DiasRetardos"], drow2["DiasFaltados"], drow2["SubProyecto"], drow2["DiasIncapacidad"])); cell.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilo; - - row = new GemBox.Document.Tables.TableRow(document); - sobrereciboTable.Rows.Add(row); - cell = new GemBox.Document.Tables.TableCell(document); - row.Cells.Add(cell); - - tconeptos = new GemBox.Document.Tables.Table(document); - tconeptos.TableFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(100, GemBox.Document.Tables.TableWidthUnit.Percentage); - cell.Blocks.Add(tconeptos); - GemBox.Document.Tables.TableRow rowx; GemBox.Document.Tables.TableCell cellx; - { - rowx = new GemBox.Document.Tables.TableRow(document); - tconeptos.Rows.Add(rowx); - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilo; - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, "Percepción"); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilostrong; - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, "Valor"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilostrong; - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, "Importe"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilostrong; - - } - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilostrong; - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, "Deducción"); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilostrong; - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, "Valor"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilostrong; - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, "Importe"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilostrong; - - } - } - //Percepción Valor Importe Deducción Valor Importe - bool gonext = true; - int cindex = 0; - while (gonext) - { - cindex = cindex + 1; - int CveConcepto; string Concepto = ""; string Codigo = ""; string importe = ""; string valor = ""; - rowx = new GemBox.Document.Tables.TableRow(document); - tconeptos.Rows.Add(rowx); - DataRow rowconcept = dtempleadosConceptos.FiltroPrimero(string.Format("CvePersonal={0} AND Tipo =1 AND SoloVisible =0 AND FilaRaya ={1} AND Importe <> 0 ", CvePersonal, cindex)); - if (rowconcept != null) - { - CveConcepto = rowconcept["CveConcepto"].ToString().ToEntero(); - importe = string.Format("${0:N2}", rowconcept["Importe"]); - valor = string.Format("{0:#,###.##}", rowconcept["Valor"]); - - Concepto = ""; - - rowconcept = dtConceptos.FiltroPrimero(string.Format("CveConcepto={0}", CveConcepto)); - if (rowconcept != null) - { - Concepto = rowconcept["Concepto"].ToString(); - Codigo = rowconcept["Codigo"].ToString(); - } - } - else - { - gonext = false; - } - //percepciones - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, Codigo); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, Concepto); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, valor); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, importe); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - - } - CveConcepto = 0; Concepto = ""; importe = ""; Codigo = ""; valor = ""; - rowconcept = dtempleadosConceptos.FiltroPrimero(string.Format("CvePersonal={0} AND Tipo =2 AND SoloVisible =0 AND FilaRaya ={1} AND Importe <> 0", CvePersonal, cindex)); - if (rowconcept != null) - { - CveConcepto = rowconcept["CveConcepto"].ToString().ToEntero(); - importe = string.Format("${0:N2}", rowconcept["Importe"]); - valor = string.Format("{0:#,###.##}", rowconcept["Valor"]); - //string valor = ""; - Concepto = ""; - - rowconcept = dtConceptos.FiltroPrimero(string.Format("CveConcepto={0}", CveConcepto)); - if (rowconcept != null) - { - Concepto = rowconcept["Concepto"].ToString(); - Codigo = rowconcept["Codigo"].ToString(); - } - gonext = true; - } - //deducciones - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, Codigo); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilo; - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, Concepto); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilo; - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, valor); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, importe); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - } - } - { - rowx = new GemBox.Document.Tables.TableRow(document); - tconeptos.Rows.Add(rowx); - } - //Total Percepciones y deducciones - { - - rowx = new GemBox.Document.Tables.TableRow(document); - tconeptos.Rows.Add(rowx); - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilo; - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, "Total Percepciones"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, string.Format("${0:N2}", drow2["SumaPercepciones"])); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilostrong; - } - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilo; - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, "Total Deducciones"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, string.Format("${0:N2}", drow2["SumaDeducciones"])); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilostrong; - - } - } - { - rowx = new GemBox.Document.Tables.TableRow(document); - tconeptos.Rows.Add(rowx); - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilo; - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - - } - - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilo; - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, "Neto a Pagar"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilostrong; - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, string.Format("${0:N2}", drow2["Total"])); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilostrong; - } - } - setborderclear(tconeptos); - keeptablesamepage(sobrereciboTable); - } - paragraphh = new GemBox.Document.Paragraph(document, "........................................................................................................................................................................"); - section.Blocks.Add(paragraphh); - paragraphh = new GemBox.Document.Paragraph(document, string.Format("Total Centro de costos {0}", SubProyecto.ToUpper())); - paragraphh.ParagraphFormat.Style = styilostrong; - - - section.Blocks.Add(paragraphh); - #region "totaldepto" - { - - sobrereciboTable = new GemBox.Document.Tables.Table(document); - sobrereciboTable.TableFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(100, GemBox.Document.Tables.TableWidthUnit.Percentage); - section.Blocks.Add(sobrereciboTable); - row = new GemBox.Document.Tables.TableRow(document); - sobrereciboTable.Rows.Add(row); - var cell = new GemBox.Document.Tables.TableCell(document); - row.Cells.Add(cell); - tconeptos = new GemBox.Document.Tables.Table(document); - tconeptos.TableFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(100, GemBox.Document.Tables.TableWidthUnit.Percentage); - cell.Blocks.Add(tconeptos); - GemBox.Document.Tables.TableRow rowx; GemBox.Document.Tables.TableCell cellx; - //Percepción Valor Importe Deducción Valor Importe - bool gonext = true; - int cindex = 0; - int OrdenP = -999; - int ordenD = -999; - #region "Titulos" - - { - rowx = new GemBox.Document.Tables.TableRow(document); - tconeptos.Rows.Add(rowx); - - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, "Percepción"); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilostrong; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, "Valor"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilostrong; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, "Importe"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilostrong; - - } - - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, "Deducción"); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilostrong; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, "Valor"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilostrong; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, "Importe"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilostrong; - - } - } - #endregion - #region "Conceptos agrupador" - - while (gonext) - { - cindex = cindex + 1; - int CveConcepto; string Concepto = ""; string Codigo = ""; string importe = ""; - - rowx = new GemBox.Document.Tables.TableRow(document); - tconeptos.Rows.Add(rowx); - DataRow rowconcept; - rowconcept = dtConceptos.FiltroPrimero(string.Format("Orden>{0} AND SoloVisible =0 AND Tipo ='P'", OrdenP), "Orden"); - bool continuarconcepto = rowconcept != null; - while (continuarconcepto) - { - double sumaimporte = dtempleadosConceptos.SUM("Importe", string.Format("CvePersonal > 0 AND CveSubProyecto={0} AND CveConcepto={1} AND Importe <> 0", CveSubProyecto, rowconcept["CveConcepto"])); - OrdenP = rowconcept["Orden"].ToString().ToEntero(); - if (sumaimporte != 0) - { - CveConcepto = rowconcept["CveConcepto"].ToString().ToEntero(); - importe = string.Format("${0:N2}", sumaimporte); - Concepto = rowconcept["Concepto"].ToString(); - Codigo = rowconcept["Codigo"].ToString(); - continuarconcepto = false; - } - else - { - - rowconcept = dtConceptos.FiltroPrimero(string.Format("Orden>{0} AND SoloVisible =0 AND Tipo ='P'", OrdenP), "Orden"); - continuarconcepto = rowconcept != null; - } - - } - //while (rowconcept == null || importe == "") - //{ - // double sumaimporte = dtempleadosConceptos.SUM("Importe", string.Format("CveSubProyecto={0} AND CveConcepto={1} AND Importe <> 0", CveSubProyecto, rowconcept["CveConcepto"])); - // OrdenP = rowconcept["Orden"].ToString().ToEntero(); - // if (sumaimporte > 0) - // { - // CveConcepto = rowconcept["CveConcepto"].ToString().ToEntero(); - // importe = string.Format("${0:N2}", sumaimporte); - // Concepto = rowconcept["Concepto"].ToString(); - // Codigo = rowconcept["Codigo"].ToString(); - - // } - //} - if (importe == "") - { - gonext = false; - } - //percepciones - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, Codigo); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, Concepto); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, importe); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - - } - - - - CveConcepto = 0; Concepto = ""; importe = ""; Codigo = ""; - - rowconcept = dtConceptos.FiltroPrimero(string.Format("Orden>{0} AND SoloVisible =0 AND Tipo ='D'", ordenD), "Orden"); - continuarconcepto = rowconcept != null; - while (continuarconcepto) - { - double sumaimporte = dtempleadosConceptos.SUM("Importe", string.Format("CvePersonal > 0 AND CveSubProyecto={0} AND CveConcepto={1} AND Importe <> 0", CveSubProyecto, rowconcept["CveConcepto"])); - ordenD = rowconcept["Orden"].ToString().ToEntero(); - if (sumaimporte != 0) - { - CveConcepto = rowconcept["CveConcepto"].ToString().ToEntero(); - importe = string.Format("${0:N2}", sumaimporte); - Concepto = rowconcept["Concepto"].ToString(); - Codigo = rowconcept["Codigo"].ToString(); - continuarconcepto = false; - - } - else - { - - rowconcept = dtConceptos.FiltroPrimero(string.Format("Orden>{0} AND SoloVisible =0 AND Tipo ='D'", ordenD), "Orden"); - continuarconcepto = rowconcept != null; - } - } - if (importe != "") - { - gonext = true; - } - - - //deducciones - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, Codigo); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, Concepto); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, importe); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - - } - } - #endregion - - { - rowx = new GemBox.Document.Tables.TableRow(document); - tconeptos.Rows.Add(rowx); - } - { - - rowx = new GemBox.Document.Tables.TableRow(document); - tconeptos.Rows.Add(rowx); - - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, "Total Percepciones"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, string.Format("${0:N2}", dtempleados.SUM("SumaPercepciones", string.Format(" CvePersonal > 0 AND CveSubProyecto={0}", CveSubProyecto)))); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilostrong; - - } - - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilostrong; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, "Total Deducciones"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilostrong; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, string.Format("${0:N2}", dtempleados.SUM("SumaDeducciones", string.Format("CvePersonal > 0 AND CveSubProyecto={0}", CveSubProyecto)))); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilostrong; - - } - } - - //no empleados - { - - rowx = new GemBox.Document.Tables.TableRow(document); - tconeptos.Rows.Add(rowx); - - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, "Total de empleados"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, string.Format("{0:N0}", dtempleados.COUNT("CvePersonal", string.Format("CvePersonal > 0 AND CveSubProyecto={0}", CveSubProyecto)))); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - } - - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilostrong; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - - } - } - //Neto depto - { - - rowx = new GemBox.Document.Tables.TableRow(document); - tconeptos.Rows.Add(rowx); - - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - - } - - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, "Neto del Centro de costos"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, string.Format("${0:N2}", dtempleados.SUM("Total", string.Format("CvePersonal > 0 AND CveSubProyecto={0}", CveSubProyecto)))); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilostrong; - - } - } - - - setborderclear(tconeptos); - keeptablesamepage(sobrereciboTable); - } - #endregion - section.Blocks.Add(new GemBox.Document.Paragraph(document, new GemBox.Document.SpecialCharacter(document, GemBox.Document.SpecialCharacterType.PageBreak))); - - } - paragraphh = new GemBox.Document.Paragraph(document, "TOTAL "); - paragraphh.ParagraphFormat.Style = styilostrong; - section.Blocks.Add(paragraphh); - - #region "total" - { - - sobrereciboTable = new GemBox.Document.Tables.Table(document); - sobrereciboTable.TableFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(100, GemBox.Document.Tables.TableWidthUnit.Percentage); - section.Blocks.Add(sobrereciboTable); - row = new GemBox.Document.Tables.TableRow(document); - sobrereciboTable.Rows.Add(row); - var cell = new GemBox.Document.Tables.TableCell(document); - row.Cells.Add(cell); - tconeptos = new GemBox.Document.Tables.Table(document); - tconeptos.TableFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(100, GemBox.Document.Tables.TableWidthUnit.Percentage); - cell.Blocks.Add(tconeptos); - GemBox.Document.Tables.TableRow rowx; GemBox.Document.Tables.TableCell cellx; - //Percepción Valor Importe Deducción Valor Importe - bool gonext = true; - int cindex = 0; - int OrdenP = -999; - int ordenD = -999; - //Titulos - { - - rowx = new GemBox.Document.Tables.TableRow(document); - tconeptos.Rows.Add(rowx); - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, "Percepción"); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilostrong; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, "Valor"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilostrong; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, "Importe"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilostrong; - - } - - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, "Deducción"); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilostrong; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, "Valor"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilostrong; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, "Importe"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilostrong; - - } - } - //conceptos percep,deduc - while (gonext) - { - cindex = cindex + 1; - int CveConcepto; string Concepto = ""; string Codigo = ""; string importe = ""; - - rowx = new GemBox.Document.Tables.TableRow(document); - tconeptos.Rows.Add(rowx); - DataRow rowconcept; - while ((rowconcept = dtConceptos.FiltroPrimero(string.Format("Orden>{0} AND SoloVisible =0 AND Tipo ='P'", OrdenP), "Orden")) != null && importe == "") - { - double sumaimporte = dtempleadosConceptos.SUM("Importe", string.Format("CvePersonal > 0 AND CveConcepto={0}", rowconcept["CveConcepto"])); - OrdenP = rowconcept["Orden"].ToString().ToEntero(); - if (sumaimporte != 0) - { - CveConcepto = rowconcept["CveConcepto"].ToString().ToEntero(); - importe = string.Format("${0:N2}", sumaimporte); - Concepto = rowconcept["Concepto"].ToString(); - Codigo = rowconcept["Codigo"].ToString(); - - } - } - if (importe == "") - { - gonext = false; - } - //percepciones - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, Codigo); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, Concepto); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, importe); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - - } - - - - CveConcepto = 0; Concepto = ""; importe = ""; Codigo = ""; - - while ((rowconcept = dtConceptos.FiltroPrimero(string.Format("Orden>{0} AND SoloVisible =0 AND Tipo ='D'", ordenD), "Orden")) != null && importe == "") - { - double sumaimporte = dtempleadosConceptos.SUM("Importe", string.Format("CvePersonal > 0 AND CveConcepto={0}", rowconcept["CveConcepto"])); - ordenD = rowconcept["Orden"].ToString().ToEntero(); - if (sumaimporte != 0) - { - CveConcepto = rowconcept["CveConcepto"].ToString().ToEntero(); - importe = string.Format("${0:N2}", sumaimporte); - Concepto = rowconcept["Concepto"].ToString(); - Codigo = rowconcept["Codigo"].ToString(); - - } - } - if (importe != "") - { - gonext = true; - } - - - //deducciones - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, Codigo); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, Concepto); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, importe); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - - } - } - { - rowx = new GemBox.Document.Tables.TableRow(document); - tconeptos.Rows.Add(rowx); - } - //Totales perceciones deducciones - { - - rowx = new GemBox.Document.Tables.TableRow(document); - tconeptos.Rows.Add(rowx); - - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, "Total Percepciones"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, string.Format("${0:N2}", dtempleados.SUM("SumaPercepciones", "CvePersonal > 0 "))); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilostrong; - - } - - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, "Total Deducciones"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, string.Format("${0:N2}", dtempleados.SUM("SumaDeducciones", "CvePersonal > 0 "))); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilostrong; - - } - } - { - - rowx = new GemBox.Document.Tables.TableRow(document); - tconeptos.Rows.Add(rowx); - - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, "Total de empleados general"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, string.Format("{0:N0}", dtempleados.COUNT("CvePersonal", "CvePersonal > 0"))); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - } - - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilostrong; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - - } - } - //neto empresa - { - - rowx = new GemBox.Document.Tables.TableRow(document); - tconeptos.Rows.Add(rowx); - - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - - } - - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, "Neto general"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, string.Format("${0:N2}", dtempleados.SUM("Total", "CvePersonal > 0"))); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - - paragraphh.ParagraphFormat.Style = styilostrong; - - } - } - gonext = true; - int OrdenO = -999; - - //basura para espacio - { - rowx = new GemBox.Document.Tables.TableRow(document); - tconeptos.Rows.Add(rowx); - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, " "); cellx.Blocks.Add(paragraphh); - } - - rowx = new GemBox.Document.Tables.TableRow(document); - tconeptos.Rows.Add(rowx); - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, " "); cellx.Blocks.Add(paragraphh); - } - } - rowx = new GemBox.Document.Tables.TableRow(document); - tconeptos.Rows.Add(rowx); - - { - - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - - } - - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, "Obligación"); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilostrong; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilostrong; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, "Importe"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilostrong; - - } - } - while (gonext) - { - cindex = cindex + 1; - int CveConcepto; string Concepto = ""; string Codigo = ""; string importe = ""; - rowx = new GemBox.Document.Tables.TableRow(document); - tconeptos.Rows.Add(rowx); - { - - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, Codigo); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.ColumnSpan = 2; - paragraphh = new GemBox.Document.Paragraph(document, Concepto); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilo; - - - //cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - //cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - //paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - //paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, importe); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - - } - } - DataRow rowconcept; - while ((rowconcept = dtConceptos.FiltroPrimero(string.Format("Orden>{0} AND SoloVisible =0 AND Tipo ='O'", OrdenO), "Orden")) != null && importe == "") - { - double sumaimporte = dtempleadosConceptos.SUM("Valor", string.Format("CvePersonal > 0 AND CveConcepto={0}", rowconcept["CveConcepto"])); - OrdenO = rowconcept["Orden"].ToString().ToEntero(); - if (sumaimporte != 0) - { - CveConcepto = rowconcept["CveConcepto"].ToString().ToEntero(); - importe = string.Format("${0:N2}", sumaimporte); - Concepto = rowconcept["Concepto"].ToString(); - Codigo = rowconcept["Codigo"].ToString(); - - } - } - if (importe == "") - { - gonext = false; - } - //Obligaciones - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, Codigo); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, Concepto); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, importe); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - - } - - - } - - { - rowx = new GemBox.Document.Tables.TableRow(document); - tconeptos.Rows.Add(rowx); - } - { - - rowx = new GemBox.Document.Tables.TableRow(document); - tconeptos.Rows.Add(rowx); - - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, " "); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilostrong; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilostrong; - - } - - { - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, "Total Obligaciones"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilo; - - - cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx); - cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage); - paragraphh = new GemBox.Document.Paragraph(document, string.Format("${0:N2}", dtempleados.SUM("SumaObligaciones"))); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right; - paragraphh.ParagraphFormat.Style = styilostrong; - - } - } - setborderclear(tconeptos); - keeptablesamepage(tconeptos); - keeptablesamepage(sobrereciboTable); - } - #endregion - GemDocumen.SustituirTags(listaTags); - GemDocumen.GuardarStreamPDF(); - System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(GemDocumen.GetBytesDocumento()); - GemDocumen.Dispose(); - Response.Clear(); - Response.ContentType = "application/pdf"; - Response.AddHeader("content-disposition", $"attachment;filename=Lista de Raya.pdf"); - Response.Buffer = true; - memoryStream.WriteTo(Response.OutputStream); - Response.End(); - } - catch (Exception e) - { - Extensiones.ModExtensiones.GuardaLog(string.Format("Nomina2(errorLayout):{0} ", e.ToString())); - Alert("No se pudo generar la lista de raya favor de contactar a soporte tecnico.", Extensiones.ModExtensiones.TipoMensaje.ToastError); - RegistraScript(string.Format("console.error('Nomina2(errorLayout):{0}'); ", e.ToString().Replace("'", "\\'"))); - } - } - else - { - Alert("No se encontro la plantilla.", Extensiones.ModExtensiones.TipoMensaje.ToastAdventencia); - } - } - else - { - Alert("es necesario calcular el periodo primero.", Extensiones.ModExtensiones.TipoMensaje.ToastAdventencia); - } - } - - #region "Gembox" - private void keeptablesamepage(GemBox.Document.Tables.Table table) - { - //Mantener tabla unida - { - // Get all Paragraph formats in a Table element. - IEnumerable formats = table.GetChildElements(true, GemBox.Document.ElementType.TableCell) - .Cast() - .SelectMany(cell => - { - if (cell.Blocks.Count == 0) - cell.Blocks.Add(new GemBox.Document.Paragraph(cell.Document)); - return cell.GetChildElements(true, GemBox.Document.ElementType.Paragraph); - }) - .Cast() - .Select(p => p.ParagraphFormat); - - // Set KeepLinesTogether and KeepWithNext properties. - foreach (GemBox.Document.ParagraphFormat format in formats) - { - format.KeepLinesTogether = true; - format.KeepWithNext = true; - } - } - } - private void setborderclear(GemBox.Document.Tables.Table table) - { - table.TableFormat.Borders.SetBorders(GemBox.Document.MultipleBorderTypes.All, GemBox.Document.BorderStyle.None, GemBox.Document.Color.Empty, 0); - foreach (var row in table.Rows) - { - foreach (var cell in row.Cells) - { - cell.CellFormat.Borders.ClearBorders(); - } - } - } - #endregion - protected void LnkListaRaya_Click(object sender, EventArgs e) - { - ImprimirReporte(); - } - #region Movtos Permanentes - - protected void CargaTipoConcepto() - { - //DdlTipo.Items.Insert(0, new ListItem("Percepciones", "P")); - //DdlTipo.Items.Insert(1, new ListItem("Deducciones", "D")); - //DdlTipo.Items.Insert(2, new ListItem("Obligaciones", "O")); - //DdlTipo.SelectedValueExist("-1"); - CargaConcepto(); - } - - protected void CargaConcepto() - { - DdlConcepto.Items.Clear(); - if (DdlTipo.SelectedValue.Contiene("P", "D", "O")) - { - DdlConcepto.DataSource = get_GlobalDTNomConceptos(UsuarioActual.CveEmpresa).FiltraParametros(string.Format("Tipo ='{0}' AND FormulaTotal = 'FNC.[MovimientosPermanentes]'", DdlTipo.SelectedValue)); - } - else - { - DdlConcepto.DataSource = get_GlobalDTNomConceptos(UsuarioActual.CveEmpresa).FiltraParametros(" FormulaTotal = 'FNC.[MovimientosPermanentes]'"); - } - DdlConcepto.DataBind(); - DdlConcepto.Items.Insert(0, new ListItem("Seleccione", "-1")); - DdlConcepto.SelectedValueExist("-1"); - } - private void CargaMovtoPermanente() - { - - using (ClsNominas ObjMovt = new ClsNominas()) - { - ObjMovt.GetMovtoPermanente(UsuarioActual.CveEmpresa, SRCvePersonal); - GVMovtoPermanente.DataSource = ObjMovt.DtResultados; - - } - GVMovtoPermanente.DataBind(); - UpMovtosPermanentes.Update(); - } - protected void DdlTipo_SelectedIndexChanged(object sender, EventArgs e) - { - CargaConcepto(); - } - - protected void LnkAddMovtoPermanente_Click(object sender, EventArgs e) - { - CargaConcepto(); - DdlTipoDescto_SelectedIndexChanged(null, null); - pnlAddupMovto.Visible = true; - LnkAddMovto.Visible = true; - LnkUpMovto.Visible = false; - LtlMovtoPermanenteaddup.Text = "Agregar Movimiento"; - - TxtDescripcion.Text = ""; - TxtValor.Text = ""; - TxtVecesAplicar.Text = ""; - TxtMontoLimite.Text = ""; - TxtFechaAplicacion.Text = ""; - ChkEstatus.Visible = true; - } - - protected void LnkAddMovto_Click(object sender, EventArgs e) - { - int cveConcepto = DdlConcepto.SelectedValue.ToEntero(); - string descripcion = TxtDescripcion.Text; - int tipoDescuento = DdlTipoDescto.SelectedValue.ToEntero(); - double valor = TxtValor.Text.ToDouble(); - int vecesAplicar = TxtVecesAplicar.Text.ToEntero(); - decimal montoLimite = TxtMontoLimite.Text.ToDecimal(); - string fechaInicioAplicacion = TxtFechaAplicacion.Text.ToDate().ToString("yyyy/MM/dd"); - bool estatus = ChkEstatus.Checked; - bool Continuar; - using (ClsNominas ObjMovt = new ClsNominas()) - { - Continuar = ObjMovt.AddMovtoPermanente(cveConcepto, SRCvePersonal, descripcion, tipoDescuento, valor, vecesAplicar, montoLimite, fechaInicioAplicacion, estatus); - - } - if (Continuar) - { - this.RegistraScript("$('#DModalMovtoPermanente').modal('hide');"); - CargaMovtoPermanente(); - UpMovtosPermanentes.Update(); - this.Alert("El Movto_Permanente Se ha agregado"); - } - - } - - protected void LnkUpMovto_Click(object sender, EventArgs e) - { - int cveConcepto = DdlConcepto.SelectedValue.ToEntero(); - string descripcion = TxtDescripcion.Text; - int tipoDescuento = DdlTipoDescto.SelectedValue.ToEntero(); - double valor = TxtValor.Text.ToDouble(); - int vecesAplicar = TxtVecesAplicar.Text.ToEntero(); - decimal montoLimite = TxtMontoLimite.Text.ToDecimal(); - string fechaInicioAplicacion = TxtFechaAplicacion.Text.ToDate().ToString("yyyy/MM/dd"); - bool estatus = ChkEstatus.Checked; - bool Continuar; - using (ClsNominas ObjMovt = new ClsNominas()) - { - Continuar = ObjMovt.UpMovtoPermanente(CcveMovtoPermanente, cveConcepto, SRCvePersonal, descripcion, tipoDescuento, valor, vecesAplicar, montoLimite, fechaInicioAplicacion, estatus); - - } - if (Continuar) - { - this.RegistraScript("$('#DModalMovtoPermanente').modal('hide');"); - CargaMovtoPermanente(); - UpMovtosPermanentes.Update(); - this.Alert("El Movto_Permanente Se ha agregado"); - } - - } - - protected void DdlTipoDescto_SelectedIndexChanged(object sender, EventArgs e) - { - pnlMonto.Visible = DdlTipoDescto.SelectedValue.ToEntero() > 2; - pnlVecesAplicar.Visible = DdlTipoDescto.SelectedValue.ToEntero() < 3; - } - - protected void LnkEditarMovtoPermanente_Click(object sender, EventArgs e) - { - - GridViewRow gvRow = (GridViewRow)(((LinkButton)sender).NamingContainer); - CcveMovtoPermanente = gvRow.DataKey("CveMovtoPermanente").ToEntero(); - int cveConcepto = gvRow.DataKey("CveConcepto").ToEntero(); - int cvePersonal = gvRow.DataKey("CvePersonal").ToEntero(); - string descripcion = gvRow.DataKey("Descripcion"); - int tipoDescuento = gvRow.DataKey("TipoDescuento").ToEntero(); - double valor = gvRow.DataKey("Valor").ToDouble(); - int vecesAplicar = gvRow.DataKey("VecesAplicar").ToEntero(); - decimal montoLimite = gvRow.DataKey("MontoLimite").ToDecimal(); - DateTime fechaInicioAplicacion = gvRow.DataKey("FechaInicioAplicacion").ToDate(); - bool estatus = gvRow.DataKey("Estatus") == "1" || gvRow.DataKey("Estatus").ToUpper() == "TRUE"; - DateTime fechaRegistro = gvRow.DataKey("FechaRegistro").ToDateTime(); - string tipo = "P"; - DataRow drow = get_GlobalDTNomConceptos(UsuarioActual.CveEmpresa).FiltroPrimero(string.Format("Tipo ='{0}'", cveConcepto)); - if (drow != null) - { - tipo = drow["Tipo"].ToString(); - DdlTipo.SelectedValueExist(tipo); - DdlTipo_SelectedIndexChanged(null, null); - } - CargaConcepto(); - DdlConcepto.SelectedValueExist(cveConcepto); - TxtDescripcion.Text = descripcion.ToString(); - DdlTipoDescto.SelectedValueExist(tipoDescuento.ToString()); - DdlTipoDescto_SelectedIndexChanged(null, null); - - TxtValor.Text = valor.ToString(); - TxtVecesAplicar.Text = vecesAplicar.ToString(); - TxtMontoLimite.Text = montoLimite.ToString(); - TxtFechaAplicacion.Text = $"{fechaInicioAplicacion:dd/MM/yyyy}"; - ChkEstatus.Checked = estatus; - this.RegistraScript("$('#DModalMovtoPermanente').modal();"); - - - pnlAddupMovto.Visible = true; - LnkAddMovto.Visible = false; - LnkUpMovto.Visible = true; - UpMovtosPermanentes.Update(); - } - #endregion - - protected void LnkGuardarFonacot_Click(object sender, EventArgs e) - { - double importe = TxtFonValor.Text.ToDouble(); - int TipoAplicacion = DdlFonTipoAplicacion.SelectedValue.ToEntero(); - int NoPagos = 0; - double SaldoIni = 0; - string descripcion02 = TxtFonDescripcion.Text; - string descripcion01 = TxtFonNumCredito.Text; - string fecha = TxtFonFechaInicio.Text.Replace("_", ""); - int estatus = ChkFonacot.Checked ? 1 : 0; - if (fecha.Length > 8) - fecha = fecha.ToDateTime().ToString("yyyy/MM/dd"); - else - fecha = ""; - bool continuar = true; - using (ClsRH ObjPersonal = new ClsRH()) - { - if (!ObjPersonal.AddConcepto(SRCvePersonal, -1, importe, TipoAplicacion, NoPagos, SaldoIni, UsuarioActual.CveUsuario, 4, descripcion01, descripcion02, fecha, "", estatus, UsuarioActual.CveEmpresa)) - continuar = false; - } - if (continuar) - { - LnkConsultar_Click(null, null); - mostrarConceptos(); - Alert("Se actualizo el calculo de fonacot"); - } - - } - - protected void LnkAutorizar_Click(object sender, EventArgs e) - { - autorizarNomina(-1); - } - - private void autorizarNomina(int FiltroCvePersonal) - { - - bool continuar = true; - string[] getcolumnas = new string[] { "CvePersonal", "CveMetodoPago", "SumaPercepciones", "Total", "SalarioDiario", "SalarioDiarioIMSS", "SalarioDiarioIntegrado", "DiasLaborados", "DiasFaltados", "DiasVacaciones", "DiasIncapacidad" }; - - DataTable dtr = dtempleados.FiltraParametros(string.Format("(CvePersonal={0} OR {0}=-1) AND CvePersonal > 0 AND NomAutorizado =0", FiltroCvePersonal), "", getcolumnas); - DataTable dtconp = null; - int CvePeriodoSeleccionado = DdlPeriodo.SelectedValue.ToEntero();//cambiar reparar - - #region PropNomina - int CvePersonal = 0; - int CveNomina = 0; - int CveMetodoPago = 0; - double SubTotal = 0; - double Total = 0; - int CveMoneda = 1; - #endregion - #region PropNominaDetalle - int CveConcepto = 0; - decimal ImporteConcepto = 0, ImporteGravadoConcepto = 0, ImporteExentoConcepto = 0, ImporteValor = 0; - #endregion - - - using (ClsNominas objNomina = new ClsNominas()) - { - objNomina.IniciaTransacSQL(); - foreach (DataRow rtemp in dtr.Rows) - { - CveNomina = 0; - CvePersonal = rtemp["CvePersonal"].ToString().ToEntero(); - CveMetodoPago = rtemp["CveMetodoPago"].ToString().ToEntero(); - SubTotal = rtemp["SumaPercepciones"].ToString().ToDouble(); - Total = rtemp["Total"].ToString().ToDouble(); - if (CvePersonal > 0) - { - if (continuar) - { - if (objNomina.GetNom_Nominas(-1, CvePersonal, CvePeriodoSeleccionado, -1, UsuarioActual.CveEmpresa)) - { - - if (objNomina.DtResultados.Rows.Count > 0) - { - CveNomina = objNomina.CveNomina; - } - else - { - if (objNomina.AddNom_Nominas(-1, 1, CvePersonal, CvePeriodoSeleccionado, SubTotal, 0, 0, Total, CveMoneda, 1, CveMetodoPago, DateTime.Now, "Deducciones nómina", - "", "", "", "", 0, 0, 0, new DateTime(), new DateTime(), new DateTime(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)) - { - CveNomina = objNomina.CveNomina; - } - else - { - continuar = false; - } - } - } - } - if (CveNomina == 0) - { - continuar = false; - } - - - if (continuar) - { - dtconp = dtempleadosConceptos.FiltraParametros(string.Format("CvePersonal={0} AND Importe<>0", CvePersonal)); - foreach (DataRow rcon in dtconp.Rows) - { - - CveConcepto = rcon["CveConcepto"].ToString().ToEntero(); - ImporteConcepto = rcon["Importe"].ToString().ToDecimal(); - ImporteGravadoConcepto = rcon["ImporteGravado"].ToString().ToDecimal(); - ImporteExentoConcepto = ImporteConcepto - ImporteGravadoConcepto; - ImporteValor = rcon["Valor"].ToString().ToDecimal(); - if (continuar) - { - - if (!objNomina.AddUPNom_NominasDetalles(CveNomina, CvePeriodoSeleccionado, CvePersonal, CveConcepto, ImporteConcepto, ImporteGravadoConcepto, ImporteExentoConcepto, ImporteValor, UsuarioActual.CveUsuario)) - { - continuar = false; - } - } - - } - } - if (continuar) - { - decimal SalarioDiario = rtemp["SalarioDiario"].ToString().ToDecimal(); - decimal SalarioDiarioIMSS = rtemp["SalarioDiarioIMSS"].ToString().ToDecimal(); - decimal SalarioDiarioIntegrado = rtemp["SalarioDiarioIntegrado"].ToString().ToDecimal(); - int DiasLaborados = rtemp["DiasLaborados"].ToString().ToEntero(); - int DiasFaltados = rtemp["DiasFaltados"].ToString().ToEntero(); - int DiasVacaciones = rtemp["DiasVacaciones"].ToString().ToEntero(); - int DiasIncapacidad = rtemp["DiasIncapacidad"].ToString().ToEntero(); - continuar = objNomina.PA_Nom_NominasAutorizarUP(CvePersonal, CvePeriodoSeleccionado, SalarioDiario, SalarioDiarioIMSS, SalarioDiarioIntegrado, 0, 0, Total, SubTotal, DiasLaborados, DiasFaltados, DiasVacaciones, DiasIncapacidad); - - continuar = objNomina.AutorizaNom_Nominas(CvePersonal, CvePeriodoSeleccionado, true); - } - - } - } - - - - - if (continuar) - { - objNomina.Commit(); - Alert("La nomina se autorizó correctamente."); - cargaDatos(); - } - else - { - objNomina.RollBack(); - - } - } - if (dtr != null) - { - dtr.Dispose(); - - } - if (dtconp != null) - { - dtconp.Dispose(); - - } - - } - - protected void LnkCargaAsistenciaMasiva_Click(object sender, EventArgs e) - { - RegistraScript("$('#DModalCargaASistenciaMasiva').modal();"); - } - - protected void LnkCargarAsistenciaMasiva_Click(object sender, EventArgs e) - { - using (ClsRH ObjPersonal = new ClsRH()) - { - ObjPersonal.IniciaTransacSQL(); - bool OcurrioError = false; - - if (!ObjPersonal.AddAsistenciaMasiva2(DdlPeriodoCM.SelectedValue.ToEntero(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)) - OcurrioError = true; - - if (OcurrioError) - { - ObjPersonal.RollBack(); - Alert("Ocurrió un error al guardar las Asistencias.", ModExtensiones.TipoMensaje.MsgError); - } - else - { - ObjPersonal.Commit(); - Alert("Las Asistencias se guardaron correctamente.", ModExtensiones.TipoMensaje.ToastInformacion); - } - - } - - } - - private void cargaPeriodosCM() - { - int tipoPeriodo = DdlTipoPeriodoCM.SelectedValue.ToEntero(); - int ejercicio = DdlEjerciciosCM.SelectedValue.ToEntero(); - DataTable dtPeriodos = null; - if (tipoPeriodo > 0) - { - using (ClsNominas objperiodos = new ClsNominas()) - { - if (objperiodos.GetPeriodos(tipoPeriodo, UsuarioActual.CveEmpresa, ejercicio, -1, -1)) - { - dtPeriodos = objperiodos.DtResultados; - } - } - } - DdlPeriodoCM.DataSource = dtPeriodos; - DdlPeriodoCM.DataBind(); - DdlPeriodoCM.Items.Insert(0, new ListItem("Seleccione", "-1")); - UpModalAsistenciaMasiva.Update(); - } - - protected void DdlEjerciciosCM_SelectedIndexChanged(object sender, EventArgs e) - { - cargaPeriodosCM(); - } - protected void DdlTipoPeriodoCM_SelectedIndexChanged(object sender, EventArgs e) - { - cargaPeriodosCM(); - } - - - - protected void LnkGuardarASistencia_Click(object sender, EventArgs e) - { - int CvePersonal = TxtasiscvePersonal.Text.ToEntero(); - DateTime fecha = TxtasisFecha.Text.ToDate(); - using (ClsRH objpersonal = new ClsRH()) - { - - if (objpersonal.AddAsistencia(CvePersonal, -1, -1, fecha, DdlTipoAsistencias.SelectedValue.ToEntero(), TxtPorPago.Text.Trim().ToDouble(), TxtHorasDobles.Text.Trim().ToDouble(), - TxtHorasTriples.Text.Trim().ToDouble(), DdlMotivoHoraExtra.SelectedValue.ToEntero(), TxtObservaciones.Text.Trim(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)) - { - - } - Alert("se ha guardado la asistencia satisfactoriamente"); - } - } - - protected void btnasis_Click(object sender, EventArgs e) - { - int CvePersonal = TxtasiscvePersonal.Text.ToEntero(); - DateTime fecha = TxtasisFecha.Text.ToDate(); - DataRow drow = dtempleados.FiltroPrimero(string.Format("CvePersonal={0}", CvePersonal)); - TxtPersonal.Text = drow["nombre"].ToString(); - if (DdlTipoAsistencias.Items.Count == 1) - { - DdlTipoAsistencias.DataSource = GlobalDTAsistenciasInasistencias.FiltraParametros(string.Format("CveEmpresa = {0}", UsuarioActual.CveEmpresa)); - DdlTipoAsistencias.DataBind(); - - } - if (DdlMotivoHoraExtra.Items.Count == 1) - { - DdlMotivoHoraExtra.DataSource = GlobalDTMotivosHorasExtras.FiltraParametros(string.Format("CveEmpresa = {0}", UsuarioActual.CveEmpresa)); - DdlMotivoHoraExtra.DataBind(); - - } - using (ClsRH objpersonal = new ClsRH()) - { - if (objpersonal.GetAsistencias(CvePersonal, -1, -1, -1, -1, -1, fecha, fecha, UsuarioActual.CveEmpresa)) - { - if (objpersonal.DtResultados.Rows.Count > 0) - { - DataRow dr = objpersonal.DtResultados.Rows[0]; - DdlTipoAsistencias.SelectedValueExist(dr["CveAsistenciasInasistencias"].ToString()); - TxtPorPago.Text = dr["PorcentajePago"].ToString(); - TxtHorasDobles.Text = dr["HorasDobles"].ToString(); - TxtHorasTriples.Text = dr["HorasTriples"].ToString(); - DdlMotivoHoraExtra.SelectedValueExist(dr["CveMotivoHoraExtra"].ToString()); - TxtObservaciones.Text = dr["Observacion"].ToString(); - // CveAsistenciasInasistencias - // PorcentajePago - // HorasDobles - // HorasTriples - //CveMotivoHoraExtra - //Observacion - // - - } - } - } - UpModalAsistencia.Update(); - RegistraScript("$('#DModalModAsistencia').modal();"); - } - - protected void LnkSimulador_Click(object sender, EventArgs e) - { - GvConceptossimulador.DataSource = new DataTable(); - GvConceptossimulador.DataBind(); - DdlTipoPeriodoSim.SelectedValue = "1"; - RegistraScript("$('#DSimulador').modal()"); - UpSimulador.Update(); - } - - - protected void LnkSimularXNeto_Click(object sender, EventArgs e) - { - int CveProyecto = -1; - int CveSubProyecto = 1; - int CveTurno = -1; - int CvePeriodo = (DdlTipoPeriodoSim.SelectedValue == "1") ? 12706 : 12551; - int CveEmpresa = UsuarioActual.CveEmpresa; - int Agrupador = -1; - decimal Neto = TxtNetoaPagar.Text.ToDecimal(); - decimal NetoSimulado = 0; - decimal SDI = (Neto * 1.25M) / (DdlTipoPeriodoSim.SelectedValue == "1" ? 7 : 15); - decimal SDIOLD = 0; - decimal sumador = 100; - decimal multiplicador = 1; - bool ismayor = false; - bool isfirst = true; - bool continuarV = true; - DataTable dtPeriodo = new DataTable(); - DataTable dtasistencia = new DataTable(); - DataTable dtConceptos = new DataTable(); - DataTable dtempleados = new DataTable(); - DataTable dtempleadosConceptos = new DataTable(); - bool continuar = false; - using (ClsNominas objnom = new ClsNominas()) - { - while (Neto != NetoSimulado && continuarV) - { - - if (objnom.GetNominaEmpleado(CveProyecto, CveSubProyecto, CveTurno, CvePeriodo, CveEmpresa, Agrupador, -1, 1, SDI) - && objnom.DTSetResultados.Tables.Count > 1) - { - dtempleados = objnom.DTSetResultados.Tables[3]; - dtempleadosConceptos = objnom.DTSetResultados.Tables[4]; - dtConceptos = objnom.DTSetResultados.Tables[0]; - dtPeriodo = objnom.DTSetResultados.Tables[1]; - dtasistencia = objnom.DTSetResultados.Tables[2]; - continuar = true; - NetoSimulado = dtempleados.SUM("Total", string.Format("CvePersonal = {0}", 1)).ToString().ToDecimal(); - } - if (continuar) - { - - if (isfirst) - { - - if (Neto > NetoSimulado) - { - ismayor = true; - } - else - { - ismayor = false; - } - isfirst = false; - } - else - { - if (!((Neto > NetoSimulado) == ismayor)) - { - SDI = SDIOLD; - sumador = sumador * 0.1M; - if (sumador < .00000001M) - { - - continuarV = false; - } - } - } - - multiplicador = (Neto > NetoSimulado) ? 1 : -1; - SDIOLD = SDI; - SDI = SDI + (multiplicador * sumador); - } - else - { - continuarV = false; - } - } - } - if (continuar) - { - { - DataTable dtx = dtConceptos.Copy(); - dtx.Columns.Add("BorradoLogico", typeof(int)); - DataTable dtper = dtx.FiltraParametros("Tipo IN ('P') AND EsPadre = 1 "); - DataTable dtded = dtx.FiltraParametros("Tipo IN ('D') AND EsPadre = 1 "); - DataTable dtObl = dtx.FiltraParametros("Tipo IN ('O') AND EsPadre = 1 "); - ////dtded.Columns.Add("BorradoLogico", typeof(int)); - ////dtObl.Columns.Add("BorradoLogico", typeof(int)); - - foreach (DataRow row in dtper.Rows) - { - int BorradoLogico = 0; - int CveConcepto = row["CveConcepto"].ToString().ToEntero(); - if (!(dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) > 0)) - { - BorradoLogico = 1; - } - row["BorradoLogico"] = BorradoLogico; - } - dtper.AcceptChanges(); - foreach (DataRow row in dtded.Rows) - { - int BorradoLogico = 0; - int CveConcepto = row["CveConcepto"].ToString().ToEntero(); - if (!(dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) > 0)) - { - BorradoLogico = 1; - } - row["BorradoLogico"] = BorradoLogico; - } - dtded.AcceptChanges(); - foreach (DataRow row in dtObl.Rows) - { - int BorradoLogico = 0; - int CveConcepto = row["CveConcepto"].ToString().ToEntero(); - if (!(dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) > 0)) - { - BorradoLogico = 1; - } - row["BorradoLogico"] = BorradoLogico; - } - dtObl.AcceptChanges(); - dtper = dtper.FiltraParametros("BorradoLogico=0"); - dtded = dtded.FiltraParametros("BorradoLogico=0"); - dtObl = dtObl.FiltraParametros("BorradoLogico=0"); - int maxper = dtper.Rows.Count; - int maxded = dtded.Rows.Count; - int maxObl = dtObl.Rows.Count; - int i = 0; - List lconc = new List(); - for (i = 0; i < maxper || i < maxded || i < maxObl; i++) - { - NConcepto nConcepto = new NConcepto(); - DataRow row; - if (maxper > i) - { - row = dtper.Rows[i]; - int CveConcepto = row["CveConcepto"].ToString().ToEntero(); - string Concepto = row["Concepto"].ToString(); - string Codigo = row["Codigo"].ToString(); - //bool visible = (dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) > 0); - double Importe = dtempleados.SUM(string.Format("[V_{0}]", CveConcepto), string.Format("CvePersonal = {0}", 1)); - nConcepto.CveConceptoP = CveConcepto; - nConcepto.ConceptoP = Concepto; - nConcepto.NoConceptoP = Codigo; - nConcepto.ImporteP = Importe; - nConcepto.ValorP = dtempleados.SUM(string.Format("[VAL_{0}]", CveConcepto), string.Format("CvePersonal = {0}", 1)); - } - if (maxded > i) - { - row = dtded.Rows[i]; - int CveConcepto = row["CveConcepto"].ToString().ToEntero(); - string Concepto = row["Concepto"].ToString(); - string Codigo = row["Codigo"].ToString(); - //bool visible = (dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) > 0); - double Importe = dtempleados.SUM(string.Format("[V_{0}]", CveConcepto), string.Format("CvePersonal = {0}", 1)); - nConcepto.CveConceptoD = CveConcepto; - nConcepto.ConceptoD = Concepto; - nConcepto.NoConceptoD = Codigo; - nConcepto.ImporteD = Importe; - nConcepto.ValorD = dtempleados.SUM(string.Format("[VAL_{0}]", CveConcepto), string.Format("CvePersonal = {0}", 1)); - } - if (maxObl > i) - { - row = dtObl.Rows[i]; - int CveConcepto = row["CveConcepto"].ToString().ToEntero(); - string Concepto = row["Concepto"].ToString(); - string Codigo = row["Codigo"].ToString(); - //bool visible = (dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) > 0); - double Importe = dtempleados.SUM(string.Format("[V_{0}]", CveConcepto), string.Format("CvePersonal = {0}", 1)); - nConcepto.CveConceptoO = CveConcepto; - nConcepto.ConceptoO = Concepto; - nConcepto.NoConceptoO = Codigo; - nConcepto.ImporteO = Importe; - nConcepto.ValorO = dtempleados.SUM(string.Format("[VAL_{0}]", CveConcepto), string.Format("CvePersonal = {0}", 1)); - } - lconc.Add(nConcepto); - } - - lconc.Add(new NConcepto()); - - NConcepto SubTotales = new NConcepto(); - SubTotales.CveConceptoP = 0; - SubTotales.ConceptoP = "Total Percepciones"; - SubTotales.EstatusP = -2; - SubTotales.ImporteP = dtempleados.SUM("SumaPercepciones", string.Format("CvePersonal = {0}", 1)); - ///Alert(SubTotales.ImporteP.ToString()); - - SubTotales.CveConceptoD = 0; - SubTotales.ConceptoD = "Total Deducciones"; - SubTotales.EstatusD = -2; - SubTotales.ImporteD = dtempleados.SUM("SumaDeducciones", string.Format("CvePersonal = {0}", 1)); - SubTotales.CveConceptoD = 0; - - SubTotales.ConceptoO = "Total Obligaciones"; - SubTotales.EstatusO = -2; - SubTotales.ImporteO = dtempleados.SUM("SumaObligaciones", string.Format("CvePersonal = {0}", 1)); - - //NConcepto Totales = new NConcepto(); - //Totales.CveConceptoD = 0; - //Totales.ConceptoD = "Total"; - //Totales.EstatusD = -3; - //Totales.ImporteD = dtempleados.SUM("Total", string.Format("CvePersonal = {0}", 1)); - - lconc.Add(SubTotales); - //lconc.Add(Totales); - GvConceptossimulador.DataSource = lconc; - GvConceptossimulador.DataBind(); - } - } - UpSimulador.Update(); - } - - protected void DdlTipoPeriodoSim_SelectedIndexChanged(object sender, EventArgs e) - { - - } - - - protected void LnkDownArchivosSua_Click(object sender, EventArgs e) - { - TxtFechaInicio.Text = DateTime.Now.AddDays(DateTime.Now.Day - 1).ToString("dd/MM/yyy"); - TXTFechaFin.Text = DateTime.Now.AddDays(DateTime.Now.Day - 1).AddMonths(1).AddDays(-1).ToString("dd/MM/yyy"); - - RegistraScript("$('#DmodalGetSua').modal();"); - UpModalGetSUA.Update(); - } - - protected void LnkGetTxtsSUA_Click(object sender, EventArgs e) - { - string concater = ""; - string MovtosAfil = ""; - string MovtosmodSalario = ""; - string movtosBajas = ""; - using (ClsRH ObjPersonal = new ClsRH()) - { - if (ObjPersonal.GetMovimientosToSUA(UsuarioActual.CveEmpresa, TxtFechaInicio.Text.ToDate().ToString("yyyy/MM/dd"), TXTFechaFin.Text.ToDate().ToString("yyyy/MM/dd"))) - { - //01: MovtosAfil - concater = ""; - foreach (var item in ObjPersonal.DtResultados.Select("Tipo=1")) - { - MovtosAfil = string.Format("{0}{1}{2}", MovtosAfil, concater, item["Movtotxt"]); - concater = "\\r\\n"; - } - - //02: MovtosmodSalario - concater = ""; - foreach (var item in ObjPersonal.DtResultados.Select("Tipo=2")) - { - MovtosmodSalario = string.Format("{0}{1}{2}", MovtosmodSalario, concater, item["Movtotxt"]); - concater = "\\r\\n"; - } - //03: movtosBajas - concater = ""; - foreach (var item in ObjPersonal.DtResultados.Select("Tipo=3")) - { - movtosBajas = string.Format("{0}{1}{2}", movtosBajas, concater, item["Movtotxt"]); - concater = "\\r\\n"; - } - - } - string script = "";// string.Format("SaveCsv(\"MovtosAfil.txt\", '{0}');SaveCsv(\"MovtosmodSalario.txt\", '{1}');SaveCsv(\"movtosBajas.txt\", '{2}');", MovtosAfil.Replace("'", "\\'"), MovtosmodSalario.Replace("'", "\\'"), movtosBajas.Replace("'", "\\'")); - if (ChkSuaAltas.Checked) - { - script = string.Format("{1}SaveCsv(\"MovtosAfil.txt\", '{0}');", MovtosAfil.Replace("'", "\\'"), script); - } - if (ChkSuaBajas.Checked) - { - script = string.Format("{1}SaveCsv(\"movtosBajas.txt\", '{0}');", movtosBajas.Replace("'", "\\'"), script); - } - - RegistraScript(script); - RegistraScript("$('#DmodalGetSua').modal('hide');"); - } - - } - - protected void LnkUpSuamodal_Click(object sender, EventArgs e) - { - TxtArchivoSua.Text = ""; - GVProcesarSUA.DataSource = null; - GVProcesarSUA.DataBind(); - RegistraScript("$('#DmodalCompareSua').modal();shownew();"); - UpArchivoSua.Update(); - } - protected void LnkUpSuaFile_Click(object sender, EventArgs e) - { - string fileurl = ""; - GVProcesarSUA.DataSource = null; - Files archivos = TxtArchivoSua.getfiles(); - if (archivos.Archivos.Count > 0) - { - fileurl = archivos.Archivos[0].FileUrl; - string SuaFiletext = System.IO.File.ReadAllText(fileurl, Encoding.GetEncoding("iso-8859-1")); - using (ClsNominas ObjPersonal = new ClsNominas()) - { - if (ObjPersonal.ProcesarSUA(SuaFiletext, UsuarioActual.CveEmpresa)) - { - if (ObjPersonal.DTSetResultados.Tables.Count > 4) - { - DateTime dateperiodo; - DateTime.TryParseExact(string.Format("{0}01", ObjPersonal.DTSetResultados.Tables[1].Rows[0]["Periodo"]), "yyyyMMdd", new System.Globalization.CultureInfo("es-MX"), System.Globalization.DateTimeStyles.None, out dateperiodo); - LtlPeriodo.Text = dateperiodo.Date.ToString("MMMM yyyy", new System.Globalization.CultureInfo("es-MX")); - DtSuaProcesado = ObjPersonal.DTSetResultados.Tables[3]; - GVProcesarSUA.DataSource = ObjPersonal.DTSetResultados.Tables[3]; - } - } - } - - } - GVProcesarSUA.DataBind(); - TxtArchivoSua.Text = ""; - RegistraScript("showResult();"); - UpArchivoSua.Update(); - } - - - - protected void GVProcesarSUA_RowDataBound(object sender, GridViewRowEventArgs e) - { - - if (e.Row.RowType == DataControlRowType.DataRow) - { - if (e.Row.RowIndex == 0) - { - e.Row.CssClass = "Totales"; - } - string SalarioSUA = string.Format("{0:N2}", e.Row.DataKey("SalarioSUA").ToDecimal()); - string SalarioSIG = string.Format("{0:N2}", e.Row.DataKey("SalarioSIG").ToDecimal()); - int celda = 1; - if (SalarioSUA != SalarioSIG) - { - e.Row.Cells[celda].CssClass = "cellFail"; - e.Row.Cells[celda + 1].CssClass = "cellFail"; - } - celda = celda + 4; - string CuotaExcedenteSUA = string.Format("{0:N2}", e.Row.DataKey("CuotaExcedenteSUA").ToDecimal()); - string CuotaExcedenteSIG = string.Format("{0:N2}", e.Row.DataKey("CuotaExcedenteSIG").ToDecimal()); - if (CuotaExcedenteSUA != CuotaExcedenteSIG) - { - e.Row.Cells[celda].CssClass = "cellFail"; - e.Row.Cells[celda + 1].CssClass = "cellFail"; - } - celda = celda + 2; - string PrestacionesDineroSUA = string.Format("{0:N2}", e.Row.DataKey("PrestacionesDineroSUA").ToDecimal()); - string PrestacionesSIG = string.Format("{0:N2}", e.Row.DataKey("PrestacionesSIG").ToDecimal()); - if (PrestacionesDineroSUA != PrestacionesSIG) - { - e.Row.Cells[celda].CssClass = "cellFail"; - e.Row.Cells[celda + 1].CssClass = "cellFail"; - } - celda = celda + 2; - string GastosMedPenSUA = string.Format("{0:N2}", e.Row.DataKey("GastosMedPenSUA").ToDecimal()); - string GastosMedicosSIG = string.Format("{0:N2}", e.Row.DataKey("GastosMedicosSIG").ToDecimal()); - if (GastosMedPenSUA != GastosMedicosSIG) - { - e.Row.Cells[celda].CssClass = "cellFail"; - e.Row.Cells[celda + 1].CssClass = "cellFail"; - } - celda = celda + 2; - string InvalidezyVidaSUA = string.Format("{0:N2}", e.Row.DataKey("InvalidezyVidaSUA").ToDecimal()); - string InvalidezyVidaSIG = string.Format("{0:N2}", e.Row.DataKey("InvalidezyVidaSIG").ToDecimal()); - if (InvalidezyVidaSUA != InvalidezyVidaSIG) - { - e.Row.Cells[celda].CssClass = "cellFail"; - e.Row.Cells[celda + 1].CssClass = "cellFail"; - } - celda = celda + 2; - string CesantiayVejezObreraSUA = string.Format("{0:N2}", e.Row.DataKey("CesantiayVejezObreraSUA").ToDecimal()); - string CesantiayVejezObreraSIG = string.Format("{0:N2}", e.Row.DataKey("CesantiayVejezObreraSIG").ToDecimal()); - if (CesantiayVejezObreraSUA != CesantiayVejezObreraSIG) - { - e.Row.Cells[celda].CssClass = "cellFail"; - e.Row.Cells[celda + 1].CssClass = "cellFail"; - } - celda = celda + 2; - string CuotaFijaSUA = string.Format("{0:N2}", e.Row.DataKey("CuotaFijaSUA").ToDecimal()); - string CuotaFijaSIG = string.Format("{0:N2}", e.Row.DataKey("CuotaFijaSIG").ToDecimal()); - if (CuotaFijaSUA != CuotaFijaSIG) - { - e.Row.Cells[celda].CssClass = "cellFail"; - e.Row.Cells[celda + 1].CssClass = "cellFail"; - } - celda = celda + 2; - string RiesgosdeTrabajoSUA = string.Format("{0:N2}", e.Row.DataKey("RiesgosdeTrabajoSUA").ToDecimal()); - string RiesgoTrabajoSIG = string.Format("{0:N2}", e.Row.DataKey("RiesgoTrabajoSIG").ToDecimal()); - if (RiesgosdeTrabajoSUA != RiesgoTrabajoSIG) - { - e.Row.Cells[celda].CssClass = "cellFail"; - e.Row.Cells[celda + 1].CssClass = "cellFail"; - } - celda = celda + 2; - string GuarderiaSUA = string.Format("{0:N2}", e.Row.DataKey("GuarderiaSUA").ToDecimal()); - string GuarderiaSIG = string.Format("{0:N2}", e.Row.DataKey("GuarderiaSIG").ToDecimal()); - if (GuarderiaSUA != GuarderiaSIG) - { - e.Row.Cells[celda].CssClass = "cellFail"; - e.Row.Cells[celda + 1].CssClass = "cellFail"; - } - celda = celda + 2; - string RetiroSUA = string.Format("{0:N2}", e.Row.DataKey("RetiroSUA").ToDecimal()); - string RetiroSIG = string.Format("{0:N2}", e.Row.DataKey("RetiroSIG").ToDecimal()); - if (RetiroSUA != RetiroSIG) - { - e.Row.Cells[celda].CssClass = "cellFail"; - e.Row.Cells[celda + 1].CssClass = "cellFail"; - } - celda = celda + 2; - string CesantiayVejezPatronalSUA = string.Format("{0:N2}", e.Row.DataKey("CesantiayVejezPatronalSUA").ToDecimal()); - string CesantiayVejezPatronalSIG = string.Format("{0:N2}", e.Row.DataKey("CesantiayVejezPatronalSIG").ToDecimal()); - if (CesantiayVejezPatronalSUA != CesantiayVejezPatronalSIG) - { - e.Row.Cells[celda].CssClass = "cellFail"; - e.Row.Cells[celda + 1].CssClass = "cellFail"; - } - - } - } - - protected void LnkDownExcelSua_Click(object sender, EventArgs e) - { - - ClosedXML.Excel.XLWorkbook wb = new ClosedXML.Excel.XLWorkbook(); - var libro = wb.AddWorksheet("SUA"); - int Fila = 1; - libro.Column(1).Width = 50; - ClosedXML.Excel.IXLRange range = libro.Range(Fila, 2, Fila, 3); - range.Merge(); - range.Value = "Salario"; - range = libro.Range(Fila, 4, Fila, 5); - range.Merge(); - range.Value = "Días"; - range = libro.Range(Fila, 6, Fila, 7); - range.Merge(); - range.Value = "Cuota Fija"; - range = libro.Range(Fila, 8, Fila, 9); - range.Merge(); - range.Value = "Cuota Excedente"; - range = libro.Range(Fila, 10, Fila, 11); - range.Merge(); - range.Value = "Prestaciones en Dinero"; - range = libro.Range(Fila, 12, Fila, 13); - range.Merge(); - range.Value = "Gastos Medicos"; - range = libro.Range(Fila, 14, Fila, 15); - range.Merge(); - range.Value = "Riesgos de Trabajo"; - range = libro.Range(Fila, 16, Fila, 17); - range.Merge(); - range.Value = "Invalidez y Vida"; - range = libro.Range(Fila, 18, Fila, 19); - range.Merge(); - range.Value = "Guarderia"; - range = libro.Range(Fila, 20, Fila, 21); - range.Merge(); - range.Value = "Retiro"; - Fila = Fila + 1; - libro.Cell(Fila, 1).Value = "Empleado"; - libro.Cell(Fila, 2).Value = "SUA"; //SalarioSUA - libro.Cell(Fila, 3).Value = "SIG";//SalarioSIG - libro.Cell(Fila, 4).Value = "SUA";//CuotaFijaSUA - libro.Cell(Fila, 5).Value = "SIG";//CuotaFijaSIG - libro.Cell(Fila, 6).Value = "SUA";//CuotaExcedenteSUA - libro.Cell(Fila, 7).Value = "SIG";//CuotaExcedenteSIG - libro.Cell(Fila, 8).Value = "SUA";//PrestacionesDineroSUA - libro.Cell(Fila, 9).Value = "SIG";//PrestacionesSIG - libro.Cell(Fila, 10).Value = "SUA";//GastosMedPenSUA - libro.Cell(Fila, 11).Value = "SIG";//GastosMedicosSIG - libro.Cell(Fila, 12).Value = "SUA";//RiesgosdeTrabajoSUA - libro.Cell(Fila, 13).Value = "SIG";//RiesgoTrabajoSIG - libro.Cell(Fila, 14).Value = "SUA";//InvalidezyVidaSUA - libro.Cell(Fila, 15).Value = "SIG";//InvalidezyVidaSIG - libro.Cell(Fila, 16).Value = "SUA";//GuarderiaSUA - libro.Cell(Fila, 17).Value = "SIG";//GuarderiaSIG - libro.Cell(Fila, 18).Value = "SUA";//RetiroSUA - libro.Cell(Fila, 19).Value = "SIG";//RetiroSIG - libro.Cell(Fila, 20).Value = "SUA";//RetiroSUA - libro.Cell(Fila, 21).Value = "SIG";//RetiroSIG - - - libro.Cell(1, 1).Style.Font.FontColor = ClosedXML.Excel.XLColor.White; - libro.Cell(1, 1).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(79, 129, 189)); - libro.Row(1).CellsUsed().Style.Font.FontColor = ClosedXML.Excel.XLColor.White; - libro.Row(1).CellsUsed().Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(79, 129, 189)); - libro.Row(2).CellsUsed().Style.Font.FontColor = ClosedXML.Excel.XLColor.White; - libro.Row(2).CellsUsed().Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(79, 129, 189)); - - foreach (DataRow erow in DtSuaProcesado.Rows) - { - Fila++; - libro.Cell(Fila, 1).Value = erow["CodigoNombreCompleto"]; - libro.Cell(Fila, 2).Value = string.Format("{0:N2}", erow["SalarioSUA"]); - libro.Cell(Fila, 3).Value = string.Format("{0:N2}", erow["SalarioSIG"]); - libro.Cell(Fila, 4).Value = string.Format("{0:N2}", erow["DiasMes"]); - libro.Cell(Fila, 5).Value = string.Format("{0:N2}", erow["DiasAsistio"]); - libro.Cell(Fila, 6).Value = string.Format("{0:N2}", erow["CuotaFijaSUA"]); - libro.Cell(Fila, 7).Value = string.Format("{0:N2}", erow["CuotaFijaSIG"]); - libro.Cell(Fila, 8).Value = string.Format("{0:N2}", erow["CuotaExcedenteSUA"]); - libro.Cell(Fila, 9).Value = string.Format("{0:N2}", erow["CuotaExcedenteSIG"]); - libro.Cell(Fila, 10).Value = string.Format("{0:N2}", erow["PrestacionesDineroSUA"]); - libro.Cell(Fila, 11).Value = string.Format("{0:N2}", erow["PrestacionesSIG"]); - libro.Cell(Fila, 12).Value = string.Format("{0:N2}", erow["GastosMedPenSUA"]); - libro.Cell(Fila, 13).Value = string.Format("{0:N2}", erow["GastosMedicosSIG"]); - libro.Cell(Fila, 14).Value = string.Format("{0:N2}", erow["RiesgosdeTrabajoSUA"]); - libro.Cell(Fila, 15).Value = string.Format("{0:N2}", erow["RiesgoTrabajoSIG"]); - libro.Cell(Fila, 16).Value = string.Format("{0:N2}", erow["InvalidezyVidaSUA"]); - libro.Cell(Fila, 17).Value = string.Format("{0:N2}", erow["InvalidezyVidaSIG"]); - libro.Cell(Fila, 18).Value = string.Format("{0:N2}", erow["GuarderiaSUA"]); - libro.Cell(Fila, 19).Value = string.Format("{0:N2}", erow["GuarderiaSIG"]); - libro.Cell(Fila, 20).Value = string.Format("{0:N2}", erow["RetiroSUA"]); - libro.Cell(Fila, 21).Value = string.Format("{0:N2}", erow["RetiroSIG"]); - } - //libro.Row(2).SetAutoFilter(); - - - - - System.IO.Stream fs = new System.IO.MemoryStream(); - wb.SaveAs(fs); - fs.Position = 0; - System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(); - using (System.IO.Stream input = fs) - - { - input.CopyTo(memoryStream); - } - memoryStream.Position = 0; - - Response.Clear(); - Response.Buffer = true; - - Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; - Response.AddHeader("content-disposition", string.Format("attachment;filename={0}.xlsx", "FormatoCargaNominas")); - Response.BinaryWrite(memoryStream.ToArray()); - Response.End(); - } - - - #region Incapacidad - private int CcvePersonalIncapacidad - { - get { return (ViewState["CcvePersonalIncapacidad"] == null) ? 0 : Convert.ToInt32(ViewState["CcvePersonalIncapacidad"]); } - set { ViewState["CcvePersonalIncapacidad"] = value; } - } - protected void CargaPersonalIncapacidad() - { - - LimpiaPersonalIncapacidad(); - LnkAgregarIncapacidad.Visible = false; - LnkActualizarIncapacidad.Visible = false; - CcvePersonalIncapacidad = 0; - - - using (ClsNominas ObjPers = new ClsNominas()) - { - ObjPers.PersonalIncapacidadGet(-1, SRCvePersonal, UsuarioActual.CveEmpresa); - GVNom_PersonalIncapacidad.DataSource = ObjPers.DtResultados; - } - GVNom_PersonalIncapacidad.DataBind(); - UpsrIncapacidadpersonal.Update(); - } - protected void LimpiaPersonalIncapacidad() - { - TxtSRINCfolio.Text = ""; - TxtSRINCfechaInicio.Text = ""; - TxtSRINCdiasAutorizados.Text = ""; - DdlSRINCcveTipodeIncidencia.SelectedValue = "-1"; - DdlSRINCcveRamoSeguro.SelectedValue = "-1"; - DdlSRINCcveTipoRiesgo.SelectedValue = "-1"; - TxtSRINCporcentajedeIncapacidad.Text = "100"; - DdlSRINCcveSecuelaConsecuencia.SelectedValue = "-1"; - DdlSRINCcveControlIncapacidad.SelectedValue = "-1"; - TxtSRINCdescripcion.Text = ""; - UpsrIncapacidadpersonal.Update(); - } - protected void LnkPersonalIncapacidad_Click(object sender, EventArgs e) - { - - LimpiaPersonalIncapacidad(); - #region GetDatos - GridViewRow gvRow = (GridViewRow)(((LinkButton)sender).NamingContainer); - CcvePersonalIncapacidad = gvRow.DataKey("CvePersonalIncapacidad").ToEntero(); - int cvePersonal = gvRow.DataKey("CvePersonal").ToEntero(); - string folio = gvRow.DataKey("Folio"); - DateTime fechaInicio = gvRow.DataKey("FechaInicio").ToDateTime(); - int diasAutorizados = gvRow.DataKey("DiasAutorizados").ToEntero(); - int cveTipodeIncidencia = gvRow.DataKey("CveTipodeIncidencia").ToEntero(); - int cveRamoSeguro = gvRow.DataKey("CveRamoSeguro").ToEntero(); - int cveTipoRiesgo = gvRow.DataKey("CveTipoRiesgo").ToEntero(); - int porcentajedeIncapacidad = gvRow.DataKey("PorcentajedeIncapacidad").ToEntero(); - int cveSecuelaConsecuencia = gvRow.DataKey("CveSecuelaConsecuencia").ToEntero(); - int cveControlIncapacidad = gvRow.DataKey("CveControlIncapacidad").ToEntero(); - string descripcion = gvRow.DataKey("Descripcion"); - #endregion - TxtSRINCfolio.Text = folio.ToString(); - TxtSRINCfechaInicio.Text = $"{fechaInicio:dd/MM/yyyy}"; - TxtSRINCdiasAutorizados.Text = diasAutorizados.ToString(); - DdlSRINCcveTipodeIncidencia.SelectedValueExist(cveTipodeIncidencia.ToString()); - DdlSRINCcveRamoSeguro.SelectedValueExist(cveRamoSeguro.ToString()); - DdlSRINCcveTipoRiesgo.SelectedValueExist(cveTipoRiesgo.ToString()); - TxtSRINCporcentajedeIncapacidad.Text = porcentajedeIncapacidad.ToString(); - DdlSRINCcveSecuelaConsecuencia.SelectedValueExist(cveSecuelaConsecuencia.ToString()); - DdlSRINCcveControlIncapacidad.SelectedValueExist(cveControlIncapacidad.ToString()); - TxtSRINCdescripcion.Text = descripcion.ToString(); - LnkAgregarIncapacidad.Visible = false; - //LnkActualizarIncapacidad.Visible = true; - } - protected void LnkshowaaddIncapacidad_Click(object sender, EventArgs e) - { - LimpiaPersonalIncapacidad(); - LnkAgregarIncapacidad.Visible = true; - LnkActualizarIncapacidad.Visible = false; - CcvePersonalIncapacidad = 0; - } - protected void LnkAgregarIncapacidad_Click(object sender, EventArgs e) - { - - string folio = TxtSRINCfolio.Text; - DateTime fechaInicio = TxtSRINCfechaInicio.Text.ToDateTime(); - int diasAutorizados = TxtSRINCdiasAutorizados.Text.ToEntero(); - int cveTipodeIncidencia = DdlSRINCcveTipodeIncidencia.Text.ToEntero(); - int cveRamoSeguro = DdlSRINCcveRamoSeguro.Text.ToEntero(); - int cveTipoRiesgo = DdlSRINCcveTipoRiesgo.Text.ToEntero(); - int porcentajedeIncapacidad = TxtSRINCporcentajedeIncapacidad.Text.ToEntero(); - int cveSecuelaConsecuencia = DdlSRINCcveSecuelaConsecuencia.Text.ToEntero(); - int cveControlIncapacidad = DdlSRINCcveControlIncapacidad.Text.ToEntero(); - string descripcion = TxtSRINCdescripcion.Text; - bool Continuar; - using (ClsNominas ObjPers = new ClsNominas()) - { - Continuar = ObjPers.PersonalIncapacidadAdd(UsuarioActual.CveUsuario, SRCvePersonal, folio, fechaInicio, diasAutorizados, cveTipodeIncidencia, cveRamoSeguro, cveTipoRiesgo, porcentajedeIncapacidad, cveSecuelaConsecuencia, cveControlIncapacidad, descripcion); - } - if (Continuar) - { - CargaPersonalIncapacidad(); - UpsrIncapacidadpersonal.Update(); - this.Alert("La incapacidad se ha agregado.", TipoMensaje.ToastInformacion); - } - } - protected void LnkActualizarIncapacidad_Click(object sender, EventArgs e) - { - - string folio = TxtSRINCfolio.Text; - DateTime fechaInicio = TxtSRINCfechaInicio.Text.ToDateTime(); - int diasAutorizados = TxtSRINCdiasAutorizados.Text.ToEntero(); - int cveTipodeIncidencia = DdlSRINCcveTipodeIncidencia.Text.ToEntero(); - int cveRamoSeguro = DdlSRINCcveRamoSeguro.Text.ToEntero(); - int cveTipoRiesgo = DdlSRINCcveTipoRiesgo.Text.ToEntero(); - int porcentajedeIncapacidad = TxtSRINCporcentajedeIncapacidad.Text.ToEntero(); - int cveSecuelaConsecuencia = DdlSRINCcveSecuelaConsecuencia.Text.ToEntero(); - int cveControlIncapacidad = DdlSRINCcveControlIncapacidad.Text.ToEntero(); - string descripcion = TxtSRINCdescripcion.Text; - bool Continuar; - using (ClsNominas ObjPers = new ClsNominas()) - { - Continuar = ObjPers.PersonalIncapacidadUp(UsuarioActual.CveUsuario, CcvePersonalIncapacidad, folio, fechaInicio, diasAutorizados, - cveTipodeIncidencia, cveRamoSeguro, cveTipoRiesgo, porcentajedeIncapacidad, cveSecuelaConsecuencia, cveControlIncapacidad, descripcion); - } - if (Continuar) - { - CargaPersonalIncapacidad(); - UpsrIncapacidadpersonal.Update(); - this.Alert("La incapacidad se ha actualizado.", TipoMensaje.ToastInformacion); - } - } - #endregion - - - protected void LnkSRVacacionesUP_Click(object sender, EventArgs e) - { - - } - - protected void LnkSRVacacionesADD_Click(object sender, EventArgs e) - { - - DateTime fInicio = TxtvacFechaInicio.Text.ToDate(); - DateTime fFin = TxtvacFechaFin.Text.ToDate(); - string fechapago = TxtvacFechaPago.Text.ToDate().ToString("yyyy/MM/dd"); - int diasinhabil = TxtvacDiasFeriados.Text.ToEntero(); - // Dim motivoVacaciones As String = TxtMotivoVacaciones.Text - int VacCveSupervisor = 0; - int VacFolioActual = 0; - if (fInicio <= fFin) - { - using (ClsRH objRHx = new ClsRH()) - { - - if (objRHx.VacacionesResumenGet(SRCvePersonal, UsuarioActual.Empresa.CveEmpresa)) - { - if (objRHx.DtResultados.Rows.Count > 0) - { - VacCveSupervisor = objRHx.DtResultados.Rows[0]["SupervisorCorreo"].ToString().ToEntero(); - } - } - - if (objRHx.VacacionesGet(SRCvePersonal, UsuarioActual.Empresa.CveEmpresa)) - { - if (objRHx.DtResultados.Rows.Count > 0) - { - VacFolioActual = objRHx.DtResultados.Compute("Max(Folio)", string.Empty).ToString().ToEntero(); - } - } - } - - VacFolioActual = VacFolioActual + 1; - ClsRH objRH = new ClsRH(); - // Dim continuar As Boolean = objRH.SolicitudVacacionesAdd(CvePersonal, fInicio, fFin, 0, UsuarioActual.CveUsuario, VacCveSupervisor, VacFolioActual, motivoVacaciones) - bool continuar = objRH.SolicitudVacacionesAdd(SRCvePersonal, fInicio, fFin, 0, UsuarioActual.CveUsuario, VacCveSupervisor, VacFolioActual, FechaPago: fechapago, diasinabiles: diasinhabil); - if (objRH.DtResultados.Rows.Count > 0) - { - string ShowError = objRH.DtResultados.Rows[0]["ShowError"].ToString(); - if (ShowError.Length > 0) - { - Alert(ShowError, TipoMensaje.MsgAdvertencia); - continuar = false; - } - } - objRH.Dispose(); - if (continuar) - { - - - TxtvacFechaInicio.Text = ""; - TxtvacFechaFin.Text = ""; - TxtvacFechaPago.Text = ""; - TxtvacDiasFeriados.Text = ""; - CargaVacaciones(); - //CargaVacacionesResumenPeriodoActual(); - //VacacionesMandaCorreoSupervisor("Solicitud Vacaciones " + NombreCompleto, VacSupervisorCorreo, VacSupervisorNombre, NombreCompleto, fInicio, fFin); - Alert("Las vacaciones se han actualizodo"); - } - } - else { Alert("La fecha Inicial debe ser inferior a la fecha final.", TipoMensaje.MsgAdvertencia); } - } - protected void GvVacaciones_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e) - { - if (e.Row.RowType == DataControlRowType.DataRow) - { - bool _Estatus = bool.Parse(e.Row.DBCampo("Estatus").ToString()); - string _Documento = e.Row.DataKey("Documento"); - int _CveAutoriza = e.Row.DataKey("CveAutoriza").ToEntero(); - string RutaDocuemntoAutorizacion = string.Format(@"{0}Personal\{1}\Vacaciones\{2}", UsuarioActual.Empresa.Ruta, SRCvePersonal, _Documento); - LinkButton lnkDescargaFormato = e.Row.FCLinkButton("ImgDescargaFormato"); - LinkButton lnkDescargaAutorizacion = e.Row.FCLinkButton("ImgDescargaAutorizacion"); - LinkButton lnkEditar = e.Row.FCLinkButton("ImgEditar"); - if (_CveAutoriza > 0 | !_Estatus) - lnkEditar.Visible = false; - lnkDescargaFormato.Visible = true; - // ScriptManager.GetCurrent(Me).RegisterAsyncPostBackControl(lnkDescargaFormato) - if (File.Exists(RutaDocuemntoAutorizacion) & _Estatus) - lnkDescargaAutorizacion.Visible = true; - else - lnkDescargaAutorizacion.Visible = false; - } - } - protected void LnkEliminarSolicitud_Click(object sender, EventArgs e) - { - GridViewRow GvRow = (GridViewRow)((LinkButton)sender).NamingContainer; - int CvePersonalVacaciones = GvRow.DataKey("CvePersonalVacaciones").ToEntero(); - - ClsRH objRH = new ClsRH(); - if (objRH.RemoverSolicitudVacaciones(CvePersonalVacaciones)) - { - CargaVacaciones(); - Alert("Las vacaciones se ha eliminado"); - } - objRH.Dispose(); - } - public void Edit_ClickVacacionDia(object sender, EventArgs e) - { - GridViewRow GvRow = (GridViewRow)((LinkButton)sender).NamingContainer; - - //CvePersonalVacaciones = GvRow.DataKey("CvePersonalVacaciones").ToEntero; - //VacFolio = GvRow.DataKey("Folio").ToString().ToEntero; - - - TxtvacFechaInicio.Text = GvRow.DataKey("FechaInicio").ToString().ToDate().ToString("dd/MM/yyyy"); - TxtvacFechaFin.Text = GvRow.DataKey("FechaFin").ToString().ToDate().ToString("dd/MM/yyyy"); - - RegistraScript("$('#divEditarDiaVacacion').modal({ backdrop: 'static', keyboard: false});"); - } - - public void DownLoad_ClickSolicitudVacaciones(object sender, EventArgs e) - { - /* - GridViewRow GvRow = (GridViewRow)(LinkButton)sender.NamingContainer; - - // Dim Folio As Integer = GvRow.DataKey("Folio").ToEntero - - // DescarSolicitudVacaciones(Folio) - string RutaFormato = string.Format(@"{0}Formatos\SolicitudVacaciones.docx", UsuarioActual.Empresa.Ruta); - - string NombreEmpleado = string.Format("{0} {1} {2}", TxtAPaterno.Text, TxtAMaterno.Text, TxtNombres.Text); - string Codigo = TxtCodigo.Text; - string Departamento = DdlDepartamento.SelectedItem.Text; - string JefeInmediato = DdlSupervisorOrganigrama.SelectedItem.Text; - DateTime fechaIngreso = TxtFechaIngreso.Text.ToDate(); - int Periodoingreso = fechaIngreso.ToString("MMdd").ToEntero(); - int PeriodoInicio = GvRow.DataKey("FechaInicio").ToDate().ToString("MMdd").ToEntero(); - string FechaInicio = GvRow.DataKey("FechaInicio").ToDateTime().ToString("dd/MM/yyyy"); - string FechaFin = GvRow.DataKey("FechaFin").ToDateTime().ToString("dd/MM/yyyy"); - string diasPermiso = GvRow.DataKey("Dias"); - string MotivoPermiso = GvRow.DataKey("Motivo"); - string Puesto = DdlPuesto.SelectedItem.Value; - string Fecha = DateTime.Now.ToString("dd/MM/yyyy"); - string Solicitante = UsuarioActual.Nombre; - int anio = GvRow.DataKey("FechaInicio").ToDate().Year; - string FechaPeriodo = GvRow.DataKey("Periodo"); - - - - - if (Periodoingreso > PeriodoInicio) - anio = anio - 1; - - - - if (File.Exists(RutaFormato)) - { - clsGemBoxDocument objGemDocument = new clsGemBoxDocument(RutaFormato); - List ListaTags = new List(); - - ListaTags = GetDatosTagsDocumentos(); - - ListaTags.Add(new TagsDocumentos("{Solicitante}", Solicitante)); - ListaTags.Add(new TagsDocumentos("{Fecha}", Fecha)); - ListaTags.Add(new TagsDocumentos("{NombreEmpleado}", NombreEmpleado)); - ListaTags.Add(new TagsDocumentos("{Codigo}", Codigo)); - ListaTags.Add(new TagsDocumentos("{Departamento}", Departamento)); - ListaTags.Add(new TagsDocumentos("{JefeInmediato}", JefeInmediato)); - ListaTags.Add(new TagsDocumentos("{FechaInicio}", FechaInicio)); - ListaTags.Add(new TagsDocumentos("{FechaFin}", FechaFin)); - ListaTags.Add(new TagsDocumentos("{diasPermiso}", diasPermiso)); - ListaTags.Add(new TagsDocumentos("{MotivoPermiso}", MotivoPermiso)); - ListaTags.Add(new TagsDocumentos("{Puesto}", Puesto)); - ListaTags.Add(new TagsDocumentos("{anio}", anio.ToString())); - ListaTags.Add(new TagsDocumentos("{FechaPeriodo}", FechaPeriodo)); - - objGemDocument.SustituirTags(ListaTags); - - // objGemDocument.GuardarStream() - objGemDocument.GuardarStreamPDF(); - - byte[] bytesInStream = objGemDocument.GetBytesDocumento(); - // Dim bytesInStream As Byte() = objGemDocument.memoryStream.ToArray - - objGemDocument.Dispose(); - - Response.Clear(); - Response.ContentType = "application/force-download"; - Response.AddHeader("content-disposition", "attachment; filename=" + CvePersonal + "_Solicitud_Vacaciones_" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".pdf"); - Response.BinaryWrite(bytesInStream); - Response.End(); - } - else - Alert("No se encontro el Formato, favor de revisarlo con soporte tecnico.", TipoMensaje.MsgAdvertencia);*/ - } - - public void DownLoad_ClickSolicitudPermiso(object sender, EventArgs e) - { - /* GridViewRow GvRow = (GridViewRow)(LinkButton)sender.NamingContainer; - // Dim Folio As Integer = GvRow.DataKey("Folio").ToEntero - // DescarSolicitudVacaciones(Folio) - string RutaFormato = string.Format(@"{0}Formatos\PermisoSolicitud.docx", UsuarioActual.Empresa.Ruta); - - string NombreEmpleado = string.Format("{0} {1} {2}", TxtAPaterno.Text, TxtAMaterno.Text, TxtNombres.Text); - string Codigo = TxtCodigo.Text; - string Departamento = DdlDepartamento.SelectedItem.Text; - string JefeInmediato = DdlSupervisorOrganigrama.SelectedItem.Text; - string FechaInicio = GvRow.DataKey("FechaInicio").ToDateTime().ToString("dd/MM/yyyy"); - string FechaFin = GvRow.DataKey("FechaFin").ToDateTime().ToString("dd/MM/yyyy"); - string diasPermiso = $"{(GvRow.DataKey("FechaFin").ToDate() - GvRow.DataKey("FechaInicio").ToDate()).Days}"; - string HorasPermiso = ""; // String.Format("{0}", ((GvRow.DataKey("FechaInicio").ToDateTime() - GvRow.DataKey("FechaFin").ToDateTime()).Hours)) - string MotivoPermiso = string.Format("{0},{1}", GvRow.DataKey("Descripcion"), GvRow.DataKey("Motivo")); - if (File.Exists(RutaFormato)) - { - clsGemBoxDocument objGemDocument = new clsGemBoxDocument(RutaFormato); - List ListaTags = new List(); - - ListaTags = GetDatosTagsDocumentos(); - - ListaTags.Add(new TagsDocumentos("{NombreEmpleado}", NombreEmpleado)); - ListaTags.Add(new TagsDocumentos("{Codigo}", Codigo)); - ListaTags.Add(new TagsDocumentos("{Departamento}", Departamento)); - ListaTags.Add(new TagsDocumentos("{JefeInmediato}", JefeInmediato)); - ListaTags.Add(new TagsDocumentos("{FechaInicio}", FechaInicio)); - ListaTags.Add(new TagsDocumentos("{FechaFin}", FechaFin)); - ListaTags.Add(new TagsDocumentos("{diasPermiso}", diasPermiso)); - ListaTags.Add(new TagsDocumentos("{HorasPermiso}", HorasPermiso)); - ListaTags.Add(new TagsDocumentos("{MotivoPermiso}", MotivoPermiso)); - - objGemDocument.SustituirTags(ListaTags); - - // objGemDocument.GuardarStream() - objGemDocument.GuardarStreamPDF(); - byte[] bytesInStream = objGemDocument.GetBytesDocumento(); - // Dim bytesInStream As Byte() = objGemDocument.memoryStream.ToArray - objGemDocument.Dispose(); - - Response.Clear(); - Response.ContentType = "application/force-download"; - Response.AddHeader("content-disposition", "attachment; filename=" + CvePersonal + "_Solicituddepermiso_" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".pdf"); - Response.BinaryWrite(bytesInStream); - Response.End(); - } - else - Alert("No se encontro el formato de Permisos", TipoMensaje.ToastAdventencia); - */ - } - - public void DownLoad_ClickSolicitudAutorizacion(object sender, EventArgs e) - { - /* - GridViewRow GvRow = (GridViewRow)(LinkButton)sender.NamingContainer; - string _Documento = GvRow.DataKey("Documento"); - string RutaDocuemntoAutorizacion = string.Format(@"{0}Personal\{1}\Vacaciones\{2}", UsuarioActual.Empresa.Ruta, CvePersonal, _Documento); - - if (File.Exists(RutaDocuemntoAutorizacion)) - { - byte[] bytesInStream = File.ReadAllBytes(RutaDocuemntoAutorizacion); - Response.Clear(); - Response.ContentType = "application/force-download"; - Response.AddHeader("content-disposition", "attachment; filename=" + _Documento); - Response.AddHeader("content-disposition", "attachment; filename=" + _Documento); - Response.BinaryWrite(bytesInStream); - Response.End(); - } - else - Alert("No se encontro el documento que intenta descargar."); - } - */ - } - - - protected void BtnGeneratepdf_Click(object sender, EventArgs e) - { - byte[] pdf = new byte[1]; - string nombre = "recibo"; - bool confiniquito = false; - int CvePersonal = TxtCvePersonal.Text.ToEntero(); int CvePeriodo = TxtCvePeriodo.Text.ToEntero(); - if (CvePersonal > 0) - { - using (ClsNominas ObjNomina = new ClsNominas()) - { - if (ObjNomina.GetNom_Nominas(-1, TxtCvePersonal.Text.ToEntero(), TxtCvePeriodo.Text.ToEntero(), -1, UsuarioActual.CveEmpresa)) - { - nombre = ObjNomina.SerieFolio; - - } - if (ObjNomina.GetNom_NominasDetalles(-1, CvePersonal, CvePeriodo, "-1")) - { - confiniquito = ObjNomina.DtResultados.COUNT("CveConcepto", " CveSistema IN(10,11,32,47) AND Importe <>0") > 0; - } - } - pdf = GeneraPDFNomina(CvePersonal, CvePeriodo, UsuarioActual.CveEmpresa, UsuarioActual.Empresa.Ruta); - if (confiniquito) - { - List pdfs = new List(); - pdfs.Add(pdf); - pdfs.Add(GeneraPDFNomina(CvePersonal, CvePeriodo, UsuarioActual.CveEmpresa, UsuarioActual.Empresa.Ruta, true)); - pdf = MergeFiles(pdfs); - - } - } - else - { - List pdfs = new List(); - //byte[] pdf2 = new byte[1]; bool notfirst = false; - foreach (DataRow dr in dtempleados.FiltraParametros("", "CveSubProyecto").Rows) - { - CvePersonal = dr["CvePersonal"].ToString().ToEntero(); - if (CvePersonal > 0) - { - pdfs.Add(GeneraPDFNomina(CvePersonal, CvePeriodo, UsuarioActual.CveEmpresa, UsuarioActual.Empresa.Ruta)); - - } - //if (notfirst) - //{ - - // pdf2 = GeneraPDFNomina(dr["CvePersonal"].ToString().ToEntero(), CvePeriodo, UsuarioActual.CveEmpresa, UsuarioActual.Empresa.Ruta); - // byte[] newByteArray2 = pdf.Concat(pdf2).ToArray(); - //} - //else - //{ - // pdf = GeneraPDFNomina(dr["CvePersonal"].ToString().ToEntero(), CvePeriodo, UsuarioActual.CveEmpresa, UsuarioActual.Empresa.Ruta); - - //} - //notfirst = true; - } - pdf = MergeFiles(pdfs); - } - ImprimirbytesPDF(pdf, nombre); - - } - public static byte[] MergeFiles(List sourceFiles) - { - //string destinationFile; - try - { - using (MemoryStream ms = new MemoryStream()) - { - int f = 0; - // we create a reader for a certain document - PdfReader reader = new PdfReader(sourceFiles[f]); - // we retrieve the total number of pages - int n = reader.NumberOfPages; - //Console.WriteLine("There are " + n + " pages in the original file."); - // step 1: creation of a document-object - iTextSharp.text.Document document = new iTextSharp.text.Document(reader.GetPageSizeWithRotation(1)); - // step 2: we create a writer that listens to the document - //PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(destinationFile, FileMode.Create)); - PdfWriter writer = PdfWriter.GetInstance(document, ms); - // step 3: we open the document - document.Open(); - PdfContentByte cb = writer.DirectContent; - PdfImportedPage page; - int rotation; - // step 4: we add content - while (f < sourceFiles.Count) - { - int i = 0; - while (i < n) - { - i++; - document.SetPageSize(reader.GetPageSizeWithRotation(i)); - document.NewPage(); - page = writer.GetImportedPage(reader, i); - rotation = reader.GetPageRotation(i); - if (rotation == 90 || rotation == 270) - { - cb.AddTemplate(page, 0, -1f, 1f, 0, 0, reader.GetPageSizeWithRotation(i).Height); - } - else - { - cb.AddTemplate(page, 1f, 0, 0, 1f, 0, 0); - } - //Console.WriteLine("Processed page " + i); - } - f++; - if (f < sourceFiles.Count) - { - reader = new PdfReader(sourceFiles[f]); - // we retrieve the total number of pages - n = reader.NumberOfPages; - //Console.WriteLine("There are " + n + " pages in the original file."); - } - } - // step 5: we close the document - document.Close(); - return ms.ToArray(); - - } - } - catch (Exception e) - { - string strOb = e.Message; - } - return null; - } - - public static int CountPageNo(string strFileName) - { - // we create a reader for a certain document - PdfReader reader = new PdfReader(strFileName); - // we retrieve the total number of pages - return reader.NumberOfPages; - } - - - protected void BtnGenerateXml_Click(object sender, EventArgs e) - { - string Ruta = ""; - string PathXML = ""; - string PathXMLF = ""; - string Xmlname = ""; - string XmlnameF = ""; - string empleado = ""; - DataRow dr = dtempleados.FiltroPrimero(string.Format("CvePersonal ={0}", TxtCvePersonal.Text.ToEntero())); - if (dr != null) - { - empleado = string.Format("{0} - {1}", dr["Codigo"], dr["Nombre"]); - } - using (ClsNominas ObjNomina = new ClsNominas()) - { - if (ObjNomina.GetNom_Nominas(-1, TxtCvePersonal.Text.ToEntero(), TxtCvePeriodo.Text.ToEntero(), -1, UsuarioActual.CveEmpresa)) - { - Ruta = $"{ModExtensiones.DirectorioBaseEmpresas}Empresas\\{UsuarioActual.CveEmpresa}\\"; - PathXML = $"{Ruta}XML\\Nomina\\{ObjNomina.SerieFolio}.xml"; - PathXMLF = $"{Ruta}XML\\Nomina\\{ObjNomina.Serie}F-{ObjNomina.Folio}.xml"; - Xmlname = ObjNomina.SerieFolio; - XmlnameF = $"{ObjNomina.Serie}F-{ObjNomina.Folio}"; - } - } - try - { - string script = ""; - if (!string.IsNullOrEmpty(PathXML) && System.IO.File.Exists(PathXML)) - { - LtlXml.Text = System.IO.File.ReadAllText(PathXML); - script = string.Format("Savexml(\"{0} {1}.xml\", $('.ltlxml').html());", Xmlname, empleado); - //System.IO.FileInfo file = new System.IO.FileInfo(PathXML); - //string mimeType = "text/plain"; - //try - //{ - // mimeType = MimeMapping.GetMimeMapping(PathXML); - //} - //catch (Exception) - //{ - - //} - //// Response.Write(path) - //Response.Clear(); - //Response.ClearHeaders(); - //Response.ClearContent(); - //Response.AddHeader("Content-Disposition", $"attachment; filename= {Uri.EscapeDataString(file.Name)}"); - //Response.AddHeader("Content-Length", file.Length.ToString()); - //Response.ContentType = mimeType; - //Response.Flush(); - //Response.TransmitFile(file.FullName); - //Response.End(); - } - if (!string.IsNullOrEmpty(PathXML) && System.IO.File.Exists(PathXMLF)) - { - LtlXmlfin.Text = System.IO.File.ReadAllText(PathXMLF); - script = string.Format("{1}Savexml(\"{0}(Indemnización) {2}.xml\", $('.ltlxmlfin').html());", Xmlname, script, empleado); - } - if (script.Trim().Length > 0) - { - RegistraScript(script); - } - else - { - Alert("No se encontro el archivo"); - } - } - catch (Exception) - { - } - } - - - protected void LnkRegistrarProvision_Click(object sender, EventArgs e) - { - using (ClsNominas objnom = new ClsNominas()) - { - if (objnom.Autorizaperiodoconta(CvePeriodoSeleccionado, UsuarioActual.CveEmpresa)) - { - int CvePrePolizaProvision = 0; int CvePrePolizaasmilidos = 0; - if (objnom.DtResultados.Rows.Count > 0) - { - CvePrePolizaProvision = objnom.DtResultados.Rows[0]["CvePrePoliza"].ToString().ToEntero(); - CvePrePolizaasmilidos = objnom.DtResultados.Rows[0]["CvePrePolizaAsimilables"].ToString().ToEntero(); - } - string mensaje = string.Format("La provision a sido autorizada.
    Provision
    Asimilados", CvePrePolizaProvision, CvePrePolizaasmilidos); - Alert(mensaje); - } - } - } - - - protected void LnkupPrimaRiesgo_Click(object sender, EventArgs e) - { - - - using (ClsNominas objnom = new ClsNominas()) - { - if (objnom.PrimaRiesgoUP(UsuarioActual.CveEmpresa, TxtFechaPRT.Text.ToDateTime(), TxtPrimaRiesgo.Text.ToDecimal())) - { - } - - } - loadtablas(); - } - private void CrearLayout(DataTable DTNomina) - { - StringBuilder sb = new StringBuilder(); - StringBuilder SbErrores = new StringBuilder(); - bool ErroresValidaciones = false; - - - SbErrores.AppendLine("Se detectaron los siguientes errores en la generación del layout"); - - foreach (DataRow dRow in DTNomina.Rows) - { - string RFC = dRow["RFC"].ToString(); - string Nombre = dRow["Nombre"].ToString(); - string BancoNumCuenta = dRow["BancoNumCuenta"].ToString(); - decimal Importe = dRow["Importe"].ToString().ToDecimal(); - - - - if (RFC.Trim().Length == 0) - SbErrores.AppendLine($"El RFC es requerido del empleado {Nombre}
    "); - - System.Text.RegularExpressions.Match Coincidencia = System.Text.RegularExpressions.Regex.Match(RFC, @"/^([A-Z,Ñ,&]{3,4}([0-9]{2})(0[1-9]|1[0-2])(0[1-9]|1[0-9]|2[0-9]|3[0-1])[A-Z|\d]{3})$/"); - if (!Coincidencia.Success) - { - SbErrores.AppendLine($"El RFC {RFC} del empleado {Nombre} no es valido
    "); - ErroresValidaciones = true; - } - - if (BancoNumCuenta.Trim().Length != 10) - { - SbErrores.AppendLine($"Empleado {Nombre} numero de cuenta incorrecto, la cuenta debe de tener 10 caracteres
    "); // Bancomer 10 caracteres - ErroresValidaciones = true; - } - - - if (Importe <= 0) - { - SbErrores.AppendLine($"Empleado {Nombre} el importe debe de ser mayor a 0 importe {Importe}"); // importe mayot a 0 - ErroresValidaciones = true; - } - } - - ErroresValidaciones = false; - - if (!ErroresValidaciones) - { - int Count = 1; - foreach (DataRow dRow in DTNomina.Rows) - { - StringBuilder SbLinea = new StringBuilder(); - - string RFC = dRow["RFC"].ToString(); - string Nombre = dRow["Nombre"].ToString(); - string BancoNumCuenta = dRow["BancoNumCuenta"].ToString(); - decimal Importe = dRow["Importe"].ToString().ToDecimal().RoundSQL(2); - - SbLinea.Append(Count.ToString("000000000")); - SbLinea.Append(RFC.Trim().PadRight(16)); - SbLinea.Append("03"); - SbLinea.Append(BancoNumCuenta.Trim().PadRight(20)); - SbLinea.Append(Importe.ToString("0000000000000.00").Replace(".", "")); - - - if (Nombre.Trim().Length > 40) - Nombre = Nombre.Substring(0, 40); - - SbLinea.Append(Nombre.Trim().PadRight(40)); - - SbLinea.Append("012"); - SbLinea.Append("000"); - - sb.AppendLine(SbLinea.ToString()); - - - Count = Count + 1; - } - - - Response.Clear(); - Response.ClearHeaders(); - Response.AppendHeader("Content-Length", sb.ToString()); - Response.ContentType = "text/plain"; - //Response.AppendHeader("Content-Disposition", $"attachment;filename=\"Nomina{DateTime.Now.ToString("yyyyMMddhhmmss").ToString()}.txt\""); - Response.AppendHeader("Content-Disposition", $"attachment;filename=\"Nomina {DdlPeriodo.SelectedItem.Text }.txt\""); - Response.Write(sb.ToString()); - Response.End(); - } - else - Alert(SbErrores.ToString(), TipoMensaje.MsgAdvertencia); - } - protected void LnkLayoutContable_Click(object sender, EventArgs e) - { - - using (ClsNominas objnom = new ClsNominas()) - { - if (objnom.GetDispersiondenomina(CvePeriodoSeleccionado, UsuarioActual.CveEmpresa)) - { - CrearLayout(objnom.DtResultados); - } - - } - } - - protected void LnkAsistenciaIncidencias_Click(object sender, EventArgs e) - { - RegistraScript("$('#DmodalReporteInicidencia').modal()"); - } - - protected void lnkreportepercepciones_Click(object sender, EventArgs e) - { - RegistraScript("$('#DmodalReportePercepcionesdeducciones').modal()"); - } - protected void LnkProcesarReporteIncidencia_Click(object sender, EventArgs e) - { - - DateTime fechai = TxtRIFechaInicio.Text.ToDateTime(); - DateTime fechaf = TxtRIFechaFin.Text.ToDateTime(); - ClosedXML.Excel.XLWorkbook wb = new ClosedXML.Excel.XLWorkbook(); - using (ClsNominas nom = new ClsNominas()) - { - if (nom.ReportedeincidenciasGET(UsuarioActual.CveEmpresa, fechai, fechaf, 4)) - { - - var libro = wb.AddWorksheet(nom.DTSetResultados.Tables[2], "Incidencias"); - libro.ColumnsUsed().AdjustToContents(); - var libroin = wb.AddWorksheet(nom.DTSetResultados.Tables[1], "Descripción incidencias"); - libroin.ColumnsUsed().AdjustToContents(); - libro.Row(1).InsertRowsAbove(4); - libro.Range(1, 2, 1, 6).Merge().Value = UsuarioActual.Empresa.Empresa; - libro.Range(2, 2, 2, 6).Merge().Value = "Reporte de incidencias"; - libro.Range(3, 2, 3, 6).Merge().Value = $"del {fechai:dd/MM/yyyy} al {fechaf:dd/MM/yyyy}"; - libro.Range(2, 7, 2, 9).Merge().Value = $"Fecha:{DateTime.Now:dd/MM/yyyy}"; - libro.Range(3, 7, 3, 9).Merge().Value = $"Hora:{DateTime.Now:HH:mm}"; - - //ws.Row(1).InsertRowsAbove(1); - } - } - - - System.IO.Stream fs = new System.IO.MemoryStream(); - wb.SaveAs(fs); - fs.Position = 0; - System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(); - using (System.IO.Stream input = fs) - - { - input.CopyTo(memoryStream); - } - memoryStream.Position = 0; - - Response.Clear(); - Response.Buffer = true; - - Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; - Response.AddHeader("content-disposition", string.Format("attachment;filename=incidencias del al{0}.xlsx", "")); - Response.BinaryWrite(memoryStream.ToArray()); - Response.End(); - } - - protected void LnkProcesarReporteAcumulados_Click(object sender, EventArgs e) - { - - //DateTime fechai = TxtRIFechaInicio.Text.ToDateTime(); - //DateTime fechaf = TxtRIFechaFin.Text.ToDateTime(); - ClosedXML.Excel.XLWorkbook wb = new ClosedXML.Excel.XLWorkbook(); - using (ClsNominas nom = new ClsNominas()) - { - if (nom.ReportedeAcumuladosGET(UsuarioActual.CveEmpresa, TxtPeriodo.Text.ToEntero(), 4)) - { - DateTime datei = new DateTime(); - DateTime datef = datei; - try - { - datei = $"{TxtPeriodo.Text}01".ToDateTime(); - datef = datei.AddMonths(1).AddDays(-1); - } - catch (Exception) { } - DataTable dt = nom.DTSetResultados.Tables[0]; - var libro = wb.AddWorksheet(dt, "Acumulados"); - libro.Tables.FirstOrDefault().Theme = ClosedXML.Excel.XLTableTheme.None; - int crow = 1; - foreach (DataRow item in dt.Rows) - { - crow++; - //220,230,241 - //79,129,189 - switch (item["Grupoid"].ToString()) - { - case "1": - libro.Range(crow, 1, crow, 11).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(79, 129, 189)); - libro.Range(crow, 1, crow, 11).Style.Font.FontColor = ClosedXML.Excel.XLColor.White; - break; - case "2": - libro.Range(crow, 1, crow, 11).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(220, 230, 241)); - //libro.Range(crow, 1, crow, 10).Style.Font.FontColor = ClosedXML.Excel.XLColor.White; - break; - case "3": - break; - case "4": - libro.Range(crow, 1, crow, 11).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(79, 129, 189)); - libro.Range(crow, 1, crow, 11).Style.Font.FontColor = ClosedXML.Excel.XLColor.White; - break; - case "5": - - libro.Range(crow, 1, crow, 11).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(79, 129, 189)); - libro.Range(crow, 1, crow, 11).Style.Font.FontColor = ClosedXML.Excel.XLColor.White; - break; - - } - } - libro.Range(2, 3, crow, 11).Style.NumberFormat.Format = "$##,###,###,0.00"; - libro.Range(2, 3, crow, 11).DataType = ClosedXML.Excel.XLDataType.Number; - libro.Column(1).Delete(); - libro.ColumnsUsed().AdjustToContents(); - libro.Row(1).InsertRowsAbove(4); - libro.Range(1, 2, 1, 6).Merge().Value = UsuarioActual.Empresa.Empresa; - libro.Range(2, 2, 2, 6).Merge().Value = $"Reporte de Acumulados del {datei:dd/MM/yyyy} al {datef:dd/MM/yyyy}"; - //libro.Range(3, 2, 3, 6).Merge().Value = $"del {fechai:dd/MM/yyyy} al {fechaf:dd/MM/yyyy}"; - libro.Range(2, 7, 2, 9).Merge().Value = $"Fecha:{DateTime.Now:dd/MM/yyyy}"; - libro.Range(3, 7, 3, 9).Merge().Value = $"Hora:{DateTime.Now:HH:mm}"; - - //ws.Row(1).InsertRowsAbove(1); - } - } - - - System.IO.Stream fs = new System.IO.MemoryStream(); - wb.SaveAs(fs); - fs.Position = 0; - System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(); - using (System.IO.Stream input = fs) - - { - input.CopyTo(memoryStream); - } - memoryStream.Position = 0; - - Response.Clear(); - Response.Buffer = true; - - Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; - Response.AddHeader("content-disposition", string.Format("attachment;filename=Acumulados.xlsx", "")); - Response.BinaryWrite(memoryStream.ToArray()); - Response.End(); - } - - protected void LnkReporteAcumulados_Click(object sender, EventArgs e) - { - RegistraScript("$('#DmodalReporteAcumulados').modal()"); - - } - - - - - - protected void LnkrRepPercpDed_Click(object sender, EventArgs e) - { - - DateTime fechai = TxtRpdFechaInicio.Text.ToDateTime(); - DateTime fechaf = TxtRpdFechaFin.Text.ToDateTime(); - ClosedXML.Excel.XLWorkbook wb = new ClosedXML.Excel.XLWorkbook(); - using (ClsNominas nom = new ClsNominas()) - { - if (nom.ReportedePercepcionesDeduccionesGet(UsuarioActual.CveEmpresa, fechai, fechaf, 4)) - { - DataTable dt = nom.DTSetResultados.Tables[0]; - var libro = wb.AddWorksheet(nom.DTSetResultados.Tables[0], "Percepciones y deducciones"); - libro.Tables.FirstOrDefault().Theme = ClosedXML.Excel.XLTableTheme.None; - - int crow = 1; - foreach (DataRow item in dt.Rows) - { - crow++; - //220,230,241 - //79,129,189 - switch (item["Grupoid"].ToString()) - { - case "10": - libro.Range(crow, 1, crow, 9).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(184, 204, 228)); - break; - case "8": - case "11": - libro.Range(crow, 1, crow, 9).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(79, 129, 189)); - libro.Range(crow, 1, crow, 11).Style.Font.FontColor = ClosedXML.Excel.XLColor.White; - break; - - - case "6": - libro.Range(crow, 1, crow, 9).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(216, 228, 188)); - break; - case "5": - case "7": - libro.Range(crow, 1, crow, 9).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(155, 187, 89)); - libro.Range(crow, 1, crow, 9).Style.Font.FontColor = ClosedXML.Excel.XLColor.White; - break; - - - - case "2": - //libro.Range(crow, 1, crow, 11).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(216, 228, 188)); - break; - case "1": - case "3": - libro.Range(crow, 1, crow, 9).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(75, 172, 198)); - libro.Range(crow, 1, crow, 9).Style.Font.FontColor = ClosedXML.Excel.XLColor.White; - break; - - } - } - - - libro.Range(2, 4, crow, 9).Style.NumberFormat.Format = "$##,###,###,0.00"; - libro.Range(2, 4, crow, 9).DataType = ClosedXML.Excel.XLDataType.Number; - libro.Column(1).Delete(); - libro.ColumnsUsed().AdjustToContents(); - libro.Row(1).InsertRowsAbove(4); - libro.Range(1, 2, 1, 6).Merge().Value = UsuarioActual.Empresa.Empresa; - libro.Range(2, 2, 2, 6).Merge().Value = $"Reporte de percepciones y deducciones del {fechai:dd/MM/yyyy} al {fechaf:dd/MM/yyyy}"; - libro.Range(1, 2, 2, 6).Style.Font.SetBold(true); - libro.Range(1, 2, 2, 6).Style.Font.SetFontSize(16); - libro.Range(2, 2, 2, 6).Style.Font.SetFontSize(14); - libro.Range(1, 2, 2, 6).Style.Alignment.Horizontal = ClosedXML.Excel.XLAlignmentHorizontalValues.Center; - //libro.Range(3, 2, 3, 6).Merge().Value = $"del {fechai:dd/MM/yyyy} al {fechaf:dd/MM/yyyy}"; - libro.Range(2, 7, 2, 9).Merge().Value = $"Fecha:{DateTime.Now:dd/MM/yyyy}"; - libro.Range(3, 7, 3, 9).Merge().Value = $"Hora:{DateTime.Now:HH:mm}"; - //ws.Row(1).InsertRowsAbove(1); - } - } - - - System.IO.Stream fs = new System.IO.MemoryStream(); - wb.SaveAs(fs); - fs.Position = 0; - System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(); - using (System.IO.Stream input = fs) - - { - input.CopyTo(memoryStream); - } - memoryStream.Position = 0; - - Response.Clear(); - Response.Buffer = true; - - Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; - Response.AddHeader("content-disposition", string.Format("attachment;filename=percepciones .xlsx", "")); - Response.BinaryWrite(memoryStream.ToArray()); - Response.End(); - } - - protected void LnkShowAddVacaciones_Click(object sender, EventArgs e) - { - LnkSRVacacionesADD.Visible = true; - } -} diff --git a/asmx/WSSIGApp.asmx b/asmx/WSSIGApp.asmx index 71ad666ea..4e223989a 100644 --- a/asmx/WSSIGApp.asmx +++ b/asmx/WSSIGApp.asmx @@ -1867,7 +1867,7 @@ Public Class WSSIGApp 'VALIDA PROMOCIONES Y EXISTENCIAS Dim ObjVentas As New ClsVentas - If ObjVentas.GetPromocionesPS(-1, Now, CveSubProyecto, CveCliente, ObjFactura.CveVendedor, UsuarioActual.CveEmpresa) Then + If ObjVentas.GetPromocionesPS(-1, Now, CveSubProyecto, CveCliente, ObjFactura.CveVendedor, -1, UsuarioActual.CveEmpresa) Then ObjFactura.DtPromociones = ObjVentas.DtResultados End If ObjVentas.Dispose() diff --git a/vwd.webinfo b/vwd.webinfo index 4f2b5ea5a..5fb864961 100644 --- a/vwd.webinfo +++ b/vwd.webinfo @@ -250,6 +250,10 @@ + + + +