262 lines
8.9 KiB
VB.net
262 lines
8.9 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
Imports System.Collections.Generic
|
|
Imports System.Data
|
|
Imports Extensiones
|
|
Imports System.Activities.Statements
|
|
Imports Microsoft.Reporting.WebForms
|
|
Imports System
|
|
|
|
Partial Class Contabilidad_LibroDiario
|
|
Inherits ClsPaginas
|
|
|
|
#Region "PROPIEDADES"
|
|
Private Property DtDatos As DataTable
|
|
Get
|
|
DtDatos = DirectCast(ViewState("DtDatos"), DataTable)
|
|
End Get
|
|
|
|
Set(ByVal value As DataTable)
|
|
ViewState("DtDatos") = value
|
|
End Set
|
|
End Property
|
|
Private Property FechaInicio As Date
|
|
Get
|
|
FechaInicio = ViewState("FechaInicio").ToString.ToDate
|
|
End Get
|
|
Set(value As Date)
|
|
ViewState("FechaInicio") = value
|
|
End Set
|
|
End Property
|
|
Private Property FechaFin As Date
|
|
Get
|
|
FechaFin = ViewState("FechaFin").ToString.ToDate
|
|
End Get
|
|
Set(value As Date)
|
|
ViewState("FechaFin") = value
|
|
End Set
|
|
End Property
|
|
Private Property IdCuenta As Integer
|
|
Get
|
|
IdCuenta = ViewState("IdCuenta").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("IdCuenta") = value
|
|
End Set
|
|
End Property
|
|
#End Region
|
|
|
|
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
If Not Page.IsPostBack Then
|
|
|
|
InicializaValores()
|
|
|
|
BtnConsultar.Enabled = True
|
|
'If UsuarioActual.Empresa.UsaAC Then
|
|
' BtnConsultar.Enabled = True
|
|
'Else
|
|
' Alert("La empresa no usa Armonización Contable", TipoMensaje.MsgError)
|
|
'End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub InicializaValores()
|
|
|
|
TxtFechaDel.Text = $"01/01/{NowADS().Year}"
|
|
TxtFechaAl.Text = NowADS().ToShortDateString
|
|
End Sub
|
|
|
|
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs)
|
|
CargaDatos()
|
|
End Sub
|
|
|
|
#Region "C A R G A - D A T O S"
|
|
Private Sub CargaDatos()
|
|
|
|
FechaInicio = If(IsDate(TxtFechaDel.Text), TxtFechaDel.Text.ToDate, MinFecha)
|
|
FechaFin = If(IsDate(TxtFechaAl.Text), TxtFechaAl.Text.ToDate, MaxFecha)
|
|
|
|
'FechaInicio = New Date(2016, 1, 1)
|
|
'FechaFin = New Date(2016, 1, 31)
|
|
|
|
|
|
If UsuarioActual.Empresa.TipoContabilidad = 1 Then
|
|
|
|
Dim ObjConta As New ClsContabilidad
|
|
If ObjConta.GetLibroDiarioSIG(FechaInicio, FechaFin, UsuarioActual.CveEmpresa) Then
|
|
DtDatos = ObjConta.DtResultados
|
|
Else
|
|
DtDatos = Nothing
|
|
End If
|
|
ObjConta.Dispose()
|
|
|
|
Else
|
|
Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
|
|
If ObjConta.GetLibroDiario(FechaInicio, FechaFin) Then
|
|
DtDatos = ObjConta.DtResultados
|
|
Else
|
|
DtDatos = Nothing
|
|
End If
|
|
ObjConta.Dispose()
|
|
End If
|
|
|
|
|
|
|
|
|
|
If DtDatos IsNot Nothing Then
|
|
ImgExcel.Visible = True
|
|
Imprimir.Visible = True
|
|
CargaGrid()
|
|
Else
|
|
ImgExcel.Visible = False
|
|
Imprimir.Visible = False
|
|
End If
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region "G R I D - GV DATOS"
|
|
Private Sub CargaGrid()
|
|
GvDatos.DataSource = DtDatos
|
|
GvDatos.DataBind()
|
|
UpDatos.Update()
|
|
End Sub
|
|
Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatos.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
|
|
''CABECERA
|
|
'If e.Row.DBCampo("Concepto").ToString <> "" And e.Row.DBCampo("Id").ToString = "" Then
|
|
' e.Row.Font.Bold = True
|
|
' e.Row.Cells(4).Text = ""
|
|
' e.Row.Cells(5).Text = ""
|
|
' e.Row.Cells(6).Text = ""
|
|
' e.Row.Cells(7).Text = ""
|
|
' e.Row.Cells(8).Text = ""
|
|
' e.Row.CssClass = "SubTotales" '
|
|
'End If
|
|
|
|
''DETALLE
|
|
'If e.Row.DBCampo("Codigo").ToString <> "" Then
|
|
' e.Row.Cells(0).Text = ""
|
|
' e.Row.Cells(1).Text = ""
|
|
' e.Row.Cells(2).Text = ""
|
|
' e.Row.Cells(3).Text = ""
|
|
'End If
|
|
|
|
''SUBTOTAL
|
|
'If e.Row.DBCampo("Fecha").ToString <> "" And e.Row.DBCampo("Concepto").ToString = "" Then
|
|
' e.Row.Font.Bold = True
|
|
' e.Row.Cells(0).Text = ""
|
|
' e.Row.Cells(1).Text = ""
|
|
' e.Row.Cells(2).Text = ""
|
|
' e.Row.Cells(3).Text = ""
|
|
' e.Row.Cells(4).Text = ""
|
|
' e.Row.Cells(5).Text = ""
|
|
' e.Row.Cells(6).HorizontalAlign = HorizontalAlign.Right
|
|
' e.Row.Cells(6).Text = "Total:"
|
|
' e.Row.CssClass = "SubTotales"
|
|
'End If
|
|
|
|
''TOTAL
|
|
'If e.Row.DBCampo("Fecha").ToString = "" Then
|
|
' e.Row.Font.Bold = True
|
|
' e.Row.Cells(0).Text = ""
|
|
' e.Row.Cells(1).Text = ""
|
|
' e.Row.Cells(2).Text = ""
|
|
' e.Row.Cells(3).Text = ""
|
|
' e.Row.Cells(4).Text = ""
|
|
' e.Row.Cells(5).Text = ""
|
|
' e.Row.Cells(6).HorizontalAlign = HorizontalAlign.Right
|
|
' e.Row.Cells(6).Text = "Total:"
|
|
' e.Row.CssClass = "Totales"
|
|
'End If
|
|
|
|
'CABECERA
|
|
If e.Row.DBCampo("TipoRenglon").ToString.ToEntero = 1 Then
|
|
e.Row.Font.Bold = True
|
|
e.Row.Cells(4).Text = ""
|
|
e.Row.Cells(5).Text = ""
|
|
e.Row.Cells(6).Text = ""
|
|
e.Row.Cells(7).Text = ""
|
|
e.Row.Cells(8).Text = ""
|
|
e.Row.CssClass = "SubTotales" '
|
|
End If
|
|
|
|
'DETALLE
|
|
If e.Row.DBCampo("TipoRenglon").ToString.ToEntero = 2 Then
|
|
e.Row.Cells(0).Text = ""
|
|
e.Row.Cells(1).Text = ""
|
|
e.Row.Cells(2).Text = ""
|
|
e.Row.Cells(3).Text = ""
|
|
End If
|
|
|
|
'SUBTOTAL
|
|
If e.Row.DBCampo("TipoRenglon").ToString.ToEntero = 3 Then
|
|
e.Row.Font.Bold = True
|
|
e.Row.Cells(0).Text = ""
|
|
e.Row.Cells(1).Text = ""
|
|
e.Row.Cells(2).Text = ""
|
|
e.Row.Cells(3).Text = ""
|
|
e.Row.Cells(4).Text = ""
|
|
e.Row.Cells(5).Text = ""
|
|
e.Row.Cells(6).HorizontalAlign = HorizontalAlign.Right
|
|
e.Row.Cells(6).Text = "Total:"
|
|
e.Row.CssClass = "SubTotales"
|
|
End If
|
|
|
|
'TOTAL
|
|
If e.Row.DBCampo("TipoRenglon").ToString.ToEntero = 4 Then
|
|
e.Row.Font.Bold = True
|
|
e.Row.Cells(0).Text = ""
|
|
e.Row.Cells(1).Text = ""
|
|
e.Row.Cells(2).Text = ""
|
|
e.Row.Cells(3).Text = ""
|
|
e.Row.Cells(4).Text = ""
|
|
e.Row.Cells(5).Text = ""
|
|
e.Row.Cells(6).HorizontalAlign = HorizontalAlign.Right
|
|
e.Row.Cells(6).Text = "Total:"
|
|
e.Row.CssClass = "Totales"
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
#Region " IMPRIMIR "
|
|
|
|
Protected Sub Imprimir_click(sender As Object, e As EventArgs) Handles Imprimir.Click
|
|
'FechaInicio = If(TxtFechaDel.Text = "" Or TxtFechaDel.Text = "__/__/____", NowADS(), TxtFechaDel.Text.ToDate)
|
|
'FechaFin = If(TxtFechaAl.Text = "" Or TxtFechaAl.Text = "__/__/____", NowADS(), TxtFechaAl.Text.ToDate)
|
|
'DtDatos = DtDatos
|
|
ImprimirReporte()
|
|
End Sub
|
|
|
|
Protected Sub ImgExcel_Click(sender As Object, e As EventArgs) Handles ImgExcel.Click
|
|
'FechaInicio = If(TxtFechaDel.Text = "" Or TxtFechaDel.Text = "__/__/____", NowADS(), TxtFechaDel.Text.ToDate)
|
|
'FechaFin = If(TxtFechaAl.Text = "" Or TxtFechaAl.Text = "__/__/____", NowADS(), TxtFechaAl.Text.ToDate)
|
|
'DtDatos = DtDatos
|
|
ImprimirReporte("EXCEL")
|
|
End Sub
|
|
|
|
Private Sub ImprimirReporte(Optional Formato As String = "PDF")
|
|
Dim Imagen As New System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png")
|
|
'Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa)
|
|
|
|
Dim lista = New List(Of CrystalParametro)
|
|
lista.Add(New CrystalParametro("Empresa", UsuarioActual.Empresa.Empresa))
|
|
lista.Add(New CrystalParametro("FechaInicio", FechaInicio.ToString("dd/MM/yyyy")))
|
|
lista.Add(New CrystalParametro("FechaFin", FechaFin.ToString("dd/MM/yyyy")))
|
|
lista.Add(New CrystalParametro("UsuarioImprimio", UsuarioActual.Nombre))
|
|
lista.Add(New CrystalParametro("LogoPath", If(Imagen.Exists, $"file://{Imagen.FullName}", "")))
|
|
|
|
ImprimirbytesPDF(ImprimirPDFCrystal(Server.MapPath("~/Empresas/Grales/Formatos/LibroDiario.rpt"), DtDatos, lista, "LibroDiario", Formato), "LibroDiario", Formato)
|
|
End Sub
|
|
#End Region
|
|
|
|
End Class
|