Files
SIG/Bancos/RepCortes.aspx.vb
2024-04-10 19:16:20 -07:00

241 lines
8.7 KiB
VB.net

Option Explicit On
Option Strict On
Imports System.Data
Imports Extensiones
Partial Class Bancos_RepCortes
Inherits ClsPaginas
#Region "PROPIEDADES"
Private Property DtCortes As DataTable
Get
Return CType(ViewState("DtCortes"), DataTable)
End Get
Set(value As DataTable)
ViewState("DtCortes") = value
End Set
End Property
Private Property DtCortesVentasResumen As DataTable
Get
Return CType(ViewState("DtCortesVentasResumen"), DataTable)
End Get
Set(value As DataTable)
ViewState("DtCortesVentasResumen") = value
End Set
End Property
Private Property DtCortesVentas As DataTable
Get
Return CType(ViewState("DtCortesVentas"), DataTable)
End Get
Set(value As DataTable)
ViewState("DtCortesVentas") = value
End Set
End Property
Private Property Fecha As String
Get
Return CType(ViewState("Fecha"), String)
End Get
Set(value As String)
ViewState("Fecha") = value
End Set
End Property
Private Property Nombre As String
Get
Return CType(ViewState("Nombre"), String)
End Get
Set(value As String)
ViewState("Nombre") = value
End Set
End Property
Private Property CveCorte As Integer
Get
Return CType(ViewState("CveCorte"), Integer)
End Get
Set(value As Integer)
ViewState("CveCorte") = value
End Set
End Property
#End Region
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
txtFechaVI.Text = NowADS().ToShortDateString
txtFechaVF.Text = NowADS().ToShortDateString
Me.Form.DefaultButton = BtnConsultar.UniqueID
CargarCentrosDeCosto(Nothing, DdlSubProyectos, Nothing, LblSubProyecto)
End If
End Sub
#Region " C A R G A - D A T O S "
Public Sub CargaDatos()
Dim FechaI As Date = If(txtFechaVI.Text <> "", txtFechaVI.Text.ToDate, MinFecha)
Dim FechaF As Date = If(txtFechaVF.Text <> "", txtFechaVF.Text.ToDate, MaxFecha)
Dim ObjPuntoVenta As New ClsPuntoVenta
If ObjPuntoVenta.GetVta_ReporteCortes(UsuarioActual.CveEmpresa, FechaI, FechaF, DdlSubProyectos.SelectedValue.ToEntero) Then
DtCortes = ObjPuntoVenta.DtResultados.Copy()
End If
ObjPuntoVenta.Dispose()
If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then
GvDatos.Columns(3).Visible = True
GvDatos.Columns(4).Visible = True
GvDatos.Columns(13).Visible = True
End If
GvDatos.DataSource = DtCortes
GvDatos.DataBind()
UPDatos.Update()
End Sub
#End Region
#Region "G V - D A T O S "
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("CveCorte").ToString = "" Then
e.Row.CssClass = "SubTotales2"
If DtCortes IsNot Nothing Then
e.Row.FCLiteral("LtlImporteInicial").Text = DtCortes.SUMD("ImporteInicial").FormatoNumero(2)
End If
End If
End If
End Sub
Protected Sub GvP_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvP.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.DBCampo("MetodoPago").ToString = "Total" Then
e.Row.CssClass = "SubTotales"
End If
End If
End Sub
Protected Sub GvD_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvD.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.DBCampo("CveVenta").ToString = "" Then
e.Row.CssClass = "Totales"
End If
If e.Row.DBCampo("ImportePagado").ToDecimal() < 0 Then
e.Row.FCLabel("LblTotal").CssClass = "badge badge-danger"
End If
End If
End Sub
'Protected Sub GvD_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles GvD.RowCommand
' If e.CommandArgument.ToString.ToEntero > 0 Then
' End If
' Dim Vent As New ClsPuntoVenta
' If Vent.GetCortesDetalleVentas(16200, 61) Then
' Alert(Vent.DtResultados.Rows.Count.ToString)
' GvD.DataSource = Vent.DtResultados
' GvD.DataBind()
' 'RegistraScript("$get")
' divDetalle.Visible = True
' End If
' Vent.Dispose()
'End Sub
#End Region
#Region "BOTONES"
Protected Sub BtnConsultar_Click(sender As Object, e As System.EventArgs) Handles BtnConsultar.Click
CargaDatos()
End Sub
Protected Sub BtnPersonalizar_Click(sender As Object, e As System.EventArgs) Handles BtnPersonalizar.Click
GvDatos.Columns(1).Visible = ChkUsuarioCancelacion.Checked
GvDatos.Columns(2).Visible = ChkTipo.Checked
UPDatos.Update()
End Sub
Protected Sub LbDescripcion_Click(sender As Object, e As EventArgs)
Dim btn As LinkButton = DirectCast(sender, LinkButton)
Dim gvr As GridViewRow = DirectCast(btn.NamingContainer, GridViewRow)
CveCorte = gvr.DataKey("CveCorte").ToString.ToEntero
Dim Finalizado As Integer = gvr.DataKey("Finalizado").ToString.ToEntero
Fecha = gvr.DataKey("FechaInicial").ToString
Nombre = gvr.DataKey("Nombre").ToString
Dim Vent As New ClsPuntoVenta
Dim Vn As New ClsVentas
If Vn.GetCortesDetalleVentasResumen(CveCorte, DdlSubProyectos.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
GvP.DataSource = Vn.DtResultados
DtCortesVentasResumen = Vn.DtResultados
End If
If UsuarioActual.CveEmpresa.Contiene(190, 192) Then
DivIVA.Visible = True
If Vn.GetCortesDetalleVentasResumenIVA(CveCorte, DdlSubProyectos.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
GvPorIVA.DataSource = Vn.DtResultados
End If
End If
If UsuarioActual.CveEmpresa.contiene(140, 141) AndAlso Vn.GetCortesDetalleDepositosCaja(CveCorte, DdlSubProyectos.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
GvDep.DataSource = Vn.DtResultados
If Vn.DtResultados.Rows.Count > 0 Then
DivDep.Visible = True
End If
End If
If Vent.GetCortesDetalleVentas(CveCorte, DdlSubProyectos.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, 2) Then
GvD.DataSource = Vent.DtResultados
DtCortesVentas = Vent.DtResultados
divDetalle.Visible = True
End If
If (DtCortesVentasResumen IsNot Nothing AndAlso DtCortesVentasResumen.Rows.Count > 0) Or (DtCortesVentas IsNot Nothing AndAlso DtCortesVentas.Rows.Count > 0) Then
HplDownPDF.Visible = True
HplDownEXCEL.Visible = True
HplDownPDF.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=CORT&CVECORTE={0}&FORMATO={1}&CVESUBPROYECTO={2}", CveCorte, "PDF", DdlSubProyectos.SelectedValue.ToEntero)))
HplDownEXCEL.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=CORT&CVECORTE={0}&FORMATO={1}&CVESUBPROYECTO={2}", CveCorte, "EXCEL", DdlSubProyectos.SelectedValue.ToEntero)))
Else
HplDownPDF.Visible = False
HplDownEXCEL.Visible = False
End If
Vn.Dispose()
Vent.Dispose()
GvD.DataBind()
GvP.DataBind()
GvDep.DataBind()
GvPorIVA.DataBind()
If UsuarioActual.CveEmpresa = 193 Then
DivAnexo.Visible = True
Dim CveCuenta As Integer = 186367
Using ObjConta As New ClsContabilidad
If ObjConta.GetAnexoCatalogo(CveCuenta, Fecha.ToDate(), Fecha.ToDate(), -1, -1, -1, UsuarioActual.CveEmpresa, 1) Then
GvAnexo.DataSource = ObjConta.DtResultados
End If
End Using
GvAnexo.DataBind()
End If
UPPDetalle.Update()
UpAcciones.Update()
End Sub
Private Sub GvDep_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDep.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.FCHyperLink("HplImpPol").NavigateUrl = $"/Compras/PopUpVerFactura.aspx?P={Encripta($"OP=PREPO&CvePrePoliza={ e.Row.DBCampo("CvePrePoliza")}")}"
End If
End Sub
#End Region
End Class