Files
SIG/Acarreos/RepPreEstimacionDetalle.aspx.vb
2023-10-09 11:55:07 -07:00

148 lines
5.5 KiB
VB.net

Imports System.Data
Imports System.Drawing
Imports Extensiones
Imports Microsoft.Reporting.WebForms
Partial Class Acarreos_RepPreEstimacionDetalle
Inherits ClsPaginas
#Region "PROPIEDADES"
Private Property CveAcarreoProyecto As Integer
Get
CveAcarreoProyecto = ViewState("CveAcarreoProyecto").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CveAcarreoProyecto") = value
End Set
End Property
Private Property CveMaterial As Integer
Get
CveMaterial = ViewState("CveMaterial").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CveMaterial") = value
End Set
End Property
Private Property NumPreEstimacion As Integer
Get
NumPreEstimacion = ViewState("NumPreEstimacion").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("NumPreEstimacion") = value
End Set
End Property
Private Property DTCont As DataTable
Get
Return If(IsNothing(ViewState("DTCont")), Nothing, CType(ViewState("DTCont"), DataTable))
End Get
Set(value As DataTable)
ViewState("DTCont") = value
End Set
End Property
#End Region
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
CveAcarreoProyecto = IfNull(Request("CveAcarreoProyecto"), "").ToString.ToEntero
CveMaterial = IfNull(Request("CveMaterial"), "").ToString.ToEntero
NumPreEstimacion = IfNull(Request("NumPreEstimacion"), "").ToString.ToEntero
CargaDatos()
End If
End Sub
Private Sub CargaDatos()
Dim ObjAcar As New ClsAcarreos
If ObjAcar.GetRepPreEstimacionDetalle(CveAcarreoProyecto, CveMaterial, UsuarioActual.CveEmpresa, NumPreEstimacion) Then
GvDatos.DataSource = ObjAcar.DtResultados
GvDatos.DataBind()
DTCont = ObjAcar.DtResultados
End If
ObjAcar.Dispose()
UPDatos.Update()
End Sub
Private Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatos.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.FCLiteral("LtlFolio").Text = "" Then
e.Row.FCLiteral("LtlFolio").Text = e.Row.DBCampo("Gpo")
e.Row.CssClass = "Totales"
Else
Dim Css As String = "Texto"
Dim Liga As String = $"/Acarreos/RegistroAcarreo.aspx?&CveAcarreo={e.Row.DBCampo("CveAcarreo")}"
e.Row.FCLiteral("LtlFolio").Text = "<a class=""" & Css & """ href=""" & Liga & """>" & e.Row.FCLiteral("LtlFolio").Text & "</a>"
End If
e.Row.FCLiteral("LtlImporte").Text = "$" + FormatNumber(e.Row.FCLiteral("LtlImporte").Text, 2, , , TriState.True)
e.Row.FCLiteral("LtlVolumen").Text = FormatNumber(e.Row.FCLiteral("LtlVolumen").Text, 2, , , TriState.True)
End If
End Sub
#Region "PDF"
Private Sub LnkPdf_Click(sender As Object, e As EventArgs) Handles LnkPdf.Click
If DTCont IsNot Nothing Then
Dim StrFiltro As New StringBuilder
StrFiltro.AppendFormat("&emsp;<b>Numero de Pre-Estimacion</b>: {0}", NumPreEstimacion)
Dim Imagen As New System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png")
Dim params As New List(Of ReportParameter)
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
params.Add(New ReportParameter("FechaImpresion", NowADS().ToDateTime.ToShortDateString))
params.Add(New ReportParameter("Filtros", StrFiltro.ToString))
If Imagen.Exists Then
params.Add(New ReportParameter("LogoPath", $"file://{Imagen}"))
Else
params.Add(New ReportParameter("LogoPath", ""))
End If
ImprimirPDF("Empresas/Grales/Formatos/RepPreEstimacionDetalle.rdlc", DTCont, params, String.Format("RepPreEstimacionDetalle-{0}", NowADS().ToDateTime.ToShortDateString))
Else
Alert("No hay datos consultados", TipoMensaje.MsgAdvertencia)
End If
End Sub
#End Region
#Region "EXCEL"
Private Sub ImgExcel_Click(sender As Object, e As EventArgs) Handles ImgExcel.Click
If DTCont IsNot Nothing Then
Dim StrFiltro As New StringBuilder
StrFiltro.AppendFormat("&emsp;<b>Numero de Pre-Estimacion</b>: {0}", NumPreEstimacion)
Dim Imagen As New System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png")
Dim params As New List(Of ReportParameter)
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
params.Add(New ReportParameter("FechaImpresion", NowADS().ToDateTime.ToShortDateString))
params.Add(New ReportParameter("Filtros", StrFiltro.ToString))
params.Add(New ReportParameter("LogoPath", If(Imagen.Exists, $"file://{Imagen.FullName}", "")))
ImprimirPDF("Empresas/Grales/Formatos/RepPreEstimacionDetalle.rdlc", DTCont, params, String.Format("RepPreEstimacionDetalle-{0}", NowADS().ToDateTime.ToShortDateString), "Excel")
Else
Alert("No hay datos consultados", TipoMensaje.MsgAdvertencia)
End If
End Sub
#End Region
End Class