Commit inicial Ventas Productivo
This commit is contained in:
205
Ventas/AuxiliarCliente.aspx.vb
Normal file
205
Ventas/AuxiliarCliente.aspx.vb
Normal file
@@ -0,0 +1,205 @@
|
||||
Option Explicit On
|
||||
Option Strict On
|
||||
|
||||
Imports System.Data
|
||||
Imports System.IO
|
||||
Imports Extensiones
|
||||
|
||||
Partial Class Ventas_AuxiliarCliente
|
||||
Inherits ClsPaginas
|
||||
|
||||
#Region " PROPIEDADES"
|
||||
Private Property DtActivosFijos As DataTable
|
||||
Get
|
||||
Return CType(ViewState("DtActivosFijos"), DataTable)
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
ViewState("DtActivosFijos") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private ReadOnly Property CveActivoFijo As Integer
|
||||
Get
|
||||
Return ViewState("CveActivoFijo").ToString.ToEntero
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private Property DTAFCaracteristicas As DataTable
|
||||
Get
|
||||
Return CType(ViewState("DTAFCaracteristicas"), DataTable)
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
ViewState("DTAFCaracteristicas") = 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
|
||||
CargaFiltros()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Private Sub CargaFiltros()
|
||||
|
||||
If (UsuarioActual.Empresa.Funcionalidad(105) = "1") Then
|
||||
DdlClientes.setEsWebService(True)
|
||||
DdlClientes.Attributes.Add("data-metodo", "getcliente")
|
||||
DdlClientes.SelectedText = "Todos"
|
||||
DdlClientes.SelectedValue = "-1"
|
||||
Else
|
||||
DdlClientes.setEsWebService(False)
|
||||
DdlClientes.ddl.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa)
|
||||
DdlClientes.ddl.DataBind()
|
||||
DdlClientes.ddl.Items.Insert(0, New ListItem("Todos", "-1"))
|
||||
End If
|
||||
|
||||
'DdlConceptosContables.DataSource = GlobalDTContaConceptosContables(-1)
|
||||
'DdlConceptosContables.DataBind()
|
||||
'DdlConceptosContables.Items.Insert(0, New ListItem("Todos", "-1"))
|
||||
|
||||
|
||||
txtFechaI.Text = Now.AddDays(-30).ToString("dd/MM/yyyy")
|
||||
txtFechaF.Text = Now.ToString("dd/MM/yyyy")
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub CargaDatos()
|
||||
|
||||
Dim ObjConta As New ClsContabilidad
|
||||
|
||||
'Falta PA
|
||||
If ObjConta.GetClienteAuxiliar(DdlClientes.SelectedValue.ToEntero, -1, txtFechaI.Text.ToDate, txtFechaF.Text.ToDate, UsuarioActual.CveEmpresa, DdlOpcion.SelectedValue.ToEntero) Then
|
||||
If DdlOpcion.SelectedValue.ToEntero = 2 Then
|
||||
GvAuxCliente.DataSource = ObjConta.DtResultados.FiltraParametros($" IIF(ISNULL(CveConceptoContable,0) = 1 AND Importe >= 0,0,1) = 1")
|
||||
Else
|
||||
GvAuxCliente.DataSource = ObjConta.DtResultados
|
||||
End If
|
||||
Else
|
||||
GvAuxCliente.DataSource = Nothing
|
||||
End If
|
||||
|
||||
ObjConta.Dispose()
|
||||
|
||||
GvAuxCliente.DataBind()
|
||||
|
||||
UpDatos.Update()
|
||||
|
||||
End Sub
|
||||
|
||||
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs)
|
||||
CargaDatos()
|
||||
End Sub
|
||||
|
||||
Private Sub ImgExcel_Click(sender As Object, e As EventArgs) Handles ImgExcel.Click
|
||||
ExportToExcelGTest(GvAuxCliente, "Auxiliar" & DdlClientes.SelectedText & ".xlsx", "Auxiliar Clientes", UsuarioActual)
|
||||
End Sub
|
||||
|
||||
Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
|
||||
End Sub
|
||||
Public Sub ExportToExcelGTest(Gv As GridView, NombreArchivoXLSx As String, Optional Titulo As String = "Reporte", Optional Usuario As Usuario = Nothing)
|
||||
Dim sw As New StringWriter()
|
||||
Dim htw As New HtmlTextWriter(sw)
|
||||
Gv.RenderControl(htw)
|
||||
GemBox.Spreadsheet.SpreadsheetInfo.SetLicense("ESWN-4QFD-26JF-1SZ8")
|
||||
|
||||
Dim excel As GemBox.Spreadsheet.ExcelFile
|
||||
Dim options = GemBox.Spreadsheet.LoadOptions.HtmlDefault
|
||||
Using htmlStream = New MemoryStream(options.Encoding.GetBytes(sw.ToString()))
|
||||
excel = GemBox.Spreadsheet.ExcelFile.Load(htmlStream, options)
|
||||
If Usuario IsNot Nothing Then
|
||||
Dim worksheet = excel.Worksheets(0)
|
||||
Dim num As Integer = worksheet.Rows.Count
|
||||
If num > 128 Then num = 128
|
||||
|
||||
Dim columnCount = worksheet.CalculateMaxUsedColumns()
|
||||
'If columnCount > 1 Then
|
||||
' For i As Integer = 1 To columnCount - 1
|
||||
' worksheet.Columns(i).AutoFit(1, worksheet.Rows(1), worksheet.Rows(num - 1))
|
||||
' Next
|
||||
'End If
|
||||
|
||||
worksheet.Rows.InsertEmpty(0, 6)
|
||||
|
||||
Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", Usuario.Empresa.Ruta))
|
||||
Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Host, HttpContext.Current.Request.Url.Port, Usuario.CveEmpresa)
|
||||
|
||||
If Imagen.Exists Then
|
||||
worksheet.Pictures.Add(logouri.ToString(), "A1", "B4")
|
||||
End If
|
||||
|
||||
Dim celdasConTexto = worksheet.GetUsedCellRange(True)
|
||||
celdasConTexto.Style.Font.Name = "Calibri Light"
|
||||
|
||||
Dim RangoNombreEmpresa = worksheet.Cells.GetSubrangeAbsolute(1, celdasConTexto.FirstColumnIndex, 1, celdasConTexto.LastColumnIndex)
|
||||
RangoNombreEmpresa.Merged = True
|
||||
RangoNombreEmpresa.Value = Usuario.Empresa.Empresa
|
||||
RangoNombreEmpresa.Style.Font.Size = 18 * 20
|
||||
RangoNombreEmpresa.Style.Font.Name = "Calibri Light"
|
||||
RangoNombreEmpresa.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center
|
||||
RangoNombreEmpresa.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center
|
||||
|
||||
Dim RangoTitulo = worksheet.Cells.GetSubrangeAbsolute(3, celdasConTexto.FirstColumnIndex, 3, celdasConTexto.LastColumnIndex)
|
||||
RangoTitulo.Merged = True
|
||||
RangoTitulo.Value = Titulo
|
||||
RangoTitulo.Style.Font.Size = 20 * 20
|
||||
RangoTitulo.Style.Font.Name = "Calibri Light"
|
||||
RangoTitulo.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center
|
||||
RangoTitulo.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center
|
||||
|
||||
For i = celdasConTexto.FirstColumnIndex To celdasConTexto.LastColumnIndex
|
||||
worksheet.Rows(6).Cells(i).Style.Font.Size = 12 * 20
|
||||
worksheet.Rows(6).Cells(i).Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center
|
||||
worksheet.Rows(6).Cells(i).Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center
|
||||
worksheet.Rows(6).Cells(i).Style.FillPattern.SetPattern(GemBox.Spreadsheet.FillPatternStyle.Solid, GemBox.Spreadsheet.SpreadsheetColor.FromArgb(75, 119, 190), GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255))
|
||||
worksheet.Rows(6).Cells(i).Style.Font.Color = GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255)
|
||||
'If i > 0 Then
|
||||
' Try
|
||||
' worksheet.Columns(i).AutoFit(1)
|
||||
' Catch ex As Exception
|
||||
' End Try
|
||||
'End If
|
||||
Next
|
||||
|
||||
|
||||
Dim IndexEndTable As Integer = Gv.Rows.Count + 8
|
||||
|
||||
worksheet.Rows(IndexEndTable).Cells(2).Value = "Usuario Imprimió"
|
||||
worksheet.Rows(IndexEndTable + 1).Cells(2).Value = Usuario.Nombre
|
||||
|
||||
worksheet.Rows(IndexEndTable).Cells(6).Value = "Fecha Impresión"
|
||||
worksheet.Rows(IndexEndTable + 1).Cells(6).Value = DateTime.Now.ToString("dd/MM/yyyy")
|
||||
End If
|
||||
|
||||
End Using
|
||||
htw.Dispose()
|
||||
|
||||
excel.Save(HttpContext.Current.Response, NombreArchivoXLSx)
|
||||
|
||||
End Sub
|
||||
Protected Sub GvAuxCliente_RowDataBound(sender As Object, e As GridViewRowEventArgs)
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
If DdlOpcion.SelectedValue.ToEntero = 2 Then
|
||||
If Not e.Row.DBCampo("CveConceptoContable").ToEntero > 0 Then
|
||||
e.Row.CssClass = "Totales"
|
||||
Else
|
||||
e.Row.Cells(0).Text = ""
|
||||
e.Row.Cells(7).Text = ""
|
||||
End If
|
||||
End If
|
||||
If e.Row.DBCampo("TipoReferencia").ToEntero = 1 Then
|
||||
e.Row.FCHyperLink("HplReferencia").NavigateUrl = $"/Bancos/IE.aspx?CveIE={e.Row.DBCampo("CveReferencia")}"
|
||||
ElseIf e.Row.DBCampo("TipoReferencia").ToEntero = 2 Then
|
||||
e.Row.FCHyperLink("HplReferencia").NavigateUrl = $"/Ventas/Ventas.aspx?CveVenta={e.Row.DBCampo("CveReferencia")}"
|
||||
ElseIf e.Row.DBCampo("TipoReferencia").ToEntero = 3 Then
|
||||
e.Row.FCHyperLink("HplReferencia").NavigateUrl = $"/Compras/Compras.aspx?CveCompra={e.Row.DBCampo("CveReferencia")}"
|
||||
End If
|
||||
|
||||
If e.Row.DBCampo("CveConceptoContable").ToEntero = 1 AndAlso e.Row.DBCampo("Importe").ToString.ToDouble < 0 Then
|
||||
e.Row.ForeColor = Drawing.Color.Red
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user