Option Explicit On Option Strict On Imports System.Data Imports System.Activities.Expressions Imports System.Web.UI.WebControls.Expressions Imports Extensiones Partial Class Prospectos_RepEncuestasDetalleTabla Inherits ClsPaginas Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then ViewState("Orden") = String.Empty If IfNull(Request("Estructura"), "0").ToString = "1" Then CargaEstructura() PnlFiltro.Visible = False Else DdlEncuesta.DataSource = GlobalDTProspectosEncuestas(UsuarioActual.CveEmpresa) DdlEncuesta.DataBind() End If 'CveEncuesta = DdlEncuesta.SelectedValue.ToEntero 'CvePregunta = IfNull(Request("CvePregunta"), "0").ToString.ToEntero 'CveRespuesta = IfNull(Request("CveRespuesta"), "0").ToString.ToEntero End If End Sub Private Sub CargaEstructura() Dim ObjProspectos As New ClsProspectos Dim dt As DataTable = nothing If ObjProspectos.GetRepEstructurasDetalleJGM() Then dt = ObjProspectos.DtResultados ViewState("DTProspectos") = dt LblTotal.Text = String.Format("Registros: {0:N0}", dt.Rows.Count) 'If ds.Tables.Count > 0 Then ' Dim dt1 As DataTable = ds.Tables(0).FiltraParametros("CveProspectoTipo = 2") ' ds = ObjProspectos.GetRepEncuestasDetalleTabla(5, -1, -1, UsuarioActual.CveEmpresa) ' dt1.Merge(ds.Tables(0)) ' ViewState("DTProspectos") = dt1.FiltraParametros("CveProspectoTipo = 2") ' LblTotal.Text = String.Format("Registros: {0}", dt1.Rows.Count) 'End If 'LtlAgrupador.Text = DdlAgrupador.SelectedItem.Text Else Me.GvDatos.DataSource = Nothing LblTotal.Text = "" End If ObjProspectos.Dispose() dt.Dispose() If ViewState("Orden").ToString() <> String.Empty Then CargaGrid(ViewState("Orden").ToString()) Else CargaGrid("") End If End Sub Public Sub CargaDatos(CveEncuesta As Integer, CvePregunta As Integer, CveRespuesta As Integer) Dim ObjProspectos As New ClsProspectos Dim ds As DataSet = ObjProspectos.GetRepEncuestasDetalleTabla(CveEncuesta, CvePregunta, CveRespuesta, UsuarioActual.CveEmpresa) If ds IsNot Nothing Then If ds.Tables.Count > 0 Then ViewState("DTProspectos") = ds.Tables(0) Dim dt1 As DataTable = ds.Tables(1) LblTotal.Text = String.Format("Registros: {0}", ds.Tables(0).Rows.Count) If GvDatos.Columns.Count > 21 Then Dim i As Integer = GvDatos.Columns.Count - 21 For jj = 0 To i - 1 GvDatos.Columns.RemoveAt(21) Next End If For Each dr As DataRow In dt1.Rows Dim bfield As New BoundField() bfield.HeaderText = dr("Pregunta").ToString : bfield.DataField = String.Format("Preg_{0}", dr("CvePregunta")) GvDatos.Columns.Add(bfield) Next End If 'LtlAgrupador.Text = DdlAgrupador.SelectedItem.Text Else Me.GvDatos.DataSource = Nothing LblTotal.Text = "" End If ObjProspectos.Dispose() If ViewState("Orden").ToString() <> String.Empty Then CargaGrid(ViewState("Orden").ToString()) Else CargaGrid("") End If End Sub Private Sub CargaGrid(Orden As String) If Orden <> String.Empty Then Dim DV As New DataView(CType(ViewState("DTProspectos"), DataTable), "", Orden, DataViewRowState.CurrentRows) GvDatos.DataSource = DV.ToTable() DV.Dispose() Else GvDatos.DataSource = CType(ViewState("DTProspectos"), DataTable) End If GvDatos.DataBind() End Sub 'Protected Sub GvDatos_RowCreated(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles GvDatos.RowCreated ' If (e.Row.RowType = DataControlRowType.DataRow AndAlso (e.Row.RowState = DataControlRowState.Normal OrElse e.Row.RowState = DataControlRowState.Alternate)) Then ' e.Row.TabIndex = -1 ' e.Row.Attributes("onclick") = String.Format("javascript:SelectRow(this, {0});", e.Row.RowIndex) ' e.Row.Attributes("onkeydown") = "javascript:return SelectSibling(event);" ' e.Row.Attributes("onselectstart") = "javascript:return false;" ' ' e.Row.Cells(10).Attributes.Add("onclick", "EC();") ' End If '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 'ElseIf e.Row.RowIndex = 1 Then ' e.Row.Cells(0).Width = Unit.Pixel(120) ' e.Row.Cells(1).Width = Unit.Pixel(60) ' e.Row.Cells(2).Width = Unit.Pixel(60) ' e.Row.Cells(3).Width = Unit.Pixel(60) ' e.Row.Cells(4).Width = Unit.Pixel(70) ' e.Row.Cells(5).Width = Unit.Pixel(60) ' e.Row.Cells(6).Width = Unit.Pixel(60) ' e.Row.Cells(7).Width = Unit.Pixel(70) ' e.Row.Cells(8).Width = Unit.Pixel(100) ' e.Row.Cells(9).Width = Unit.Pixel(80) ' e.Row.Cells(10).Width = Unit.Pixel(105) ' e.Row.Cells(11).Width = Unit.Pixel(100) ' e.Row.Cells(12).Width = Unit.Pixel(100) ' e.Row.Cells(13).Width = Unit.Pixel(110) ' e.Row.Cells(14).Width = Unit.Pixel(100) ' e.Row.Cells(15).Width = Unit.Pixel(80) ' e.Row.Cells(16).Width = Unit.Pixel(70) ' e.Row.Cells(17).Width = Unit.Pixel(70) ' e.Row.Cells(18).Width = Unit.Pixel(60) ' e.Row.Cells(19).Width = Unit.Pixel(60) ' e.Row.Cells(20).Width = Unit.Pixel(120) ' e.Row.Cells(21).Width = Unit.Pixel(60) ' e.Row.Cells(22).Width = Unit.Pixel(60) End If End If End Sub Protected Sub ImgExcel_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs) Handles ImgExcel.Click Dim ObjProspectos As New ClsProspectos Dim ds As DataSet = ObjProspectos.GetRepEncuestasDetalleTabla(DdlEncuesta.SelectedValue.ToEntero, -1, -1, UsuarioActual.CveEmpresa) If ds IsNot Nothing Then If ds.Tables.Count > 0 Then 'ViewState("DTProspectos") = ds.Tables(0) Dim dt1 As DataTable = ds.Tables(1) 'If GvDatos.Columns.Count > 21 Then ' Dim i As Integer = GvDatos.Columns.Count - 21 ' For jj = 0 To i - 1 ' GvDatos.Columns.RemoveAt(21) ' Next 'End If For Each dr As DataRow In dt1.Rows Dim bfield As New BoundField() bfield.HeaderText = dr("Pregunta").ToString : bfield.DataField = String.Format("Preg_{0}", dr("CvePregunta")) GVD.Columns.Add(bfield) Next Dim cvefield As New BoundField() cvefield.HeaderText = "Clave" : cvefield.DataField = "CveProspecto" GVD.Columns.Add(cvefield) GVD.DataSource = ds.Tables(0) GVD.DataBind() End If 'LtlAgrupador.Text = DdlAgrupador.SelectedItem.Text Else Me.GvDatos.DataSource = Nothing LblTotal.Text = "" End If ObjProspectos.Dispose() GVD.ExportToExcel("Estructuras") End Sub Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click CargaDatos(DdlEncuesta.SelectedValue.ToEntero, -1, -1) End Sub Protected Sub Btn1y2_Click(sender As Object, e As EventArgs) Handles Btn1y2.Click Dim ObjProspectos As New ClsProspectos Dim ds As DataSet = ObjProspectos.GetRepEncuestasDetalleTabla2(DdlEncuesta.SelectedValue.ToEntero, -1, -1, UsuarioActual.CveEmpresa) If ds IsNot Nothing Then If ds.Tables.Count > 0 Then 'ViewState("DTProspectos") = ds.Tables(0) Dim dt1 As DataTable = ds.Tables(1) 'If GvDatos.Columns.Count > 21 Then ' Dim i As Integer = GvDatos.Columns.Count - 21 ' For jj = 0 To i - 1 ' GvDatos.Columns.RemoveAt(21) ' Next 'End If For Each dr As DataRow In dt1.Rows Dim bfield As New BoundField() bfield.HeaderText = dr("Pregunta").ToString : bfield.DataField = String.Format("Preg_{0}", dr("CvePregunta")) GV1y2.Columns.Add(bfield) Next GV1y2.DataSource = ds.Tables(0) GV1y2.DataBind() End If 'LtlAgrupador.Text = DdlAgrupador.SelectedItem.Text Else Me.GV1y2.DataSource = Nothing LblTotal.Text = "" End If ObjProspectos.Dispose() GV1y2.ExportToExcel("Encuestas") End Sub End Class