From 3ca9d53df3577d4ecd27111a73ebbe507b36b646 Mon Sep 17 00:00:00 2001 From: Hector Javier Rodriguez Flores Date: Mon, 16 Aug 2021 13:05:30 -0700 Subject: [PATCH] Reporte Existencia Lote --- App_Code/ClsInventarios.vb | 28 ++ App_Code/ClsPaginas.vb | 1 + Inventarios/RepExistenciaLote.aspx | 164 ++++++++ Inventarios/RepExistenciaLote.aspx.vb | 514 ++++++++++++++++++++++++++ 4 files changed, 707 insertions(+) create mode 100644 Inventarios/RepExistenciaLote.aspx create mode 100644 Inventarios/RepExistenciaLote.aspx.vb diff --git a/App_Code/ClsInventarios.vb b/App_Code/ClsInventarios.vb index e72bfba0e..11949c8fb 100644 --- a/App_Code/ClsInventarios.vb +++ b/App_Code/ClsInventarios.vb @@ -1,6 +1,7 @@ Option Explicit On Option Strict On +Imports System Imports System.Data Imports System.Data.SqlClient Imports Extensiones @@ -1753,6 +1754,33 @@ Public Class ClsInventarios Return Retorno End Function + Public Function RepExistenciasLote(CveEmpresa As Integer, FechaI As Date, FechaF As Date, CveProveedor As Integer, Almacenes As String, + CvePS As Integer, CveClasificacion As Integer, Optional CveMarca As Integer = -1, Optional CveTipoAlmacen As String = "-1") As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Inv_RepExistenciaLote") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor + .Add("@Almacenes", SqlDbType.VarChar).Value = Almacenes + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + .Add("@CveMarca", SqlDbType.Int).Value = CveMarca + .Add("@CveTipoAlmacen", SqlDbType.VarChar).Value = CveTipoAlmacen + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener la lista de movimientos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function 'Nuevo R: 19/10/2017 Public Function RepMovimientosGen(CveEmpresa As Integer, FechaI As String, FechaF As String, CveProveedor As Integer, CveAlmacen As Integer, CvePS As Integer, CveClasificacion As Integer, Agrupador As Integer, Optional CveClasificacion2 As Integer = -1) As Boolean diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 24d24e0cd..0813cc12b 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -4716,6 +4716,7 @@ Public Class ClsPaginas PaginaDict.Add("/Inventarios/CatAlmacenClasificacionSecciones.aspx".ToUpper(), 764) PaginaDict.Add("/Inventarios/ReconstruirCostos.aspx".ToUpper(), 764) PaginaDict.Add("/Inventarios/RecepcionDevolucion.aspx".ToUpper(), 696) + PaginaDict.Add("/Inventarios/RepExistenciaLote.aspx".ToUpper(), 109) #End Region diff --git a/Inventarios/RepExistenciaLote.aspx b/Inventarios/RepExistenciaLote.aspx new file mode 100644 index 000000000..7967e6e56 --- /dev/null +++ b/Inventarios/RepExistenciaLote.aspx @@ -0,0 +1,164 @@ +<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="RepExistenciaLote.aspx.vb" Inherits="Inventarios_RepExistenciaLote" %> + + +
  • + Generar PDF +
  • +
  • + Generar Excel +
  • + + +
    + + + + + Reporte de Existencia Lote + + + + <%--Tabla con los campos para filtrar--%> + + +
    +
    +
    + + "> + +
    +
    +
    +
    Almacén
    +
    + +
    +
    Fecha Inicio
    +
    +
    + + + + +
    + + + + + + + + +
    + +
    Fecha Fin
    +
    +
    + + + + +
    + + + + + + +
    +
    + +
    +
    +
    > + +
    +
    Proveedor
    +
    + +
    +
    Clasificación
    +
    + +
    +
    PS
    +
    + + <%----%> +
    +
    +
    Marca
    +
    + +
    +
    +
    +
    + +
    Personal
    +
    + +
    + +
    Tipo Almacén:
    +
    + +
    + + + +
    +
    +
    +
    +
    + +
    +
    +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    +
    +
    + +
    +
    + + + + + + + + + + + + + +
    +
    +
    + + + + + diff --git a/Inventarios/RepExistenciaLote.aspx.vb b/Inventarios/RepExistenciaLote.aspx.vb new file mode 100644 index 000000000..685490a6f --- /dev/null +++ b/Inventarios/RepExistenciaLote.aspx.vb @@ -0,0 +1,514 @@ +Imports System.Data +Imports Extensiones +Imports Microsoft.Reporting.WebForms +Imports System.IO + +Partial Class Inventarios_RepExistenciaLote + Inherits ClsPaginas +#Region "propiedades" + 'Private ReadOnly Property reporteador As Microsoft.Reporting.WebForms.ReportViewer + ' Get + ' Return CType(Master.FindControl("ReportMaster"), Microsoft.Reporting.WebForms.ReportViewer) + ' End Get + 'End Property + Private Property dt As DataTable + Get + Try + dt = DirectCast(ViewState("dt"), DataTable) + Return DirectCast(ViewState("dt"), DataTable) + Catch ex As Exception + Return Nothing + End Try + End Get + Set(value As DataTable) + ViewState("dt") = value + End Set + End Property + Public Property DtEquivalencias() As DataTable + Get + Return CType(ViewState("dtReporte"), DataTable) + End Get + Set(value As DataTable) + ViewState("dtReporte") = value + End Set + End Property + Public Property FechaInicial As String + Get + Return ViewState("FechaInicial").ToString + End Get + Set(value As String) + ViewState("FechaInicial") = value + End Set + End Property + Public Property FechaFinal As String + Get + Return ViewState("FechaFinal").ToString + End Get + Set(value As String) + ViewState("FechaFinal") = value + End Set + End Property + + Private ReadOnly Property PermiteClasificacion2 As Boolean + Get + Return (UsuarioActual.CveEmpresa.Contiene(72, 80)) + End Get + End Property +#End Region + + Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load + If Not IsPostBack Then + + TxtFechaI.Text = Now.AddMonths(-1).ToShortDateString + TxtFechaF.Text = Now + FechaInicial = "-1" + FechaFinal = "-1" + + CargaCombos() + + GvM.DataBind() + If Not IsNothing(Request("CveAlmacen")) Then + DdlAlmacen.SelectedValue = Request("CveAlmacen").ToString() + TxtFechaI.Text = "01/01/2000" + If Not IsNothing(Request("FechaCorte")) Then + TxtFechaF.Text = Request("FechaCorte") + End If + + If Not IsNothing(Request("FechaInicio")) And IsDate(Request("FechaInicio")) Then + TxtFechaI.Text = Request("FechaInicio") + End If + + btConsultar_Click(Nothing, Nothing) + End If + End If + End Sub + + + Private Sub CargaCombos() + + + DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("") 'GlobalDTAlmacen(UsuarioActual.CveEmpresa) + DdlAlmacen.DataBind() + DdlAlmacen.Items.Insert(0, New ListItem("Todos", "-1")) + If Not IsNothing(Request("CveAlmacen")) Then + If DdlAlmacen.Items.FindByValue(Request("CveAlmacen").ToString) Is Nothing Then + Dim CveAlmacen = Request("CveAlmacen").ToString + Dim Almacen As String = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Almacen", $"CveAlmacen = {Request("CveAlmacen").ToString}") + DdlAlmacen.Items.Insert(0, New ListItem(Almacen, CveAlmacen)) + End If + Else + DdlAlmacen.SelectedValuesIfExistM("-1") + End If + + 'Llenar dropdownlist de proveedores + DdlProveedor.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa) + DdlProveedor.DataBind() + DdlProveedor.Items.Insert(0, New ListItem("Todos", "-1")) + + 'CARGA CLASIFICACIONES + Dim ObjClasificaciones As New ClsClasificaciones + If ObjClasificaciones.GetClasificacionesExistencias(UsuarioActual.CveEmpresa) Then + DdlClasificacion.DataSource = ObjClasificaciones.DtResultados + End If + ObjClasificaciones.Dispose() + DdlClasificacion.DataBind() + DdlClasificacion.Items.Insert(0, New ListItem("Todos", "-1")) + + + + + 'Carga Productos + DdlPS.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1") + + If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then + DdlPS.ddlWS.Attributes.Add("data-cveclasificacion", DdlClasificacion.SelectedValue) + DdlPS.SelectedText = "" + DdlPS.SelectedValue = "-1" + Else + DdlPS.ddl.Items.Clear() + DdlPS.ddl.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=DdlClasificacion.SelectedValue.ToEntero) + DdlPS.ddl.DataBind() + DdlPS.ddl.Items.Insert(0, New ListItem("Seleccione el Producto", "-1")) + End If + + + 'Llenar dropdownlist de personal + DdlPersonal.DataSource = GlobalDTRHPersonal(UsuarioActual.CveEmpresa) + DdlPersonal.DataBind() + DdlPersonal.Items.Insert(0, New ListItem("Todos", "-1")) + + CargarMarcas() + + DdlTipoAlmacen.DataSource = GlobalDTTipoAlmacen(1) + DdlTipoAlmacen.DataBind() + DdlTipoAlmacen.Items.Insert(0, New ListItem("Todos", "-1")) + + End Sub + + Protected Sub btConsultar_Click(sender As Object, e As EventArgs) Handles btConsultar.Click + CargaDatos() + End Sub + + Private Sub CargaDatos() + Dim Reporte As New ClsInventarios + Dim rpt As DataTable = Nothing + Dim CveMarca As Integer = -1 + + 'Dim fechaI As String = If(TxtFechaI.Text.Trim <> "" AndAlso TxtFechaI.Text <> "__/__/____", TxtFechaI.Text, "-1") + 'Dim fechaF As String = If(TxtFechaF.Text.Trim <> "" AndAlso TxtFechaF.Text <> "__/__/____", TxtFechaF.Text, "-1") + FechaInicial = If(TxtFechaI.Text.Trim <> "" AndAlso TxtFechaI.Text <> "__/__/____", TxtFechaI.Text, "-1") + FechaFinal = If(TxtFechaF.Text.Trim <> "" AndAlso TxtFechaF.Text <> "__/__/____", TxtFechaF.Text, "-1") + Dim TipoAlmacen As String = If(DdlTipoAlmacen.GetSelectedValuesM = "", "-1", DdlTipoAlmacen.GetSelectedValuesM) + Dim Almacenes As String = If(DdlAlmacen.GetSelectedValuesM = "", "-1", DdlAlmacen.GetSelectedValuesM) + + If UsuarioActual.Empresa.Funcionalidad(130) = "1" Then + CveMarca = DdlMarca.SelectedValue.ToEntero + End If + + If Reporte.RepExistenciasLote(UsuarioActual.CveEmpresa, FechaInicial.ToDate, FechaFinal.ToDate, DdlProveedor.SelectedValue.ToEntero, Almacenes, DdlPS.SelectedValue.ToEntero, + DdlClasificacion.SelectedValue.ToEntero, CveMarca, TipoAlmacen) Then + If Reporte.DtResultados.Rows.Count > 0 Then + GvM.DataSource = Reporte.DtResultados + GvM.DataBind() + ViewState("dtReporte") = Reporte.DtResultados + dt = Reporte.DtResultados + + End If + + + End If + Reporte.Dispose() + UPPMov.Update() + End Sub + + Protected Sub DdlClasificacion_SelectedIndexChanged(sender As Object, e As EventArgs) + If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then + DdlPS.ddlWS.Attributes.Add("data-cveclasificacion", DdlClasificacion.SelectedValue) + DdlPS.SelectedText = "" + DdlPS.SelectedValue = "-1" + Else + DdlPS.ddl.Items.Clear() + DdlPS.ddl.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=DdlClasificacion.SelectedValue.ToEntero) + DdlPS.ddl.DataBind() + DdlPS.ddl.Items.Insert(0, New ListItem("Seleccione el Producto", "-1")) + End If + End Sub + + Protected Sub GvM_RowCreated(sender As Object, e As GridViewRowEventArgs) Handles GvM.RowCreated + + 'If e.Row.RowType = DataControlRowType.Header Then + ' 'GENERO ENCABEZADO + ' Dim FC As New SortedList + ' FC.Add(0, "Código,1,2,Titulos") + + ' If ChkCodigoAlterno.Checked Then + ' FC.Add(1, "Código Alterno,1,2,Titulos") + ' End If + + ' FC.Add(10, "Descripción,1,2,Titulos") + ' FC.Add(20, "CANTIDAD,4,1,Titulos") + ' FC.Add(30, "IMPORTE,4,1,Titulos") + + ' Dim FC2 As New SortedList + ' FC2.Add(0, "Exist. inicial,1,1,Titulos") + ' FC2.Add(1, "Entradas,1,1S,Titulos") + ' FC2.Add(2, "Salidas,1,1,Titulos") + ' FC2.Add(3, "Exist. final,1,1,Titulos") + ' FC2.Add(4, "Saldo inicial,1,1,Titulos") + ' FC2.Add(5, "Entradas,1,1,Titulos") + ' FC2.Add(6, "Salidas,1,1,Titulos") + ' FC2.Add(7, "Saldo final,1,1,Titulos") + + ' GetMultiRowHeader(DirectCast(sender, GridView), e, FC2, "Titulosfijos") + ' GetMultiRowHeader(DirectCast(sender, GridView), e, FC, "Titulosfijos") + + ''End If + + End Sub + + Protected Sub gvMovimientos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvM.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + + + End If + End Sub + + +#Region "MARCA" + Protected Sub CargarMarcas() + + If UsuarioActual.Empresa.Funcionalidad(130) = "1" Then + DivMarca.Visible = True + + Dim ObjMarcas As New ClsProductosServicios + ObjMarcas.GetMarcas(UsuarioActual.CveEmpresa) + DdlMarca.DataSource = ObjMarcas.DtResultados + ObjMarcas.Dispose() + DdlMarca.DataBind() + End If + + DdlMarca.Items.Insert(0, New ListItem(" Todas ", "-1")) + End Sub +#End Region + + +#Region " EXPORTAR - PDF - EXCEL " + Private Sub LnkExportar_Click(sender As Object, e As EventArgs) Handles LnkExportar.Click + ' GvM.ExportToExcel("Reporte de Entradas y Salidas") + ImprimiReporte("EXCEL") + End Sub + Private Sub LnkImprimir_Click(sender As Object, e As EventArgs) Handles LnkImprimir.Click + ImprimiReporte() + End Sub + + Protected Sub ImprimiReporte(Optional Formato As String = "PDF", Optional FormatoInventario As Boolean = False) + + Dim RutaPDF As String + Dim NombreArchivoDescarga = "ReporteExistenciaLotes" + + RutaPDF = "Empresas/Grales/Formatos/RepExistenciaLotes.rdlc" + + + Dim params As New List(Of ReportParameter) + params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa)) + params.Add(New ReportParameter("LogoPath", New Uri(Server.MapPath(String.Format("~/Empresas/{0}/Logo.png", UsuarioActual.CveEmpresa))).AbsoluteUri)) + params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) + params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToShortDateString)) + + ImprimirPDF(RutaPDF, dt, params, NombreArchivoDescarga, Formato) + + End Sub + +#End Region + + + Protected Sub Lnkcompuxlsinventarios_Click(sender As Object, e As EventArgs) + Dim continuar = True + Try + + Dim wb As New ClosedXML.Excel.XLWorkbook() + Dim libro As ClosedXML.Excel.IXLWorksheet = wb.AddWorksheet("Reporte de inventarios") + + + + Dim Fila As Integer = 0 + libro.Range(libro.Cell(Fila + 1, 1), libro.Cell(Fila + 2, 7)).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(217, 225, 242)) + libro.Range(libro.Cell(Fila + 3, 1), libro.Cell(Fila + 3, 7)).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(0, 176, 80)) + libro.Cell(Fila + 3, 5).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(166, 166, 166)) + libro.Range(libro.Cell(Fila + 1, 1), libro.Cell(Fila + 3, 7)).Style.Border.InsideBorder = ClosedXML.Excel.XLBorderStyleValues.Thin + libro.Range(libro.Cell(Fila + 1, 1), libro.Cell(Fila + 3, 7)).Style.Border.OutsideBorder = ClosedXML.Excel.XLBorderStyleValues.Thin + libro.Column(1).Width = 34.43 + libro.Cell(Fila + 1, 1).Value = "TIPO DO REGISTRO" + libro.Cell(Fila + 2, 1).Value = "RECORD Type" + libro.Cell(Fila + 3, 1).Value = "OBLIGATORIO" + + libro.Column(2).Width = 24 + libro.Cell(Fila + 1, 2).Value = "Codigo del Partner" + libro.Cell(Fila + 2, 2).Value = "Reporter_id " + libro.Cell(Fila + 3, 2).Value = "OBLIGATORIO" + + libro.Column(3).Width = 28.71 + libro.Cell(Fila + 1, 3).Value = "Nombre de la Empresa" + libro.Cell(Fila + 2, 3).Value = "Reporter Company Name" + libro.Cell(Fila + 3, 3).Value = "OBLIGATORIO" + + libro.Column(4).Width = 23.57 + libro.Cell(Fila + 1, 4).Value = "CÓDIGO DEL PAÍS" + libro.Cell(Fila + 2, 4).Value = "COUNTRY CD" + libro.Cell(Fila + 3, 4).Value = "OBLIGATORIO" + + libro.Column(5).Width = 17.57 + libro.Cell(Fila + 1, 5).Value = "Ubicación" + libro.Cell(Fila + 2, 5).Value = "LOCATION" + libro.Cell(Fila + 3, 5).Value = "OPCIONAL" + + libro.Column(6).Width = 35.29 + libro.Cell(Fila + 1, 6).Value = "FECHA DEL INVENTARIO" + libro.Cell(Fila + 2, 6).Value = "Period End Date" + libro.Cell(Fila + 3, 6).Value = "OBLIGATORIO" + + libro.Column(7).Width = 23.43 + libro.Cell(Fila + 1, 7).Value = "REENVIO" + libro.Cell(Fila + 2, 7).Value = "RESUBMIT" + libro.Cell(Fila + 3, 7).Value = "OBLIGATORIO" + + libro.Column(8).Width = 29.29 + libro.Column(9).Width = 25 + libro.Column(10).Width = 18.14 + libro.Column(11).Width = 32.71 + libro.Column(12).Width = 13.57 + libro.Column(13).Width = 13 + libro.Column(14).Width = 32 + libro.Column(15).Width = 12.71 + libro.Column(16).Width = 13 + + + + Fila = Fila + 3 + + libro.Cell(Fila + 1, 1).Value = "IH" + libro.Cell(Fila + 1, 2).Value = "10245068" + libro.Cell(Fila + 1, 3).Value = "COMPUPROVEEDORES SA DE CV" + libro.Cell(Fila + 1, 4).Value = "MX" + libro.Cell(Fila + 1, 5).Value = "" + libro.Cell(Fila + 1, 6).Value = String.Format("{0:yyyyMMdd}", TxtFechaF.Text.ToDate()) + libro.Cell(Fila + 1, 7).Value = "N" + + + Fila = Fila + 1 + libro.Range(libro.Cell(Fila + 1, 1), libro.Cell(Fila + 2, 16)).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(217, 225, 242)) + libro.Range(libro.Cell(Fila + 3, 1), libro.Cell(Fila + 3, 16)).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(0, 176, 80)) + libro.Range(libro.Cell(Fila + 3, 3), libro.Cell(Fila + 3, 15)).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(166, 166, 166)) + libro.Cell(Fila + 3, 7).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(0, 176, 80)) + libro.Cell(Fila + 3, 10).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(0, 176, 80)) + libro.Range(libro.Cell(Fila + 1, 1), libro.Cell(Fila + 3, 16)).Style.Border.InsideBorder = ClosedXML.Excel.XLBorderStyleValues.Thin + libro.Range(libro.Cell(Fila + 1, 1), libro.Cell(Fila + 3, 16)).Style.Border.OutsideBorder = ClosedXML.Excel.XLBorderStyleValues.Thin + libro.Cell(Fila + 1, 1).Value = "TIPO DO REGISTRO" + libro.Cell(Fila + 1, 2).Value = "NÚMERO DEL PRODUCTO" + libro.Cell(Fila + 1, 3).Value = "OPCION DEL PRODUCTO" + libro.Cell(Fila + 1, 4).Value = "UPC" + libro.Cell(Fila + 1, 5).Value = "CODIGO SKU" + libro.Cell(Fila + 1, 6).Value = "ORDENES DE COMPRAS EN ABIERTO " + libro.Cell(Fila + 1, 7).Value = "INVENTARIO DISPONIBLE" + libro.Cell(Fila + 1, 8).Value = "DEVOLUCIONES" + libro.Cell(Fila + 1, 9).Value = "INVENTARIO RESERVADO" + libro.Cell(Fila + 1, 10).Value = "INVENTARIO TOTAL" + libro.Cell(Fila + 1, 11).Value = "EN TRANSITO" + libro.Cell(Fila + 1, 12).Value = "VALOR UNITARIO DEL PRODUCTO HP" + libro.Cell(Fila + 1, 13).Value = "VALOR TOTAL DEL INVENTARIO" + libro.Cell(Fila + 1, 14).Value = "NOMBRE DE LA TIENDA" + libro.Cell(Fila + 1, 15).Value = "Codigo de la tienda" + libro.Cell(Fila + 1, 16).Value = "MONEDA" + + Fila = Fila + 1 + libro.Cell(Fila + 1, 1).Value = "RECORD TYPE " + libro.Cell(Fila + 1, 2).Value = "Partner Reported Product ID" + libro.Cell(Fila + 1, 3).Value = "PROD_OPTION" + libro.Cell(Fila + 1, 4).Value = "UPC" + libro.Cell(Fila + 1, 5).Value = "Reseller product number " + libro.Cell(Fila + 1, 6).Value = "Quantity on Order" + libro.Cell(Fila + 1, 7).Value = "Quantity on Hand" + libro.Cell(Fila + 1, 8).Value = "Quantity in stock allocated to be returned to supplier" + libro.Cell(Fila + 1, 9).Value = "Reserved Inventory" + libro.Cell(Fila + 1, 10).Value = "Quantity avail. for sale" + libro.Cell(Fila + 1, 11).Value = "Quantity in float (In transit between partner warehouses)" + libro.Cell(Fila + 1, 12).Value = "INVENTORY UNIT VALUE" + libro.Cell(Fila + 1, 13).Value = "INVENTORY VALUATION" + libro.Cell(Fila + 1, 14).Value = "Sell from name (For retailers, ""Store Name / Site Name"")" + libro.Cell(Fila + 1, 15).Value = "Sell From Location ID" + libro.Cell(Fila + 1, 16).Value = "CURRENCY" + + Fila = Fila + 1 + libro.Cell(Fila + 1, 1).Value = "OBLIGATORIO" + libro.Cell(Fila + 1, 2).Value = "OBLIGATORIO" + libro.Cell(Fila + 1, 3).Value = "OPCIONAL" + libro.Cell(Fila + 1, 4).Value = "OPCIONAL" + libro.Cell(Fila + 1, 5).Value = "OPCIONAL" + libro.Cell(Fila + 1, 6).Value = "OPCIONAL" + libro.Cell(Fila + 1, 7).Value = "OBLIGATORIO" + libro.Cell(Fila + 1, 8).Value = "OPCIONAL" + libro.Cell(Fila + 1, 9).Value = "OPCIONAL" + libro.Cell(Fila + 1, 10).Value = "OBLIGATORIO" + libro.Cell(Fila + 1, 11).Value = "OPCIONAL" + libro.Cell(Fila + 1, 12).Value = "OPCIONAL" + libro.Cell(Fila + 1, 13).Value = "OPCIONAL" + libro.Cell(Fila + 1, 14).Value = "OPCIONAL" + libro.Cell(Fila + 1, 15).Value = "OPCIONAL" + libro.Cell(Fila + 1, 16).Value = "OBLIGATORIO" + + + If Not IsNothing(dt) AndAlso dt.Rows.Count > 0 Then + + For Each row As DataRow In dt.Select("CvePS>0 AND SaldoFCant >0") + + Fila = Fila + 1 + libro.Cell(Fila + 1, 1).Value = "ID" ' "TIPO DO REGISTRO" + libro.Cell(Fila + 1, 2).Value = String.Format("'{0}", row("Codigo")) ' "NÚMERO DEL PRODUCTO" + libro.Cell(Fila + 1, 3).Value = "" ' "OPCION DEL PRODUCTO" + libro.Cell(Fila + 1, 4).Value = "" ' "UPC" + libro.Cell(Fila + 1, 5).Value = "" ' "CODIGO SKU" + libro.Cell(Fila + 1, 6).Value = "" ' "ORDENES DE COMPRAS EN ABIERTO " + libro.Cell(Fila + 1, 7).Value = String.Format("{0}", row("SaldoFCant")) ' "INVENTARIO DISPONIBLE" + 'libro.Cell(Fila + 1, 7).Style.NumberFormat.Format = "N2" + libro.Cell(Fila + 1, 8).Value = "" ' "DEVOLUCIONES" + libro.Cell(Fila + 1, 9).Value = "" ' "INVENTARIO RESERVADO" + libro.Cell(Fila + 1, 10).Value = String.Format("{0}", row("SaldoFCant")) ' "INVENTARIO TOTAL" + 'libro.Cell(Fila + 1, 10).Style.NumberFormat.Format = "$ #,##0.00" + libro.Cell(Fila + 1, 11).Value = "" ' "EN TRANSITO" + libro.Cell(Fila + 1, 12).Value = "" ' "VALOR UNITARIO DEL PRODUCTO HP" + libro.Cell(Fila + 1, 13).Value = "" ' "VALOR TOTAL DEL INVENTARIO" + libro.Cell(Fila + 1, 14).Value = "" ' "NOMBRE DE LA TIENDA" + libro.Cell(Fila + 1, 15).Value = "" ' "Codigo de la tienda" + libro.Cell(Fila + 1, 16).Value = "MXN" ' "MONEDA" + Next + End If + + Fila = Fila + 1 + libro.Range(libro.Cell(Fila + 1, 1), libro.Cell(Fila + 2, 4)).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(217, 225, 242)) + libro.Range(libro.Cell(Fila + 3, 1), libro.Cell(Fila + 3, 4)).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(0, 176, 80)) + libro.Range(libro.Cell(Fila + 1, 1), libro.Cell(Fila + 3, 4)).Style.Border.InsideBorder = ClosedXML.Excel.XLBorderStyleValues.Thin + libro.Range(libro.Cell(Fila + 1, 1), libro.Cell(Fila + 3, 4)).Style.Border.OutsideBorder = ClosedXML.Excel.XLBorderStyleValues.Thin + libro.Cell(Fila + 1, 1).Value = "TIPO DEL REGISTRO" + libro.Cell(Fila + 1, 2).Value = "TOTAL DE REGISTROS" + libro.Cell(Fila + 1, 3).Value = "Suma del Inventario Disponible" + libro.Cell(Fila + 1, 4).Value = "Suma del Inventario Total" + + Fila = Fila + 1 + libro.Cell(Fila + 1, 1).Value = "RECORD TYPE" + libro.Cell(Fila + 1, 2).Value = "COUNT OF RECORDS" + libro.Cell(Fila + 1, 3).Value = "SUM OF “"On Hand”"" + libro.Cell(Fila + 1, 4).Value = "SUM OF “"Total Inventory"”" + + + Fila = Fila + 1 + libro.Cell(Fila + 1, 1).Value = "OBLIGATORIO" + libro.Cell(Fila + 1, 2).Value = "OBLIGATORIO" + libro.Cell(Fila + 1, 3).Value = "OBLIGATORIO" + libro.Cell(Fila + 1, 4).Value = "OBLIGATORIO" + + Dim Codigo As Double = 0 + Dim SaldoFCant As Double = 0 + Dim SaldoFImp As Double = 0 + If Not IsNothing(dt) AndAlso dt.Rows.Count > 0 Then + Codigo = dt.COUNT("Codigo", "CvePS>0") + SaldoFCant = dt.SUM("SaldoFCant", "CvePS>0") + SaldoFImp = dt.SUM("SaldoFImp", "CvePS>0") + End If + Fila = Fila + 1 + libro.Cell(Fila + 1, 1).Value = "IT" + libro.Cell(Fila + 1, 2).Value = String.Format("{0}", Codigo) + 'libro.Cell(Fila + 1, 2).Style.NumberFormat.Format = "N2" + libro.Cell(Fila + 1, 3).Value = String.Format("{0}", SaldoFCant) + 'libro.Cell(Fila + 1, 3).Style.NumberFormat.Format = "N2" + libro.Cell(Fila + 1, 4).Value = String.Format("{0}", SaldoFCant) + 'libro.Cell(Fila + 1, 4).Style.NumberFormat.Format = "$ #,##0.00" + + + ''Guarda streem y descarga + Dim fs As Stream = New MemoryStream() + wb.SaveAs(fs) + fs.Position = 0 + Dim memoryStream As New MemoryStream() + Using input As Stream = fs + input.CopyTo(memoryStream) + End Using + memoryStream.Position = 0 + + Response.Clear() + Response.Buffer = True + + Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" + Response.AddHeader("content-disposition", String.Format("attachment;filename={0}.xlsx", "Reporte de Inventarios HP")) + Response.BinaryWrite(memoryStream.ToArray()) + Response.End() + + ''endGuarda streem y descarga + Catch + + continuar = False + End Try + If Not continuar Then + Alert("Ocurrió un error al gener el excel", TipoMensaje.MsgAdvertencia) + End If + End Sub +End Class