diff --git a/App_Code/CalendarEvent.vb b/App_Code/CalendarEvent.vb index da3261896..f0a7a8aca 100644 --- a/App_Code/CalendarEvent.vb +++ b/App_Code/CalendarEvent.vb @@ -62,4 +62,8 @@ Public Class CalendarEvent Public Property NumeroContrato As String Public Property Observaciones As String + Public Property CveMoneda As Integer + Public Property Moneda As String + + End Class diff --git a/App_Code/ClsContratos.vb b/App_Code/ClsContratos.vb index 52d3826f9..6d8b7fdf3 100644 --- a/App_Code/ClsContratos.vb +++ b/App_Code/ClsContratos.vb @@ -684,6 +684,48 @@ Public Class ClsContratos Return Retorno End Function + Public Function GetContratosValUnidadesAgendadas(CveAF As Integer, FechaInicial As DateTime, FechaFinal As DateTime, CveEmpresa As Integer, CveContrato As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Con_ContratosValUnidadesAgendadasGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveAF", SqlDbType.Int).Value = CveAF + .Add("@FechaInicial", SqlDbType.DateTime).Value = FechaInicial + .Add("@FechaFinal", SqlDbType.DateTime).Value = FechaFinal + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveContrato", SqlDbType.Int).Value = CveContrato + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las unidades agendadas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + + Public Function UpdateContratoArchivo(CveContrato As Integer, Archivo As String, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Con_ContratosArchivoUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveContrato", SqlDbType.Int).Value = CveContrato + .Add("@Archivo", SqlDbType.VarChar).Value = Archivo + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el archivo adjunto.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + #End Region diff --git a/Ashx/CargaEventos.ashx b/Ashx/CargaEventos.ashx index d5dbda671..75b6ae9e5 100644 --- a/Ashx/CargaEventos.ashx +++ b/Ashx/CargaEventos.ashx @@ -107,12 +107,8 @@ Public Class CargaEventos : Implements IHttpHandler, IRequiresSessionState If context.Request("U").ToEntero > 0 Then CveUsuario = context.Request("U").ToEntero - CveEmpresa = context.Request("E").ToEntero - - Dim CveSubProyecto As Integer = If(context.Request("CveSubProyecto") IsNot Nothing, context.Request("CveSubProyecto").ToEntero, -1) - Dim CveUsuarioPara As Integer = If(context.Request("CveUsuarioPara") IsNot Nothing, context.Request("CveUsuarioPara").ToEntero, -1) - - + CveEmpresa = context.Request("E").ToEntero + FI = context.Request("start").ToDate FF = context.Request("end").ToDate @@ -487,168 +483,208 @@ Public Class CargaEventos : Implements IHttpHandler, IRequiresSessionState Dim tipoVista As String = context.Request("tipoVista") DT_SubProyectos.Columns.Add("CveSubProyecto", GetType(Integer)) DT_SubProyectos.Columns.Add("backgroundColor") - DT_EstatusOS.Columns.Add("", GetType(Integer)) - - Dim cveContrato As Integer = -1 + DT_EstatusOS.Columns.Add("", GetType(Integer)) - If context.Request("cveContrato") IsNot Nothing Then - cveContrato = context.Request("cveContrato").ToEntero() + + Dim cveContrato As Integer = If(context.Request("cveContrato") IsNot Nothing, context.Request("cveContrato").ToEntero, -1) + Dim CveSubProyecto As Integer = If(context.Request("CveSubProyecto") IsNot Nothing, context.Request("CveSubProyecto").ToEntero, -1) + Dim CveUsuarioPara As Integer = If(context.Request("CveUsuarioPara") IsNot Nothing, context.Request("CveUsuarioPara").ToEntero, -1) + + Dim CveCliente As Integer = If(context.Request("CveCliente") IsNot Nothing, context.Request("CveCliente").ToEntero, -1) + Dim CveContratoEstatus As Integer = If(context.Request("CveContratoEstatus") IsNot Nothing, context.Request("CveContratoEstatus").ToEntero, -1) + Dim CveTipoActivoFijo As Integer = If(context.Request("CveTipoActivoFijo") IsNot Nothing, context.Request("CveTipoActivoFijo").ToEntero, -1) + Dim CvePersonal As Integer = If(context.Request("CvePersonal") IsNot Nothing, context.Request("CvePersonal").ToEntero, -1) + + If Not cveContrato > 0 Then + cveContrato = -1 + End If + + If Not CveCliente > 0 Then + CveCliente = -1 End If - If ObjContratos.GetContratos(cveContrato, usuarioActual_.CveEmpresa, TipoContrato:=34) Then - - If ObjContratos.DtResultados.Rows.Count > 0 Then - - Try - For Each dr As DataRow In ObjContratos.DtResultados.Rows - Dim cevent As CalendarEvent = New CalendarEvent() - - cevent.id = dr("CveContrato").ToString.ToEntero - cevent.title = dr("DescripcionContrato").ToString - cevent.start = String.Format("{0:s}", dr("FechaInicial").ToString.ToDateTime) - cevent.end = If(tipoVista = "fecha", String.Format("{0:s}", dr("FechaInicial").ToString.ToDateTime.AddHours(1)), String.Format("{0:s}", dr("FechaFinal").ToString.ToDateTime)) - cevent.FechaFinal = String.Format("{0:s}", dr("FechaFinal").ToString.ToDateTime) - cevent.allDay = False - cevent.NombreAcercamiento = dr("Ubicacion").ToString - cevent.CveCliente = dr("CveCliente").ToString.ToEntero - cevent.NombreComercial = dr("NombreComercial").ToString - cevent.CvePersonal = dr("CveChofer").ToString.ToEntero - cevent.CvePersonal2 = dr("CveChofer2").ToString.ToEntero - cevent.CveEventoEstatus = dr("CveContratosEstatus").ToString.ToEntero - cevent.Dolares = dr("Importe").ToString.ToDecimal - cevent.Pesos = dr("ImporteMax").ToString.ToDecimal - cevent.Anticipo = dr("ImporteMin").ToString.ToDecimal + If ObjContratos.GetContratos(cveContrato, usuarioActual_.CveEmpresa, TipoContrato:=34, CveCliente:=CveCliente, CveEstatus:=CveContratoEstatus) Then + + 'CveTipoAF + 'CveChofer, CveChofer2 + Dim filtro As String = "" + If CveTipoActivoFijo > 0 Then + filtro = $"{filtro} CveTipoAF = {CveTipoActivoFijo}" + End If + + If CvePersonal > 0 Then + If filtro.Length > 0 Then + filtro = $"{filtro} AND " + End If + filtro = $"{filtro} CveChofer = {CvePersonal} OR CveChofer2 = {CvePersonal} " + End If + + + If CveSubProyecto > 0 Then + If filtro.Length > 0 Then + filtro = $"{filtro} AND " + End If + filtro = $"{filtro} CveSubProyecto = {CveSubProyecto} " + End If + + Dim DTContratos As DataTable = ObjContratos.DtResultados.FiltraParametros(filtro) + + If DTContratos.Rows.Count > 0 Then + + Try + For Each dr As DataRow In DTContratos.Rows + Dim cevent As CalendarEvent = New CalendarEvent() + + cevent.id = dr("CveContrato").ToString.ToEntero + cevent.title = dr("DescripcionContrato").ToString + cevent.start = String.Format("{0:s}", dr("FechaInicial").ToString.ToDateTime) + cevent.end = If(tipoVista = "fecha", String.Format("{0:s}", dr("FechaInicial").ToString.ToDateTime.AddHours(1)), String.Format("{0:s}", dr("FechaFinal").ToString.ToDateTime)) + cevent.FechaFinal = String.Format("{0:s}", dr("FechaFinal").ToString.ToDateTime) + cevent.allDay = False + cevent.NombreAcercamiento = dr("Ubicacion").ToString + cevent.CveCliente = dr("CveCliente").ToString.ToEntero + cevent.NombreComercial = dr("NombreComercial").ToString + cevent.CvePersonal = dr("CveChofer").ToString.ToEntero + cevent.CvePersonal2 = dr("CveChofer2").ToString.ToEntero + cevent.CveEventoEstatus = dr("CveContratosEstatus").ToString.ToEntero + cevent.Dolares = dr("Importe").ToString.ToDecimal + cevent.Pesos = dr("ImporteMax").ToString.ToDecimal + cevent.Anticipo = dr("ImporteMin").ToString.ToDecimal cevent.CveActivoFijo = dr("CveAF").ToString.ToEntero cevent.CveTipoAF = dr("CveTipoAF").ToString.ToEntero - cevent.backgroundColor = dr("BackgroundColor").ToString - cevent.CantidadPasajeros = dr("CantidadPasajeros").ToString - cevent.NumeroContrato = dr("NumeroContrato").ToString - cevent.Observaciones = dr("Observaciones").ToString - - If Not cevent.recurrenciatipo > 0 Then - - 'AGREGAMOS CUANDO NO ES RECURRENTE - Dim tFecha As DateTime = DateAdd(DateInterval.Month, -6, ClsPaginas.NowADS()) - 'SI LA FECHA DEL EVENTO ES MENOR DE 6 MESES DE LA FECHA ACTUAL NO LO AGREGA - If dr("FechaFinal").ToString.ToDateTime > tFecha Or dr("FechaInicial").ToString.ToDateTime > tFecha Then - events.Add(cevent) - End If - Else - - 'EMPIEZA METODO PARA AGREGAR CUANDO SI ES RECURRENTE - - Dim FinRecurrencia As Integer = cevent.recurrenciafin.ToEntero - Dim FI As DateTime, FF As DateTime, FT As DateTime - Dim DiasSemana As String() = cevent.diassemana.Split(","c) - FI = cevent.start.ToDateTime - FF = cevent.end.ToDateTime - - 'OBTENEMOS LA FECHA TERMINO (FT) DE LA RECURRENCIA - Select Case FinRecurrencia - Case -1 - FT = DateAdd(DateInterval.Year, 2, dr("FechaInicial").ToString.ToDateTime) - Case Is > 0 - FinRecurrencia -= 1 - Select Case cevent.recurrenciatipo - Case 1 - FT = DateAdd(DateInterval.Hour, FinRecurrencia * cevent.frecuencia, dr("FechaInicial").ToString.ToDateTime) - Case 2 - FT = DateAdd(DateInterval.Day, FinRecurrencia * cevent.frecuencia, dr("FechaInicial").ToString.ToDateTime) - Case 3 - FT = DateAdd(DateInterval.WeekOfYear, FinRecurrencia * cevent.frecuencia, dr("FechaInicial").ToString.ToDateTime) - FT = DateAdd(DateInterval.Day, (7 - Weekday(FT)).ToString.ToDouble, FT) - Case 4 - FT = DateAdd(DateInterval.Month, FinRecurrencia * cevent.frecuencia, dr("FechaInicial").ToString.ToDateTime) - Case 5 - FT = DateAdd(DateInterval.Year, FinRecurrencia * cevent.frecuencia, dr("FechaInicial").ToString.ToDateTime) - End Select - End Select - - 'SI ES TIPO SEMANAL Y DIASSEMANA TIENE VALORES CHECKEA ESTOS VALORES - Do - If DiasSemana.Length > 0 AndAlso DiasSemana(0) <> "" Then - For Each drDias As String In DiasSemana - Dim FIT As Date = FI, FFT As Date = FF - - FIT = DateAdd(DateInterval.Day, (drDias.ToEntero - Weekday(FI)).ToString.ToDouble, FI) - FFT = DateAdd(DateInterval.Day, (drDias.ToEntero - Weekday(FF)).ToString.ToDouble, FF) - - cevent = New CalendarEvent() - cevent.id = dr("CveContrato").ToString.ToEntero - cevent.description = dr("DescripcionContrato").ToString - cevent.start = String.Format("{0:s}", dr("FechaInicial").ToString.ToDateTime) - cevent.end = If(tipoVista = "fecha", String.Format("{0:s}", dr("FechaInicial").ToString.ToDateTime.AddHours(1)), String.Format("{0:s}", dr("FechaFinal").ToString.ToDateTime)) - cevent.allDay = False - cevent.CveCliente = dr("CveCliente").ToString.ToEntero - cevent.NombreComercial = dr("NombreComercial").ToString - cevent.NombreAcercamiento = dr("Ubicacion").ToString + cevent.backgroundColor = dr("BackgroundColor").ToString + cevent.CantidadPasajeros = dr("CantidadPasajeros").ToString + cevent.NumeroContrato = dr("NumeroContrato").ToString + cevent.Observaciones = dr("Observaciones").ToString + cevent.CveSubProyecto = dr("CveSubProyecto").ToString.ToEntero + cevent.CveMoneda = dr("CveMoneda").ToString.ToEntero + cevent.Moneda = dr("Moneda").ToString + + + If Not cevent.recurrenciatipo > 0 Then + + 'AGREGAMOS CUANDO NO ES RECURRENTE + Dim tFecha As DateTime = DateAdd(DateInterval.Month, -6, ClsPaginas.NowADS()) + 'SI LA FECHA DEL EVENTO ES MENOR DE 6 MESES DE LA FECHA ACTUAL NO LO AGREGA + If dr("FechaFinal").ToString.ToDateTime > tFecha Or dr("FechaInicial").ToString.ToDateTime > tFecha Then + events.Add(cevent) + End If + Else + + 'EMPIEZA METODO PARA AGREGAR CUANDO SI ES RECURRENTE + + Dim FinRecurrencia As Integer = cevent.recurrenciafin.ToEntero + Dim FI As DateTime, FF As DateTime, FT As DateTime + Dim DiasSemana As String() = cevent.diassemana.Split(","c) + FI = cevent.start.ToDateTime + FF = cevent.end.ToDateTime + + 'OBTENEMOS LA FECHA TERMINO (FT) DE LA RECURRENCIA + Select Case FinRecurrencia + Case -1 + FT = DateAdd(DateInterval.Year, 2, dr("FechaInicial").ToString.ToDateTime) + Case Is > 0 + FinRecurrencia -= 1 + Select Case cevent.recurrenciatipo + Case 1 + FT = DateAdd(DateInterval.Hour, FinRecurrencia * cevent.frecuencia, dr("FechaInicial").ToString.ToDateTime) + Case 2 + FT = DateAdd(DateInterval.Day, FinRecurrencia * cevent.frecuencia, dr("FechaInicial").ToString.ToDateTime) + Case 3 + FT = DateAdd(DateInterval.WeekOfYear, FinRecurrencia * cevent.frecuencia, dr("FechaInicial").ToString.ToDateTime) + FT = DateAdd(DateInterval.Day, (7 - Weekday(FT)).ToString.ToDouble, FT) + Case 4 + FT = DateAdd(DateInterval.Month, FinRecurrencia * cevent.frecuencia, dr("FechaInicial").ToString.ToDateTime) + Case 5 + FT = DateAdd(DateInterval.Year, FinRecurrencia * cevent.frecuencia, dr("FechaInicial").ToString.ToDateTime) + End Select + End Select + + 'SI ES TIPO SEMANAL Y DIASSEMANA TIENE VALORES CHECKEA ESTOS VALORES + Do + If DiasSemana.Length > 0 AndAlso DiasSemana(0) <> "" Then + For Each drDias As String In DiasSemana + Dim FIT As Date = FI, FFT As Date = FF + + FIT = DateAdd(DateInterval.Day, (drDias.ToEntero - Weekday(FI)).ToString.ToDouble, FI) + FFT = DateAdd(DateInterval.Day, (drDias.ToEntero - Weekday(FF)).ToString.ToDouble, FF) + + cevent = New CalendarEvent() + cevent.id = dr("CveContrato").ToString.ToEntero + cevent.description = dr("DescripcionContrato").ToString + cevent.start = String.Format("{0:s}", dr("FechaInicial").ToString.ToDateTime) + cevent.end = If(tipoVista = "fecha", String.Format("{0:s}", dr("FechaInicial").ToString.ToDateTime.AddHours(1)), String.Format("{0:s}", dr("FechaFinal").ToString.ToDateTime)) + cevent.allDay = False + cevent.CveCliente = dr("CveCliente").ToString.ToEntero + cevent.NombreComercial = dr("NombreComercial").ToString + cevent.NombreAcercamiento = dr("Ubicacion").ToString cevent.CveActivoFijo = dr("CveAF").ToString.ToEntero - cevent.CveActivoFijo = dr("CveAF").ToString.ToEntero - cevent.CvePersonal = dr("CveChofer").ToString.ToEntero - - - '11/05/2018 - Evento Gasto Recurrente - cevent.CveTipoEvento = dr("CveTipoEvento").ToString.ToEntero - If cevent.CveTipoEvento = 10 Then - cevent.Importe = dr("Importe").ToString.ToDouble - End If - - If cevent.CveEventoEstatus.ToString.ToEntero = 3 Then - cevent.backgroundColor = "#1BBC9B" - End If - - 'SI LA FECHA DEL EVENTO ES MENOR DE 6 MESES DE LA FECHA ACTUAL Y/0 SI LA FECHA INICIAL DE LA RECURRENCIA ES MENOR A LA FECHA QUE SE CREO EL EVENTO NO LO AGREGA - If FIT > DateAdd(DateInterval.Month, -6, ClsPaginas.NowADS()) And FIT >= dr("FechaInicial").ToString.ToDateTime Then - events.Add(cevent) - End If - Next - Else - cevent = New CalendarEvent() - cevent.id = dr("CveContrato").ToString.ToEntero - cevent.description = dr("DescripcionContrato").ToString - cevent.start = String.Format("{0:s}", dr("FechaInicial").ToString.ToDateTime) - cevent.end = If(tipoVista = "fecha", String.Format("{0:s}", dr("FechaInicial").ToString.ToDateTime.AddHours(1)), String.Format("{0:s}", dr("FechaFinal").ToString.ToDateTime)) - cevent.NombreAcercamiento = dr("Ubicacion").ToString + cevent.CveActivoFijo = dr("CveAF").ToString.ToEntero + cevent.CvePersonal = dr("CveChofer").ToString.ToEntero + + + '11/05/2018 - Evento Gasto Recurrente + cevent.CveTipoEvento = dr("CveTipoEvento").ToString.ToEntero + If cevent.CveTipoEvento = 10 Then + cevent.Importe = dr("Importe").ToString.ToDouble + End If + + If cevent.CveEventoEstatus.ToString.ToEntero = 3 Then + cevent.backgroundColor = "#1BBC9B" + End If + + 'SI LA FECHA DEL EVENTO ES MENOR DE 6 MESES DE LA FECHA ACTUAL Y/0 SI LA FECHA INICIAL DE LA RECURRENCIA ES MENOR A LA FECHA QUE SE CREO EL EVENTO NO LO AGREGA + If FIT > DateAdd(DateInterval.Month, -6, ClsPaginas.NowADS()) And FIT >= dr("FechaInicial").ToString.ToDateTime Then + events.Add(cevent) + End If + Next + Else + cevent = New CalendarEvent() + cevent.id = dr("CveContrato").ToString.ToEntero + cevent.description = dr("DescripcionContrato").ToString + cevent.start = String.Format("{0:s}", dr("FechaInicial").ToString.ToDateTime) + cevent.end = If(tipoVista = "fecha", String.Format("{0:s}", dr("FechaInicial").ToString.ToDateTime.AddHours(1)), String.Format("{0:s}", dr("FechaFinal").ToString.ToDateTime)) + cevent.NombreAcercamiento = dr("Ubicacion").ToString cevent.CveActivoFijo = dr("CveAF").ToString.ToEntero - cevent.CveActivoFijo = dr("CveAF").ToString.ToEntero - cevent.allDay = False - - - - 'SI LA FECHA DEL EVENTO ES MENOR DE 6 MESES DE LA FECHA ACTUAL NO LO AGREGA - If FI > DateAdd(DateInterval.Month, -6, ClsPaginas.NowADS()) Then - events.Add(cevent) - End If - End If - - Select Case cevent.recurrenciatipo - Case 1 - FI = DateAdd(DateInterval.Hour, cevent.frecuencia, FI) - FF = DateAdd(DateInterval.Hour, cevent.frecuencia, FF) - Case 2 - FI = DateAdd(DateInterval.Day, cevent.frecuencia, FI) - FF = DateAdd(DateInterval.Day, cevent.frecuencia, FF) - Case 3 - FI = DateAdd(DateInterval.WeekOfYear, cevent.frecuencia, FI) - FF = DateAdd(DateInterval.WeekOfYear, cevent.frecuencia, FF) - Case 4 - FI = DateAdd(DateInterval.Month, cevent.frecuencia, FI) - FF = DateAdd(DateInterval.Month, cevent.frecuencia, FF) - Case 5 - FI = DateAdd(DateInterval.Year, cevent.frecuencia, FI) - FF = DateAdd(DateInterval.Year, cevent.frecuencia, FF) - End Select - - Loop Until FI > FT - End If - Next - Catch ex As Exception - GuardaLog(ex.ToString()) - End Try - End If - - End If - ObjContratos.Dispose() + cevent.CveActivoFijo = dr("CveAF").ToString.ToEntero + cevent.allDay = False + + + + 'SI LA FECHA DEL EVENTO ES MENOR DE 6 MESES DE LA FECHA ACTUAL NO LO AGREGA + If FI > DateAdd(DateInterval.Month, -6, ClsPaginas.NowADS()) Then + events.Add(cevent) + End If + End If + + Select Case cevent.recurrenciatipo + Case 1 + FI = DateAdd(DateInterval.Hour, cevent.frecuencia, FI) + FF = DateAdd(DateInterval.Hour, cevent.frecuencia, FF) + Case 2 + FI = DateAdd(DateInterval.Day, cevent.frecuencia, FI) + FF = DateAdd(DateInterval.Day, cevent.frecuencia, FF) + Case 3 + FI = DateAdd(DateInterval.WeekOfYear, cevent.frecuencia, FI) + FF = DateAdd(DateInterval.WeekOfYear, cevent.frecuencia, FF) + Case 4 + FI = DateAdd(DateInterval.Month, cevent.frecuencia, FI) + FF = DateAdd(DateInterval.Month, cevent.frecuencia, FF) + Case 5 + FI = DateAdd(DateInterval.Year, cevent.frecuencia, FI) + FF = DateAdd(DateInterval.Year, cevent.frecuencia, FF) + End Select + + Loop Until FI > FT + End If + Next + Catch ex As Exception + GuardaLog(ex.ToString()) + End Try + End If + + End If + ObjContratos.Dispose() Return ErrorEventos End Function diff --git a/Compras/eFacturas.aspx.vb b/Compras/eFacturas.aspx.vb index 0c556ae5a..722ac2d7f 100644 --- a/Compras/eFacturas.aspx.vb +++ b/Compras/eFacturas.aspx.vb @@ -2852,7 +2852,7 @@ Partial Class Compras_eFacturas Protected Sub LnkSolicitarSat_Click(ByVal sender As Object, ByVal e As EventArgs) - Exit Sub + Dim sbResultado As StringBuilder = New StringBuilder() Dim idSolicitudCFDI As Integer = 0 diff --git a/Transportes/RepContratoDetalle.aspx b/Transportes/RepContratoDetalle.aspx index eb0470f9f..5812337ce 100644 --- a/Transportes/RepContratoDetalle.aspx +++ b/Transportes/RepContratoDetalle.aspx @@ -117,8 +117,7 @@