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 />
<asp:UpdatePanel runat="server" ID="UppD" UpdateMode="Conditional">
<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>
<asp:BoundField HeaderText="Producto" DataField="CodigoPS" />
<asp:BoundField HeaderText="Serie" DataField="Serie" ItemStyle-Width="5%" />

View File

@@ -1,6 +1,7 @@

Imports System.Data
Imports Extensiones
Imports GemBox.Spreadsheet
Partial Class Inventarios_AjustesSeccionAlmacen
Inherits ClsPaginas
@@ -145,21 +146,69 @@ Partial Class Inventarios_AjustesSeccionAlmacen
End Sub
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"
Dim Archivo As New IO.FileInfo(Directorio)
If Archivo.Exists Then
Response.Clear()
Response.ClearHeaders()
Response.ClearContent()
Response.AddHeader("Content-Disposition", "attachment; filename=" + Archivo.Name)
Response.AddHeader("Content-Length", Archivo.Length.ToString())
Response.ContentType = "text/plain"
Response.Flush()
Response.TransmitFile(Archivo.FullName)
Response.End()
If GvD.Rows.Count > 0 Then
DescargarExcel()
Else
Dim Directorio As String = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\Formatos\FormatoAjusteSecCad.xlsx"
Dim Archivo As New IO.FileInfo(Directorio)
If Archivo.Exists Then
Response.Clear()
Response.ClearHeaders()
Response.ClearContent()
Response.AddHeader("Content-Disposition", "attachment; filename=" + Archivo.Name)
Response.AddHeader("Content-Length", Archivo.Length.ToString())
Response.ContentType = "text/plain"
Response.Flush()
Response.TransmitFile(Archivo.FullName)
Response.End()
End If
End If
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
If TxtExcel.getfiles().Archivos.Count > 0 Then
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 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 Lote As String = RowExcel("Lote").ToString()