Commit inicial Ventas Productivo

This commit is contained in:
JORGE LUIS CAUDILLO ESPARZA
2019-08-14 16:40:54 -07:00
commit c35cf91883
13328 changed files with 3711549 additions and 0 deletions

View File

@@ -0,0 +1,270 @@
Option Explicit On
Option Strict On
Imports System.Data
Imports Extensiones
Imports Microsoft.Reporting.WebForms
Partial Class Contabilidad_RepBalanzaComprobacion
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
Private Property ModoImpresion As Boolean
Get
ModoImpresion = CType(ViewState("ModoImpresion"), Boolean)
End Get
Set(value As Boolean)
ViewState("ModoImpresion") = 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
Dim ErrorParametros = True
ModoImpresion = False
TxtFechaDel.Text = DateSerial(Year(Now), Month(Now), 1).ToShortDateString
TxtFechaAl.Text = Date.Now.ToShortDateString
If UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.UsaContabilidad Then
BtnConsultar.Enabled = True
If Request("ID") IsNot Nothing AndAlso IsNumeric(Request("ID")) AndAlso Request("ID").ToEntero > 0 Then
'If Request("FI") IsNot Nothing AndAlso Request("FI").ToString.Length = 10 AndAlso Request("FI").ToDate > "01/01/1000".ToDate Then
If Request("FF") IsNot Nothing AndAlso Request("FF").ToString.Length = 10 AndAlso Request("FF").ToDate > "01/01/1000".ToDate Then
IdCuenta = Request("ID").ToEntero
'FechaInicio = Request("FI").ToDate
FechaFin = Request("FF").ToDate
FechaInicio = DateSerial(Year(FechaFin), Month(FechaFin), 1)
ErrorParametros = False
End If
'End If
End If
If Not ErrorParametros Then
CargaDatos()
End If
If IsNothing(DtDatos) Then
FechaInicio = If(TxtFechaDel.Text = "" Or TxtFechaDel.Text = "__/__/____", Date.Now, TxtFechaDel.Text.ToDate)
FechaFin = If(TxtFechaAl.Text = "" Or TxtFechaAl.Text = "__/__/____", Date.Now, TxtFechaAl.Text.ToDate)
CargaDatos()
End If
Else
Alert("La empresa no usa Armonización Contable o Contabilidad.", TipoMensaje.MsgAdvertencia)
End If
End If
End Sub
#Region "CARGA DATOS Y GRID"
Private Sub CargaDatos()
Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
If ObjConta.GetBalanzaComprobacion(FechaInicio, FechaFin, DdlTipoCuentas.SelectedValue.ToEntero) Then
DtDatos = ObjConta.DtResultados
CargaGrid()
Else
DtDatos = Nothing
Alert("Ocurrio un error al cargar los datos del Anexo del Catálogo", TipoMensaje.MsgError)
End If
ObjConta.Dispose()
End Sub
Private Sub CargaGrid()
GvDatos.DataSource = DtDatos
GvDatos.DataBind()
UpDatos.Update()
End Sub
#End Region
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs)
FechaInicio = If(TxtFechaDel.Text = "" Or TxtFechaDel.Text = "__/__/____", Date.Now, TxtFechaDel.Text.ToDate)
FechaFin = If(TxtFechaAl.Text = "" Or TxtFechaAl.Text = "__/__/____", Date.Now, TxtFechaAl.Text.ToDate)
CargaDatos()
RegistraScript("Enable();")
End Sub
Protected Sub GvIngresos_RowDataBound(sender As Object, e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.DBCampo("CtaMayor") = "1" Or e.Row.DBCampo("CtaMayor") = "1" Then
e.Row.ControlStyle.Font.Bold = True
End If
'Acomoda Deudor y Acreedor
If e.Row.DBCampo("CveTipo") = "1" Then
e.Row.FCLabel("LbSaldoInicial").Text = String.Format("{0} ", e.Row.DBCampo("SaldoInicial").FormatoNumero)
e.Row.FCLabel("LbSaldoActual").Text = " "
End If
'Colorea NEGATIVOS
If e.Row.DBCampo("SaldoInicial").ToString.ToDouble < 0 Then
e.Row.FCLabel("LbSaldoInicial").ForeColor = Drawing.Color.Red
End If
If e.Row.DBCampo("Cargos").ToString.ToDouble < 0 Then
e.Row.FCLabel("LbCargos").ForeColor = Drawing.Color.Red
End If
If e.Row.DBCampo("Abonos").ToString.ToDouble < 0 Then
e.Row.FCLabel("LbAbonos").ForeColor = Drawing.Color.Red
End If
If e.Row.DBCampo("SaldoActual").ToString.ToDouble < 0 Then
e.Row.FCHyperLink("HLSaldoActual").ForeColor = Drawing.Color.Red
End If
'Total general
If e.Row.DBCampo("Id") = "" Then
e.Row.ControlStyle.Font.Bold = True
e.Row.ControlStyle.Font.Size = 9
e.Row.ControlStyle.Height = 30
e.Row.FCLabel("LbNombre").Text = "Sumas Iguales"
e.Row.FCLabel("LbSaldoInicial").Text = String.Format("{0} <br/>{1}", e.Row.DBCampo("SaldoID").FormatoNumero, e.Row.DBCampo("SaldoIA").FormatoNumero)
e.Row.FCLabel("LbCargos").Text = e.Row.DBCampo("TotalCargos").FormatoNumero
e.Row.FCLabel("LbAbonos").Text = e.Row.DBCampo("TotalAbonos").FormatoNumero
e.Row.FCLabel("LbSaldoActual").Visible = True
e.Row.FCLabel("LbSaldoActual").Text = String.Format("{0} <br/>{1}", e.Row.DBCampo("SaldoAD").FormatoNumero, e.Row.DBCampo("SaldoAA").FormatoNumero)
Else
If ModoImpresion Then e.Row.Cells(5).Text = e.Row.FCHyperLink("HLSaldoActual").Text Else e.Row.FCHyperLink("HLSaldoActual").NavigateUrl = String.Format("/Contabilidad/RepMovimientosAuxiliaresCatalogo.aspx?ID={0}&FF={1}", e.Row.DBCampo("ID"), FechaFin.ToShortDateString)
End If
End If
End Sub
Protected Sub BtnImprimir_Click(sender As Object, e As EventArgs) Handles BtnImprimir.Click
ModoImpresion = True
CargaGrid()
FechaInicio = If(TxtFechaDel.Text = "" Or TxtFechaDel.Text = "__/__/____", Date.Now, TxtFechaDel.Text.ToDate)
FechaFin = If(TxtFechaAl.Text = "" Or TxtFechaAl.Text = "__/__/____", Date.Now, TxtFechaAl.Text.ToDate)
'RegistraScript("Enable();")
GenerarPDFCrystal()
'Using sw As New StringWriter()
' Using hw As New HtmlTextWriter(sw)
' Dim style As StringBuilder = New StringBuilder()
' style.Append("<style> ")
' style.Append(File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory & "Styles\EstilosExcel.css"))
' style.Append(" </style> ")
' 'To Export all pages
' 'Gv.AllowPaging = False
' 'Gv.DataBind()
' Tbl.RenderControl(hw)
' Dim sr As New StringReader(sw.ToString())
' Dim pdfDoc As New Document(PageSize.A2, 10.0F, 10.0F, 10.0F, 0.0F)
' Dim htmlparser As New HTMLWorker(pdfDoc)
' PdfWriter.GetInstance(pdfDoc, Response.OutputStream)
' pdfDoc.Open()
' htmlparser.Parse(sr)
' pdfDoc.Close()
' Response.ContentType = "application/pdf"
' Response.AddHeader("content-disposition", "attachment;filename=BalanzaComprobacion.pdf")
' Response.Cache.SetCacheability(HttpCacheability.NoCache)
' Response.Write(style.ToString)
' Response.Write(pdfDoc)
' Response.[End]()
' End Using
'End Using
End Sub
'No quitar porque no funciona el exporta PDF
Public Overrides Sub VerifyRenderingInServerForm(control As Control)
' Verifies that the control is rendered
End Sub
Protected Sub ImgExcel_Click(sender As Object, e As EventArgs) Handles ImgExcel.Click
'GvDatos.ExportToExcel("BalanzaComprobacion")
ModoImpresion = True
CargaGrid()
FechaInicio = If(TxtFechaDel.Text = "" Or TxtFechaDel.Text = "__/__/____", Date.Now, TxtFechaDel.Text.ToDate)
FechaFin = If(TxtFechaAl.Text = "" Or TxtFechaAl.Text = "__/__/____", Date.Now, TxtFechaAl.Text.ToDate)
'RegistraScript("Enable();")
GenerarPDFCrystal("EXCEL")
End Sub
Private Sub GenerarPDFCrystal(Optional Formato As String = "PDF")
Dim Archivo As New System.IO.FileInfo(String.Format("{0}Contabilidad/Reportes/RepBalanzaComprobacion.rpt", UsuarioActual.Empresa.Ruta))
Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta))
Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa)
If Not IsNothing(DtDatos) Then
'Dim dr As DataRow = DtCxC.Rows(0)
Dim lista = New List(Of CrystalParametro)
lista.Add(New CrystalParametro("pEmp", UsuarioActual.Empresa.Empresa))
lista.Add(New CrystalParametro("pFechaFin", FechaFin.ToString("dd/MM/yyyy")))
lista.Add(New CrystalParametro("pFechaIni", FechaInicio.ToString("dd/MM/yyyy")))
If Imagen.Exists Then
lista.Add(New CrystalParametro("pImg", logouri))
Else
lista.Add(New CrystalParametro("pImg", ""))
End If
ImprimirbytesPDF(ImprimirPDFCrystal(Server.MapPath("~/Contabilidad/Reportes/RepBalanzaComprobacion.rpt"), DtDatos, lista, "Balanza de Comprobación", Formato), "Balanza de Comprobación", Formato)
Else
Alert("No se tienen registrados movimientos", TipoMensaje.MsgAdvertencia)
End If
End Sub
'Private Sub ImprimirReporte(Optional Formato As String = "PDF")
' 'ubicacion del rdlc
' Dim reportpath As String = "Contabilidad/Reportes/RepBalanzaComprobacion.rdlc"
' 'nombre del reporte
' Dim fileName As String = "BalanzaComprobacion"
' 'parametros a enviar al reporte
' Dim params As New List(Of ReportParameter)
' params.Add(New ReportParameter("pEmp", UsuarioActual.Empresa.Empresa))
' params.Add(New ReportParameter("pImg", New Uri(Server.MapPath(String.Format("~/Empresas/{0}/Logo.png", UsuarioActual.CveEmpresa))).AbsoluteUri))
' params.Add(New ReportParameter("pFechaFin", FechaFin.ToString("dd/MM/yyyy")))
' params.Add(New ReportParameter("pFechaIni", FechaInicio.ToString("dd/MM/yyyy")))
' ImprimirPDF(reportpath, DtDatos, params, fileName, Formato)
'End Sub
End Class