500 lines
18 KiB
VB.net
500 lines
18 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports Extensiones
|
|
Imports System.Data
|
|
Partial Class General_Encuestas
|
|
Inherits ClsPaginas
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
If Not Page.IsPostBack Then
|
|
InicializaValores()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub InicializaValores()
|
|
CargaGridCampañas()
|
|
CargaGridTiposEncuestas()
|
|
CargaDdlTemaPregunta()
|
|
CargaGridEncuestas()
|
|
CargaEstructura()
|
|
End Sub
|
|
|
|
|
|
|
|
#Region " C A M P A Ñ A "
|
|
Private Sub CargaGridCampañas()
|
|
Dim Objeto As New ClsGralEncuestas
|
|
If Objeto.GetCampañas(-1, -1, UsuarioActual.CveEmpresa) Then
|
|
GvCampañas.DataSource = Objeto.DtResultados
|
|
GvCampañas.DataBind()
|
|
UpCampañas.Update()
|
|
End If
|
|
Objeto.Dispose()
|
|
End Sub
|
|
|
|
Private Sub BtnAgregarCampaña_Click(sender As Object, e As EventArgs) Handles BtnAgregarCampaña.ServerClick
|
|
TxtCampaña.Text = ""
|
|
TxtObservaciones.Text = ""
|
|
UpModalCampaña.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal();", "ModalCampaña"))
|
|
End Sub
|
|
|
|
Private Sub LbAgregarCampaña_Click(sender As Object, e As EventArgs) Handles LbAgregarCampaña.Click
|
|
Dim Objeto As New ClsGralEncuestas
|
|
If Objeto.AddCampañas(TxtCampaña.Text, TxtObservaciones.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
CargaGridCampañas()
|
|
Alert("Se agregó correctamente la Campaña.", TipoMensaje.MsgInformacion)
|
|
OcultaDiv("ModalCampaña")
|
|
End If
|
|
Objeto.Dispose()
|
|
End Sub
|
|
|
|
Protected Sub GvCampañas_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvCampañas.RowDeleting
|
|
Dim Objeto As New ClsGralEncuestas
|
|
If Objeto.RemoveCampañas(GvCampañas.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then
|
|
CargaGridCampañas()
|
|
Alert("La Campaña se eliminó correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
Objeto.Dispose()
|
|
End Sub
|
|
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
#Region " T i p o E n c u e s t a s"
|
|
Private Sub CargaGridTiposEncuestas()
|
|
Dim Objeto As New ClsGralEncuestas
|
|
If Objeto.GetTiposEncuestas(-1, -1, UsuarioActual.CveEmpresa) Then
|
|
GvTipoEncuesta.DataSource = Objeto.DtResultados
|
|
GvTipoEncuesta.DataBind()
|
|
UpTipoEncuesta.Update()
|
|
End If
|
|
Objeto.Dispose()
|
|
End Sub
|
|
|
|
Private Sub BtnAgregarTipo_Click(sender As Object, e As EventArgs) Handles BtnAgregarTipo.ServerClick
|
|
TxtTipo.Text = ""
|
|
UpModalTipoEncuesta.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal();", "ModalTipoEncuesta"))
|
|
End Sub
|
|
|
|
Private Sub LbAgregarTipoEncuesta_Click(sender As Object, e As EventArgs) Handles LbAgregarTipoEncuesta.Click
|
|
Dim Objeto As New ClsGralEncuestas
|
|
If Objeto.AddTiposEncuestas(TxtTipo.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
CargaGridTiposEncuestas()
|
|
Alert("Se agregó correctamente el Tipo de Encuesta.", TipoMensaje.MsgInformacion)
|
|
OcultaDiv("ModalTipoEncuesta")
|
|
End If
|
|
Objeto.Dispose()
|
|
End Sub
|
|
|
|
Protected Sub GvTipoEncuesta_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvTipoEncuesta.RowDeleting
|
|
Dim Objeto As New ClsGralEncuestas
|
|
If Objeto.RemoveTiposEncuestas(GvTipoEncuesta.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then
|
|
CargaGridTiposEncuestas()
|
|
Alert("El Tipo de Encuesta se eliminó correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
Objeto.Dispose()
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
|
|
#Region " T e m a E n c u e s t a s"
|
|
Private Sub CargaDdlTemaPregunta()
|
|
Dim Objeto As New ClsGralEncuestas
|
|
If Objeto.GetTemasEncuestas(-1, -1, UsuarioActual.CveEmpresa) Then
|
|
DdlTemaPregunta.Items.Clear()
|
|
DdlTemaPregunta.DataSource = Objeto.DtResultados
|
|
DdlTemaPregunta.DataBind()
|
|
DdlTemaPregunta.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
UpModalPreguntas.Update()
|
|
End If
|
|
Objeto.Dispose()
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
Private Sub BtnAgregarTema_Click(sender As Object, e As EventArgs) Handles BtnAgregarTema.ServerClick
|
|
HdnModalidad.Value = "I"
|
|
HdnID.Value = "-1"
|
|
TxtTema.Text = ""
|
|
UpHdn.Update()
|
|
UpModalTema.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal();", "ModalTema"))
|
|
End Sub
|
|
|
|
|
|
Private Sub ActualizaTema(GvRow As GridViewRow)
|
|
HdnModalidad.Value = "U"
|
|
HdnID.Value = GvRow.DataKey("CveTema")
|
|
CargaPreguntasEnModal()
|
|
TxtTema.Text = GvRow.DataKey("Tema")
|
|
UpHdn.Update()
|
|
UpModalTema.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal();", "ModalTema"))
|
|
End Sub
|
|
|
|
Private Sub LbAgregarTema_Click(sender As Object, e As EventArgs) Handles LbAgregarTema.Click
|
|
Dim Objeto As New ClsGralEncuestas
|
|
If HdnModalidad.Value = "I" Then
|
|
If Objeto.AddTemasEncuestas(TxtTema.Text, DdlEncuestaTema.SelectedValue.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
CargaDdlTemaPregunta()
|
|
Alert("Se agregó correctamente el Tema de Encuesta.", TipoMensaje.MsgInformacion)
|
|
OcultaDiv("ModalTema")
|
|
CargaEstructura()
|
|
End If
|
|
Else
|
|
If HdnID.Value.ToEntero <> -1 Then
|
|
If Objeto.UpdateTemasEncuestas(HdnID.Value.ToEntero, TxtTema.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
CargaDdlTemaPregunta()
|
|
Alert("Se actualizó correctamente el Tema de Encuesta.", TipoMensaje.MsgInformacion)
|
|
OcultaDiv("ModalTema")
|
|
CargaEstructura()
|
|
End If
|
|
End If
|
|
End If
|
|
Objeto.Dispose()
|
|
|
|
End Sub
|
|
|
|
Protected Sub EliminarTema(GvRow As GridViewRow)
|
|
Dim Objeto As New ClsGralEncuestas
|
|
If Objeto.RemoveTemasEncuestas(GvRow.DataKey("CveTema").ToEntero) Then
|
|
CargaEstructura()
|
|
Alert("El Tema se eliminó correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
Objeto.Dispose()
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
|
|
#Region " P r e g u n t a s "
|
|
Private Sub AgregaPregunta(GvRow As GridViewRow)
|
|
HdnModalidad.Value = "I"
|
|
HdnID.Value = "-1"
|
|
TxtPregunta.Text = ""
|
|
DdlTemaPregunta.SelectedValue = GvRow.DataKey("CveTema")
|
|
DdlTipoPregunta.SelectedIndex = 0
|
|
UpModalPreguntas.Update()
|
|
|
|
UpHdn.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal();", "ModalPreguntas"))
|
|
End Sub
|
|
|
|
|
|
Private Sub ActualizaPregunta(GvRow As GridViewRow)
|
|
HdnModalidad.Value = "U"
|
|
HdnID.Value = GvRow.DataKey("CvePregunta")
|
|
TxtPregunta.Text = GvRow.DataKey("Pregunta")
|
|
DdlTemaPregunta.SelectedValue = GvRow.DataKey("CveTema")
|
|
DdlTipoPregunta.SelectedIndex = 0
|
|
UpModalPreguntas.Update()
|
|
UpHdn.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal();", "ModalPreguntas"))
|
|
End Sub
|
|
|
|
Private Sub LbAgregarPregunta_Click(sender As Object, e As EventArgs) Handles LbAgregarPregunta.Click
|
|
Dim Objeto As New ClsGralEncuestas
|
|
|
|
If HdnModalidad.Value = "I" Then
|
|
If Objeto.AddPreguntas(TxtPregunta.Text, DdlTipoPregunta.SelectedValue.ToEntero, DdlTemaPregunta.SelectedValue.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
Alert("La Pregunta se agregó correctamente.", TipoMensaje.MsgInformacion)
|
|
OcultaDiv("ModalPreguntas")
|
|
CargaEstructura()
|
|
End If
|
|
Else
|
|
If HdnID.Value.ToEntero <> -1 Then
|
|
If Objeto.UpdatePreguntas(HdnID.Value.ToEntero, TxtPregunta.Text, DdlTipoPregunta.SelectedValue.ToEntero, DdlTemaPregunta.SelectedValue.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
Alert("La Pregunta se actualizó correctamente.", TipoMensaje.MsgInformacion)
|
|
OcultaDiv("ModalPreguntas")
|
|
CargaEstructura()
|
|
End If
|
|
End If
|
|
End If
|
|
Objeto.Dispose()
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Sub EliminarPregunta(GvRow As GridViewRow)
|
|
Dim Objeto As New ClsGralEncuestas
|
|
If Objeto.RemovePreguntas(GvRow.DataKey("CvePregunta").ToEntero) Then
|
|
CargaEstructura()
|
|
Alert("La Pregunta se eliminó correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
Objeto.Dispose()
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
|
|
#Region " R E S P U E S T A S "
|
|
Private Sub CargaPreguntasEnModal()
|
|
Dim Objeto As New ClsGralEncuestas
|
|
If Objeto.GetPreguntas(-1, -1, -1, UsuarioActual.CveEmpresa) Then
|
|
DdlPregunta.DataSource = Objeto.DtResultados
|
|
DdlPregunta.Items.Clear()
|
|
DdlPregunta.Items.Insert(0, New ListItem("Seleccione (Todos)", "-1"))
|
|
DdlPregunta.DataBind()
|
|
UpModalRespuestas.Update()
|
|
End If
|
|
Objeto.Dispose()
|
|
End Sub
|
|
|
|
|
|
Private Sub AgregaRespuestas(GvRow As GridViewRow)
|
|
HdnModalidad.Value = "I"
|
|
HdnID.Value = "-1"
|
|
CargaPreguntasEnModal()
|
|
DdlPregunta.SelectedValue = GvRow.DataKey("CvePregunta")
|
|
TxtRespuesta.Text = ""
|
|
UpHdn.Update()
|
|
UpModalRespuestas.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal();", "ModalRespuestas"))
|
|
End Sub
|
|
|
|
|
|
Private Sub ActualizaRespuestas(GvRow As GridViewRow)
|
|
HdnModalidad.Value = "U"
|
|
HdnID.Value = GvRow.DataKey("CveRespuesta")
|
|
CargaPreguntasEnModal()
|
|
DdlPregunta.SelectedValue = GvRow.DataKey("CvePregunta")
|
|
TxtRespuesta.Text = GvRow.DataKey("Respuesta")
|
|
UpHdn.Update()
|
|
UpModalRespuestas.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal();", "ModalRespuestas"))
|
|
End Sub
|
|
|
|
|
|
|
|
Private Sub LbAgregarRespuesta_Click(sender As Object, e As EventArgs) Handles LbAgregarRespuesta.Click
|
|
Dim Objeto As New ClsGralEncuestas
|
|
If HdnModalidad.Value = "I" Then
|
|
If Objeto.AddRespuestas(TxtRespuesta.Text, DdlPregunta.SelectedValue.ToEntero) Then
|
|
Alert("La Respuesta se registró correctamente.", TipoMensaje.MsgInformacion)
|
|
OcultaDiv("ModalRespuestas")
|
|
CargaEstructura()
|
|
End If
|
|
Else
|
|
If HdnID.Value.ToEntero <> -1 Then
|
|
If Objeto.UpdateRespuestas(HdnID.Value.ToEntero, TxtRespuesta.Text, DdlPregunta.SelectedValue.ToEntero) Then
|
|
Alert("La Respuesta se actualizó correctamente.", TipoMensaje.MsgInformacion)
|
|
OcultaDiv("ModalRespuestas")
|
|
CargaEstructura()
|
|
End If
|
|
End If
|
|
End If
|
|
Objeto.Dispose()
|
|
|
|
End Sub
|
|
|
|
|
|
Private Sub EliminarRespuesta(GvRow As GridViewRow)
|
|
Dim Objeto As New ClsGralEncuestas
|
|
If Objeto.RemoveRespuesta(GvRow.DataKey("CveRespuesta").ToEntero) Then
|
|
Alert("La respuesta se eliminó correctamente.", TipoMensaje.MsgInformacion)
|
|
CargaEstructura()
|
|
End If
|
|
Objeto.Dispose()
|
|
End Sub
|
|
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
#Region " E N C U E S T A S "
|
|
|
|
Private Sub BtnAgregarEncuesta_Click(sender As Object, e As EventArgs) Handles BtnAgregarEncuesta.ServerClick
|
|
CargaModalEncuestas()
|
|
TxtFecha.Text = ""
|
|
TxtEncuesta.Text = ""
|
|
TxtObservacionesEncuesta.Text = ""
|
|
RegistraScript(String.Format("$('#{0}').modal();", "ModalEncuestas"))
|
|
End Sub
|
|
|
|
Private Sub BtnFiltrar_ServerClick(sender As Object, e As EventArgs) Handles BtnFiltrar.ServerClick
|
|
DdlFiltroEncuestas.SelectedIndex = 0
|
|
RegistraScript(String.Format("$('#{0}').modal();", "ModalFiltroEncuestas"))
|
|
End Sub
|
|
|
|
|
|
Private Sub BtnFiltrarEncuestas_Click(sender As Object, e As EventArgs) Handles BtnFiltrarEncuestas.Click
|
|
FiltraEstructura(DdlFiltroEncuestas.SelectedValue.ToEntero)
|
|
OcultaDiv("ModalFiltroEncuestas")
|
|
End Sub
|
|
|
|
|
|
Private Sub CargaModalEncuestas()
|
|
Dim Objeto As New ClsGralEncuestas
|
|
|
|
|
|
If Objeto.GetCampañas(-1, -1, UsuarioActual.CveEmpresa) Then
|
|
DdlCampana.DataSource = Objeto.DtResultados
|
|
DdlCampana.Items.Clear()
|
|
DdlCampana.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlCampana.DataBind()
|
|
End If
|
|
|
|
If Objeto.GetTiposEncuestas(-1, -1, UsuarioActual.CveEmpresa) Then
|
|
DdlTipoEncuesta.DataSource = Objeto.DtResultados
|
|
DdlTipoEncuesta.Items.Clear()
|
|
DdlTipoEncuesta.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlTipoEncuesta.DataBind()
|
|
End If
|
|
Objeto.Dispose()
|
|
UpModalEncuestas.Update()
|
|
End Sub
|
|
|
|
|
|
Private Sub LbAgregarEncuesta_Click(sender As Object, e As EventArgs) Handles LbAgregarEncuesta.Click
|
|
Dim Objeto As New ClsGralEncuestas
|
|
If Objeto.AddEncuesta(DdlCampana.SelectedValue.ToEntero, -1, TxtEncuesta.Text, TxtObservacionesEncuesta.Text, -1,
|
|
DdlTipoEncuesta.SelectedValue.ToEntero, True, TxtFecha.Text.ToDate, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
Alert("La Encuesta se agregó correctamente.", TipoMensaje.MsgInformacion)
|
|
CargaGridEncuestas()
|
|
OcultaDiv("ModalEncuestas")
|
|
End If
|
|
Objeto.Dispose()
|
|
End Sub
|
|
|
|
|
|
Protected Sub GvEncuesta_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvEncuesta.RowDeleting
|
|
Dim Objeto As New ClsGralEncuestas
|
|
If Objeto.RemoveEncuestas(GvEncuesta.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then
|
|
CargaGridEncuestas()
|
|
Alert("La Encuesta se eliminó correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
Objeto.Dispose()
|
|
End Sub
|
|
|
|
|
|
Private Sub CargaGridEncuestas()
|
|
Dim Objeto As New ClsGralEncuestas
|
|
If Objeto.GetEncuestas(UsuarioActual.CveEmpresa) Then
|
|
GvEncuesta.DataSource = Objeto.DtResultados
|
|
DdlFiltroEncuestas.Items.Clear()
|
|
DdlEncuestaTema.Items.Clear()
|
|
DdlFiltroEncuestas.DataSource = Objeto.DtResultados
|
|
DdlEncuestaTema.DataSource = Objeto.DtResultados
|
|
DdlFiltroEncuestas.DataBind()
|
|
DdlEncuestaTema.DataBind()
|
|
GvEncuesta.DataBind()
|
|
End If
|
|
Objeto.Dispose()
|
|
UpEncuestas.Update()
|
|
UpModalTema.Update()
|
|
UpFiltroEncuestas.Update()
|
|
End Sub
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
|
|
#Region " E S T R U C T U R A "
|
|
Private Sub CargaEstructura()
|
|
Dim Objeto As New ClsGralEncuestas
|
|
If Objeto.GetEstructura(-1, UsuarioActual.CveEmpresa) Then
|
|
GvEstructura.DataSource = Objeto.DtResultados
|
|
GvEstructura.DataBind()
|
|
UpEstructura.Update()
|
|
End If
|
|
Objeto.Dispose()
|
|
End Sub
|
|
|
|
Private Sub FiltraEstructura(CveEncuesta As Integer)
|
|
Dim Objeto As New ClsGralEncuestas
|
|
If Objeto.GetEstructura(CveEncuesta, UsuarioActual.CveEmpresa) Then
|
|
GvEstructura.DataSource = Objeto.DtResultados
|
|
GvEstructura.DataBind()
|
|
UpEstructura.Update()
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub GvEstructura_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvEstructura.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
Dim Tipo = e.Row.DataKey("Tipo").ToString
|
|
Select Case Tipo
|
|
Case "1"
|
|
e.Row.Font.Bold = True
|
|
e.Row.ForeColor = Drawing.Color.White
|
|
e.Row.BackColor = Drawing.Color.FromArgb(1, 186, 205, 206)
|
|
e.Row.FCLiteral("LtlTema").Visible = True
|
|
e.Row.FCLinkButton("ImgA").Visible = True
|
|
Case "2"
|
|
e.Row.BackColor = Drawing.Color.FromArgb(1, 213, 225, 225)
|
|
e.Row.FCLiteral("LtlPregunta").Visible = True
|
|
e.Row.FCLinkButton("ImgA").Visible = True
|
|
|
|
Case "3"
|
|
e.Row.BackColor = Drawing.Color.White
|
|
e.Row.FCLiteral("LtlRespuesta").Visible = True
|
|
End Select
|
|
End If
|
|
End Sub
|
|
|
|
|
|
Protected Sub AddEstructura(sender As Object, e As EventArgs)
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
Dim Tipo As Integer = GvRow.DataKey("Tipo").ToString.ToEntero
|
|
Select Case Tipo
|
|
Case -1
|
|
Case 2
|
|
AgregaRespuestas(GvRow)
|
|
Case 1
|
|
AgregaPregunta(GvRow)
|
|
End Select
|
|
End Sub
|
|
|
|
Protected Sub EliminarEstructura(sender As Object, e As EventArgs)
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
Dim Tipo As Integer = GvRow.DataKey("Tipo").ToString.ToEntero
|
|
Select Case Tipo
|
|
Case 3
|
|
'RESPUESTA
|
|
EliminarRespuesta(GvRow)
|
|
Case 2
|
|
'PREGUNTAS
|
|
EliminarPregunta(GvRow)
|
|
Case 1
|
|
'TEMA
|
|
EliminarTema(GvRow)
|
|
End Select
|
|
End Sub
|
|
|
|
Protected Sub UpdateEstructura(sender As Object, e As EventArgs)
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
Dim Tipo As Integer = GvRow.DataKey("Tipo").ToString.ToEntero
|
|
Select Case Tipo
|
|
Case 3
|
|
ActualizaRespuestas(GvRow)
|
|
Case 2
|
|
ActualizaPregunta(GvRow)
|
|
' ActualizaPregunta(GvRow)
|
|
Case 1
|
|
'ActualizaTema(GvRow)
|
|
ActualizaTema(GvRow)
|
|
End Select
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region " E X T R A S "
|
|
Private Sub OcultaDiv(Modal As String)
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", Modal))
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
End Class
|