266 lines
13 KiB
VB.net
266 lines
13 KiB
VB.net
|
|
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports Extensiones
|
|
Imports Microsoft.Reporting.WebForms
|
|
|
|
Partial Class Compras_RepComprasPeriodo
|
|
Inherits ClsPaginas
|
|
|
|
#Region "PROPIEDADES"
|
|
|
|
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
|
|
|
|
#End Region
|
|
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
If Not IsPostBack Then
|
|
CargaCombos()
|
|
End If
|
|
End Sub
|
|
|
|
#Region "CARGAS"
|
|
Private Sub CargaGrupo()
|
|
DdlGrupo.Items.Insert(0, New ListItem("Año", "1"))
|
|
DdlGrupo.Items.Insert(1, New ListItem("Mes", "2"))
|
|
DdlGrupo.Items.Insert(2, New ListItem("Año/Mes", "3"))
|
|
DdlGrupo.Items.Insert(3, New ListItem("Fecha", "4"))
|
|
DdlGrupo.Items.Insert(4, New ListItem("Fecha Captura", "9"))
|
|
DdlGrupo.Items.Insert(5, New ListItem("Proveedor", "5"))
|
|
DdlGrupo.Items.Insert(6, New ListItem("Tipo Documento", "6"))
|
|
DdlGrupo.Items.Insert(7, New ListItem("Clasificación Prov.", "7"))
|
|
DdlGrupo.Items.Insert(8, New ListItem("Responsable", "8"))
|
|
DdlGrupo.Items.Insert(9, New ListItem("Remesa", "10"))
|
|
DdlGrupo.DataBind()
|
|
DdlGrupo.SelectedValueExist("3")
|
|
End Sub
|
|
|
|
Private Sub CargaCombos()
|
|
|
|
'Carga Tipo Centro de Costo
|
|
CargarCentrosDeCosto(DdlProyecto, DdlSubProyecto, LblProyecto, LblSubProyecto, divProyecto:=DivProyecto)
|
|
|
|
'Carga Proveedores
|
|
DdlProveedores.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa)
|
|
DdlProveedores.DataBind()
|
|
|
|
'Carga Tipo de Gasto
|
|
DdlTipoGasto.DataSource = GlobalDTTiposGastos(UsuarioActual.CveEmpresa)
|
|
DdlTipoGasto.DataBind()
|
|
|
|
'Carga Usuarios Responsable
|
|
DdlUsuario.DataSource = GlobalDTUsuarioResponsable(UsuarioActual.CveEmpresa)
|
|
DdlUsuario.DataBind()
|
|
|
|
'Carga Usuarios Captura
|
|
DDlUsuarioCaptura.DataSource = GlobalDTUsuarios(-1, UsuarioActual.CveEmpresa)
|
|
DDlUsuarioCaptura.DataBind()
|
|
|
|
'Carga Monedas
|
|
DdlMonedas.DataSource = GlobalDTMonedas()
|
|
DdlMonedas.DataBind()
|
|
|
|
'Carga Grupo
|
|
CargaGrupo()
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaDatos()
|
|
Dim ObjCompras As New ClsCompras()
|
|
|
|
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")
|
|
|
|
If RblTipoCambio.SelectedValue.ToEntero = 3 And TxtEspecifico.Text <> "" Then
|
|
TCEspecifico = TxtEspecifico.Text.ToDouble
|
|
Else
|
|
TCEspecifico = -1
|
|
End If
|
|
|
|
Dim VerEn As Integer = -1
|
|
If RbSubTotal.Checked Then VerEn = 1
|
|
If RbTotal.Checked Then VerEn = 2
|
|
If RbIVA.Checked Then VerEn = 3
|
|
|
|
Dim FechaICaptura, FechaFCaptura As String
|
|
FechaICaptura = If(IsDate(TxtFechaICaptura.Text.Trim()), TxtFechaICaptura.Text.Trim(), "-1")
|
|
FechaFCaptura = If(IsDate(TxtFechaFCaptura.Text.Trim()), TxtFechaFCaptura.Text.Trim(), "-1")
|
|
|
|
If ObjCompras.GetRepComprasPeriodo(FechaI, FechaF, DdlProveedores.SelectedValue.ToEntero, DdlUsuario.SelectedValue.ToEntero, DDlUsuarioCaptura.SelectedValue.ToEntero, FechaICaptura, FechaFCaptura,
|
|
DdlMonedas.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, DdlGrupo.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero,
|
|
RblTipoCambio.SelectedValue.ToEntero, TCEspecifico, DdlTipoGasto.SelectedValue.ToEntero, CveUsuarioConsulta:=UsuarioActual.CveUsuario, VerEn:=VerEn, CveProyecto:=DdlProyecto.SelectedValue.ToEntero) Then
|
|
GvDatos.DataSource = ObjCompras.DtResultados
|
|
Else
|
|
GvDatos.DataSource = Nothing
|
|
End If
|
|
ObjCompras.Dispose()
|
|
GvDatos.DataBind()
|
|
End Sub
|
|
|
|
|
|
#End Region
|
|
|
|
#Region "SELECTED INDEX CHANGE"
|
|
|
|
Protected Sub DdlProyecto_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlProyecto.SelectedIndexChanged
|
|
CargarSubProyecto(DdlSubProyecto, DdlProyecto.SelectedValue)
|
|
End Sub
|
|
|
|
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(NowADS())
|
|
TxtEspecifico.Text = TipoCambio.ToString
|
|
Else
|
|
LiEspecifico.Visible = False
|
|
End If
|
|
UpBodyTipoCambio.Update()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "CONSULTAR"
|
|
|
|
Protected Sub BtnConsultar_Click(sender As Object, e As System.EventArgs) Handles BtnConsultar.Click
|
|
CargaDatos()
|
|
UPDatos.Update()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "GRIDVIEW"
|
|
Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
'Dim Css As String = "Texto"
|
|
'If e.Row.RowIndex = 0 Then
|
|
' e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Center
|
|
' e.Row.Cells(0).Width = Unit.Pixel(200)
|
|
' e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Center
|
|
' e.Row.Cells(1).Width = Unit.Pixel(60)
|
|
' e.Row.Cells(2).Width = Unit.Pixel(90)
|
|
' e.Row.Cells(3).Width = Unit.Pixel(90)
|
|
' e.Row.Cells(4).Width = Unit.Pixel(90)
|
|
' e.Row.Cells(5).Width = Unit.Pixel(80)
|
|
' e.Row.Cells(8).Width = Unit.Pixel(100)
|
|
'End If
|
|
|
|
If e.Row.DBCampo("Orden") = "" Then
|
|
e.Row.CssClass = "Totales"
|
|
e.Row.HorizontalAlign = HorizontalAlign.Center
|
|
End If
|
|
|
|
'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 = String.Format("/Compras/RepComprasDetalle.aspx?GPO={0}&Anio={1}&Mes={2}&AnioMes={3}&Fecha={4}&CveProveedor={5}&CveUsuario={6}&FechaI={7}&FechaF={8}&CveMoneda={9}&CveUsuarioCaptura={10}&NumeroRemesa={11}&FechaICaptura={12}&FechaFCaptura={13}&FechaCaptura={14}&CveSubProyecto={15}&CveUsuarioRemesa={16}&TipoDocto={17}&CveTipoGasto={18}&CveProyecto={19}",
|
|
' DdlGrupo.SelectedValue, e.Row.DBCampo("Anio"), e.Row.DBCampo("Mes"), e.Row.DBCampo("AnioMes"), e.Row.DBCampo("Fecha"), e.Row.DBCampo("CveProveedor"), e.Row.DBCampo("CveUsuario"), FechaI, FechaF, e.Row.DBCampo("CveMoneda"), e.Row.DBCampo("CveUsuarioCaptura"), e.Row.DBCampo("NumeroRemesa"), e.Row.DBCampo("FechaICaptura"), e.Row.DBCampo("FechaFCaptura"), e.Row.DBCampo("FechaCaptura"),
|
|
' e.Row.DBCampo("CveSubProyecto"), e.Row.DBCampo("CveUsuarioRemesa"), e.Row.DBCampo("TipoDocto"), DdlTipoGasto.SelectedValue, e.Row.DBCampo("CveProyecto"))
|
|
|
|
|
|
'If e.Row.DBCampo("Orden") = "" Then
|
|
' e.Row.FCLiteral("LtlGrupo").Text = e.Row.FCLiteral("LtlGrupo").Text
|
|
' e.Row.FCLiteral("LtlCantidad").Text = e.Row.FCLiteral("LtlCantidad").Text
|
|
'Else
|
|
' e.Row.FCLiteral("LtlGrupo").Text = String.Format("<a class='{0}' href='{1}'>{2}</a>", Css, Liga, e.Row.FCLiteral("LtlGrupo").Text)
|
|
' e.Row.FCLiteral("LtlCantidad").Text = String.Format("<a class='{0}' href='{1}'>{2}</a>", Css, Liga, e.Row.FCLiteral("LtlCantidad").Text)
|
|
'End If
|
|
|
|
If e.Row.Cells(2).Text.ToDouble = 0 Then e.Row.Cells(2).Text = ""
|
|
If e.Row.Cells(3).Text.ToDouble = 0 Then e.Row.Cells(3).Text = ""
|
|
If e.Row.Cells(4).Text.ToDouble = 0 Then e.Row.Cells(4).Text = ""
|
|
If e.Row.Cells(5).Text.ToDouble = 0 Then e.Row.Cells(5).Text = ""
|
|
If e.Row.Cells(6).Text.ToDouble = 0 Then e.Row.Cells(6).Text = ""
|
|
If e.Row.Cells(7).Text.ToDouble = 0 Then e.Row.Cells(7).Text = ""
|
|
If e.Row.Cells(8).Text.ToDouble = 0 Then e.Row.Cells(8).Text = ""
|
|
If e.Row.Cells(9).Text.ToDouble = 0 Then e.Row.Cells(9).Text = ""
|
|
If e.Row.Cells(10).Text.ToDouble = 0 Then e.Row.Cells(10).Text = ""
|
|
If e.Row.Cells(11).Text.ToDouble = 0 Then e.Row.Cells(11).Text = ""
|
|
If e.Row.Cells(12).Text.ToDouble = 0 Then e.Row.Cells(12).Text = ""
|
|
If e.Row.Cells(13).Text.ToDouble = 0 Then e.Row.Cells(13).Text = ""
|
|
If e.Row.Cells(14).Text.ToDouble = 0 Then e.Row.Cells(14).Text = ""
|
|
End If
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "PERSONALIZAR"
|
|
Protected Sub BtnPersonalizar_Click(sender As Object, e As System.EventArgs) Handles BtnPersonalizar.Click
|
|
CargaDatos()
|
|
UPDatos.Update()
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "IMPRIMIR"
|
|
Protected Sub ImgExcel_Click(sender As Object, e As System.EventArgs) Handles LnkExportar.Click
|
|
GvDatos.ExportToExcel("ReporteComprasPeriodo_" & NowADS().ToShortDateString)
|
|
End Sub
|
|
Private Sub ImgImprimir_Click(sender As Object, e As EventArgs) Handles LnkPdf.Click
|
|
Dim ObjCompras As New ClsCompras()
|
|
|
|
Dim FechaICaptura, FechaFCaptura As String
|
|
FechaICaptura = If(IsDate(TxtFechaICaptura.Text.Trim()), TxtFechaICaptura.Text.Trim(), "-1")
|
|
FechaFCaptura = If(IsDate(TxtFechaFCaptura.Text.Trim()), TxtFechaFCaptura.Text.Trim(), "-1")
|
|
|
|
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 Proveedor = If(DdlProveedores.SelectedValue = "-1", "", $" <b>Proveedor:</b> {DdlProveedores.SelectedItem.Text}")
|
|
Dim Capturo = If(DDlUsuarioCaptura.SelectedValue = "-1", "", $" <b>Capturó:</b> {DDlUsuarioCaptura.SelectedItem.Text}")
|
|
Dim Grupo = DdlGrupo.SelectedItem.Text
|
|
Dim Moneda = If(DdlMonedas.SelectedValue = "-1", "", $" <b>Monedas:</b> {DdlMonedas.SelectedItem.Text}")
|
|
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 = ""
|
|
Dim Proyecto = If(DdlProyecto.SelectedValue = "-1", "", $" <b>Proyecto:</b> {DdlProyecto.SelectedItem.Text}")
|
|
Dim SubProyecto = If(DdlSubProyecto.SelectedValue = "-1", "", $" <b>SubProyecto:</b> {DdlSubProyecto.SelectedItem.Text}")
|
|
|
|
If RblTipoCambio.SelectedValue.ToEntero = 3 And TxtEspecifico.Text <> "" Then
|
|
TCEspecifico = TxtEspecifico.Text.ToDouble
|
|
Else
|
|
TCEspecifico = -1
|
|
End If
|
|
|
|
|
|
If ObjCompras.GetRepComprasPeriodo(FechaI, FechaF, DdlProveedores.SelectedValue.ToEntero, DdlUsuario.SelectedValue.ToEntero, DDlUsuarioCaptura.SelectedValue.ToEntero, FechaICaptura, FechaFCaptura,
|
|
DdlMonedas.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, DdlGrupo.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero,
|
|
RblTipoCambio.SelectedValue.ToEntero, TCEspecifico, DdlTipoGasto.SelectedValue.ToEntero, CveUsuarioConsulta:=UsuarioActual.CveUsuario) Then
|
|
|
|
Dim Imagen As New System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png")
|
|
|
|
Dim dt As DataTable = ObjCompras.DtResultados
|
|
Dim params As New List(Of ReportParameter)
|
|
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
|
|
params.Add(New ReportParameter("FechaInicio", FechaI))
|
|
params.Add(New ReportParameter("FechaFin", FechaF))
|
|
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
|
|
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
|
|
params.Add(New ReportParameter("FechaImpresion", NowADS().ToString))
|
|
params.Add(New ReportParameter("AgrupadoPor", $"<b>Agrupado Por:</b> {Proveedor}{Capturo}{Grupo}{Moneda}{FechaIn}{FechaFn}{Proyecto}{SubProyecto}"))
|
|
params.Add(New ReportParameter("LogoPath", If(Imagen.Exists, $"file://{Imagen.FullName}", "")))
|
|
ImprimirPDF("Empresas/Grales/Formatos/RepComprasPeriodo.rdlc", dt, params, "RepComprasPeriodo")
|
|
Else
|
|
Alert("No hay datos consultados", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End Sub
|
|
#End Region
|
|
|
|
End Class
|