441 lines
17 KiB
VB.net
441 lines
17 KiB
VB.net
Option Strict On
|
|
Option Explicit On
|
|
|
|
Imports Microsoft.Reporting.WebForms
|
|
Imports Extensiones
|
|
Imports System.Data
|
|
Imports System.IO
|
|
|
|
Partial Class Compras_RepComprasAFDetalle
|
|
Inherits ClsPaginas
|
|
|
|
#Region " PROPIEDADES "
|
|
|
|
Private Property DTDatos As DataTable
|
|
Get
|
|
If ViewState("DTDatos") Is Nothing Then
|
|
Return New DataTable
|
|
Else
|
|
Return DirectCast(ViewState("DTDatos"), DataTable)
|
|
End If
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DTDatos") = value
|
|
End Set
|
|
End Property
|
|
Private Property TCEspecifico As Double
|
|
Get
|
|
If ViewState("TCEspecifico") Is Nothing Then
|
|
Return -1
|
|
Else
|
|
Return DirectCast(ViewState("TCEspecifico"), Double)
|
|
End If
|
|
End Get
|
|
Set(value As Double)
|
|
ViewState("TCEspecifico") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property CveMoneda As Integer
|
|
Get
|
|
Return ViewState("CveMoneda").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveMoneda") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property Grupo As Integer
|
|
Get
|
|
Return ViewState("Grupo").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("Grupo") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property Anio As String
|
|
Get
|
|
Return ViewState("Anio").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("Anio") = value
|
|
End Set
|
|
End Property
|
|
Private Property Mes As String
|
|
Get
|
|
Return ViewState("Mes").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("Mes") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property AnioMes As String
|
|
Get
|
|
Return ViewState("AnioMes").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("AnioMes") = value
|
|
End Set
|
|
End Property
|
|
|
|
#End Region
|
|
|
|
Private Sub Compras_RepComprasAFDetalle_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
If Not IsPostBack Then
|
|
CargaCombos()
|
|
'ImgPersonalizar.Attributes.Add("onclick", "javascript:$('#DivPersonalizar').show(1000); PosicionaObjeto(this.id,'DivPersonalizar');")
|
|
DdlPS.ddl.Visible = False
|
|
|
|
|
|
|
|
Try
|
|
Dim Fecha, FechaI, FechaF As String
|
|
|
|
'txtFechaI.Text = If(Request.QueryString("FechaI").ToString = "-1", "", Request.QueryString("FechaI").ToString)
|
|
'txtFechaF.Text = If(Request.QueryString("FechaF").ToString = "-1", "", Request.QueryString("FechaF").ToString)
|
|
|
|
'DdlGrupo.SelectedValueExist(Request.QueryString("GPO").ToString)
|
|
|
|
DdlTipoActivoFijo.SelectedValueExist(Request.QueryString("CveTipoActivoFijo").ToString)
|
|
DdlSubTipoActivoFijo.SelectedValueExist(Request.QueryString("CveSubTipoActivofijo").ToString)
|
|
DdlActivoFijo.SelectedValueExist(Request.QueryString("CveActivoFijo").ToString)
|
|
DdlMonedas.SelectedValueExist(Request.QueryString("CveMoneda").ToString)
|
|
|
|
DdlProyecto.SelectedValueExist(Request.QueryString("CveProyecto").ToString)
|
|
DdlSubProyecto.SelectedValueExist(Request.QueryString("CveSubProyecto").ToString)
|
|
DdlProveedores.SelectedValueExist(Request.QueryString("CveProveedor").ToString)
|
|
DdlClasificacion.SelectedValueExist(Request.QueryString("CveClasificacion").ToString)
|
|
|
|
If Request.QueryString("CvePS").ToString.Length > 0 Then
|
|
DdlPS.txtText.Value = Request.QueryString("PS").ToString
|
|
DdlPS.txtValue.Value = If(Request.QueryString("CvePS").ToString = "-1", "", Request.QueryString("CvePS").ToString)
|
|
End If
|
|
|
|
Anio = Request.QueryString("Anio").ToString()
|
|
Mes = Request.QueryString("Mes").ToString()
|
|
AnioMes = Request.QueryString("AnioMes").ToString()
|
|
Fecha = Request.QueryString("Fecha").ToString()
|
|
|
|
Anio = If(Request("Anio") IsNot Nothing, Request("Anio").ToString, "-1").ToString
|
|
Mes = If(Request("Mes") IsNot Nothing, Request("Mes").ToString, "-1").ToString
|
|
AnioMes = If(Request("AnioMes") IsNot Nothing, Request("AnioMes").ToString, "-1").ToString
|
|
Fecha = If(Request("Fecha") IsNot Nothing, Request("Fecha").ToString, "-1").ToString
|
|
FechaI = If(Request("FechaI") IsNot Nothing, Request("FechaI").ToString, "-1").ToString
|
|
FechaF = If(Request("FechaF") IsNot Nothing, Request("FechaF").ToString, "-1").ToString
|
|
|
|
txtFechaI.Text = If(Anio <> "-1", String.Format("01/01/{0}", Anio), txtFechaI.Text)
|
|
txtFechaI.Text = If(Mes <> "-1", String.Format("01/{0}/0001", Mes), txtFechaI.Text)
|
|
txtFechaI.Text = If(AnioMes <> "-1", String.Format("01/{0}/{1}", AnioMes.Substring(5, 2).PadLeft(2, "0"c), AnioMes.Substring(0, 4)), txtFechaI.Text)
|
|
|
|
If Fecha <> "-1" Then
|
|
txtFechaI.Text = Fecha
|
|
txtFechaF.Text = Fecha
|
|
ElseIf FechaI <> "-1" Then
|
|
txtFechaI.Text = FechaI
|
|
|
|
If FechaF <> "-1" Then
|
|
txtFechaF.Text = FechaF
|
|
End If
|
|
ElseIf FechaF <> "-1" Then
|
|
txtFechaF.Text = FechaF
|
|
End If
|
|
|
|
CargaDatos()
|
|
Catch ex As Exception
|
|
Dim asd As Integer = 1
|
|
End Try
|
|
|
|
If UsuarioActual.Empresa.GralSoloProyecto Then
|
|
|
|
LblSubProyecto.Text = "Proyecto:"
|
|
DdlSubProyecto.Items.Clear()
|
|
DdlSubProyecto.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1)
|
|
DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlSubProyecto.SelectedValue = "-1"
|
|
DdlSubProyecto.DataBind()
|
|
'DdlSubProyecto.SelectedValueExist(Request.QueryString("CveSubProyecto").ToString)
|
|
DdlProyecto.Visible = False
|
|
DdlProyecto.Items(0).Text = ""
|
|
LblProyecto.Visible = False
|
|
|
|
End If
|
|
|
|
If UsuarioActual.CveEmpresa = 72 Then
|
|
GvDatos.Columns(2).Visible = True
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CargaCombos()
|
|
|
|
DdlProveedores.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa)
|
|
DdlProveedores.DataBind()
|
|
|
|
DdlMonedas.DataSource = GlobalDTMonedas()
|
|
DdlMonedas.DataBind()
|
|
|
|
DdlProyecto.DataSource = GlobalDTProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1)
|
|
DdlProyecto.DataBind()
|
|
|
|
DdlTipoActivoFijo.DataSource = GlobalDTTipoActivoFijo(UsuarioActual.CveEmpresa).FiltraParametros("", "TipoActivoFijo")
|
|
DdlTipoActivoFijo.DataBind()
|
|
|
|
DdlClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros(" Codigo = '' OR Codigo IS NULL ", Orderby:="Clasificacion")
|
|
DdlClasificacion.DataBind()
|
|
|
|
DdlActivoFijo.DataSource = GlobalDTActivoFijos(UsuarioActual.CveEmpresa)
|
|
DdlActivoFijo.DataBind()
|
|
DdlActivoFijo.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
|
|
If UsuarioActual.Empresa.Tipo_CentroCosto = 1 Then
|
|
DdlProyecto.Visible = False
|
|
LblSubProyecto.Text = "Sucursal"
|
|
LblProyecto.Visible = False
|
|
DdlSubProyecto.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1)
|
|
DdlSubProyecto.DataBind()
|
|
DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 2 Then
|
|
DdlProyecto.Visible = False
|
|
LblSubProyecto.Text = "Proyecto"
|
|
LblProyecto.Visible = False
|
|
DdlSubProyecto.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1)
|
|
DdlSubProyecto.DataBind()
|
|
DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 3 Or UsuarioActual.Empresa.Tipo_CentroCosto = 0 Then
|
|
LblProyecto.Text = "Proyecto"
|
|
|
|
ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 4 Then
|
|
LblProyecto.Text = "Sucursal"
|
|
LblSubProyecto.Text = "Proyecto"
|
|
ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 5 Then
|
|
LblProyecto.Text = "Proyecto"
|
|
LblSubProyecto.Text = "Sucursal"
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
Private Sub DdlTipoActivoFijo_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlTipoActivoFijo.SelectedIndexChanged
|
|
|
|
DdlSubTipoActivoFijo.Items.Clear()
|
|
DdlSubTipoActivoFijo.DataSource = GlobalDTSubTipoActivoFijo(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CveTipoActivoFijo = {0}", DdlTipoActivoFijo.SelectedValue), "SubTipoActivoFijo")
|
|
DdlSubTipoActivoFijo.DataBind()
|
|
DdlSubTipoActivoFijo.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlSubTipoActivoFijo.SelectedIndex = 0
|
|
|
|
End Sub
|
|
Protected Sub DdlProyecto_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlProyecto.SelectedIndexChanged
|
|
CargaSubProyecto()
|
|
End Sub
|
|
Private Sub CargaSubProyecto()
|
|
|
|
DdlSubProyecto.Items.Clear()
|
|
DdlSubProyecto.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1)
|
|
DdlSubProyecto.DataBind()
|
|
DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
End Sub
|
|
Protected Sub BtnConsultar_Click(sender As Object, e As System.EventArgs) Handles BtnConsultar.Click
|
|
CargaDatos()
|
|
|
|
UPDatos.Update()
|
|
End Sub
|
|
Private Sub CargaDatos()
|
|
|
|
|
|
Dim ObjCompras As New ClsCompras()
|
|
|
|
Dim FechaI, FechaF As String
|
|
Dim CvePS As Integer = If(DdlPS.txtValue.Value = "", -1, DdlPS.txtValue.Value.ToString.ToEntero)
|
|
|
|
FechaI = If(IsDate(txtFechaI.Text.Trim()), txtFechaI.Text.Trim(), "-1")
|
|
FechaF = If(IsDate(txtFechaF.Text.Trim()), txtFechaF.Text.Trim(), "-1")
|
|
|
|
|
|
If RblTipoCambio.SelectedValue.ToEntero = 3 And TxtEspecifico.Text <> "" Then
|
|
TCEspecifico = TxtEspecifico.Text.ToDouble
|
|
Else
|
|
TCEspecifico = -1
|
|
End If
|
|
|
|
|
|
If ObjCompras.GetRepComprasAFDetalle(FechaI, FechaF, DdlProveedores.SelectedValue.ToEntero, DdlMonedas.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, -1,
|
|
DdlProyecto.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, RblTipoCambio.SelectedValue.ToEntero, TCEspecifico,
|
|
DdlClasificacion.SelectedValue.ToEntero, DdlActivoFijo.SelectedValue.ToEntero, DdlTipoActivoFijo.SelectedValue.ToEntero, DdlSubTipoActivoFijo.SelectedValue.ToEntero,
|
|
CvePS, Anio.ToEntero, Mes.ToEntero, AnioMes, CveUsuarioConsulta:=UsuarioActual.CveUsuario) Then
|
|
DTDatos = ObjCompras.DtResultados
|
|
|
|
GvDatos.DataSource = ObjCompras.DtResultados
|
|
Else
|
|
GvDatos.DataSource = Nothing
|
|
DTDatos = Nothing
|
|
End If
|
|
|
|
|
|
ObjCompras.Dispose()
|
|
GvDatos.DataBind()
|
|
|
|
|
|
|
|
End Sub
|
|
Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound
|
|
|
|
If e.Row.RowType = DataControlRowType.Header Then
|
|
' e.Row.Cells(0).Text = DdlGrupo.SelectedItem.Text
|
|
End If
|
|
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
Dim FechaI, FechaF As String
|
|
FechaI = If(IsDate(txtFechaI.Text.Trim()), txtFechaI.Text.Trim(), "-1")
|
|
FechaF = If(IsDate(txtFechaF.Text.Trim()), txtFechaF.Text.Trim(), "-1")
|
|
|
|
|
|
Dim Liga As String = $"/Compras/Compras.aspx?CveCompra={e.Row.DBCampo("CveCompra")}"
|
|
|
|
|
|
If e.Row.DBCampo("Orden") = "1" Then
|
|
e.Row.Cells(0).Text = String.Format("<a class='{0}' target='_blank' href='{1}'>{2}</a>", "Texto", Liga, e.Row.DBCampo("SerieFolio").ToString)
|
|
Else
|
|
e.Row.BackColor = Drawing.Color.LightGray
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
#Region "I M P R I M I R P D F/Excel"
|
|
|
|
Private Sub LnkExportar_Click(sender As Object, e As EventArgs) Handles LnkExportar.Click
|
|
GenerarPDF("Excel")
|
|
End Sub
|
|
Private Sub LinkPDF_Click(sender As Object, e As EventArgs) Handles LinkPDF.Click
|
|
GenerarPDF()
|
|
End Sub
|
|
|
|
Private Sub GenerarPDF(Optional Formato As String = "PDF")
|
|
Dim ObjTareas As New ClsOIEventos
|
|
|
|
Dim RutaPDF As String
|
|
Dim Ruta As String = $"{ModExtensiones.DirectorioBaseEmpresas}Empresas\{UsuarioActual.CveEmpresa}\"
|
|
RutaPDF = $"{Ruta}\Formatos\RepComprasAFDetalle.rdlc"
|
|
If Not File.Exists(RutaPDF) Then
|
|
RutaPDF = "Empresas\Grales\Formatos\RepComprasAFDetalle.rdlc"
|
|
End If
|
|
|
|
Dim params As New List(Of ReportParameter)
|
|
|
|
|
|
|
|
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 FechaI, FechaF As String
|
|
FechaI = If(txtFechaI.Text = "" Or txtFechaI.Text = "__/__/____", "-1", txtFechaI.Text)
|
|
FechaF = If(txtFechaF.Text = "" Or txtFechaF.Text = "__/__/____", "-1", txtFechaF.Text)
|
|
|
|
params.Add(New ReportParameter("AgrupadoPor", FiltrosUsados()))
|
|
'params.Add(New ReportParameter("GPO", DdlGrupo.SelectedItem.Text))
|
|
params.Add(New ReportParameter("Titulo", "REPORTE COMPRAS ACTIVOS FIJOS DETALLE"))
|
|
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
|
|
params.Add(New ReportParameter("FechaInicio", FechaI))
|
|
params.Add(New ReportParameter("FechaFin", FechaF))
|
|
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
|
|
params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToShortDateString))
|
|
|
|
If Imagen.Exists Then
|
|
params.Add(New ReportParameter("LogoPath", logouri))
|
|
Else
|
|
params.Add(New ReportParameter("LogoPath", ""))
|
|
End If
|
|
|
|
ImprimirPDF(RutaPDF, DTDatos, params, "ReporteComprasAFDetalle_" & Now.ToString("yyyyMMddmmss"), Formato:=Formato)
|
|
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
Private Sub RblTipoCambio_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RblTipoCambio.SelectedIndexChanged
|
|
If RblTipoCambio.SelectedValue.ToEntero = 3 Then
|
|
Dim TipoCambio As Double
|
|
LiEspecifico.Visible = True
|
|
TipoCambio = GlobalTipoCambio(Now)
|
|
TxtEspecifico.Text = TipoCambio.ToString
|
|
Else
|
|
LiEspecifico.Visible = False
|
|
End If
|
|
UpBodyTipoCambio.Update()
|
|
End Sub
|
|
Private Function FiltrosUsados() As String
|
|
Dim filtro As String = "<b>Filtros:</b> "
|
|
Dim ListaFiltros As New List(Of String)
|
|
Dim Contador As Integer = 0
|
|
|
|
|
|
If txtFechaI.Text.Length > 0 Then
|
|
|
|
ListaFiltros.Add("<b>FechaI:</b> " & txtFechaI.Text)
|
|
End If
|
|
|
|
If txtFechaF.Text.Length > 0 Then
|
|
|
|
ListaFiltros.Add("<b>FechaF:</b> " & txtFechaF.Text)
|
|
End If
|
|
|
|
If DdlTipoActivoFijo.SelectedIndex > 0 Then
|
|
|
|
ListaFiltros.Add("<b>Tipo:</b> " & DdlTipoActivoFijo.SelectedItem.Text)
|
|
End If
|
|
|
|
If DdlSubTipoActivoFijo.SelectedIndex > 0 Then
|
|
ListaFiltros.Add("<b>SubTipo:</b> " & DdlSubTipoActivoFijo.SelectedItem.Text)
|
|
End If
|
|
|
|
If DdlActivoFijo.SelectedIndex > 0 Then
|
|
ListaFiltros.Add("<b>AF:</b> " & DdlActivoFijo.SelectedItem.Text)
|
|
End If
|
|
|
|
If DdlMonedas.SelectedIndex > 0 Then
|
|
ListaFiltros.Add("<b>Moneda:</b> " & DdlMonedas.SelectedItem.Text)
|
|
End If
|
|
|
|
If DdlProyecto.SelectedIndex > 0 Then
|
|
ListaFiltros.Add("<b>Proyecto:</b> " & DdlProyecto.SelectedItem.Text)
|
|
End If
|
|
|
|
If DdlSubProyecto.SelectedIndex > 0 Then
|
|
ListaFiltros.Add("<b>SubProyecto:</b> " & DdlSubProyecto.SelectedItem.Text)
|
|
End If
|
|
|
|
If DdlProveedores.SelectedIndex > 0 Then
|
|
ListaFiltros.Add("<b>Proveedor:</b> " & DdlProveedores.SelectedItem.Text)
|
|
End If
|
|
|
|
If DdlPS.txtValue.Value.ToEntero > 0 Then
|
|
ListaFiltros.Add("<b>Producto:</b> " & DdlPS.txtText.Value)
|
|
End If
|
|
|
|
If DdlClasificacion.SelectedIndex > 0 Then
|
|
ListaFiltros.Add("<b>Clasificación:</b> " & DdlClasificacion.SelectedItem.Text)
|
|
End If
|
|
|
|
For Each s As String In ListaFiltros
|
|
|
|
If Contador > 0 Then
|
|
filtro = filtro & ", " & s
|
|
Else
|
|
filtro = filtro & " " & s
|
|
End If
|
|
|
|
Contador = Contador + 1
|
|
|
|
Next
|
|
|
|
Return filtro
|
|
End Function
|
|
End Class |