747 lines
35 KiB
VB.net
747 lines
35 KiB
VB.net
Imports System.Data
|
|
Imports Extensiones
|
|
Imports Microsoft.Reporting.WebForms
|
|
Imports System.IO
|
|
|
|
Partial Class Inventarios_ReporteEntradasSalidas
|
|
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
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then
|
|
DivFamiliaSubFamilia.Visible = True
|
|
End If
|
|
|
|
If UsuarioActual.CveEmpresa.Contiene(119) Then
|
|
LnkFormatoInventario.Visible = True
|
|
End If
|
|
|
|
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
|
|
CargaPermisos()
|
|
CargaGvBitacora()
|
|
Lnkcompuxlsinventarios.Visible = UsuarioActual.CveEmpresa = 72
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CargaPermisos()
|
|
Dim TienePermisoImportes As Boolean = UsuarioActual.TienePermisoProceso(201)
|
|
|
|
dvImp.Visible = TienePermisoImportes
|
|
GvM.Columns(10).Visible = TienePermisoImportes
|
|
GvM.Columns(11).Visible = TienePermisoImportes
|
|
GvM.Columns(12).Visible = TienePermisoImportes
|
|
GvM.Columns(13).Visible = TienePermisoImportes
|
|
GvM.Columns(14).Visible = TienePermisoImportes
|
|
|
|
End Sub
|
|
Private Sub CargaCombos()
|
|
|
|
DdlTipoMovimiento.DataSource = GlobalDTInvConceptos()
|
|
DdlTipoMovimiento.DataBind()
|
|
DdlTipoMovimiento.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
|
|
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
|
|
End If
|
|
|
|
'Llenar dropdownlist de monedas
|
|
DdlMoneda.DataSource = GlobalDTMonedas
|
|
DdlMoneda.DataBind()
|
|
DdlMoneda.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
|
|
'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"))
|
|
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then
|
|
DdlFamilia.DataSource = GlobalDTFamilias(UsuarioActual.CveEmpresa)
|
|
DdlFamilia.DataBind()
|
|
End If
|
|
DdlFamilia.Items.Insert(0, New ListItem("Todas", "-1"))
|
|
DdlSubFamilia.Items.Insert(0, New ListItem("Todas", "-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
|
|
|
|
DdlMovs.SelectedValue = "2"
|
|
|
|
'Llenar dropdownlist de personal
|
|
DdlPersonal.DataSource = GlobalDTRHPersonal(UsuarioActual.CveEmpresa)
|
|
DdlPersonal.DataBind()
|
|
DdlPersonal.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
|
|
|
|
DdlClasificacion2.DataSource = GlobalDTClasificaciones2(UsuarioActual.CveEmpresa)
|
|
DdlClasificacion2.DataBind()
|
|
DdlClasificacion2.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
DdlClasificacion2.SelectedValueExist("-1")
|
|
'BLOQUEA DDL CLASIFICACION
|
|
DivClaisficacionLabel.Visible = PermiteClasificacion2
|
|
DdlClasificacion2.Visible = PermiteClasificacion2
|
|
TdModalClasificacion2.Visible = PermiteClasificacion2
|
|
|
|
CargarMarcas()
|
|
|
|
|
|
DdlTipoAlmacen.DataSource = GlobalDTTipoAlmacen(1)
|
|
DdlTipoAlmacen.DataBind()
|
|
DdlTipoAlmacen.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
|
|
End Sub
|
|
Protected Sub DdlFamilia_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
DdlSubFamilia.DataSource = GlobalDTSubFamilias(UsuarioActual.CveEmpresa, DdlFamilia.SelectedValue.ToEntero)
|
|
DdlSubFamilia.DataBind()
|
|
DdlSubFamilia.Items.Insert(0, New ListItem("Todas", "-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)
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(130) = "1" Then
|
|
CveMarca = DdlMarca.SelectedValue.ToEntero
|
|
End If
|
|
|
|
If Reporte.RepMovimientos(UsuarioActual.CveEmpresa, DdlMoneda.SelectedValue.ToEntero, FechaInicial, FechaFinal, DdlTipoMovimiento.SelectedValue.ToEntero, DdlProveedor.SelectedValue.ToEntero,
|
|
DdlAlmacen.SelectedValue.ToEntero, DdlFamilia.SelectedValue.ToEntero, DdlSubFamilia.SelectedValue.ToEntero, DdlPS.SelectedValue.ToEntero, DdlClasificacion.SelectedValue.ToEntero,
|
|
DdlMovs.SelectedValue.ToEntero, CveMarca, CvePersonal:=DdlPersonal.SelectedValue.ToEntero, CveClasificacion2:=DdlClasificacion2.SelectedValue.ToEntero, CveTipoAlmacen:=TipoAlmacen,
|
|
Modalidad:=DdlModalidadFiltro.SelectedValue.ToEntero) Then
|
|
dt = Reporte.DtResultados
|
|
|
|
|
|
GvM.DataSource = dt
|
|
ViewState("dtReporte") = dt
|
|
rpt = dt
|
|
End If
|
|
|
|
|
|
Reporte.Dispose()
|
|
GvM.DataBind()
|
|
|
|
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
|
|
If e.Row.DBCampo("CvePS").ToEntero <= 0 Then
|
|
e.Row.CssClass = "Totales"
|
|
Else
|
|
e.Row.Cells(9).BackColor = Drawing.Color.LightGray
|
|
e.Row.Cells(13).BackColor = Drawing.Color.LightGray
|
|
|
|
'e.Row.FCLabel("lbSaldoI").Text = If(e.Row.DBCampo("SaldoIniCant").ToString().ToEntero = 0, "-", e.Row.DBCampo("SaldoIniCant").ToDouble.ToString("N2"))
|
|
'e.Row.FCLabel("lbEntradasCant").Text = If(e.Row.DBCampo("EntradaCant").ToString().ToEntero = 0, "-", e.Row.DBCampo("EntradaCant").ToDouble.ToString("N2"))
|
|
'e.Row.FCLabel("lbSalidasCant").Text = If(e.Row.DBCampo("SalidaCant").ToString().ToEntero = 0, "-", e.Row.DBCampo("SalidaCant").ToDouble.ToString("N2"))
|
|
'e.Row.FCLabel("lbSaldoF").Text = If(e.Row.DBCampo("SaldoFCant").ToString().ToEntero = 0, "-", e.Row.DBCampo("SaldoFCant").ToDouble.ToString("N2"))
|
|
e.Row.FCLabel("lbSaldoI2").Text = If(e.Row.DBCampo("SaldoIniImp").ToString().ToDecimal = 0, "-", e.Row.DBCampo("SaldoIniImp").ToDouble.ToString("N2"))
|
|
e.Row.FCLabel("lbEntradaImp").Text = If(e.Row.DBCampo("EntradaImp").ToString().ToDecimal = 0, "-", e.Row.DBCampo("EntradaImp").ToDouble.ToString("N2"))
|
|
e.Row.FCLabel("lbSalidaImp").Text = If(e.Row.DBCampo("SalidaImp").ToString().ToDecimal = 0, "-", e.Row.DBCampo("SalidaImp").ToDouble.ToString("N2"))
|
|
e.Row.FCLabel("lbSaldoF2").Text = If(e.Row.DBCampo("SaldoFImp").ToString().ToDecimal = 0, "-", e.Row.DBCampo("SaldoFImp").ToDouble.ToString("N2"))
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
'Protected Sub gv_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles Gv.RowDataBound
|
|
' If e.Row.RowType = DataControlRowType.DataRow Then
|
|
' If e.Row.DBCampo("CvePS").ToEntero = -1 Then
|
|
|
|
' e.Row.Cells(3).Text = ""
|
|
' e.Row.Cells(4).Text = ""
|
|
' e.Row.Cells(5).Text = ""
|
|
' e.Row.CssClass = "SubTotales"
|
|
' e.Row.Height = 22
|
|
|
|
' End If
|
|
' 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 FechaI As String = FechaInicial
|
|
Dim FechaF As String = FechaFinal
|
|
|
|
Dim Almacen = If(DdlAlmacen.SelectedValue = "-1", "", $" <b>Almacén:</b> {DdlAlmacen.SelectedItem.Text}")
|
|
Dim TipoMov = If(DdlTipoMovimiento.SelectedValue = "-1", "", $" <b>Tipo Movimiento:</b> {DdlTipoMovimiento.SelectedItem.Text}")
|
|
Dim Moneda = If(DdlMoneda.SelectedValue = "-1", "", $" <b>Moneda:</b> {DdlMoneda.SelectedItem.Text}")
|
|
Dim SoloConMov = If(DdlMovs.SelectedValue = "-1", "", $" <b>Solo Movimientos:</b> {DdlMovs.SelectedItem.Text}")
|
|
Dim Proveedor = If(DdlProveedor.SelectedValue = "-1", "", $" <b>Proveedor:</b> {DdlProveedor.SelectedItem.Text}")
|
|
Dim Clasificacion = If(DdlClasificacion.SelectedValue = "-1", "", $" <b>Clasificación:</b> {DdlClasificacion.SelectedItem.Text}")
|
|
Dim Familia = If(DdlFamilia.SelectedValue = "-1", "", $" <b>Familia:</b> {DdlFamilia.SelectedItem.Text}")
|
|
Dim SubFamilia = If(DdlSubFamilia.SelectedValue = "-1", "", $" <b>SubFamilia:</b> {DdlSubFamilia.SelectedItem.Text}")
|
|
Dim PS = If(DdlPS.SelectedValue = "-1", "", $" <b>PS:</b> {DdlPS.SelectedText}")
|
|
Dim FechaIn As String = $" <b>Fecha Inicio:</b> {TxtFechaI.Text}"
|
|
Dim FechaFn As String = $" <b>Fecha Fin:</b> {TxtFechaF.Text}"
|
|
If TxtFechaI.Text = "" Then FechaIn = ""
|
|
If TxtFechaF.Text = "" Then FechaFn = ""
|
|
|
|
If FechaI = "-1" Then
|
|
FechaI = "01-01-0001"
|
|
End If
|
|
If FechaF = "-1" OrElse FechaFinal.ToDate > Now.ToDate Then
|
|
FechaF = Now
|
|
End If
|
|
Dim RutaPDF As String
|
|
Dim Ruta As String = $"{AppDomain.CurrentDomain.BaseDirectory}Empresas\{UsuarioActual.CveEmpresa}\"
|
|
Dim NombreArchivoDescarga = "ReporteEntradas-Salidas"
|
|
|
|
If UsuarioActual.CveEmpresa.Contiene(119) Then
|
|
|
|
If FormatoInventario Then
|
|
RutaPDF = $"{Ruta}\Formatos\FormatoAlmacen.rdlc"
|
|
NombreArchivoDescarga = "Formato Inventario"
|
|
Else
|
|
If DdlTipoMovimiento.SelectedValue.ToEntero = 2 Then
|
|
RutaPDF = $"{Ruta}\Formatos\EntradaAlmacen.rdlc"
|
|
ElseIf DdlTipoMovimiento.SelectedValue.ToEntero = 3 Then
|
|
RutaPDF = $"{Ruta}\Formatos\SalidaAlmacen.rdlc"
|
|
Else
|
|
RutaPDF = $"{Ruta}\Formatos\EntradasSalidas.rdlc"
|
|
End If
|
|
End If
|
|
Else
|
|
RutaPDF = $"{Ruta}\Formatos\EntradasSalidas.rdlc"
|
|
End If
|
|
|
|
If Not File.Exists(RutaPDF) Then
|
|
RutaPDF = "Empresas/Grales/Formatos/EntradasSalidas.rdlc"
|
|
End If
|
|
|
|
Dim params As New List(Of ReportParameter)
|
|
params.Add(New ReportParameter("pEmp", UsuarioActual.Empresa.Empresa))
|
|
params.Add(New ReportParameter("pImg", 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))
|
|
If FormatoInventario Then
|
|
params.Add(New ReportParameter("Sucursal", DdlAlmacen.SelectedItem.Text))
|
|
params.Add(New ReportParameter("Bodega", DdlAlmacen.SelectedItem.Text))
|
|
Else
|
|
params.Add(New ReportParameter("FechaInicial", FechaI))
|
|
params.Add(New ReportParameter("FechaFinal", FechaF))
|
|
params.Add(New ReportParameter("AgrupadoPor", $"{Almacen}{TipoMov}{Moneda}{SoloConMov}{Proveedor}{Clasificacion}{Familia}{SubFamilia}{PS}{FechaIn}{FechaFn}"))
|
|
End If
|
|
ImprimirPDF(RutaPDF, If(FormatoInventario, dt.FiltraParametros("", "RazonSocial, PS ASC"), dt), params, NombreArchivoDescarga, Formato:=Formato)
|
|
|
|
End Sub
|
|
Private Sub BtnPersonalizar_Click(sender As Object, e As EventArgs) Handles BtnPersonalizar.Click
|
|
RegistraScript("$('#DivPersonalizar').modal('hide')")
|
|
GvM.Columns(1).Visible = ChkCodigoAlterno.Checked
|
|
GvM.Columns(2).Visible = ChkCodigoBarras.Checked
|
|
GvM.Columns(3).Visible = ChkClasificacion2.Checked
|
|
GvM.Columns(5).Visible = ChkSeccionAlmacen.Checked
|
|
|
|
GvM.Columns(15).Visible = ChkFechaUltimaCompra.Checked
|
|
GvM.Columns(16).Visible = ChkFechaUltimaVenta.Checked
|
|
|
|
'GvM.Columns(4).Visible = ChkSeccionAlmacen.Checked
|
|
If ChkSeccionAlmacen.Checked OrElse ChkCodigoBarras.Checked OrElse ChkCodigoAlterno.Checked Then
|
|
dvArt.Style.Add("width", "39%")
|
|
dvCan.Style.Add("width", "25%")
|
|
|
|
If ChkFechaUltimaCompra.Checked OrElse ChkFechaUltimaVenta.Checked Then
|
|
dvArt.Style.Add("width", "34%")
|
|
dvCan.Style.Add("width", "23%")
|
|
End If
|
|
|
|
If ChkFechaUltimaCompra.Checked AndAlso ChkFechaUltimaVenta.Checked Then
|
|
dvArt.Style.Add("width", "32%")
|
|
dvCan.Style.Add("width", "22%")
|
|
|
|
End If
|
|
|
|
ElseIf ChkClasificacion2.Checked Then
|
|
dvArt.Style.Add("width", "38%")
|
|
dvCan.Style.Add("width", "26%")
|
|
|
|
If ChkFechaUltimaCompra.Checked Or ChkFechaUltimaVenta.Checked Then
|
|
dvArt.Style.Add("width", "35%")
|
|
dvCan.Style.Add("width", "22%")
|
|
|
|
End If
|
|
|
|
Else
|
|
If ChkFechaUltimaCompra.Checked OrElse ChkFechaUltimaVenta.Checked Then
|
|
dvArt.Style.Add("width", "30%")
|
|
dvCan.Style.Add("width", "26%")
|
|
dvImp.Style.Add("width", "44%")
|
|
|
|
End If
|
|
If ChkFechaUltimaCompra.Checked And ChkFechaUltimaVenta.Checked Then
|
|
dvArt.Style.Add("width", "28%")
|
|
dvCan.Style.Add("width", "25%")
|
|
dvImp.Style.Add("width", "50%")
|
|
End If
|
|
End If
|
|
|
|
|
|
If (ChkSeccionAlmacen.Checked AndAlso ChkCodigoBarras.Checked) Then
|
|
dvArt.Style.Add("width", "50%")
|
|
dvCan.Style.Add("width", "21%")
|
|
ElseIf (ChkSeccionAlmacen.Checked AndAlso ChkCodigoAlterno.Checked) Then
|
|
dvArt.Style.Add("width", "42%")
|
|
dvCan.Style.Add("width", "22%")
|
|
ElseIf (ChkCodigoBarras.Checked AndAlso ChkCodigoAlterno.Checked) Then
|
|
dvArt.Style.Add("width", "45%")
|
|
dvCan.Style.Add("width", "22%")
|
|
End If
|
|
|
|
If (ChkSeccionAlmacen.Checked AndAlso ChkCodigoBarras.Checked AndAlso ChkCodigoAlterno.Checked) Then
|
|
dvArt.Style.Add("width", "54%")
|
|
dvCan.Style.Add("width", "22%")
|
|
ElseIf (Not ChkSeccionAlmacen.Checked AndAlso Not ChkCodigoBarras.Checked AndAlso Not ChkCodigoAlterno.Checked AndAlso Not ChkFechaUltimaCompra.Checked AndAlso Not ChkFechaUltimaVenta.Checked) Then
|
|
dvArt.Style.Add("width", "32%")
|
|
dvCan.Style.Add("width", "30%")
|
|
End If
|
|
|
|
If (ChkSeccionAlmacen.Checked AndAlso ChkCodigoBarras.Checked AndAlso ChkCodigoAlterno.Checked AndAlso ChkClasificacion2.Checked) Then
|
|
dvArt.Style.Add("width", "62%")
|
|
dvCan.Style.Add("width", "21%")
|
|
End If
|
|
|
|
CargaDatos()
|
|
UpEncabezado.Update()
|
|
End Sub
|
|
|
|
Private Sub LnkFormatoInventario_Click(sender As Object, e As EventArgs) Handles LnkFormatoInventario.Click
|
|
ImprimiReporte("EXCEL", True)
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "B I T A C O R A"
|
|
Private Sub CargaGvBitacora()
|
|
Dim ObjGral As New ClsGenerales
|
|
If ObjGral.GetHistorialBitacoraRemoveGet("Inventarios", UsuarioActual.CveEmpresa) Then
|
|
GvBitacora.DataSource = ObjGral.DtResultados
|
|
ObjGral.Dispose()
|
|
End If
|
|
GvBitacora.DataBind()
|
|
End Sub
|
|
|
|
Private Sub BtnMostrar_Click(sender As Object, e As EventArgs) Handles BtnMostrar.Click
|
|
GvBitacora.Visible = True
|
|
BtnOcultar.Visible = True
|
|
BtnMostrar.Visible = False
|
|
UpBitacora.Update()
|
|
End Sub
|
|
|
|
Private Sub BtnOcultar_Click(sender As Object, e As EventArgs) Handles BtnOcultar.Click
|
|
GvBitacora.Visible = False
|
|
BtnOcultar.Visible = False
|
|
BtnMostrar.Visible = True
|
|
UpBitacora.Update()
|
|
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("SaldoFImp")) ' "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}", SaldoFImp)
|
|
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
|