nuevo filtro y mecanica para nueva tabla en kardex horizontal
This commit is contained in:
@@ -337,6 +337,137 @@ Partial Class Inventarios_KardexAlmacen
|
||||
excel.Save(HttpContext.Current.Response, $"{NombreArchivoXLSx}.xlsx")
|
||||
|
||||
End Sub
|
||||
|
||||
Protected Sub LnkProyectos_Click(sender As Object, e As EventArgs)
|
||||
RegistraScript(String.Format("$('#{0}').modal();", "DivProyeccion"))
|
||||
End Sub
|
||||
|
||||
Protected Sub BtnDescargarFormato_Click(sender As Object, e As EventArgs)
|
||||
Dim Directorio As String = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\Formatos\KardexProyeccion.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 = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
||||
Response.Flush()
|
||||
Response.TransmitFile(Archivo.FullName)
|
||||
Response.End()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Protected Sub BtnAgregarProyeccion_Click(sender As Object, e As EventArgs)
|
||||
If TxtProyeccionExcel.getfiles().Archivos.Count > 0 Then
|
||||
Dim file As Archivo = TxtProyeccionExcel.getfiles().Archivos(0)
|
||||
Dim Directorio As String = Server.MapPath("~") & file.patch
|
||||
Dim Tipo As String = If(file.Extencion.Contiene("xlsx", "xlsx", "xlsm", "xlsb"), "EXCEL", "CSV")
|
||||
CargarArchivo(Directorio, file.filename, Tipo)
|
||||
Else
|
||||
Alert("No existe el archivo.Favor de subir un archivo csv o excel a la plataforma", TipoMensaje.MsgError)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub CargarArchivo(Ruta As String, FileName As String, Tipo As String)
|
||||
Dim dt As New DataTable
|
||||
dt = ReadExcelFile(Ruta + FileName, True)
|
||||
If Not dt.Columns(0).ColumnName = "Código" Then
|
||||
Alert("La primera columna del archivo debe ser 'Código'", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
If Not dt.Columns(1).ColumnName = "Cantidad" Then
|
||||
Alert("La primera columna del archivo debe ser 'Cantidad'", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
AgregarProyeccion(dt)
|
||||
End Sub
|
||||
|
||||
Private Sub AgregarProyeccion(dt As DataTable)
|
||||
Dim TieneError As Boolean = False
|
||||
Dim ObjInventarios As New ClsInventarios
|
||||
ObjInventarios.IniciaTransacSQL()
|
||||
|
||||
Dim TipoMovot As Integer = If(RblProyeccionOpcion.SelectedValue = "1", 0, 1)
|
||||
|
||||
If ObjInventarios.DeleteMovimientosProyectados(TipoMovot) Then
|
||||
Dim DtProductosEmpresas As DataTable = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa)
|
||||
For Each dtRow As DataRow In dt.Rows
|
||||
Dim Codigo As String = dtRow("Código").ToString
|
||||
Dim CvePS As Integer = DtProductosEmpresas.FiltroPrimeroValor("CvePS", String.Format("Codigo = '{0}'", Codigo))
|
||||
Dim Cantidad As Decimal = dtRow("Cantidad").ToString.ToDecimal
|
||||
If Not ObjInventarios.AddMovimientosProyectados(CvePS, Cantidad, RblProyeccionOpcion.SelectedValue.ToEntero()) Then
|
||||
TieneError = True
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
Else
|
||||
TieneError = True
|
||||
End If
|
||||
|
||||
If TieneError Then
|
||||
ObjInventarios.RollBack()
|
||||
Else
|
||||
ObjInventarios.Commit()
|
||||
End If
|
||||
ObjInventarios.Dispose()
|
||||
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivProyeccion"))
|
||||
Alert("Se ha agregado la proyección de productos correctamente")
|
||||
End Sub
|
||||
|
||||
Private Function ReadExcelFile(ByVal flatFilePath As String, ByVal firstRowHasHeaders As Boolean) As DataTable
|
||||
SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet)
|
||||
Dim excelFile As ExcelFile = ExcelFile.Load(flatFilePath)
|
||||
|
||||
Dim unnamed As Integer = 0
|
||||
Dim cols As Integer
|
||||
Dim columns As String()
|
||||
Dim curRow As Integer = 0
|
||||
Dim curCol As Integer = 0
|
||||
Dim dataTable As DataTable = New DataTable()
|
||||
Dim worksheet As ExcelWorksheet = excelFile.Worksheets(0)
|
||||
|
||||
For cols = 0 To worksheet.Rows(0).AllocatedCells.Count - 1
|
||||
|
||||
If firstRowHasHeaders Then
|
||||
|
||||
If worksheet.Rows(0).Cells(cols).Value IsNot Nothing Then
|
||||
dataTable.Columns.Add(worksheet.Rows(0).Cells(cols).Value.ToString().Trim)
|
||||
Else
|
||||
dataTable.Columns.Add("Unnamed Column " & (System.Threading.Interlocked.Increment(unnamed)))
|
||||
End If
|
||||
|
||||
curRow = 1
|
||||
Else
|
||||
dataTable.Columns.Add("Column " & (cols + 1))
|
||||
End If
|
||||
|
||||
Next
|
||||
|
||||
While curRow < worksheet.Rows.Count
|
||||
|
||||
columns = New String(cols - 1) {}
|
||||
|
||||
For curCol = 0 To cols - 1
|
||||
|
||||
If worksheet.Rows(curRow).Cells(curCol).Value Is Nothing Then
|
||||
columns(curCol) = ""
|
||||
Else
|
||||
columns(curCol) = worksheet.Rows(curRow).Cells(curCol).Value.ToString()
|
||||
End If
|
||||
|
||||
Next
|
||||
|
||||
dataTable.Rows.Add(columns)
|
||||
curRow += 1
|
||||
|
||||
End While
|
||||
|
||||
Return dataTable
|
||||
|
||||
End Function
|
||||
Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user