diff --git a/App_Code/ClsInventarios.vb b/App_Code/ClsInventarios.vb index de4c0e719..28ddfee29 100644 --- a/App_Code/ClsInventarios.vb +++ b/App_Code/ClsInventarios.vb @@ -5178,6 +5178,48 @@ Public Class ClsInventarios Return Retorno End Function +#Region "Proyeccion" + Public Function AddMovimientosProyectados(CvePS As Integer, Cantidad As Decimal, TipoMovto As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("Inv_MovimientosProyectadosAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@Cantidad", SqlDbType.Money).Value = Cantidad + .Add("@TipoMovto", SqlDbType.TinyInt).Value = TipoMovto + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar la proyección.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function DeleteMovimientosProyectados(TipoMovto As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("Inv_MovimientosProyectadosDelete") + + With SqlAdapter.SelectCommand.Parameters + .Add("@TipoMovto", SqlDbType.TinyInt).Value = TipoMovto + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar la proyección.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function +#End Region + #Region "SUGERENCIAS SALIDA DE ALMACEN" Public Function GetSugerenciasSalidaAlmacen(CveVenta As Integer, CveAlmacen As Integer, CveEmpresa As Integer) As Boolean diff --git a/App_Code/DtDatos.xsd b/App_Code/DtDatos.xsd index 1a5c1befa..59b50901b 100644 --- a/App_Code/DtDatos.xsd +++ b/App_Code/DtDatos.xsd @@ -12,7 +12,7 @@ - + @@ -28,7 +28,7 @@ - + @@ -46,7 +46,7 @@ - + @@ -64,7 +64,7 @@ - + @@ -87,7 +87,7 @@ - + @@ -111,7 +111,7 @@ - + @@ -137,7 +137,7 @@ - + @@ -153,7 +153,7 @@ - + @@ -170,7 +170,7 @@ - + @@ -179,7 +179,7 @@ - + @@ -215,7 +215,7 @@ - + @@ -240,7 +240,7 @@ - + @@ -256,7 +256,7 @@ - + @@ -291,10 +291,11 @@ + - + @@ -304,7 +305,7 @@ - + diff --git a/App_Code/DtDatos.xss b/App_Code/DtDatos.xss index 7c380feb0..e18bb1b5a 100644 --- a/App_Code/DtDatos.xss +++ b/App_Code/DtDatos.xss @@ -4,7 +4,7 @@ Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. --> - + @@ -18,7 +18,7 @@ - + diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index 6109d4080..7da8d0e62 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -11,6 +11,7 @@ Imports System.IO Imports ADServerControl Imports System.Threading.Tasks Imports System.Diagnostics +Imports System.Text.RegularExpressions Partial Class Compras_Compras Inherits ClsPaginas @@ -20312,7 +20313,6 @@ Partial Class Compras_Compras Private Function VerificarProductosCompraConOC() As Boolean - Dim ProductosNoValidados As New StringBuilder() Dim DtCompras As New DataTable() @@ -20338,7 +20338,12 @@ Partial Class Compras_Compras Dim TipoPS As String = GvOCRow.DataKey("CveTipoPS") If TipoPS = "2" Then - Dim ProductoAisloadoString As String = GvOCRow.DataKey("PS").Split("-"c)(1).Trim() + Dim ProductoAisloadoString As String = "" + If CveFactura > 0 Then + ProductoAisloadoString = Regex.Replace(GvOCRow.DataKey("PS"), "^\d*\s-\s", "") + Else + ProductoAisloadoString = GvOCRow.DataKey("PS") + End If Dim PSOC As String = ProductoAisloadoString Dim CantidadOC As String = GvOCRow.DataKey("CantidadF") Dim PrecioUnitarioOC As String = GvOCRow.DataKey("Importe") diff --git a/Inventarios/KardexAlmacenHorizontal.aspx b/Inventarios/KardexAlmacenHorizontal.aspx index 1dc493670..d0a684ef8 100644 --- a/Inventarios/KardexAlmacenHorizontal.aspx +++ b/Inventarios/KardexAlmacenHorizontal.aspx @@ -92,6 +92,9 @@
  • Generar Excel
  • +
  • + +
  • @@ -188,7 +191,7 @@
    - +
    @@ -250,6 +253,40 @@ + diff --git a/Inventarios/KardexAlmacenHorizontal.aspx.vb b/Inventarios/KardexAlmacenHorizontal.aspx.vb index 7acdada23..21866757e 100644 --- a/Inventarios/KardexAlmacenHorizontal.aspx.vb +++ b/Inventarios/KardexAlmacenHorizontal.aspx.vb @@ -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