Option Explicit On Option Strict On Imports System.Data Imports Extensiones Imports Microsoft.Reporting.WebForms Imports System.Net.Http Partial Class RepVentasDetalle Inherits ClsPaginas #Region "P R O P I E D A D E S" Private Property CveProyecto As Integer Get Return ViewState("CveProyecto").ToString.ToEntero End Get Set(value As Integer) ViewState("CveProyecto") = value End Set End Property Private Property CveSubProyecto() As String Get Return ViewState("CveSubProyecto").ToString End Get Set(ByVal value As String) ViewState("CveSubProyecto") = value End Set End Property Private Property DtVentas As DataTable Get If ViewState("DtVentas") Is Nothing Then ViewState("DtVentas") = New DataTable End If Return DirectCast(ViewState("DtVentas"), DataTable) End Get Set(value As DataTable) ViewState("DtVentas") = value End Set End Property Private Property TipoCambio As Integer Get Return ViewState("TipoCambio").ToString.ToEntero End Get Set(value As Integer) ViewState("TipoCambio") = 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 TipoCliente As Integer Get If ViewState("TipoCliente") Is Nothing Then Return -1 Else Return ViewState("TipoCliente").ToString.ToEntero End If End Get Set(value As Integer) ViewState("TipoCliente") = value End Set End Property Private Property TCEspecifico As Decimal Get Return ViewState("TCEspecifico").ToString.ToDecimal End Get Set(value As Decimal) ViewState("TCEspecifico") = value End Set End Property Private Property Personalizo As Integer Get Return ViewState("Personalizo").ToString.ToEntero End Get Set(value As Integer) ViewState("Personalizo") = value End Set End Property Private Property Agrupador As String Get Return ViewState("Agrupador").ToString End Get Set(value As String) ViewState("Agrupador") = value End Set End Property Public Property Primeracontsulta As Boolean Get If ViewState("Primeracontsulta") Is Nothing Then ViewState("Primeracontsulta") = True End If Return Boolean.Parse(ViewState("Primeracontsulta").ToString) End Get Set(value As Boolean) ViewState("Primeracontsulta") = value End Set End Property Private Property ConsultaAlCargar As Boolean Get Return CBool((IfNull(ViewState("ConsultaAlCargar"), False, ViewState("ConsultaAlCargar")))) End Get Set(value As Boolean) ViewState("ConsultaAlCargar") = value End Set End Property #End Region 'pRivate ReadOnly Property ColumnasVisibles As Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not IsPostBack Then If UsuarioActual.CveEmpresa = 2 AndAlso UsuarioActual.CveUsuario.Contiene(77, 21) Then Response.Redirect("/Inicio.aspx") Personalizo = 0 CargaCombos() InicializaValores() ConfiguraEmpresa() If ConsultaAlCargar Then CargaDatos() If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then LblServicioDomicilioFiltro.Visible = True DVServicioDomicilio.Visible = True End If If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then LblFacturaGlobal.Visible = True DivFacturaGlobal.Visible = True End If PrePersonalizacion() CargaPersonalizacion() End If End Sub Private Sub InicializaValores() Dim Grupo, CveCliente, CveSucursal, CveSubProyectoEjecucion, CveVendedor, CveUsuario, CveEstatusFactura, CveCorte, IVA, TipoDocto, CveClienteClasificacion, CveCondicionesPago, CveTipoRelacion As String Dim Anio, Mes, AnioMes, Fecha, FechaI, FechaF As String Dim AnioEjec, MesEjec, AnioMesEjec, FechaEjec, FechaIEjec, FechaFEjec As String Grupo = If(Request("GPO") IsNot Nothing AndAlso Request("GPO").ToEntero() > 0, Request("GPO").ToEntero(), -1).ToString ConsultaAlCargar = If(Grupo <> "-1", True, False) CveCliente = If(Request("CveCliente") IsNot Nothing AndAlso Request("CveCliente").ToEntero() > 0, Request("CveCliente").ToEntero(), -1).ToString CveClienteClasificacion = If(Request("CveClienteClasificacion") IsNot Nothing, Request("CveClienteClasificacion").ToEntero(), -1).ToString CveSucursal = If(Request("CveSucursal") IsNot Nothing AndAlso Request("CveSucursal").ToEntero() > 0, Request("CveSucursal").ToEntero(), -1).ToString CveSubProyectoEjecucion = If(Request("CveSubProyectoEjecucion") IsNot Nothing AndAlso Request("CveSubProyectoEjecucion").ToEntero() > 0, Request("CveSubProyectoEjecucion").ToEntero(), -1).ToString CveUsuario = If(Request("CveUsuario") IsNot Nothing AndAlso Request("CveUsuario").ToEntero() > 0, Request("CveUsuario").ToEntero(), -1).ToString CveCorte = If(Request("CveCorte") IsNot Nothing AndAlso Request("CveCorte").ToEntero() > 0, Request("CveCorte").ToEntero(), -1).ToString IVA = If(Request("IVA") IsNot Nothing, Request("IVA").ToString, "-1").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 AnioEjec = If(Request("AnioEjec") IsNot Nothing, Request("AnioEjec").ToString, "-1").ToString MesEjec = If(Request("MesEjec") IsNot Nothing, Request("MesEjec").ToString, "-1").ToString AnioMesEjec = If(Request("AnioMesEjec") IsNot Nothing, Request("AnioMesEjec").ToString, "-1").ToString FechaEjec = If(Request("FechaEjec") IsNot Nothing, Request("FechaEjec").ToString, "-1").ToString FechaIEjec = If(Request("FechaIEjec") IsNot Nothing, Request("FechaIEjec").ToString, "-1").ToString FechaFEjec = If(Request("FechaFEjec") IsNot Nothing, Request("FechaFEjec").ToString, "-1").ToString CveProyecto = If(Request("CveProyecto") IsNot Nothing, Request("CveProyecto").ToString.ToEntero, -1).ToString.ToEntero TipoCambio = If(Request("TipoCambio") IsNot Nothing, Request("TipoCambio").ToString.ToEntero, -1).ToString.ToEntero TCEspecifico = If(Request("TCEspecifico") IsNot Nothing, Request("TCEspecifico").ToString.ToEntero, -1).ToString.ToDecimal CveMoneda = If(Request("CveMoneda") IsNot Nothing, Request("CveMoneda").ToString.ToEntero, -1).ToString.ToEntero TipoCliente = If(Request("TipoCliente") IsNot Nothing, Request("TipoCliente").ToString.ToEntero, -1).ToString.ToEntero CveTipoRelacion = If(Request("CveTipoRelacion") IsNot Nothing, Request("CveTipoRelacion").ToString, "-1").ToString DdlTipoCliente.SelectedValueExist(TipoCliente) 'LISTBOXS TipoDocto = If(Request("TipoDocto") IsNot Nothing, Request("TipoDocto").ToString, "-1").ToString CveSubProyecto = If(Request("CveSubProyecto") IsNot Nothing, Request("CveSubProyecto").ToString, "-1").ToString CveVendedor = If(Request("CveVendedor") IsNot Nothing AndAlso Request("CveVendedor") <> "", Request("CveVendedor"), "-1").ToString CveEstatusFactura = If(Request("CveEstatusFactura") IsNot Nothing AndAlso Request("CveEstatusFactura") <> "", Request("CveEstatusFactura"), "-1").ToString CveCondicionesPago = If(Request("CveCondicionesPago") IsNot Nothing AndAlso Request("CveCondicionesPago") <> "", Request("CveCondicionesPago"), "-1").ToString DdlTipoComprobante.SelectedValuesIfExistM(TipoDocto) CargaEstatus() DdlEstatus.SelectedValuesIfExistM(CveEstatusFactura) DdlCondicionesPago.SelectedValueExist(CveCondicionesPago) DdlProyecto.SelectedValueExist(CveProyecto) 'If DivProyecto.Visible Then CargaSubProyecto() If CveProyecto.ToEntero > 0 Then CargarSubProyecto(DdlSubProyecto, DdlProyecto.SelectedValue, AplicaTodos:="Todos") DdlSubProyecto.SelectedValuesIfExistM(CveSubProyecto) DdlSubProyectoEjecucion.SelectedValueExist(CveSubProyectoEjecucion) DdlVendedor.SelectedValuesIfExistM(CveVendedor) DdlClienteClasificacion.SelectedValueExist(CveClienteClasificacion) DdlTipoRelacion.SelectedValueExist(CveTipoRelacion) CargaClientes() DdlClientes.SelectedValue = CveCliente DdlUsuario.SelectedValueExist(CveUsuario) DdlGrupo.SelectedValueExist(Grupo) DdlServicioDomicilio.SelectedValue = If(Request("ServicioDomicilio") IsNot Nothing, Request("ServicioDomicilio").ToString, "-1").ToString DdlFacturaGlobal.SelectedValue = If(Request("EsFacturaGlobal") IsNot Nothing, Request("EsFacturaGlobal").ToString, "-1").ToString DdlFilial.SelectedValue = IfNull(Request("EsFilial"), "-1").ToString UPFiltros.Update() 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) Dim sMes As String Dim sAnio As String = If(AnioMes <> "-1", AnioMes.Substring(0, 4), "") If AnioMes.Trim.Length = 7 Then sMes = AnioMes.Substring(5, 2).ToEntero.ToString("00") Else sMes = If(AnioMes <> "-1", AnioMes.Substring(5, 1).ToEntero.ToString("00"), "") End If txtFechaI.Text = If(AnioMes <> "-1", String.Format("01/{0}/{1}", sMes, sAnio), txtFechaI.Text) If Anio <> "-1" AndAlso txtFechaF.Text = "" Then txtFechaF.Text = String.Format("31/12/{0}", Anio) ElseIf Mes <> "-1" AndAlso txtFechaF.Text = "" Then txtFechaF.Text = txtFechaI.Text.ToDate.LastDayOfMonth.ToShortDateString ElseIf AnioMes <> "-1" AndAlso txtFechaF.Text = "" Then txtFechaF.Text = txtFechaI.Text.ToDate.LastDayOfMonth.ToShortDateString End If If FechaF <> "-1" Then txtFechaF.Text = FechaF End If If FechaI <> "-1" Then txtFechaI.Text = FechaI End If If Fecha <> "-1" Then txtFechaI.Text = Fecha txtFechaF.Text = Fecha End If TxtFechaIEjec.Text = If(AnioEjec <> "-1", String.Format("01/01/{0}", AnioEjec), TxtFechaIEjec.Text) TxtFechaIEjec.Text = If(MesEjec <> "-1", String.Format("01/{0}/0001", MesEjec), TxtFechaIEjec.Text) TxtFechaIEjec.Text = If(AnioMesEjec <> "-1", String.Format("01/{0}/{1}", AnioMesEjec.Substring(5, 1).PadLeft(2, "0"c), AnioMesEjec.Substring(0, 4)), TxtFechaIEjec.Text) If AnioEjec <> "-1" Then TxtFechaFEjec.Text = String.Format("31/12/{0}", AnioEjec) ElseIf MesEjec <> "-1" Then TxtFechaFEjec.Text = TxtFechaIEjec.Text.ToDate.LastDayOfMonth.ToShortDateString ElseIf AnioMesEjec <> "-1" Then TxtFechaFEjec.Text = TxtFechaIEjec.Text.ToDate.LastDayOfMonth.ToShortDateString End If If FechaFEjec <> "-1" Then TxtFechaFEjec.Text = FechaFEjec End If If FechaIEjec <> "-1" Then TxtFechaIEjec.Text = FechaIEjec End If If FechaEjec <> "-1" Then TxtFechaIEjec.Text = FechaEjec TxtFechaFEjec.Text = FechaEjec End If If UsuarioActual.CveEmpresa.Contiene(4, 7, 11, 12) Then ImgExcelVSH.Visible = True ImgExcel.Visible = False End If If UsuarioActual.CveVendedor > 0 AndAlso Not UsuarioActual.TienePermisoProceso(263) Then DdlVendedor.SelectedValuesIfExistM(UsuarioActual.CveVendedor.ToString) DdlVendedor.Attributes.Add("disabled", "") DdlVendedor.Enabled = False End If If Request("Menu") IsNot Nothing AndAlso Request("Menu").ToString() = "1" Then ConsultaAlCargar = False End If End Sub #Region "CARGA COMBOS" 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("Cliente", "5")) DdlGrupo.Items.Insert(5, New ListItem("Corte", "16")) DdlGrupo.Items.Insert(6, New ListItem("Vendedor", "7")) DdlGrupo.Items.Insert(7, New ListItem("Usuario", "8")) DdlGrupo.Items.Insert(8, New ListItem("Estatus", "9")) DdlGrupo.Items.Insert(9, New ListItem("% IVA", "10")) DdlGrupo.Items.Insert(10, New ListItem("Año Ejec.", "11")) DdlGrupo.Items.Insert(11, New ListItem("Mes Ejec.", "12")) DdlGrupo.Items.Insert(12, New ListItem("Año/Mes Ejec.", "13")) DdlGrupo.Items.Insert(13, New ListItem("Fecha Ejec.", "14")) DdlGrupo.Items.Insert(13, New ListItem("Vendedor/Cliente", "21")) DdlGrupo.DataBind() End Sub Private Sub CargaCombos() CargarCentrosDeCosto(DdlProyecto, DdlSubProyecto, LblProyecto, LblSubProyecto, divProyecto:=DivProyecto, VisualizacionReporte:=1) CargaClientes() 'DdlClientes.ddl.Items.Insert(0, New ListItem("Todos", "-1")) txtFechaI.Text = NowADS().FirstDayOfMonth.ToShortDateString txtFechaF.Text = NowADS().LastDayOfMonth.ToShortDateString 'Vendedor DdlVendedor.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa, VendedorTipo:=-1).FiltraParametros("VendedorTipo in (1,4)") 'vendedores y vendedores de piso DdlVendedor.DataBind() DdlVendedor.Items.Insert(0, New ListItem("Sin Vendedor", "-2")) 'CargaUsuarios DdlUsuario.DataSource = GlobalDTUsuarios(-1, UsuarioActual.CveEmpresa) DdlUsuario.DataBind() 'CargaEstatus DdlEstatus.DataSource = GlobalDTEstatusFactura DdlEstatus.DataBind() 'Carga Clasificacion Cliente DdlClienteClasificacion.DataSource = GlobalDTClienteClasificaciones(UsuarioActual.CveEmpresa) DdlClienteClasificacion.DataBind() DdlClienteClasificacion.Items.Insert(0, New ListItem("Todos", "-1")) DdlClienteClasificacion.Items.Insert(0, New ListItem("Sin Giro", "-2")) DdlTipoRelacion.DataSource = GlobalDTVtaTiposRelacion DdlTipoRelacion.DataBind() DdlTipoRelacion.Items.Insert(0, New ListItem("Todos", "-1")) CargaGrupo() End Sub Private Sub CargaEstatus() DdlEstatus.Items.Clear() If DdlTipoComprobante.GetSelectedText <> "" Then DdlEstatus.DataSource = GlobalDTEstatusFactura.FiltraParametros(String.Format("TipoDocto IN ({0})", DdlTipoComprobante.GetSelectedValuesM(True).Replace("Ant", "Ing"))) Else DdlEstatus.DataSource = GlobalDTEstatusFactura End If ' DdlEstatus.Items.Add(New ListItem("Todos", "-1")) DdlEstatus.DataBind() If DdlTipoComprobante.GetSelectedValuesM(True).Contains("Rem") Then For Each item As ListItem In DdlEstatus.Items If item.Value = "11" Then DdlEstatus.Items.Remove(item) DdlEstatus.Items.Insert(0, New ListItem("Registrada", "2")) Exit For End If Next End If End Sub #End Region #Region "SELECTED INDEX CHANGE" Protected Sub DdlTipoComprobante_SelectedIndexChanged(sender As Object, e As EventArgs) CargaEstatus() End Sub Protected Sub DdlProyecto_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlProyecto.SelectedIndexChanged CargarSubProyecto(DdlSubProyecto, DdlProyecto.SelectedValue, AplicaTodos:="Todos") End Sub Protected Sub DdlClienteClasificacion_SelectedIndexChanged(sender As Object, e As EventArgs) CargaClientes() End Sub Private Sub CargaClientes() Dim EsWS As Boolean = If(UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(141) = "1", True, False) If EsWS Then DdlClientes.setEsWebService(True) Else DdlClientes.setEsWebService(False) DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1).FiltraParametros($"CveClienteClasificacion = {DdlClienteClasificacion.SelectedValue.ToEntero} OR {DdlClienteClasificacion.SelectedValue.ToEntero} = -1") DdlClientes.DataBind() DdlClientes.ddl.Items.Insert(0, New ListItem("Todos", "-1")) End If 'DdlClientes.ddl.Items.Clear() 'DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1).FiltraParametros($"CveClienteClasificacion = {DdlClienteClasificacion.SelectedValue.ToEntero} OR {DdlClienteClasificacion.SelectedValue.ToEntero} = -1") 'DdlClientes.DataBind() 'DdlClientes.ddl.Items.Insert(0, New ListItem("Todos", "-1")) 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 Private Sub CargaDatos() Dim AnioMes As String = "-1" ' If(Request("AnioMes") IsNot Nothing, Request("AnioMes").ToString, "-1").ToString Dim Fecha As String = If(Request("Fecha") IsNot Nothing, Request("Fecha").ToString, "-1").ToString Dim IVA As String = If(Request("IVA") IsNot Nothing, Request("IVA").ToString, "-1").ToString Dim FechaI, FechaF, FechaIEjec, FechaFEjec As Date Dim Anio As String = If(Request("Anio") IsNot Nothing, Request("Anio").ToString, "-1").ToString Dim Mes As String = If(Request("Mes") IsNot Nothing, Request("Mes").ToString, "-1").ToString Dim CveCorte As String = If(Request("CveCorte") IsNot Nothing AndAlso Request("CveCorte").ToEntero() > 0, Request("CveCorte").ToEntero(), -1).ToString 'PARAMETROS DE LOS LISTBOXS Dim TipoComprobante As String = If(DdlTipoComprobante.GetSelectedValuesM = "", "-1", DdlTipoComprobante.GetSelectedValuesM) Dim Sucursales As String = If(DdlSubProyecto.GetSelectedValuesM = "", "-1", DdlSubProyecto.GetSelectedValuesM) Dim Estatus As String = If(DdlEstatus.GetSelectedValuesM = "", "-1", DdlEstatus.GetSelectedValuesM) Dim CveCondicionesPago As Integer = If(DdlCondicionesPago.SelectedValue = "", -1, DdlCondicionesPago.SelectedValue.ToEntero) Dim Vendedores As String = If(DdlVendedor.GetSelectedValuesM = "", "-1", DdlVendedor.GetSelectedValuesM) Dim CveCliente As Integer = If(DdlClientes.SelectedValue = "", -1, DdlClientes.SelectedValue.ToEntero) 'Anio = txtFechaI.Text.ToDate.Year.ToString 'Mes = txtFechaI.Text.ToDate.Month.ToString AnioMes = "-1" 'String.Format("{0}/{1}", txtFechaI.Text.ToDate.Year.ToString, txtFechaI.Text.ToDate.Month.ToString) FechaI = If(IsDate(txtFechaI.Text.Trim()), txtFechaI.Text.Trim.ToDate, MinFecha) FechaF = If(IsDate(txtFechaF.Text.Trim()), txtFechaF.Text.Trim.ToDate, MaxFecha) FechaIEjec = If(IsDate(TxtFechaIEjec.Text.Trim()), TxtFechaIEjec.Text.Trim.ToDate, MinFecha) FechaFEjec = If(IsDate(TxtFechaFEjec.Text.Trim()), TxtFechaFEjec.Text.Trim.ToDate, MaxFecha) If TipoComprobante.Contiene("Rem") And Not Estatus.Contiene("11") Then Estatus = Estatus & ",11" End If Dim ModalidadContable As Boolean = CBool(If(Request("ModalidadContable") IsNot Nothing, Request("ModalidadContable").ToEntero(), 0)) ChkLecturaAdmin.Checked = Not ModalidadContable CveProyecto = DdlProyecto.SelectedValue.ToEntero Dim ObjVentas As New ClsVentas() 'FechaI, FechaF, -1, UsuarioActual.CveEmpresa, DdlGrupo.SelectedValue.ToEntero If ObjVentas.GetRepVentasDetalle(DdlGrupo.SelectedValue.ToEntero, Anio.ToEntero, Mes.ToEntero, AnioMes, Fecha, CveCliente, IVA, Vendedores, DdlUsuario.SelectedValue.ToEntero, Estatus, FechaI, FechaF, CveCorte.ToEntero, TipoComprobante, DdlSubProyectoEjecucion.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, FechaIEjec, FechaFEjec, CveProyecto, Sucursales, TipoCambio, TCEspecifico, CveMoneda, CveUsuarioConsulta:=UsuarioActual.CveUsuario, CveClienteClasificacion:=DdlClienteClasificacion.SelectedValue.ToEntero, CveCondicionesPago:=CveCondicionesPago, TipoCliente:=DdlTipoCliente.SelectedValue.ToEntero, ModalidadContable:=Not ChkLecturaAdmin.Checked, CveTipoRelacion:=DdlTipoRelacion.SelectedValue.ToEntero(), ServicioDomicilio:=DdlServicioDomicilio.SelectedValue.ToEntero, EsFacturaGlobal:=DdlFacturaGlobal.SelectedValue.ToEntero, EsFilial:=DdlFilial.SelectedValue.ToEntero) Then DtVentas = AddRows(ObjVentas.DtResultados) ImgImprimir.Enabled = True GvDatos.DataSource = AddRows(ObjVentas.DtResultados) GvVsh.DataSource = ObjVentas.DtResultados.FiltraParametros("CveVenta > 0") If DtVentas.SUMD("Descuento") <= 0 Then GvDatos.Columns(5).Visible = False ' se oculta descuentos, si está vac+io Else If Primeracontsulta Then GvDatos.Columns(5).Visible = True ChkDescuento.Checked = True End If End If Else GvDatos.DataSource = Nothing GvVsh.DataSource = Nothing End If ObjVentas.Dispose() If DtVentas IsNot Nothing AndAlso DtVentas.Rows.Count > 0 AndAlso DtVentas.SUMD("Descuento") <= 0 Then GvDatos.Columns(5).Visible = False ' se oculta descuentos, si está vac+io Agrupador = DdlGrupo.SelectedItem.Text GvDatosDataBind() GvVsh.DataBind() Primeracontsulta = False End Sub Private Sub GvDatosDataBind() GvDatos.DataSource = DtVentas GvDatos.DataBind() UPDatos.Update() End Sub #End Region #Region "GRIDVIEW" Private Function AddRows(ByRef DT As DataTable) As DataTable Dim i As Integer = 0 Dim Ultima As String = String.Empty Dim Rows As Integer = 0 Dim dbRow As DataRow While i < DT.Rows.Count If DT.Rows(i)("GPO").ToString <> "" AndAlso DT.Rows(i)("CveVenta").ToString = "" AndAlso Ultima <> DT.Rows(i)("GPO").ToString Then dbRow = DT.NewRow() dbRow("GPO") = DT.Rows(i)("GPO") : Ultima = DT.Rows(i)("GPO").ToString DT.Rows.InsertAt(dbRow, i) End If i += 1 End While Return DT End Function Private Sub ConfiguraEmpresa() If Not UsuarioActual.Empresa.MostrarRetIVA Then GvDatos.Columns(10).Visible = False If Not UsuarioActual.Empresa.MostrarRetISR Then GvDatos.Columns(11).Visible = False ChkIEPS.Checked = UsuarioActual.Empresa.Funcionalidad(713) = "1" 'empresa deduce IEPS GvDatos.Columns(9).Visible = ChkIEPS.Checked ChkKilometraje.Visible = UsuarioActual.Empresa.Funcionalidad(558) = "1" 'empresa llantera End Sub Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.RowIndex = 0 Then e.Row.CssClass = "Totales" End If If e.Row.DBCampo("GPO") <> "" AndAlso e.Row.DBCampo("Cantidad") = "" Then For i As Integer = 1 To GvDatos.Columns.Count - 1 e.Row.Cells(i).Visible = False Next e.Row.Cells(0).ColumnSpan = GvDatos.Columns.Count e.Row.CssClass = "SubTotales2" e.Row.FCLiteral("LtlTipo").Text = e.Row.DBCampo("GPO") e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left e.Row.Visible = False ElseIf e.Row.DBCampo("CveVenta") = "" Then If e.Row.RowIndex > 0 Then e.Row.CssClass = "SubTotales" e.Row.FCLiteral("LtlFolio").Text = e.Row.DBCampo("Cantidad") e.Row.Cells(3).Text = e.Row.DBCampo("GPO") Else e.Row.FCLiteral("LtlFolio").Text = "" & e.Row.DBCampo("SerieFolio") & "" e.Row.FCLiteral("LtlCodCliente").Text = "" & e.Row.DBCampo("Codigo") & "" e.Row.FCLiteral("LtlCliente").Text = "" & e.Row.DBCampo("Nombre") & "" e.Row.FCLiteral("LtlFacturaCotizacion").Text = "" & e.Row.DBCampo("FolioVenta") & "" End If If e.Row.DBCampo("SubTotal").ToDouble = 0 Then e.Row.FCLiteral("LtlSubTotal").Text = "-" If e.Row.DBCampo("Descuento").ToDouble = 0 Then e.Row.FCLiteral("LtlDescuento").Text = "-" If e.Row.DBCampo("Amortizacion").ToDouble = 0 Then e.Row.FCLiteral("LtlAmortizacion").Text = "-" If e.Row.DBCampo("IVA").ToDouble = 0 Then e.Row.FCLiteral("LtlIVA").Text = "-" If e.Row.DBCampo("RetIVA").ToDouble = 0 Then e.Row.FCLiteral("LtlRetIVA").Text = "-" If e.Row.DBCampo("RetISR").ToDouble = 0 Then e.Row.FCLiteral("LtlRetISR").Text = "-" If e.Row.DBCampo("Total").ToDouble = 0 Then e.Row.FCLiteral("LtlTotal").Text = "-" If e.Row.DBCampo("SubTotal").ToDouble < 0 Then e.Row.Cells(4).ForeColor = Drawing.Color.Red If e.Row.DBCampo("Descuento").ToDouble < 0 Then e.Row.Cells(5).ForeColor = Drawing.Color.Red If e.Row.DBCampo("Amortizacion").ToDouble < 0 Then e.Row.Cells(7).ForeColor = Drawing.Color.Red If e.Row.DBCampo("IVA").ToDouble < 0 Then e.Row.Cells(8).ForeColor = Drawing.Color.Red If e.Row.DBCampo("RetIVA").ToDouble < 0 Then e.Row.Cells(9).ForeColor = Drawing.Color.Red If e.Row.DBCampo("RetISR").ToDouble < 0 Then e.Row.Cells(10).ForeColor = Drawing.Color.Red If e.Row.DBCampo("Total").ToDouble < 0 Then e.Row.Cells(11).ForeColor = Drawing.Color.Red If e.Row.DBCampo("Total").ToDouble < 0 Then e.Row.Cells(12).ForeColor = Drawing.Color.Red If e.Row.DBCampo("Total").ToDouble < 0 Then e.Row.Cells(13).ForeColor = Drawing.Color.Red Dim Ruta As String = UsuarioActual.Empresa.Ruta If IO.File.Exists($"{Ruta}XML\{e.Row.DBCampo("TipoDocto")}\{e.Row.DBCampo("SerieFolio")}.xml") Then e.Row.FCLiteral("LtlXML").Text = String.Format("
", e.Row.DBCampo("TipoDocto"), e.Row.DBCampo("SerieFolio")) Else e.Row.FCLiteral("LtlXML").Text = "" End If If UsuarioActual.Empresa.Funcionalidad(558) = "1" Then If e.Row.DBCampo("TipoDocto") <> "Cot" AndAlso IO.File.Exists($"{Ruta}PDF\{e.Row.DBCampo("TipoDocto")}\{e.Row.DBCampo("SerieFolio")}.pdf") Then e.Row.FCLiteral("LtlPDF").Text = String.Format("", e.Row.DBCampo("TipoDocto"), e.Row.DBCampo("SerieFolio")) Else e.Row.FCLiteral("LtlPDF").Text = "" End If Else If IO.File.Exists($"{Ruta}PDF\{e.Row.DBCampo("TipoDocto")}\{e.Row.DBCampo("SerieFolio")}.pdf") Then e.Row.FCLiteral("LtlPDF").Text = String.Format("", e.Row.DBCampo("TipoDocto"), e.Row.DBCampo("SerieFolio")) Else e.Row.FCLiteral("LtlPDF").Text = "" End If End If 'If e.Row.DBCampo("MAX_SubTotal").ToDouble = 0 Then e.Row.FCLiteral("LtlMaxSubTotal").Text = "" 'If e.Row.DBCampo("AVG_SubTotal").ToDouble = 0 Then e.Row.FCLiteral("LtlAVGSubTotal").Text = "" 'If e.Row.DBCampo("MIN_SubTotal").ToDouble = 0 Then e.Row.FCLiteral("LtlMinSubTotal").Text = "" 'If e.Row.DBCampo("MAX_Total").ToDouble = 0 Then e.Row.FCLiteral("LtlMaxTotal").Text = "" 'If e.Row.DBCampo("AVG_Total").ToDouble = 0 Then e.Row.FCLiteral("LtlAVGTotal").Text = "" 'If e.Row.DBCampo("MIN_Total").ToDouble = 0 Then e.Row.FCLiteral("LtlMinTotal").Text = "" End If End Sub Protected Sub GvVsh_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvVsh.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then GvVsh.Caption = String.Format("{0} {1} {2}