-- mejora
This commit is contained in:
@@ -5,16 +5,19 @@ Imports System.Data
|
||||
Imports System.IO
|
||||
Imports System.IO.Compression
|
||||
Imports System.Net.Http
|
||||
Imports System.Windows.Forms
|
||||
Imports ADSTimbrado
|
||||
Imports DocumentFormat.OpenXml.Spreadsheet
|
||||
Imports Extensiones
|
||||
Imports GemBox.Spreadsheet
|
||||
|
||||
Imports iText.Barcodes.Dmcode
|
||||
|
||||
Partial Class Ventas_FacturacionAcarreos
|
||||
Inherits ClsPaginas
|
||||
|
||||
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
||||
If Not Page.IsPostBack Then
|
||||
txtFechaI.Text = NowADS.FirstDayOfMonth().ToShortDateString
|
||||
CargaDatos()
|
||||
End If
|
||||
If IfNull(Request("OP"), "").ToString = "File" Then
|
||||
@@ -30,7 +33,7 @@ Partial Class Ventas_FacturacionAcarreos
|
||||
CveCliente = DdlClientes.SelectedValue.ToEntero()
|
||||
End If
|
||||
Using ObjVentas As New ClsVentas
|
||||
If ObjVentas.GetFacturacionAcarreos(-1, CveCliente, -1, DdlEstatus.SelectedValue.ToEntero(), NowADS(), UsuarioActual.CveEmpresa) Then
|
||||
If ObjVentas.GetFacturacionAcarreos(-1, CveCliente, -1, DdlEstatus.SelectedValue.ToEntero(), txtFechaI.Text.ToDate, UsuarioActual.CveEmpresa) Then
|
||||
GvDatos.DataSource = ObjVentas.DtResultados
|
||||
End If
|
||||
End Using
|
||||
@@ -133,7 +136,7 @@ Partial Class Ventas_FacturacionAcarreos
|
||||
FechaLlegada = row("FechaLlegada").ToString().ToDateTime().AddHours(14)
|
||||
End If
|
||||
|
||||
Dim Chofer, Configuracion, Remolque1, Remolque2 As String
|
||||
Dim Folio, FolioAdicional, Remolque1, Remolque2 As String
|
||||
Dim dtu As DataRow = GlobalDTInvCamiones(UsuarioActual.CveEmpresa).FiltroPrimero($"Placa = '{row("Unidad")}'")
|
||||
If dtu IsNot Nothing Then
|
||||
'Chofer = dtu("Chofer").ToString
|
||||
@@ -141,15 +144,15 @@ Partial Class Ventas_FacturacionAcarreos
|
||||
Remolque1 = dtu("Remolque1").ToString
|
||||
Remolque2 = dtu("Remolque2").ToString
|
||||
Else
|
||||
Chofer = "" : Configuracion = "" : Remolque1 = "" : Remolque2 = ""
|
||||
Folio = "" : FolioAdicional = "" : Remolque1 = "" : Remolque2 = ""
|
||||
End If
|
||||
|
||||
'temporal
|
||||
Chofer = row("Folio").ToString
|
||||
Configuracion = row("HojaServicio").ToString
|
||||
Folio = row("Folio").ToString
|
||||
FolioAdicional = row("HojaServicio").ToString
|
||||
|
||||
Dim msg As String = ObjVentas.AddFacturacionAcarreos(row("Sucursal").ToString(), row("RFC").ToString(), row("Cantidad").ToString().ToDecimal(), row("ProductoGeneral").ToString(), row("Origen").ToString(),
|
||||
row("Destino").ToString(), FechaSalida, FechaLlegada, row("Unidad").ToString(), Chofer, Configuracion,
|
||||
row("Destino").ToString(), FechaSalida, FechaLlegada, row("Unidad").ToString(), Folio, FolioAdicional,
|
||||
Remolque1, Remolque2, row("Distancia").ToString().ToDecimal(), UsuarioActual.CveEmpresa)
|
||||
If msg = "Correcto" Then
|
||||
RowsCargados += 1
|
||||
@@ -216,6 +219,11 @@ Partial Class Ventas_FacturacionAcarreos
|
||||
Dim ArchivoDestino As String = String.Format("{0}Temp/{1}", UsuarioActual.Empresa.Ruta, NombreArchivo)
|
||||
Dim HuboInexistentes As Boolean = False
|
||||
Dim archiveZip As ZipArchive = ZipFile.Open(ArchivoDestino, ZipArchiveMode.Create)
|
||||
Dim dtt As New DataTable
|
||||
dtt.Columns.Add("Cantidad", GetType(String))
|
||||
dtt.Columns.Add("Boleta", GetType(String))
|
||||
dtt.Columns.Add("HojaServicio", GetType(String))
|
||||
dtt.Columns.Add("SerieFolio", GetType(String))
|
||||
|
||||
For Each GvRow As GridViewRow In GvDatos.Rows
|
||||
If GvRow.RowType = DataControlRowType.DataRow Then
|
||||
@@ -252,6 +260,13 @@ Partial Class Ventas_FacturacionAcarreos
|
||||
If Not resp.TieneError Then
|
||||
If resp.SerieFolio <> String.Empty Then
|
||||
msgDescarga.AppendFormat("{0},", resp.SerieFolio)
|
||||
Dim drr As DataRow = dtt.NewRow
|
||||
drr("Cantidad") = GvRow.DataKey("Cantidad")
|
||||
drr("Boleta") = GvRow.DataKey("Folio")
|
||||
drr("HojaServicio") = GvRow.DataKey("FolioAdicional")
|
||||
drr("SerieFolio") = resp.SerieFolio
|
||||
dtt.Rows.Add(drr)
|
||||
|
||||
DescargarFactura(resp.CveVenta, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario)
|
||||
Archivo = String.Format("{0}PDF/ING/{1}.pdf", UsuarioActual.Empresa.Ruta.Replace("\", "/"), resp.SerieFolio)
|
||||
If File.Exists(Archivo) Then
|
||||
@@ -276,9 +291,18 @@ Partial Class Ventas_FacturacionAcarreos
|
||||
archiveZip.Dispose()
|
||||
If NumFacturasGeneradas > 0 Then
|
||||
Dim stt As String = $"Se generaron {NumFacturasGeneradas} y se timbraron {NumFacturasTimbradas} facturas. <br/>"
|
||||
Dim nombreexcel As String = "AcarreosListado.xlsx"
|
||||
Dim rutaexcel As String = UsuarioActual.Empresa.Ruta & "\Temp\" & nombreexcel
|
||||
GemBox.Spreadsheet.SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet)
|
||||
Dim workbook As New ExcelFile()
|
||||
Dim worksheet As ExcelWorksheet = workbook.Worksheets.Add("Acarreos")
|
||||
worksheet.InsertDataTable(dtt, New InsertDataTableOptions() With {.ColumnHeaders = True})
|
||||
workbook.Save(rutaexcel)
|
||||
|
||||
If msgDescarga.Length > 0 Then
|
||||
stt += String.Format("<a target='_blank' class='Texto' href='/Ventas/FacturacionAcarreos.aspx?OP=File&File={0}'>Descarga zip</a>", NombreArchivo)
|
||||
stt += String.Format("<a target='_blank' class='Texto' href='/Ventas/FacturacionAcarreos.aspx?OP=File&File={0}'>Descarga xml/pdf</a>", NombreArchivo)
|
||||
End If
|
||||
stt += String.Format("<br/><a target='_blank' class='Texto' href='/Ventas/FacturacionAcarreos.aspx?OP=File&File={0}'>Descarga excel</a>", nombreexcel)
|
||||
Alert(stt, TipoMensaje.MsgInformacion)
|
||||
|
||||
Else
|
||||
|
||||
Reference in New Issue
Block a user