331 lines
14 KiB
VB.net
331 lines
14 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
|
|
Dim AplicaTodos As String = ""
|
|
If UsuarioActual.CveEmpresa.Contiene(140, 141) Then AplicaTodos = "Todos"
|
|
CargarCentrosDeCosto(Nothing, DdlSubProyectos, Nothing, LblSubProyecto, AplicaTodos:=AplicaTodos)
|
|
|
|
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 ObjVenta As New ClsVentas
|
|
If ObjVenta.GetVta_ReporteCortes(UsuarioActual.CveEmpresa, FechaI, FechaF, DdlSubProyectos.SelectedValue.ToEntero) Then
|
|
DtCortes = ObjVenta.DtResultados.Copy()
|
|
End If
|
|
ObjVenta.Dispose()
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then
|
|
GvDatos.Columns(3).Visible = True
|
|
GvDatos.Columns(4).Visible = True
|
|
End If
|
|
|
|
GvP.DataBind()
|
|
GvDep.DataBind()
|
|
GvPorIVA.DataBind()
|
|
GvAnexo.DataBind()
|
|
GvD.DataBind()
|
|
|
|
GvDatos.DataSource = DtCortes
|
|
GvDatos.DataBind()
|
|
UPDatos.Update()
|
|
UPPDetalle.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("FechaInicial").ToString = "" Then
|
|
e.Row.CssClass = "SubTotales2"
|
|
If DtCortes IsNot Nothing Then
|
|
e.Row.FCLiteral("LtlImporteInicial").Text = DtCortes.SUMD("ImporteInicial").FormatoNumero(2)
|
|
End If
|
|
Else
|
|
If UsuarioActual.CveRol = 1 Then
|
|
If e.Row.DBCampo("VentasCorte").ToDecimal <> e.Row.DBCampo("VentaTotalIngreso").ToDecimal + e.Row.DBCampo("VentaTotalRemision").ToDecimal Then
|
|
e.Row.Cells(2).ForeColor = Drawing.Color.Red
|
|
e.Row.Cells(2).ToolTip = (e.Row.DBCampo("VentasCorte").ToDecimal - (e.Row.DBCampo("VentaTotalIngreso").ToDecimal + e.Row.DBCampo("VentaTotalRemision").ToDecimal)).ToString
|
|
End If
|
|
If e.Row.DBCampo("VentasCorte").ToDecimal <> e.Row.DBCampo("VentasContado").ToDecimal + e.Row.DBCampo("VentasCredito").ToDecimal Then
|
|
e.Row.Cells(6).ForeColor = Drawing.Color.Red
|
|
e.Row.Cells(6).ToolTip = (e.Row.DBCampo("VentasCorte").ToDecimal - (e.Row.DBCampo("VentasContado").ToDecimal + e.Row.DBCampo("VentasCredito").ToDecimal)).ToString
|
|
End If
|
|
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 GvIngresosRetiros_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvIngresosRetiros.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If e.Row.DBCampo("CveMovimiento").ToString = "" Then
|
|
e.Row.CssClass = "Totales"
|
|
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").ToEntero()
|
|
|
|
Dim Finalizado As Integer = gvr.DataKey("Finalizado").ToEntero()
|
|
Fecha = gvr.DataKey("FechaInicial")
|
|
Nombre = gvr.DataKey("Nombre")
|
|
|
|
'If ObjPuntoVenta.GetCortesDetalleVentas(CveCorte, DdlSubProyectos.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, 2) Then
|
|
' DtCortesVentas = ObjPuntoVenta.DtResultados.Copy()
|
|
' GvD.DataSource = DtCortesVentas
|
|
|
|
' divDetalle.Visible = True
|
|
'End If
|
|
|
|
'If ObjVentas.GetCortesDetalleVentasResumen(CveCorte, DdlSubProyectos.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
|
|
' GvP.DataSource = ObjVentas.DtResultados
|
|
' DtCortesVentasResumen = ObjVentas.DtResultados
|
|
'End If
|
|
|
|
'If UsuarioActual.CveEmpresa.Contiene(190, 192) Then
|
|
' DivIVA.Visible = True
|
|
' If ObjVentas.GetCortesDetalleVentasResumenIVA(CveCorte, DdlSubProyectos.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
|
|
' GvPorIVA.DataSource = ObjVentas.DtResultados
|
|
' End If
|
|
'End If
|
|
Dim FechaConsulta = ModExtensiones.MaxFecha
|
|
|
|
Dim ConsultaPorSucursal As Boolean = UsuarioActual.Empresa.Funcionalidad(382) = "1"
|
|
|
|
If ConsultaPorSucursal Then
|
|
CveCorte = -1
|
|
FechaConsulta = gvr.DataKey("FechaInicial").ToDate()
|
|
End If
|
|
|
|
Dim ObjVentas As New ClsVentas
|
|
If ObjVentas.GetVta_ReporteCortesDetalle(CveCorte, DdlSubProyectos.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, Opcion:=2, ConsultaIVA:=UsuarioActual.CveEmpresa.Contiene(190, 192), FechaConsulta:=FechaConsulta) Then
|
|
Dim DsDatos = ObjVentas.DataSetResultados.Copy()
|
|
If DsDatos IsNot Nothing Then
|
|
'DESGLOSE
|
|
DtCortesVentas = DsDatos.Tables(0)
|
|
GvD.DataSource = DtCortesVentas
|
|
|
|
divDetalle.Visible = True
|
|
'RESUMEN
|
|
DtCortesVentasResumen = DsDatos.Tables(1)
|
|
GvP.DataSource = DtCortesVentasResumen
|
|
|
|
'RESUMEN - IVA
|
|
If UsuarioActual.CveEmpresa.Contiene(190, 192) AndAlso DsDatos.Tables.Count > 2 Then
|
|
DivIVA.Visible = True
|
|
GvPorIVA.DataSource = DsDatos.Tables(2)
|
|
Dim tsum As Decimal = DsDatos.Tables(2).SUMD("IVA16") + DsDatos.Tables(2).SUMD("IVA0")
|
|
If Math.Abs(tsum - DtCortesVentasResumen.MAX("Importe").ToDecimal) > 1 Then
|
|
GvPorIVA.ForeColor = Drawing.Color.Red
|
|
GvPorIVA.ToolTip = (tsum - DtCortesVentasResumen.MAX("Importe").ToDecimal).ToString
|
|
Else
|
|
GvPorIVA.ForeColor = Drawing.Color.Black
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
End If
|
|
|
|
If CveCorte > 0 Then
|
|
If ObjVentas.GetVta_MovimientosCajasReporte(CveCorte, -1, CveSubProyecto:=DdlSubProyectos.SelectedValue.ToEntero(), FechaConsulta:=FechaConsulta) Then
|
|
GvIngresosRetiros.DataSource = ObjVentas.DtResultados.Copy()
|
|
End If
|
|
End If
|
|
|
|
If Not UsuarioActual.CveEmpresa.Contiene(140, 141) AndAlso ObjVentas.GetCortesDetalleDepositosCaja(CveCorte, DdlSubProyectos.SelectedValue.ToEntero(), UsuarioActual.CveEmpresa, FechaConsulta:=FechaConsulta) Then
|
|
GvDep.DataSource = ObjVentas.DtResultados
|
|
If ObjVentas.DtResultados.Rows.Count > 0 Then
|
|
DivDep.Visible = True
|
|
End If
|
|
End If
|
|
ObjVentas.Dispose()
|
|
|
|
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}&FECHA={3}", CveCorte, "PDF", DdlSubProyectos.SelectedValue.ToEntero, FechaConsulta.ToString("yyyy-MM-dd"))))
|
|
HplDownEXCEL.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=CORT&CVECORTE={0}&FORMATO={1}&CVESUBPROYECTO={2}&FECHA={3}", CveCorte, "EXCEL", DdlSubProyectos.SelectedValue.ToEntero, FechaConsulta.ToString("yyyy-MM-dd"))))
|
|
Else
|
|
HplDownPDF.Visible = False
|
|
HplDownEXCEL.Visible = False
|
|
End If
|
|
|
|
GvD.DataBind()
|
|
GvP.DataBind()
|
|
GvDep.DataBind()
|
|
GvPorIVA.DataBind()
|
|
GvIngresosRetiros.DataBind()
|
|
|
|
If UsuarioActual.CveEmpresa.Contiene(189, 193, 195, 196, 197) Then
|
|
Dim CveCuenta As Integer = 0
|
|
'obtener relación contable
|
|
Dim objC As New ClsContabilidad
|
|
If objC.GetCuentasAsignaciones(UsuarioActual.CveEmpresa, 30) Then
|
|
'obtengo la cvecuentabancaria
|
|
Dim tCveBancoCuenta As Integer = GlobalDTBancosCuentasGral(UsuarioActual.CveEmpresa, Estatus:=-1, CveTipoCuenta:=1).FiltroPrimeroValor("CveCuenta", $"CveSubProyecto = {DdlSubProyectos.SelectedValue}").ToEntero
|
|
CveCuenta = objC.DtResultados.FiltroPrimeroValor("CveCuenta", $"CveBancoCuenta = {tCveBancoCuenta}").ToEntero
|
|
End If
|
|
objC.Dispose()
|
|
|
|
DivAnexo.Visible = True
|
|
|
|
'CveCuenta = If(UsuarioActual.CveEmpresa = 193, 186367, 0)
|
|
'If DdlSubProyectos.SelectedValue = "12756" Then 'nav
|
|
' CveCuenta = 188796
|
|
'End If
|
|
'If DdlSubProyectos.SelectedValue = "12755" Then 'hillo
|
|
' CveCuenta = 188795
|
|
'End If
|
|
'obtener la cuen
|
|
|
|
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
|