886 lines
26 KiB
C#
886 lines
26 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using System.Data;
|
|
using Microsoft.Reporting.WebForms;
|
|
using Extensiones;
|
|
using System.ComponentModel.Design;
|
|
using DocumentFormat.OpenXml.Wordprocessing;
|
|
using Profact.TimbraCFDI33.Complementos.CartaPorte10;
|
|
|
|
public partial class CRM_CatTipoProceso : ClsPaginas
|
|
{
|
|
#region "PROPIEDADES"
|
|
private int EsEditar
|
|
{
|
|
get
|
|
{
|
|
return ViewState["EsEditar"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["EsEditar"] = value;
|
|
}
|
|
}
|
|
private DataTable TmpDT
|
|
{
|
|
get
|
|
{
|
|
return (DataTable)ViewState["TmpDT"];
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["TmpDT"] = value;
|
|
}
|
|
}
|
|
private int CveTipoProceso
|
|
{
|
|
get
|
|
{
|
|
return ViewState["CveTipoProceso"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveTipoProceso"] = value;
|
|
}
|
|
}
|
|
|
|
|
|
private int CvePregunta{
|
|
get
|
|
{
|
|
if (ViewState["CvePregunta"] == null)
|
|
{
|
|
ViewState["CvePregunta"] = -1;
|
|
}
|
|
return ViewState["CvePregunta"].ToString().ToEntero();
|
|
}
|
|
set{
|
|
ViewState["CvePregunta"] = value;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//private int CveCampana
|
|
//{
|
|
// get
|
|
// {
|
|
// if(ViewState["CveCampana"] == null)
|
|
// {
|
|
// ViewState["CveCampana"] = -1;
|
|
// }
|
|
// return ViewState["CveCampana"].ToString().ToEntero();
|
|
// }
|
|
|
|
// set
|
|
// {
|
|
// ViewState["CveCampana"] = value;
|
|
// }
|
|
//}
|
|
|
|
//private int CveTipoEncuesta
|
|
//{
|
|
// get
|
|
// {
|
|
// if (ViewState["CveTipoEncuesta"] == null)
|
|
// {
|
|
// ViewState["CveTipoEncuesta"] = -1;
|
|
// }
|
|
|
|
// return ViewState["CveTipoEncuesta"].ToString().ToEntero();
|
|
// }
|
|
|
|
// set
|
|
// {
|
|
// ViewState["CveTipoEncuesta"] = value;
|
|
// }
|
|
//}
|
|
|
|
private int CveEncuesta
|
|
{
|
|
get
|
|
{
|
|
if (ViewState["CveEncuesta"] == null)
|
|
{
|
|
ViewState["CveEncuesta"] = -1;
|
|
}
|
|
return ViewState["CveEncuesta"].ToString().ToEntero();
|
|
}
|
|
set
|
|
{
|
|
ViewState["CveEncuesta"] = value;
|
|
}
|
|
}
|
|
|
|
private int CveTema
|
|
{
|
|
get
|
|
{
|
|
if (ViewState["CveTema"] == null)
|
|
{
|
|
ViewState["CveTema"] = -1;
|
|
}
|
|
return ViewState["CveTema"].ToString().ToEntero();
|
|
}
|
|
set
|
|
{
|
|
ViewState["CveTema"] = value;
|
|
}
|
|
}
|
|
|
|
|
|
private int CveRespuesta
|
|
{
|
|
get
|
|
{
|
|
if (ViewState["CveRespuesta"] == null)
|
|
{
|
|
ViewState["CveRespuesta"] = -1;
|
|
}
|
|
return ViewState["CveRespuesta"].ToString().ToEntero();
|
|
}
|
|
set
|
|
{
|
|
ViewState["CveRespuesta"] = value;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
CargaDatos();
|
|
}
|
|
}
|
|
#region "CARGA DATOS"
|
|
protected void CargaDatos()
|
|
{
|
|
ClsCRM ObjCRM = new ClsCRM();
|
|
|
|
if (ObjCRM.GetTipoProceso(UsuarioActual.CveEmpresa, -1))
|
|
{
|
|
TmpDT = ObjCRM.DtResultados;
|
|
GVTiposProcesos.DataSource = TmpDT;
|
|
}
|
|
ObjCRM.Dispose();
|
|
GVTiposProcesos.DataBind();
|
|
UPDatos.Update();
|
|
}
|
|
protected void limpiarCamposModal()
|
|
{
|
|
if (EsEditar == 1)
|
|
{
|
|
//LtlModalTitulo.Text = "Actualizar Tipo de Proceso";
|
|
BtnGuardar.Text = "Actualizar";
|
|
DivEstatus.Visible = true;
|
|
}
|
|
else
|
|
{
|
|
//LtlModalTitulo.Text = "Agregar Tipo de Proceso";
|
|
BtnGuardar.Text = "Guardar";
|
|
DivEstatus.Visible = false;
|
|
}
|
|
TxtTipoProceso.Text = "";
|
|
TxtDescripcion.Text = "";
|
|
ChkEstatus.Checked = true;
|
|
ChkRequiereMedioCaptacion.Checked = false;
|
|
ChkRequiereImporte.Checked = false;
|
|
ChkRequiereProbabilidadAcercamiento.Checked = false;
|
|
ChkRequierePS.Checked = false;
|
|
ChkRequiereComision.Checked = false;
|
|
}
|
|
#endregion
|
|
|
|
#region "ACCIONES"
|
|
protected void LnkAgregarTipoProceso_Click(object sender, EventArgs e)
|
|
{
|
|
EsEditar = 0;
|
|
limpiarCamposModal();
|
|
UPModalTipoProceso.Update();
|
|
|
|
this.RegistraScript("$('#DivModalTipoProceso').modal();");
|
|
}
|
|
|
|
protected void LnkEditar_Click(object sender, EventArgs e)
|
|
{
|
|
EsEditar = 1;
|
|
limpiarCamposModal();
|
|
|
|
GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
|
|
|
CveTipoProceso = GvRow.DataKey("CveTipoProceso").ToEntero();
|
|
TxtTipoProceso.Text = GvRow.DataKey("TipoProceso").ToString();
|
|
TxtDescripcion.Text = GvRow.DataKey("Descripcion").ToString();
|
|
ChkEstatus.Checked = GvRow.DataKey("CveEstatus").ToString() == "True" ? true : false;
|
|
ChkRequiereMedioCaptacion.Checked = GvRow.DataKey("RequiereMedioCaptacion").ToString() == "True" ? true : false;
|
|
ChkRequiereImporte.Checked = GvRow.DataKey("RequiereImporte").ToString() == "True" ? true : false;
|
|
ChkRequiereProbabilidadAcercamiento.Checked = GvRow.DataKey("RequiereProbabilidadAcercamiento").ToString() == "True" ? true : false;
|
|
ChkRequierePS.Checked = GvRow.DataKey("RequierePS").ToString() == "True" ? true : false;
|
|
ChkRequiereComision.Checked = GvRow.DataKey("RequiereComision").ToString() == "True" ? true : false;
|
|
|
|
UPModalTipoProceso.Update();
|
|
|
|
this.RegistraScript("$('#DivModalTipoProceso').modal();");
|
|
}
|
|
|
|
protected void BtnGuardar_Click(object sender, EventArgs e)
|
|
{
|
|
ClsCRM ObjCRM = new ClsCRM();
|
|
|
|
String TipoProceso = TxtTipoProceso.Text;
|
|
String Descripcion = TxtDescripcion.Text;
|
|
Boolean Estatus = ChkEstatus.Checked;
|
|
|
|
int CveUsuarioIng = UsuarioActual.CveUsuario;
|
|
|
|
if (EsEditar == 0)
|
|
{
|
|
if (ObjCRM.AddTipoProceso(TipoProceso, Descripcion, UsuarioActual.CveEmpresa, CveUsuarioIng,ChkRequiereMedioCaptacion.Checked,ChkRequiereImporte.Checked,
|
|
ChkRequiereProbabilidadAcercamiento.Checked,ChkRequierePS.Checked,ChkRequiereComision.Checked))
|
|
{
|
|
Alert("El Tipo de Proceso fue creado correctamente.", ModExtensiones.TipoMensaje.MsgInformacion);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (ObjCRM.UpdateTipoProceso(TipoProceso, Descripcion, Estatus, CveTipoProceso, ChkRequiereMedioCaptacion.Checked, ChkRequiereImporte.Checked,
|
|
ChkRequiereProbabilidadAcercamiento.Checked, ChkRequierePS.Checked, ChkRequiereComision.Checked))
|
|
{
|
|
Alert("El Tipo de Proceso fue actualizado correctamente.", ModExtensiones.TipoMensaje.MsgInformacion);
|
|
}
|
|
}
|
|
|
|
ObjCRM.Dispose();
|
|
limpiarCamposModal();
|
|
this.RegistraScript("$('#DivModalTipoProceso').modal('hide');");
|
|
CargaDatos();
|
|
}
|
|
|
|
protected void GVTiposProcesos_RowDeleting(object sender, GridViewDeleteEventArgs e)
|
|
{
|
|
CveTipoProceso = GVTiposProcesos.Rows[e.RowIndex].DataKey("CveTipoProceso").ToEntero();
|
|
|
|
ClsCRM ObjCRM = new ClsCRM();
|
|
|
|
if (ObjCRM.RemoveTipoProceso(CveTipoProceso))
|
|
{
|
|
Alert("El Tipo de Proceso ha sido eliminado.", ModExtensiones.TipoMensaje.MsgInformacion);
|
|
}
|
|
|
|
ObjCRM.Dispose();
|
|
CargaDatos();
|
|
}
|
|
|
|
protected void GVTiposProcesos_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
if (Convert.ToBoolean(e.Row.DataKey("CveEstatus")))
|
|
{
|
|
e.Row.FCLabel("lblEstatus").CssClass = "label label-sm label-success";
|
|
}
|
|
else
|
|
{
|
|
e.Row.FCLabel("lblEstatus").CssClass = "label label-sm label-danger";
|
|
}
|
|
|
|
if (e.Row.DataKey("NoEtapas").ToEntero() > 0)
|
|
{
|
|
e.Row.FCLabel("lblNoEtapas").Text = String.Format("<b>{0}</b>", e.Row.DataKey("NoEtapas"));
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
protected void LnkImprimir_Click(object sender, EventArgs e)
|
|
{
|
|
Imprimir("PDF");
|
|
}
|
|
|
|
protected void LnkImprimirExcel_Click(object sender, EventArgs e)
|
|
{
|
|
Imprimir("EXCEL");
|
|
}
|
|
|
|
public void Imprimir(string formato)
|
|
{
|
|
System.IO.FileInfo Image = new System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png");
|
|
string logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa);
|
|
|
|
List<ReportParameter> param = new List<ReportParameter>();
|
|
|
|
param.Add(new ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa));
|
|
if (Image.Exists)
|
|
{
|
|
param.Add(new ReportParameter("LogoPath", logouri));
|
|
}
|
|
else
|
|
{
|
|
param.Add(new ReportParameter("LogoPath", ""));
|
|
}
|
|
param.Add(new ReportParameter("UsuarioImprimio", UsuarioActual.Nombre));
|
|
param.Add(new ReportParameter("FechaImpresion", DateTime.Now.ToString()));
|
|
|
|
ImprimirPDF("Empresas/Grales/Formatos/RepCatTipoProceso.rdlc", TmpDT, param, "Report Cat Tipo Proceso", formato, RDSName: "DataSet1");
|
|
}
|
|
|
|
|
|
|
|
|
|
#region "ENCUESTAS"
|
|
|
|
private bool ValidaEncuesta(int CveTipoProcesoEnc, string TipoProcesEnc)
|
|
{
|
|
//CveCampana = -1;
|
|
//CveTipoEncuesta = -1;
|
|
|
|
//CveEncuesta = -1;
|
|
|
|
bool respuesta = false;
|
|
bool ActualizarDatos = false;
|
|
|
|
ClsEncuestas objEcuesta = new ClsEncuestas();
|
|
objEcuesta.IniciaTransacSQL();
|
|
|
|
int CveCampanaVal = 0;
|
|
int CveTipoEncuestaVal = 0;
|
|
|
|
|
|
if ( objEcuesta.GetCampañas(-1, -1, UsuarioActual.CveEmpresa))
|
|
{
|
|
CveCampanaVal = ModExtensiones.FiltroPrimeroValor(objEcuesta.DtResultados, "CveCampana", $" Campana = 'CRM Tipos de Procesos'").ToEntero();
|
|
|
|
if(!(CveCampanaVal > 0))
|
|
{
|
|
|
|
if (objEcuesta.AddCampañas("CRM Tipos de Procesos", "CRM Tipos de Procesos", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa))
|
|
{
|
|
if (objEcuesta.GetCampañas(-1, -1, UsuarioActual.CveEmpresa))
|
|
{
|
|
CveCampanaVal = ModExtensiones.FiltroPrimeroValor(objEcuesta.DtResultados, "CveCampana", $" Campana = 'CRM Tipos de Procesos'").ToEntero();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if(CveCampanaVal > 0)
|
|
{
|
|
if (objEcuesta.GetTiposEncuestas(-1, -1, UsuarioActual.CveEmpresa))
|
|
{
|
|
CveTipoEncuestaVal = ModExtensiones.FiltroPrimeroValor(objEcuesta.DtResultados, "CveTipoEncuesta", $" TipoEncuesta = 'CRM Tipos de Procesos'").ToEntero();
|
|
|
|
if (!(CveTipoEncuestaVal > 0))
|
|
{
|
|
if (objEcuesta.AddTiposEncuestas("CRM Tipos de Procesos", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa,6))
|
|
{
|
|
if (objEcuesta.GetTiposEncuestas(-1, -1, UsuarioActual.CveEmpresa))
|
|
{
|
|
CveTipoEncuestaVal = ModExtensiones.FiltroPrimeroValor(objEcuesta.DtResultados, "CveTipoEncuesta", $" TipoEncuesta = 'CRM Tipos de Procesos'").ToEntero();
|
|
|
|
if (!(CveTipoEncuestaVal > 0))
|
|
{
|
|
Alert("No se pudo obtener el Tipo de encuesta", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert("No se pudo obtener la campaña", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
}
|
|
|
|
if(CveCampanaVal > 0 && CveTipoEncuestaVal > 0 && CveTema > 0 && CveEncuesta <= 0)
|
|
{
|
|
if(objEcuesta.AddEncuesta(CveCampanaVal, -1,$"CRM {TipoProcesEnc}", $"CRM {TipoProcesEnc}",0, CveTipoEncuestaVal, false, DateTime.Now, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoProceso: CveTipoProcesoEnc))
|
|
{
|
|
CveEncuesta = objEcuesta.CveEncuesta;
|
|
respuesta = true;
|
|
ActualizarDatos = true;
|
|
}
|
|
}
|
|
|
|
if (respuesta)
|
|
{
|
|
objEcuesta.Commit();
|
|
}
|
|
else
|
|
{
|
|
objEcuesta.RollBack();
|
|
}
|
|
|
|
objEcuesta.Dispose();
|
|
|
|
|
|
if (ActualizarDatos)
|
|
{
|
|
CargaDatos();
|
|
}
|
|
|
|
return respuesta;
|
|
}
|
|
|
|
private bool ValidaEncuestaTemaPreguntas()
|
|
{
|
|
|
|
CveTema = -1;
|
|
|
|
bool respuesta = false;
|
|
|
|
ClsEncuestas objEcuesta = new ClsEncuestas();
|
|
objEcuesta.IniciaTransacSQL();
|
|
|
|
int CveTemaVal = 0;
|
|
|
|
if (objEcuesta.GetTemasEncuestas(-1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa))
|
|
{
|
|
CveTemaVal = ModExtensiones.FiltroPrimeroValor(objEcuesta.DtResultados, "CveTema", $" Tema = 'CRM Tipos de Procesos'").ToEntero();
|
|
|
|
if (CveTemaVal > 0)
|
|
{
|
|
CveTema = CveTemaVal;
|
|
respuesta = true;
|
|
}
|
|
else
|
|
{
|
|
if (objEcuesta.AddTemasEncuestas("CRM Tipos de Procesos", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa))
|
|
{
|
|
if (objEcuesta.GetTemasEncuestas(-1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa))
|
|
{
|
|
CveTemaVal = ModExtensiones.FiltroPrimeroValor(objEcuesta.DtResultados, "CveTema", $" Tema = 'CRM Tipos de Procesos'").ToEntero();
|
|
CveTema = CveTemaVal;
|
|
|
|
if (CveTema > 0)
|
|
{
|
|
respuesta = true;
|
|
}
|
|
else
|
|
{
|
|
Alert("No se pudo obtener el tema de las preguntas", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (respuesta)
|
|
{
|
|
objEcuesta.Commit();
|
|
}
|
|
else
|
|
{
|
|
objEcuesta.RollBack();
|
|
}
|
|
|
|
objEcuesta.Dispose();
|
|
|
|
|
|
return respuesta;
|
|
|
|
}
|
|
|
|
|
|
protected void LnkEncuesta_Click(object sender, EventArgs e)
|
|
{
|
|
GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
|
|
|
int CveTipoProcesoEnc = GvRow.DataKey("CveTipoProceso").ToEntero();
|
|
string TipoProcesEnc = GvRow.DataKey("TipoProceso");
|
|
CveEncuesta = GvRow.DataKey("CveEncuesta").ToEntero();
|
|
//Literal LltlModalEncuestaTitulo = GvRow.FCLiteral("LltlModalEncuestaTitulo");
|
|
|
|
if (!ValidaEncuestaTemaPreguntas())
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (!(CveEncuesta > 0))
|
|
{
|
|
if (!ValidaEncuesta(CveTipoProcesoEnc, TipoProcesEnc) )
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
LltlModalEncuestaTitulo.Text = $"Encuesta {TipoProcesEnc}";
|
|
UpModalEncuesta.Update();
|
|
CargaEstructura(CveEncuesta);
|
|
RegistraScript("$('#DVModalEncuesta').modal('show');");
|
|
|
|
// Alert($"CveEncuesta: {CveEncuesta} <br> CveTema:{CveTema}");
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
protected void LnkAgregarPregunta_Click(object sender, EventArgs e)
|
|
{
|
|
CvePregunta = -1;
|
|
LimpiaControlesModalEncuesta();
|
|
|
|
RegistraScript("$('#DVModalPreguntas').modal('show');");
|
|
}
|
|
|
|
private void LimpiaControlesModalEncuesta()
|
|
{
|
|
TxtPregunta.Text = " ";
|
|
DdlTipoPregunta.SelectedIndex = 0;
|
|
DivChkrespuestaDefult.Visible = false;
|
|
ChkRespuestaDefault.Checked = true;
|
|
UpModalPreguntas.Update();
|
|
}
|
|
protected void DdlTipoPregunta_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
// REVISAR PORQUE NO ENTRA BIEN AQUI, DIV MAL CERRADO???
|
|
if (DdlTipoPregunta.SelectedValue == "4")
|
|
DivChkrespuestaDefult.Visible = true;
|
|
else
|
|
DivChkrespuestaDefult.Visible = false;
|
|
UpModalPreguntas.Update();
|
|
}
|
|
|
|
|
|
protected void LbAgregarPregunta_Click(object sender, EventArgs e)
|
|
{
|
|
ClsEncuestas Objeto = new ClsEncuestas();
|
|
|
|
Objeto.IniciaTransacSQL();//ESTA TRANSACCIONADO POR QUE EL UPDATE ELIMINA RESPUESTAS CUANDO SE CAMBIA EL TIPO DE PREGUNTA
|
|
|
|
bool errorProceso = true;
|
|
|
|
int RespuestaDefault = -1;
|
|
if (DdlTipoPregunta.SelectedValue.ToEntero() == 4)
|
|
{
|
|
RespuestaDefault = ChkRespuestaDefault.Checked ? 1 : 0;
|
|
}
|
|
|
|
|
|
|
|
if (CvePregunta> 0)
|
|
{
|
|
if (Objeto.UpdatePreguntas(CvePregunta, TxtPregunta.Text, DdlTipoPregunta.SelectedValue.ToEntero(), CveTema, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, RespuestaDefault))
|
|
{
|
|
Alert("La Pregunta se actualizó correctamente.", ModExtensiones.TipoMensaje.ToastInformacion);
|
|
errorProceso = false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (Objeto.AddPreguntas(TxtPregunta.Text, CveEncuesta, DdlTipoPregunta.SelectedValue.ToEntero(), CveTema, UsuarioActual.CveUsuario, RespuestaDefault))
|
|
{
|
|
Alert("La Pregunta se agregó correctamente.", ModExtensiones.TipoMensaje.ToastInformacion);
|
|
errorProceso = false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (errorProceso)//ESTA TRANSACCIONADO POR QUE EL UPDATE ELIMINA RESPUESTAS CUANDO SE CAMBIA EL TIPO DE PREGUNTA
|
|
{
|
|
Objeto.RollBack();
|
|
}
|
|
else
|
|
{
|
|
Objeto.Commit();
|
|
}
|
|
|
|
|
|
Objeto.Dispose();
|
|
|
|
|
|
|
|
if (!errorProceso)
|
|
{
|
|
CargaEstructura(CveEncuesta);
|
|
RegistraScript("$('#DVModalPreguntas').modal('hide');");
|
|
}
|
|
|
|
}
|
|
|
|
private void CargaEstructura(int tCveEncuesta)
|
|
{
|
|
ClsEncuestas Objeto = new ClsEncuestas();
|
|
|
|
if (Objeto.GetEstructura(tCveEncuesta, UsuarioActual.CveEmpresa))
|
|
{
|
|
GvEstructura.DataSource = Objeto.DtResultados;
|
|
}
|
|
|
|
Objeto.Dispose();
|
|
|
|
GvEstructura.DataBind();
|
|
UpModalEncuesta.Update();
|
|
}
|
|
|
|
protected void GvEstructura_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
|
|
{
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
var Tipo = e.Row.DataKey("Tipo").ToString();
|
|
|
|
switch (Tipo)
|
|
{
|
|
case "1":
|
|
{
|
|
e.Row.Font.Bold = true;
|
|
e.Row.ForeColor = System.Drawing.Color.White;
|
|
e.Row.BackColor = System.Drawing.Color.FromArgb(1, 186, 205, 206);
|
|
|
|
break;
|
|
}
|
|
|
|
case "2":
|
|
{
|
|
e.Row.BackColor = System.Drawing.Color.FromArgb(1, 213, 225, 225);
|
|
e.Row.FCLiteral("LtlPregunta").Visible = true;
|
|
e.Row.FCLinkButton("ImgA").Visible = true;
|
|
|
|
e.Row.FCLinkButton("imgE").Visible = true;
|
|
e.Row.FCLinkButton("imgD").Visible = true;
|
|
|
|
|
|
|
|
break;
|
|
}
|
|
|
|
case "3":
|
|
{
|
|
e.Row.BackColor = System.Drawing.Color.White;
|
|
e.Row.FCLiteral("LtlRespuesta").Visible = true;
|
|
e.Row.FCLinkButton("imgE").Visible = true;
|
|
e.Row.FCLinkButton("imgD").Visible = true;
|
|
|
|
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!(e.Row.DataKey("CvePregunta").ToEntero() > 0))
|
|
e.Row.FCLiteral("LtlTipoPregunta").Text = e.Row.DataKey("Tema");
|
|
|
|
if (e.Row.DataKey("RespuestaDefault").ToString() == "0")
|
|
e.Row.FCLiteral("LtlDefault").Text = "No";
|
|
else if (e.Row.DataKey("RespuestaDefault").ToString() == "1")
|
|
e.Row.FCLiteral("LtlDefault").Text = "Si";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
protected void AddEstructura(object sender, EventArgs e)
|
|
{
|
|
GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
|
int Tipo = GvRow.DataKey("Tipo").ToString().ToEntero();
|
|
|
|
if (Tipo == 2)
|
|
{
|
|
LtlRespuesta.Text = "Agregar Respuesta";
|
|
LbAgregarRespuesta.Text = "Guardar";
|
|
CveRespuesta = -1;
|
|
CvePregunta = GvRow.DataKey("CvePregunta").ToEntero();
|
|
TxtRespuesta.Text = "";
|
|
UpModalRespuestas.Update();
|
|
|
|
RegistraScript(string.Format("$('#{0}').modal();", "ModalRespuestas"));
|
|
}
|
|
}
|
|
|
|
protected void EliminarEstructura(object sender, EventArgs e)
|
|
{
|
|
GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
|
int Tipo = GvRow.DataKey("Tipo").ToString().ToEntero();
|
|
switch (Tipo)
|
|
{
|
|
case 3:
|
|
{
|
|
// RESPUESTA
|
|
EliminarRespuesta(GvRow);
|
|
break;
|
|
}
|
|
|
|
case 2:
|
|
{
|
|
// PREGUNTAS
|
|
EliminarPregunta(GvRow);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void UpdateEstructura(object sender, EventArgs e)
|
|
{
|
|
GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
|
int Tipo = GvRow.DataKey("Tipo").ToString().ToEntero();
|
|
switch (Tipo)
|
|
{
|
|
case 3:
|
|
{
|
|
ActualizaRespuestas(GvRow);
|
|
break;
|
|
}
|
|
case 2:
|
|
{
|
|
ActualizaPregunta(GvRow);
|
|
break;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
private void ActualizaPregunta(GridViewRow GvRow)
|
|
{
|
|
|
|
LtlPregunta.Text = "Editar Pregunta";
|
|
LbAgregarPregunta.Text = "Actualizar";
|
|
CvePregunta = GvRow.DataKey("CvePregunta").ToEntero();
|
|
TxtPregunta.Text = GvRow.DataKey("Pregunta");
|
|
DdlTipoPregunta.SelectedValueExist(GvRow.DataKey("CveTipoPregunta"));
|
|
|
|
if (DdlTipoPregunta.SelectedValue == "4")
|
|
{
|
|
DivChkrespuestaDefult.Visible = true;
|
|
|
|
if (GvRow.DataKey("RespuestaDefault").ToEntero() == 1)
|
|
ChkRespuestaDefault.Checked = true;
|
|
else
|
|
ChkRespuestaDefault.Checked = false;
|
|
}
|
|
else
|
|
DivChkrespuestaDefult.Visible = false;
|
|
|
|
UpModalPreguntas.Update();
|
|
RegistraScript(string.Format("$('#{0}').modal();", "DVModalPreguntas"));
|
|
}
|
|
|
|
protected void EliminarPregunta(GridViewRow GvRow)
|
|
{
|
|
ClsEncuestas Objeto = new ClsEncuestas();
|
|
if (Objeto.RemovePreguntas(GvRow.DataKey("CvePregunta").ToEntero()))
|
|
{
|
|
Alert("La Pregunta se eliminó correctamente.", ModExtensiones.TipoMensaje.ToastInformacion);
|
|
}
|
|
|
|
Objeto.Dispose();
|
|
CargaEstructura(CveEncuesta);
|
|
}
|
|
|
|
|
|
|
|
|
|
#region "RESPUESTAS"
|
|
|
|
|
|
//private void CargaPreguntasEnModal()
|
|
//{
|
|
// ClsEncuestas Objeto = new ClsEncuestas();
|
|
// if (Objeto.GetPreguntas(DdlFiltroEncuestas.SelectedValue.ToEntero, -1, -1, -1, UsuarioActual.CveEmpresa))
|
|
// {
|
|
// DdlPregunta.DataSource = Objeto.DtResultados;
|
|
// DdlPregunta.Items.Clear();
|
|
// DdlPregunta.Items.Insert(0, new ListItem("Seleccione (Todos)", "-1"));
|
|
// DdlPregunta.DataBind();
|
|
// UpModalRespuestas.Update();
|
|
// }
|
|
// Objeto.Dispose();
|
|
//}
|
|
|
|
|
|
//private void AgregaRespuestas(GridViewRow GvRow)
|
|
//{
|
|
|
|
// LtlRespuesta.Text = "Agregar Respuesta";
|
|
// LbAgregarRespuesta.Text = "Guardar";
|
|
|
|
// CveRespuesta = -1;
|
|
// //CargaPreguntasEnModal();
|
|
// DdlPregunta.SelectedValue = GvRow.DataKey("CvePregunta");
|
|
// TxtRespuesta.Text = "";
|
|
// //UpHdn.Update();
|
|
// UpModalRespuestas.Update();
|
|
|
|
// RegistraScript(string.Format("$('#{0}').modal();", "ModalRespuestas"));
|
|
//}
|
|
|
|
|
|
private void ActualizaRespuestas(GridViewRow GvRow)
|
|
{
|
|
|
|
LtlRespuesta.Text = "Editar Respuesta";
|
|
LbAgregarRespuesta.Text = "Actualizar";
|
|
CveRespuesta = GvRow.DataKey("CveRespuesta").ToEntero();
|
|
CvePregunta = GvRow.DataKey("CvePregunta").ToEntero();
|
|
TxtRespuesta.Text = GvRow.DataKey("Respuesta");
|
|
UpModalRespuestas.Update();
|
|
RegistraScript(string.Format("$('#{0}').modal();", "ModalRespuestas"));
|
|
}
|
|
|
|
|
|
|
|
protected void LbAgregarRespuesta_Click(object sender, EventArgs e)
|
|
{
|
|
bool errorProceso = true;
|
|
ClsEncuestas Objeto = new ClsEncuestas();
|
|
if (!(CveRespuesta > 0))
|
|
{
|
|
if (Objeto.AddRespuestas(TxtRespuesta.Text, CvePregunta))
|
|
{
|
|
Alert("La Respuesta se registró correctamente..", ModExtensiones.TipoMensaje.ToastInformacion);
|
|
errorProceso = false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (Objeto.UpdateRespuestas(CveRespuesta, TxtRespuesta.Text, CvePregunta))
|
|
{
|
|
Alert("La Respuesta se actualizó correctamente.", ModExtensiones.TipoMensaje.ToastInformacion);
|
|
errorProceso = false;
|
|
}
|
|
}
|
|
|
|
Objeto.Dispose();
|
|
|
|
if (!errorProceso)
|
|
{
|
|
if (ChkSeguirRespondiendo.Checked)
|
|
{
|
|
TxtRespuesta.Text = "";
|
|
UpModalRespuestas.Update();
|
|
}
|
|
else
|
|
{
|
|
RegistraScript("$('#ModalRespuestas').modal('hide');;");
|
|
}
|
|
|
|
CargaEstructura(CveEncuesta);
|
|
}
|
|
}
|
|
|
|
|
|
protected void EliminarRespuesta(GridViewRow GvRow)
|
|
{
|
|
ClsEncuestas Objeto = new ClsEncuestas();
|
|
if (Objeto.RemoveRespuesta(GvRow.DataKey("CveRespuesta").ToEntero()))
|
|
{
|
|
Alert("La respuesta se eliminó correctamente.", ModExtensiones.TipoMensaje.ToastInformacion);
|
|
CargaEstructura(CveEncuesta);
|
|
}
|
|
Objeto.Dispose();
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
} |