205 lines
10 KiB
VB.net
205 lines
10 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports Extensiones
|
|
Imports System.Data
|
|
Imports ADSNetLibrary.SIGAPI.Services.Generales
|
|
Imports ADSNetLibrary.SIGAPI.Models.Generales.Request
|
|
Imports ADSNetLibrary.SIGAPI.Models.Generales.Response
|
|
Imports MoreLinq
|
|
|
|
Partial Class Ventas_RepIndicadoresPorProyecto
|
|
Inherits ClsPaginas
|
|
|
|
#Region "Propiedades"
|
|
|
|
#End Region
|
|
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
If Not IsPostBack Then
|
|
InicializaValores()
|
|
End If
|
|
End Sub
|
|
|
|
#Region " INICIALIZA VALORES "
|
|
|
|
Private Sub InicializaValores()
|
|
txtFechaI.Text = FirstDayOfMonth(NowADS()).ToShortDateString
|
|
txtFechaF.Text = NowADS().LastDayOfMonth.ToShortDateString
|
|
CargarCentrosDeCosto(Nothing, DdlSubProyecto, Nothing, LblSubProyecto)
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region " CARGA DATOS "
|
|
Protected Sub BtnConsultar_Click(sender As Object, e As System.EventArgs) Handles BtnConsultar.Click
|
|
CargaDatos()
|
|
End Sub
|
|
Private Sub CargaDatos()
|
|
|
|
If Not IsDate(txtFechaI.Text) Then
|
|
Alert("La fecha inicial no es valida.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not IsDate(txtFechaF.Text) Then
|
|
Alert("La fecha final no es valida.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
|
|
|
|
GvResumenCxC.DataSource = Nothing
|
|
GvResumenCxP.DataSource = Nothing
|
|
GvRepCobrado.DataSource = Nothing
|
|
GvRepPagado.DataSource = Nothing
|
|
GvRepIngresosFact.DataSource = Nothing
|
|
GvRepCostosGastos.DataSource = Nothing
|
|
|
|
Dim gralService = New GeneralesService(System.Configuration.ConfigurationManager.ConnectionStrings("Conexion").ConnectionString)
|
|
|
|
|
|
Dim DatResumenCxC = gralService.GetResumenCxC(New RequestResumenCxC() With {.tipoDocto = "Ing",
|
|
.cveUsuario = UsuarioActual.CveUsuario,
|
|
.cveEmpresa = UsuarioActual.CveEmpresa,
|
|
.cveSubProyecto = DdlSubProyecto.SelectedValue.ToEntero,
|
|
.fechaInicial = txtFechaI.Text,
|
|
.fechaFinal = txtFechaF.Text})
|
|
|
|
Dim DatResumenCxP = gralService.GetResumenCxP(New RequestResumenCxP() With {.tipoDocto = "Fac",
|
|
.cveUsuario = UsuarioActual.CveUsuario,
|
|
.cveEmpresa = UsuarioActual.CveEmpresa,
|
|
.cveSubProyecto = DdlSubProyecto.SelectedValue.ToEntero,
|
|
.fechaInicial = txtFechaI.Text,
|
|
.fechaFinal = txtFechaF.Text})
|
|
|
|
Dim DatRepCobrado = gralService.RepCobrado(New RequestRepCobrado() With {.tipoDocto = "Ing",
|
|
.cveUsuario = UsuarioActual.CveUsuario,
|
|
.cveEmpresa = UsuarioActual.CveEmpresa,
|
|
.cveSubProyecto = DdlSubProyecto.SelectedValue.ToEntero,
|
|
.fechaInicial = txtFechaI.Text,
|
|
.fechaFinal = txtFechaF.Text})
|
|
|
|
Dim DatRepPagado = gralService.RepPagado(New RequestRepPagado() With {.tipoDocto = "Fac",
|
|
.cveUsuario = UsuarioActual.CveUsuario,
|
|
.cveEmpresa = UsuarioActual.CveEmpresa,
|
|
.cveSubProyecto = DdlSubProyecto.SelectedValue.ToEntero,
|
|
.fechaInicial = txtFechaI.Text,
|
|
.fechaFinal = txtFechaF.Text})
|
|
|
|
Dim DatRepIngresosFact = gralService.RepIngresosFact(New RequestRepIngresosFact() With {.tipoDocto = "Ing",
|
|
.cveUsuario = UsuarioActual.CveUsuario,
|
|
.cveEmpresa = UsuarioActual.CveEmpresa,
|
|
.cveSubProyecto = DdlSubProyecto.SelectedValue.ToEntero,
|
|
.fechaInicial = txtFechaI.Text,
|
|
.fechaFinal = txtFechaF.Text})
|
|
|
|
Dim DatRepCostosGastos = gralService.RepCostosGastos(New RequestRepCostosGastos() With {.tipoDocto = "Fac",
|
|
.cveUsuario = UsuarioActual.CveUsuario,
|
|
.cveEmpresa = UsuarioActual.CveEmpresa,
|
|
.cveSubProyecto = DdlSubProyecto.SelectedValue.ToEntero,
|
|
.fechaInicial = txtFechaI.Text,
|
|
.fechaFinal = txtFechaF.Text})
|
|
|
|
If DatResumenCxC.Result.Count > 0 Then
|
|
GvResumenCxC.DataSource = DatResumenCxC.Result.ToDataTable
|
|
SPResumenCxC.InnerText = $"Total: {DatResumenCxC.Result.ToDataTable.SUMD("saldoMN").ToString("###,###,###.00")} MXN"
|
|
End If
|
|
If DatResumenCxP.Result.Count > 0 Then
|
|
GvResumenCxP.DataSource = DatResumenCxP.Result.ToDataTable
|
|
SPResumenCxP.InnerText = $"Total: {DatResumenCxP.Result.ToDataTable.SUMD("saldoMN").ToString("###,###,###.00")} MXN"
|
|
End If
|
|
If DatRepCobrado.Result.Count > 0 Then
|
|
GvRepCobrado.DataSource = DatRepCobrado.Result.ToDataTable
|
|
SPRepCobrado.InnerText = $"Total: {DatRepCobrado.Result.ToDataTable.SUMD("cobradoMN").ToString("###,###,###.00")} MXN"
|
|
End If
|
|
If DatRepPagado.Result.Count > 0 Then
|
|
GvRepPagado.DataSource = DatRepPagado.Result.ToDataTable
|
|
SPRepPagado.InnerText = $"Total: {DatRepPagado.Result.ToDataTable.SUMD("pagadoMN").ToString("###,###,###.00")} MXN"
|
|
End If
|
|
If DatRepIngresosFact.Result.Count > 0 Then
|
|
GvRepIngresosFact.DataSource = DatRepIngresosFact.Result.ToDataTable.FiltraParametros("nRow <= 50")
|
|
SPRepIngresosFact.InnerText = $"Total: {DatRepIngresosFact.Result.ToDataTable.SUMD("importeMN").ToString("###,###,###.00")} MXN"
|
|
End If
|
|
If DatRepCostosGastos.Result.Count > 0 Then
|
|
GvRepCostosGastos.DataSource = DatRepCostosGastos.Result.ToDataTable.FiltraParametros("nRow <= 50")
|
|
SPRepCostosGastos.InnerText = $"Total: {DatRepCostosGastos.Result.ToDataTable.SUMD("importeMN").ToString("###,###,###.00")} MXN"
|
|
End If
|
|
|
|
|
|
LblMargenBruto.Text = $"{(DatRepIngresosFact.Result.ToDataTable.SUMD("importeMN") - DatRepCostosGastos.Result.ToDataTable.SUMD("importeMN")).ToString("###,###,###.00")}"
|
|
|
|
GvResumenCxC.DataBind()
|
|
GvResumenCxP.DataBind()
|
|
GvRepCobrado.DataBind()
|
|
GvRepPagado.DataBind()
|
|
GvRepIngresosFact.DataBind()
|
|
GvRepCostosGastos.DataBind()
|
|
|
|
DVMargenBruto.Visible = True
|
|
|
|
UpDatos.Update()
|
|
|
|
End Sub
|
|
|
|
Private Sub GvResumenCxC_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvResumenCxC.RowDataBound
|
|
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
Dim liga As String = $"../CxC/RepCxC.aspx?CveSubProyecto={DdlSubProyecto.SelectedValue}&FechaInicio={txtFechaI.Text}&FechaFin={txtFechaF.Text}&CveMoneda={e.Row.DataKey("CveMoneda")}&TipoDocto=Ing"
|
|
e.Row.Cells(0).Text = $"<a target='_blank' href='{liga}'>{e.Row.Cells(0).Text}</a>"
|
|
e.Row.Cells(1).Text = $"<a target='_blank' href='{liga}' >{e.Row.Cells(1).Text}</a>"
|
|
e.Row.Cells(2).Text = $"<a target='_blank' href='{liga}'>{e.Row.Cells(2).Text}</a>"
|
|
End If
|
|
|
|
End Sub
|
|
Private Sub GvResumenCxP_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvResumenCxP.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
Dim liga As String = $"../Compras/RepCxP.aspx?CveSubProyecto={DdlSubProyecto.SelectedValue}&FechaInicio={txtFechaI.Text}&FechaFin={txtFechaF.Text}&CveMoneda={e.Row.DataKey("CveMoneda")}&TipoDocto=Fac"
|
|
e.Row.Cells(0).Text = $"<a target='_blank' href='{liga}'>{e.Row.Cells(0).Text}</a>"
|
|
e.Row.Cells(1).Text = $"<a target='_blank' href='{liga}' >{e.Row.Cells(1).Text}</a>"
|
|
e.Row.Cells(2).Text = $"<a target='_blank' href='{liga}'>{e.Row.Cells(2).Text}</a>"
|
|
End If
|
|
End Sub
|
|
Private Sub GvRepCobrado_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvRepCobrado.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
Dim liga As String = $"../Ventas/RepRecuperacion.aspx?CveSubProyecto={DdlSubProyecto.SelectedValue}&FechaInicio={txtFechaI.Text}&FechaFin={txtFechaF.Text}&CveMoneda={e.Row.DataKey("CveMoneda")}&TipoDocto=Ing"
|
|
e.Row.Cells(0).Text = $"<a target='_blank' href='{liga}'>{e.Row.Cells(0).Text}</a>"
|
|
e.Row.Cells(1).Text = $"<a target='_blank' href='{liga}' >{e.Row.Cells(1).Text}</a>"
|
|
End If
|
|
End Sub
|
|
Private Sub GvRepPagado_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvRepPagado.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
Dim liga As String = $"../Compras/RepPagado.aspx?CveSubProyecto={DdlSubProyecto.SelectedValue}&FechaInicio={txtFechaI.Text}&FechaFin={txtFechaF.Text}&CveMoneda={e.Row.DataKey("CveMoneda")}&TipoDocto=Fac"
|
|
e.Row.Cells(0).Text = $"<a target='_blank' href='{liga}'>{e.Row.Cells(0).Text}</a>"
|
|
e.Row.Cells(1).Text = $"<a target='_blank' href='{liga}' >{e.Row.Cells(1).Text}</a>"
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub GvRepIngresosFact_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvRepIngresosFact.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If e.Row.DataKey("Fecha").ToString.Trim = "01/01/0001 12:00:00 a. m." Then
|
|
e.Row.CssClass = "Totales"
|
|
e.Row.Cells(0).Text = ""
|
|
End If
|
|
End If
|
|
End Sub
|
|
Private Sub GvRepCostosGastos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvRepCostosGastos.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If e.Row.DataKey("CveClasificacion").ToString.Trim.ToEntero = 0 Then
|
|
e.Row.CssClass = "Totales"
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
|
|
#End Region
|
|
|
|
#Region " GV DATOS "
|
|
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
End Class
|