This commit is contained in:
rakcsle
2024-10-14 08:16:44 -07:00
parent 94100af37d
commit d9cd4d4dc6
4 changed files with 659 additions and 136 deletions

View File

@@ -72,7 +72,8 @@ Partial Class RepContratosCalendario
CveTipoAF:=DdlTipoUnidad.SelectedValue.ToEntero,
CveChofer:=DdlChoferFiltro.SelectedValue.ToEntero) Then
DtAvance = ObjContratos.DtResultados.Copy()
CargaCronograma(DdlTipoVista.SelectedValue.ToEntero)
CargaCronograma(DdlTipoVistaCalendario.SelectedValue.ToEntero)
CargaDiagramadeGant(DdlTipoVista.SelectedValue.ToEntero)
End If
GvContratos.DataSource = DtAvance
DdlEstatusContrato.Enabled = UsuarioActual.TienePermisoProceso(173)
@@ -91,9 +92,9 @@ Partial Class RepContratosCalendario
Private Sub CargaCronograma(Optional TipoVista As Integer = -1)
If DtAvance IsNot Nothing Then
Dim separator As String = ""
Dim str As New StringBuilder()
str.AppendLine("datosGant=[")
'Dim separator As String = ""
'Dim str As New StringBuilder()
'str.AppendLine("datosGant=[")
Dim StrFiltro As String = ""
@@ -110,30 +111,32 @@ Partial Class RepContratosCalendario
'DATOS
Dim strAF As New StringBuilder
'se quitan los estatus cancelados
Dim randomNumber As New Random
For Each Row As DataRow In DtAvance.FiltraParametros("CodigoAF <> '' AND TipoEstatus <> 3").Rows
Dim obj As New JObject(
New JProperty("category", Row("CodigoAF")),
New JProperty("fromDate", Row("FechaInicial").ToString().ToDateTime().ToString("dd/MM/yyyy HH:mm").ToDateTime()),
New JProperty("toDate", Row("FechaFinal").ToString().ToDateTime.ToString("dd/MM/yyyy HH:mm").ToDateTime()),
New JProperty("fromDate", Row("FechaInicial").ToString().ToDateTime().ToString("yyyy-MM-dd HH:mm:ss")),
New JProperty("toDate", Row("FechaFinal").ToString().ToDateTime.ToString("yyyy-MM-dd HH:mm:ss")),
New JProperty("columnSettings", New JObject(
New JProperty("fill", String.Format("#{0:X6}", random.Next(16777216)))
)),
New JProperty("unidad", Row("NombreAF")),
New JProperty("cveContrato", Row("CveContrato")),
New JProperty("contrato", Row("NumeroContrato")),
New JProperty("fechaFinalViaje", Row("FechaFinal").ToString().ToDateTime().ToString("dd/MM/yyyy HH:mm"))
New JProperty("fechaFinalViaje", Row("FechaFinal").ToString().ToDateTime().ToString("yyyy-MM-dd HH:mm:ss"))
)
jsonData.Add(obj)
strAF.AppendFormat("{0},", Row("CveAF"))
'uniad contrato y duracion
Dim unidad As String = $"{Row("CodigoAF")}-{Row("NombreAF")}"
Dim duracion As String = $"{Row("FechaInicial").ToString.ToDate.ToString("dd/MM/yyyy HH:mm")} - {Row("FechaFinal").ToString.ToDate.ToString("dd/MM/yyyy HH:mm")}"
'Dim unidad As String = $"{Row("CodigoAF")}-{Row("NombreAF")}"
'Dim duracion As String = $"{Row("FechaInicial").ToString.ToDate.ToString("dd/MM/yyyy HH:mm")} - {Row("FechaFinal").ToString.ToDate.ToString("dd/MM/yyyy HH:mm")}"
str.AppendLine(String.Format("{0}{{id: {1}, text: ""{2}"", start_date: ""{3:yyyy/MM/dd HH:mm}"", end_date: ""{4:yyyy/MM/dd HH:mm}"", parent: {5}, progress:{6}, open: true, unidad: ""{7}"",duracion: ""{8}""}}",
separator, Row("CveContrato"), Row("NumeroContrato").ToString().Replace("\\", "\\\\").Replace("""", "\"""), Row("FechaInicial"), Row("FechaFinal"), 0, 100, unidad, duracion))
separator = ","
'str.AppendLine(String.Format("{0}{{id: {1}, text: ""{2}"", start_date: ""{3:yyyy/MM/dd HH:mm}"", end_date: ""{4:yyyy/MM/dd HH:mm}"", parent: {5}, progress:{6}, open: true, unidad: ""{7}"",duracion: ""{8}"", color: ""{9}"",codigoaf: ""{10}""}}",
' separator, Row("CveContrato"), Row("NumeroContrato").ToString().Replace("\\", "\\\\").Replace("""", "\"""), Row("FechaInicial"), Row("FechaFinal"), 0, 100, unidad, duracion, ColorAleatorio(randomNumber), Row("CodigoAF").ToString))
'separator = ","
Next
@@ -151,18 +154,188 @@ Partial Class RepContratosCalendario
Dim FechaI = txtFechaI.Text.ToDateTime()
Dim FechaF = txtFechaF.Text.ToDateTime()
Dim ScriptZoom = $"zoomAxis({FechaI.Year},{FechaI.Month - 1},{FechaI.Day},{FechaF.Year},{FechaF.Month - 1},{FechaF.Day});"
RegistraScript($"cargaDiagramaGrant({jsonData.ToString()},{jsonCategorias.ToString()},{TipoVista});{ScriptZoom}", "A1")
Dim ScriptZoomx = $"zoomAxis({FechaI.Year},{FechaI.Month - 1},{FechaI.Day},{FechaF.Year},{FechaF.Month - 1},{FechaF.Day});"
Dim ScriptZoomy = $"zoomAxisy(0,{If(jsonCategorias.Count > 9, 9, jsonCategorias.Count - 1)});"
RegistraScript($"cargaDiagramaGrant({jsonData.ToString()},{jsonCategorias.ToString()},{TipoVista});{ScriptZoomx};{ScriptZoomy};", "A1")
'RegistraScript($"cargaDiagramaGrant({jsonData.ToString()},{jsonCategorias.ToString()},{TipoVista});", "A1")
str.AppendLine("];loadGant();")
RegistraScript(str.ToString())
'str.AppendLine("];loadGant();")
'RegistraScript(str.ToString())
UPPGantt.Update()
UPGat.Update()
End If
End Sub
Private Sub CargaDiagramadeGant(Optional TipoVista As Integer = -1)
Dim randomNumber As New Random
If DtAvance IsNot Nothing Then
Dim str As New StringBuilder()
str.AppendLine("datosGant=[")
If TipoVista = 1 Then 'solo con viajes
Else
Dim StrFiltro As String = ""
If DdlTipoUnidad.SelectedValue.ToEntero > 0 Then StrFiltro = " AND CveTipoActivoFijo = " & DdlTipoUnidad.SelectedValue
Dim DtUnidades As DataTable = GlobalDTActivoFijos(UsuarioActual.CveEmpresa).FiltraParametros("Codigo <> '' AND MedidaVehicular IN (2,3) " & StrFiltro, Orderby:=" TipoActivoFijo ASC, CodigoNumeroOrden ASC", DistinctColumns:={"Codigo", "CveActivoFijo"})
Dim separator As String = ""
Dim encontrados As Integer = 0
Dim CvePadre As Integer = -1
For Each dRowUnidad As DataRow In DtUnidades.Rows
Dim CveActivoFijo As Integer = dRowUnidad("CveActivoFijo").ToString.ToEntero
Dim CodigoAF As String = dRowUnidad("Codigo").ToString
'Dim unidad As String = $"{dRowUnidad("Codigo").ToString}-{dRowUnidad("Descripcion").tostring}"
Dim SeEncontro As Boolean = False
Dim EsHijo As Boolean = False
For Each Row As DataRow In DtAvance.FiltraParametros("CodigoAF <> '' AND TipoEstatus <> 3").Rows
Dim CveActivoFijoContrato As Integer = Row("CveAF").ToString.ToEntero
'If CveActivoFijo = CveActivoFijoContrato Then
' str.AppendLine(String.Format("{0}", separator))
' SeEncontro = True
' Dim unidad As String = $"{Row("CodigoAF")}-{Row("NombreAF")}"
' Dim duracion As String = $"{Row("FechaInicial").ToString.ToDate.ToString("dd/MM/yyyy HH:mm")} - {Row("FechaFinal").ToString.ToDate.ToString("dd/MM/yyyy HH:mm")}"
' str.AppendLine(String.Format("{{id: {1}, text: ""{2}"", start_date: ""{3:yyyy/MM/dd HH:mm}"", end_date: ""{4:yyyy/MM/dd HH:mm}"", parent: {5}, progress:{6}, open: true, unidad: ""{7}"",duracion: ""{8}"", color: ""{9}"",codigoaf: ""{10}""}} ",
' separator, Row("CveContrato"), Row("NumeroContrato").ToString().Replace("\\", "\\\\").Replace("""", "\"""), Row("FechaInicial"), Row("FechaFinal"), 0, 100, unidad, duracion, ColorAleatorio(randomNumber), Row("CodigoAF").ToString))
' separator = ","
' encontrados = encontrados + 1
'End If
If CveActivoFijo = CveActivoFijoContrato Then
str.AppendLine(String.Format("{0}", separator))
SeEncontro = True
Dim unidad As String = $"{Row("CodigoAF")}-{Row("NombreAF")}"
Dim duracion As String = $"{Row("FechaInicial").ToString.ToDate.ToString("dd/MM/yyyy HH:mm")} - {Row("FechaFinal").ToString.ToDate.ToString("dd/MM/yyyy HH:mm")}"
If EsHijo Then
str.AppendLine(String.Format("{{id: {1}, text: ""{2}"", start_date: ""{3:yyyy/MM/dd HH:mm}"", end_date: ""{4:yyyy/MM/dd HH:mm}"", progress:{6}, open: true, unidad: ""{7}"",duracion: ""{8}"", color: ""{9}"",codigoaf: ""{10}"", cvecontrato: ""{11}"", parent: {12} }} ",
separator, Row("CveContrato").ToString, Row("NumeroContrato").ToString().Replace("\\", "\\\\").Replace("""", "\"""), Row("FechaInicial"), Row("FechaFinal"), 0, 100, unidad, duracion, ColorAleatorio(randomNumber), Row("CodigoAF").ToString, Row("CveContrato").ToString, CvePadre)
)
Else
str.AppendLine(String.Format("{{id: {1}, text: ""{2}"", start_date: ""{3:yyyy/MM/dd HH:mm}"", end_date: ""{4:yyyy/MM/dd HH:mm}"", progress:{6}, open: true, unidad: ""{7}"",duracion: ""{8}"", color: ""{9}"",codigoaf: ""{10}"", cvecontrato: ""{11}"",parent: 0 }} ",
separator, Row("CveContrato").ToString, Row("NumeroContrato").ToString().Replace("\\", "\\\\").Replace("""", "\"""), Row("FechaInicial"), Row("FechaFinal"), 0, 100, unidad, duracion, ColorAleatorio(randomNumber), Row("CodigoAF").ToString, Row("CveContrato").ToString)
)
End If
If Not EsHijo Then
CvePadre = Row("CveContrato").ToString.ToEntero
EsHijo = True
End If
separator = ","
encontrados = encontrados + 1
Else
EsHijo = False
End If
Next
'If Not SeEncontro Then
' If encontrados > 0 Then
' separator = ","
' End If
' str.AppendLine(String.Format("{0}", separator))
' str.AppendLine(String.Format("{{id: {1}, text: ""{2}"", start_date: ""{3}"", end_date: ""{4}"", parent: {5}, progress:{6}, open: true, unidad: ""{7}"",duracion: ""{8}"", color: ""{9}"",codigoaf: ""{10}"", hidden: true}} ",
' "", CveActivoFijo, -1, txtFechaF.Text.ToDate.ToString("yyyy/MM/dd HH:mm"), txtFechaF.Text.ToDate.ToString("yyyy/MM/dd HH:mm"), 0, 100, "", "", ColorAleatorio(randomNumber), CodigoAF))
' separator = ","
'End If
'str.AppendLine(String.Format("}"))
Next
End If
str.AppendLine("];loadGant();")
'RegistraScript(str.ToString())
UPPGantt.Update()
UPGat.Update()
End If
End Sub
Private Function ColorAleatorio(randomNumber As Random) As String
Dim listaColores As New List(Of String)
listaColores.Add("#94f35a")
listaColores.Add("#1989a9")
listaColores.Add("#5a3c98")
listaColores.Add("#556855")
listaColores.Add("#e199cf")
listaColores.Add("#50cc77")
listaColores.Add("#559f9d")
listaColores.Add("#ede805")
listaColores.Add("#f1e489")
listaColores.Add("#c381f6")
listaColores.Add("#f2496b")
listaColores.Add("#c4d7dc")
listaColores.Add("#f3f9f9")
listaColores.Add("#fd8ffe")
listaColores.Add("#f2496b")
listaColores.Add("#5a8f9c")
listaColores.Add("#87bfbd")
listaColores.Add("#fb01fd")
listaColores.Add("#6836dc")
listaColores.Add("#67627e")
listaColores.Add("#1b9f44")
listaColores.Add("#3a54dc")
listaColores.Add("#fb66f1")
listaColores.Add("#24f6b4")
listaColores.Add("#60feee")
listaColores.Add("#82a199")
listaColores.Add("#93a9e1")
listaColores.Add("#ff8809")
listaColores.Add("#8379ba")
listaColores.Add("#f62ea2")
listaColores.Add("#41cf69")
listaColores.Add("#8624b2")
listaColores.Add("#f4948a")
listaColores.Add("#205da6")
listaColores.Add("#9f38b6")
listaColores.Add("#540466")
listaColores.Add("#7a4e49")
listaColores.Add("#bd22ce")
listaColores.Add("#6d89a0")
listaColores.Add("#7e6d8c")
listaColores.Add("#124a70")
listaColores.Add("#c3d2c2")
listaColores.Add("#506702")
listaColores.Add("#058106")
listaColores.Add("#0485f2")
listaColores.Add("#401685")
Dim ranNumber As Integer = randomNumber.Next(0, listaColores.Count - 1)
Return listaColores(ranNumber)
End Function
'Public Sub loadEvento()
' Dim separator As String = ""
' Dim str As New StringBuilder()
@@ -487,16 +660,47 @@ Partial Class RepContratosCalendario
End Sub
Protected Sub LnkExcel_Click(sender As Object, e As EventArgs) Handles LnkExcel.Click
GvContratos.ExportToExcel("ReporteCompras" & NowADS().ToShortDateString)
Protected Sub LnkExcel_Click(sender As Object, e As EventArgs) Handles LnkExcel.Click
Dim SubProyecto As String = ""
SubProyecto = DdlSubProyectos.SelectedItem.Text
Dim SbFiltros As New StringBuilder()
SbFiltros.AppendFormat($"Fecha Inicio: {txtFechaI.Text} Fecha Fin: {txtFechaF.Text}|")
SbFiltros.AppendFormat("SubProyecto: {0}|", SubProyecto)
GvContratos.ExportToExcelGembox($"Reporte_Contratos_{NowADS.ToString("yyyyMMddHHmmss")}", UsuarioActual, "Reporte Contratos", DatoTituloExtra:=$"", DatosFiltros:=SbFiltros.ToString())
End Sub
Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
' Esto es necesario para permitir la renderización del control fuera de un formulario servidor
' No se requiere implementación específica, solo la anulación.
End Sub
Protected Sub LnkPDF_Click(sender As Object, e As EventArgs) Handles LnkPdf.Click
Protected Sub LnkPDF_Click(sender As Object, e As EventArgs) Handles LnkPdf.Click
ImprimirReporte()
End Sub
Private Sub ImprimirReporte(Optional Formato As String = "PDF")
Dim ObjContratos As New ClsContratos
Dim DTDatos As New DataTable
If ObjContratos.GetContratos(-1, UsuarioActual.CveEmpresa, TipoContrato:=2) Then
DTDatos = ObjContratos.DtResultados
Else
Alert("No hay datos consultados", TipoMensaje.MsgAdvertencia)
End If
ObjContratos.Dispose()
If DTDatos IsNot Nothing Then
Dim Imagen As New IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png")
Dim logouri As String = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa)
Dim Cliente As String = If(DdlClientes.SelectedValue = "-1", "", $"&emsp;<b>Cliente:</b>&nbsp;{DdlClientes.SelectedText}")
Dim dt As DataTable = ObjContratos.DtResultados
Dim Cliente As String = If(DdlClientes.SelectedValue = "-1", "", $"&emsp;<b>Cliente:</b>&nbsp;{DdlClientes.SelectedText}")
Dim params As New List(Of ReportParameter) From {
New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa),
New ReportParameter("FechaInicio", "-1"),
@@ -506,23 +710,25 @@ Partial Class RepContratosCalendario
New ReportParameter("FechaImpresion", NowADS().ToDateTime.ToShortDateString),
New ReportParameter("LogoPath", If(Imagen.Exists, $"file://{Imagen.FullName}", ""))
}
ImprimirPDF("Empresas/Grales/Formatos/RepContratos.rdlc", dt, params, NombreArchivo:="Reporte Contratos")
Else
Alert("No hay datos consultados", TipoMensaje.MsgAdvertencia)
End If
ObjContratos.Dispose()
ImprimirPDF("Empresas/Grales/Formatos/RepContratos.rdlc", DTDatos, params, NombreArchivo:="Reporte Contratos", Formato:=Formato)
End If
End Sub
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs)
CargaDatos()
End Sub
Protected Sub RBTipoVista_SelectedIndexChanged(sender As Object, e As EventArgs)
InicializaCalendar()
CargaCronograma()
CargaDiagramadeGant()
End Sub
Protected Sub DdlTipoVista_SelectedIndexChanged(sender As Object, e As EventArgs)
CargaCronograma(DdlTipoVista.SelectedValue.ToEntero)
CargaDiagramadeGant(DdlTipoVista.SelectedValue.ToEntero)
End Sub
@@ -537,4 +743,8 @@ Partial Class RepContratosCalendario
End Sub
Protected Sub DdlTipoVistaCalendario_SelectedIndexChanged(sender As Object, e As EventArgs)
CargaCronograma(DdlTipoVistaCalendario.SelectedValue.ToEntero)
End Sub
End Class