Files
SIG/Ventas/RepEntregasEcommerce.aspx.vb
2023-12-18 06:58:53 -07:00

172 lines
6.3 KiB
VB.net

Imports System.Data
Imports Extensiones
Imports Microsoft.Reporting.WebForms
Partial Class Ventas_RepEntregasEcommerce
Inherits ClsPaginas
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
CargaCombos()
CargaDatos()
End If
End Sub
Private Sub CargaCombos()
txtFechaI.Text = NowADS.AddDays(-5).ToShortDateString
txtFechaF.Text = NowADS.ToShortDateString
End Sub
Private Sub CargaDatos()
Dim FechaI, FechaF As Date
If txtFechaI.Text <> "" Then FechaI = txtFechaI.Text.Trim.ToDate Else FechaI = MinFecha
If txtFechaF.Text <> "" Then FechaF = txtFechaF.Text.Trim.ToDate Else FechaF = MaxFecha
Dim Obj As New ClsVentas
If Obj.GetEntregasEcommerce(FechaI, FechaF, RBL.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
If RBL.SelectedValue = "1" Then
GvD.DataSource = Obj.DtResultados
GvD.Visible = True : GvR.Visible = False
Else
GvR.DataSource = Obj.DtResultados
GvR.Visible = True : GvD.Visible = False
End If
End If
Obj.Dispose()
GvD.DataBind()
GvR.DataBind()
UPDatos.Update()
End Sub
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click
CargaDatos()
End Sub
#Region " I M P R I M I R P D F"
Protected Sub LnkExcel_Click(sender As Object, e As EventArgs) Handles LnkExcel.Click
Dim EsVisibleColPagoProveedor As Boolean = False
If GvD.Columns(10).Visible Then
EsVisibleColPagoProveedor = True
GvD.Columns(10).Visible = False
End If
GenerarPDFpp("Excel")
End Sub
Protected Sub LnkPDF_Click(sender As Object, e As EventArgs) Handles LnkPDF.Click
GenerarPDFpp()
End Sub
Protected Sub LnkPDFSubProyecto_Click(sender As Object, e As EventArgs)
GenerarPDFpp(AgrupadoPorSubProyecto:=True)
End Sub
Protected Sub LnkExcelSubProyecto_Click(sender As Object, e As EventArgs)
Dim EsVisibleColPagoProveedor As Boolean = False
If GvD.Columns(10).Visible Then
EsVisibleColPagoProveedor = True
GvD.Columns(10).Visible = False
End If
GenerarPDFpp("Excel", True)
If EsVisibleColPagoProveedor Then
GvD.Columns(10).Visible = True
End If
End Sub
Private Sub GenerarPDFpp(Optional Formato As String = "PDF", Optional AgrupadoPorSubProyecto As Boolean = False)
Dim Imagen As New System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png")
'OBTENEMOS LOS DATOS
Dim DTpp As DataTable = Nothing
If DTpp.Rows.Count > 0 Then
Dim dr As DataRow = DTpp.Rows(0)
Dim params As New List(Of ReportParameter)
Dim Filtros As New StringBuilder
Filtros.Append("<b>Filtros </b>")
Dim ExistenFechas As Boolean = False
If txtFechaI.Text.Trim.Length > 0 Then
Filtros.Append($" Fecha Inicio: {txtFechaI.Text.Trim}")
ExistenFechas = True
End If
If txtFechaF.Text.Trim.Length > 0 Then
Filtros.Append($" Fecha Fin: {txtFechaF.Text.Trim}")
ExistenFechas = True
End If
If ExistenFechas Then
params.Add(New ReportParameter("AgrupadoPor", Filtros.ToString))
End If
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
' params.Add(New ReportParameter("FechaInicio", FI))
' params.Add(New ReportParameter("FechaFin", FF))
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
params.Add(New ReportParameter("FechaImpresion", NowADS().ToDateTime.ToString))
' params.Add(New ReportParameter("AgrupadoPor", $"{Programo} {Proveedor} {Registro} {Responsable} {Clasificacion} {Moneda} {Estatus} {SubProyecto} {FechaIn} {FechaFn}{FVI}{FVF}"))
params.Add(New ReportParameter("LogoPath", If(Imagen.Exists, $"file://{Imagen.FullName}", "")))
ImprimirPDF("Empresas/Grales/Formatos/RepPagoProveedores.rdlc", DTpp, params, "ReportePagoProveedores", Formato)
Else
Alert("No se tienen registrados movimientos", TipoMensaje.MsgAdvertencia)
End If
End Sub
Private Sub GvD_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvD.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.DBCampo("CvePS") = "" Then
e.Row.CssClass = "SubTotales"
If e.Row.DBCampo("HMO").ToDecimal >= e.Row.DBCampo("Cantidad").ToDecimal Then e.Row.FCButton("BtnHMO").Visible = True
If e.Row.DBCampo("CUL").ToDecimal >= e.Row.DBCampo("Cantidad").ToDecimal Then e.Row.FCButton("BtnCUL").Visible = True
If e.Row.DBCampo("Mex").ToDecimal >= e.Row.DBCampo("Cantidad").ToDecimal Then e.Row.FCButton("BtnMex").Visible = True
If e.Row.DBCampo("LP").ToDecimal >= e.Row.DBCampo("Cantidad").ToDecimal Then e.Row.FCButton("BtnLP").Visible = True
e.Row.FCLabel("LblHmo").Visible = False
e.Row.FCLabel("LblCUL").Visible = False
e.Row.FCLabel("LblMex").Visible = False
e.Row.FCLabel("LblLP").Visible = False
Else
If e.Row.DBCampo("CveAlmacenTraspasoOrigen") <> "" Then
Dim tCve As Integer = e.Row.DBCampo("CveAlmacenTraspasoOrigen").ToEntero
Dim tCol As Integer = If(tCve = 153, 4, If(tCve = 271, 5, If(tCve = 275, 6, 7)))
e.Row.Cells(tCol).BackColor = Drawing.Color.LightGreen
End If
End If
End If
End Sub
#End Region
Private Sub GvD_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles GvD.RowCommand
If e.CommandName <> "" Then
Dim ObjSurtir As New ClsInventarios
If ObjSurtir.UpdateAlmacenTraspasoOrigen(e.CommandName.ToEntero, e.CommandArgument.ToString.ToEntero, UsuarioActual.CveEmpresa) Then
Alert("Se asignó el almacen por surtir.")
End If
ObjSurtir.Dispose()
CargaDatos()
End If
End Sub
End Class