159 lines
6.4 KiB
VB.net
159 lines
6.4 KiB
VB.net
Option Strict On
|
|
Option Explicit On
|
|
|
|
Imports System.Data
|
|
Imports Extensiones
|
|
Imports Microsoft.Reporting.WebForms
|
|
|
|
Partial Class RepMovimientosRep
|
|
Inherits ClsPaginas
|
|
|
|
#Region " PROPIEDADES "
|
|
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
|
|
|
|
Private Property DtMovimientos As DataTable
|
|
Get
|
|
Return DirectCast(ViewState("DtMovimientos"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtMovimientos") = value
|
|
End Set
|
|
End Property
|
|
#End Region
|
|
|
|
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
If Not IsPostBack Then
|
|
|
|
InicializaValores()
|
|
|
|
End If
|
|
End Sub
|
|
|
|
|
|
#Region " INICIALIZA VALORES "
|
|
Private Sub InicializaValores()
|
|
TxtFechaF.Text = Date.Now.ToShortDateString
|
|
TxtFechaI.Text = Now.FirstDayOfMonth.ToShortDateString
|
|
|
|
TxtFechaIngFin.Text = Date.Now.ToShortDateString
|
|
TxtFechaIngInicio.Text = Now.FirstDayOfMonth.ToShortDateString
|
|
|
|
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"))
|
|
|
|
DdlUsuarios.DataSource = GlobalDTUsuarios(CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros("", "Nombre")
|
|
DdlUsuarios.DataBind()
|
|
DdlUsuarios.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region " CARGA DATOS "
|
|
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 FechaInicial = If(TxtFechaI.Text.Trim <> "" AndAlso TxtFechaI.Text <> "__/__/____", TxtFechaI.Text.ToDate, MinFecha)
|
|
Dim FechaFinal = If(TxtFechaF.Text.Trim <> "" AndAlso TxtFechaF.Text <> "__/__/____", TxtFechaF.Text.ToDate, MaxFecha)
|
|
Dim FechaIngI = If(TxtFechaIngInicio.Text.Trim <> "" AndAlso TxtFechaIngInicio.Text <> "__/__/____", TxtFechaIngInicio.Text.ToDate, MinFecha)
|
|
Dim FechaIngF = If(TxtFechaIngFin.Text.Trim <> "" AndAlso TxtFechaIngFin.Text <> "__/__/____", TxtFechaIngFin.Text.ToDate, MaxFecha)
|
|
|
|
If Reporte.GetMovimientosRep(DdlAlmacen.SelectedValue.ToEntero, DdlTipoMovimiento.SelectedValue.ToEntero, If(TxtFolio.Text = "", "-1", TxtFolio.Text.Trim).ToEntero, FechaIngI, FechaIngF, FechaInicial, FechaFinal, DdlUsuarios.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
|
|
GvM.DataSource = Reporte.DtResultados
|
|
DtMovimientos = Reporte.DtResultados
|
|
Else
|
|
GvM.DataSource = Nothing
|
|
End If
|
|
|
|
GvM.DataBind()
|
|
|
|
If (GvM.Rows.Count > 0) Then
|
|
GvM.UseAccessibleHeader = True
|
|
GvM.HeaderRow.TableSection = TableRowSection.TableHeader
|
|
RegistraScript("OrdenarGV();")
|
|
End If
|
|
|
|
UpDatosGV.Update()
|
|
Reporte.Dispose()
|
|
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")
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "PDF"
|
|
|
|
Private Sub LnkPdf_Click(sender As Object, e As EventArgs) Handles LnkPdf.Click
|
|
If DtMovimientos IsNot Nothing Then
|
|
Dim StrFiltro As New StringBuilder
|
|
If DdlAlmacen.SelectedValue <> "-1" Then StrFiltro.AppendFormat("<b>Almacen</b>: {0}", DdlAlmacen.SelectedItem.Text)
|
|
If DdlTipoMovimiento.SelectedValue <> "-1" Then StrFiltro.AppendFormat(" <b>Tipo Movimiento</b>: {0}", DdlTipoMovimiento.SelectedItem.Text)
|
|
If DdlUsuarios.SelectedValue <> "-1" Then StrFiltro.AppendFormat(" <b>Usuario</b>: {0}", DdlUsuarios.SelectedItem.Text)
|
|
|
|
If TxtFechaI.Text <> "" Then StrFiltro.AppendFormat(" <b>Fecha Inicio </b>: {0}", TxtFechaI.Text.ToDate.ToShortDateString)
|
|
If TxtFechaF.Text <> "" Then StrFiltro.AppendFormat(" <b>Fecha Fin </b>: {0}", TxtFechaF.Text.ToDate.ToShortDateString)
|
|
If TxtFechaIngInicio.Text <> "" Then StrFiltro.AppendFormat(" <b>Fecha Ingreso Inicio </b>: {0}", TxtFechaIngInicio.Text.ToDate.ToShortDateString)
|
|
If TxtFechaIngFin.Text <> "" Then StrFiltro.AppendFormat(" <b>Fecha Ingreso Fin </b>: {0}", TxtFechaIngFin.Text.ToDate.ToShortDateString)
|
|
If TxtFolio.Text <> "" Then StrFiltro.AppendFormat(" <b>Folio </b>: {0}", TxtFolio.Text.ToDate.ToShortDateString)
|
|
|
|
Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta))
|
|
Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa)
|
|
|
|
Dim params As New List(Of ReportParameter)
|
|
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
|
|
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
|
|
params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToShortDateString))
|
|
params.Add(New ReportParameter("Filtros", StrFiltro.ToString))
|
|
|
|
If Imagen.Exists Then
|
|
params.Add(New ReportParameter("LogoPath", logouri))
|
|
Else
|
|
params.Add(New ReportParameter("LogoPath", ""))
|
|
End If
|
|
|
|
ImprimirPDF("Empresas/Grales/Formatos/RepMovimientos.rdlc", DtMovimientos, params, String.Format("ReporteMovimientos-{0}", Now.ToDateTime.ToShortDateString))
|
|
|
|
Else
|
|
Alert("No hay datos consultados", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
End Class
|