Ajustes de seccion de almace

This commit is contained in:
2020-06-06 13:20:50 -07:00
parent e14db2ad9a
commit a1395defad
2 changed files with 68 additions and 14 deletions

View File

@@ -54,7 +54,7 @@
<br /> <br />
<asp:UpdatePanel runat="server" ID="UppD" UpdateMode="Conditional"> <asp:UpdatePanel runat="server" ID="UppD" UpdateMode="Conditional">
<ContentTemplate> <ContentTemplate>
<asp:GridView ID="GvD" DataKeyNames="CvePS,CveUM,CveAlmacen,PU,Existencia,Serie,CveSeccionAlmacen,FechaCaducidad,Lote" runat="server" AutoGenerateColumns="False" EmptyDataText="No hay movimientos pendientes" CssClass="table table-hover Widthall" GridLines="None"> <asp:GridView ID="GvD" DataKeyNames="CvePS,CveUM,CveAlmacen,PU,Existencia,Serie,SeccionAlmacen,CveSeccionAlmacen,FechaCaducidad,Lote,Codigo,PS" runat="server" AutoGenerateColumns="False" EmptyDataText="No hay movimientos pendientes" CssClass="table table-hover Widthall" GridLines="None">
<Columns> <Columns>
<asp:BoundField HeaderText="Producto" DataField="CodigoPS" /> <asp:BoundField HeaderText="Producto" DataField="CodigoPS" />
<asp:BoundField HeaderText="Serie" DataField="Serie" ItemStyle-Width="5%" /> <asp:BoundField HeaderText="Serie" DataField="Serie" ItemStyle-Width="5%" />

View File

@@ -1,6 +1,7 @@
 
Imports System.Data Imports System.Data
Imports Extensiones Imports Extensiones
Imports GemBox.Spreadsheet
Partial Class Inventarios_AjustesSeccionAlmacen Partial Class Inventarios_AjustesSeccionAlmacen
Inherits ClsPaginas Inherits ClsPaginas
@@ -145,21 +146,69 @@ Partial Class Inventarios_AjustesSeccionAlmacen
End Sub End Sub
Protected Sub BtnDescargar_Click(sender As Object, e As EventArgs) Handles LbDescargarExcel.Click, BtnDescargar.Click Protected Sub BtnDescargar_Click(sender As Object, e As EventArgs) Handles LbDescargarExcel.Click, BtnDescargar.Click
Dim Directorio As String = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\Formatos\FormatoAjusteSecCad.xlsx" If GvD.Rows.Count > 0 Then
Dim Archivo As New IO.FileInfo(Directorio) DescargarExcel()
If Archivo.Exists Then Else
Response.Clear() Dim Directorio As String = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\Formatos\FormatoAjusteSecCad.xlsx"
Response.ClearHeaders() Dim Archivo As New IO.FileInfo(Directorio)
Response.ClearContent() If Archivo.Exists Then
Response.AddHeader("Content-Disposition", "attachment; filename=" + Archivo.Name) Response.Clear()
Response.AddHeader("Content-Length", Archivo.Length.ToString()) Response.ClearHeaders()
Response.ContentType = "text/plain" Response.ClearContent()
Response.Flush() Response.AddHeader("Content-Disposition", "attachment; filename=" + Archivo.Name)
Response.TransmitFile(Archivo.FullName) Response.AddHeader("Content-Length", Archivo.Length.ToString())
Response.End() Response.ContentType = "text/plain"
Response.Flush()
Response.TransmitFile(Archivo.FullName)
Response.End()
End If
End If End If
End Sub End Sub
Private Sub DescargarExcel()
Dim DtExcel As DataTable = (From row As GridViewRow In GvD.Rows
Where row.RowType = DataControlRowType.DataRow
Select New With
{
.Cantidad = row.DataKey("Existencia"),
.Codigo = row.DataKey("Codigo"),
.PS = row.DataKey("PS"),
.SeccionAlmacen = row.DataKey("SeccionAlmacen"),
.Serie = row.DataKey("Serie"),
.Lote = row.DataKey("Lote"),
.FechaCaducidad = row.DataKey("FechaCaducidad")
}).QueryToDataTable(True)
If DtExcel.Rows.Count < 1 Then
Alert("No hay resutados en la busqueda.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
DtExcel.TableName = "Ajustes"
DtExcel.Columns("Codigo").ColumnName = "Código"
DtExcel.Columns("PS").ColumnName = "Producto/Servicio"
SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet)
Dim FileExcel As New ExcelFile()
Dim worksheet = FileExcel.Worksheets.Add(DtExcel.TableName)
worksheet.InsertDataTable(DtExcel, New InsertDataTableOptions() With
{
.ColumnHeaders = True,
.StartRow = 0,
.StartColumn = 0
})
worksheet.Rows(0).Style.FillPattern.SetPattern(FillPatternStyle.Solid, SpreadsheetColor.FromArgb(75, 119, 190), SpreadsheetColor.FromArgb(255, 255, 255))
worksheet.Rows(0).Style.Font.Color = SpreadsheetColor.FromArgb(255, 255, 255)
Dim columnCount = worksheet.CalculateMaxUsedColumns()
For i = 0 To columnCount
worksheet.Columns(i).AutoFit(1, worksheet.Rows(0), worksheet.Rows(worksheet.Rows.Count - 1))
Next
FileExcel.Save(Response, "FormatoAjusteSecCad.xlsx", SaveOptions.XlsxDefault)
End Sub
Protected Sub BtnCargaExcel_Click(sender As Object, e As EventArgs) Handles BtnCargaExcel.Click Protected Sub BtnCargaExcel_Click(sender As Object, e As EventArgs) Handles BtnCargaExcel.Click
If TxtExcel.getfiles().Archivos.Count > 0 Then If TxtExcel.getfiles().Archivos.Count > 0 Then
Dim file As Archivo = TxtExcel.getfiles().Archivos(0) Dim file As Archivo = TxtExcel.getfiles().Archivos(0)
@@ -257,7 +306,12 @@ Partial Class Inventarios_AjustesSeccionAlmacen
Dim CveUM As Integer = DrPS("CveUM").ToString().ToEntero() Dim CveUM As Integer = DrPS("CveUM").ToString().ToEntero()
Dim SeccionAlmacen As String = RowExcel("SeccionAlmacen").ToString.Trim Dim SeccionAlmacen As String = RowExcel("SeccionAlmacen").ToString.Trim
Dim CveSeccionAlmacen As Integer = dtSecciones.FiltroPrimeroValor("CveSeccion", $"SeccionAlmacen='{SeccionAlmacen}'") Dim CveSeccionAlmacen As Integer = -1
Dim DrSeccion As DataRow = dtSecciones.FiltroPrimero($"SeccionAlmacen='{SeccionAlmacen}'")
If DrSeccion IsNot Nothing Then
CveSeccionAlmacen = DrSeccion("CveSeccion").ToString().ToEntero()
End If
Dim Serie As String = RowExcel("Serie").ToString() Dim Serie As String = RowExcel("Serie").ToString()
Dim Lote As String = RowExcel("Lote").ToString() Dim Lote As String = RowExcel("Lote").ToString()