private void Guardar(string ID, DataTable Tabla) { try { RR_NuevaRespuesta Datos = new RR_NuevaRespuesta { IDEncuesta = ID, TablaDatos = Tabla, Conexion = Comun.Conexion, IDUsuario = User.Identity.Name }; RR_CatalogosNegocio EN = new RR_CatalogosNegocio(); EN.AEncuestaContestadas(Datos); if (Datos.Completado) { Response.Redirect("frmRespuestaEncuestaGrid.aspx", false); } else { string ScriptError = DialogMessage.Show(TipoMensaje.Error, "Error el guardar los datos", "Error", ShowMethod.FadeIn, HideMethod.FadeOut, ToastPosition.TopFullWidth, true); ScriptManager.RegisterStartupScript(this, typeof(Page), "popup", ScriptError, true); } } catch (Exception ex) { throw ex; } }
public EM_Encuesta ObtenerPreguntaRespuestaXID(EM_Encuesta Datos) { try { DataSet Ds = SqlHelper.ExecuteDataset(Datos.Conexion, "EM_spCSLDB_get_PreguntasRespuestaXID", Datos.IDEncuesta); if (Ds != null) { if (Ds.Tables.Count == 2) { DataTableReader Dr = Ds.Tables[0].CreateDataReader(); while (Dr.Read()) { Datos.IDEncuesta = !Dr.IsDBNull(Dr.GetOrdinal("IDRespuesta")) ? Dr.GetString(Dr.GetOrdinal("IDRespuesta")) : string.Empty; Datos.NombreEncuesta = !Dr.IsDBNull(Dr.GetOrdinal("Folio")) ? Dr.GetString(Dr.GetOrdinal("Folio")) : string.Empty; Datos.ListaPregunta = new List <EM_Preguntas>(); } List <EM_Preguntas> ListaPreguntas = new List <EM_Preguntas>(); EM_Preguntas Item; DataTableReader DTR = Ds.Tables[1].CreateDataReader(); DataTable Tbl1 = Ds.Tables[1]; while (DTR.Read()) { Item = new EM_Preguntas(); Item.ListaRespuesta = new List <RR_NuevaRespuesta>(); Item.IDPreguntas = !DTR.IsDBNull(DTR.GetOrdinal("IDPregunta")) ? DTR.GetString(DTR.GetOrdinal("IDPregunta")) : string.Empty; Item.NombrePregunta = !DTR.IsDBNull(DTR.GetOrdinal("NombrePregunta")) ? DTR.GetString(DTR.GetOrdinal("NombrePregunta")) : string.Empty; Item.IDTipoPregunta = !DTR.IsDBNull(DTR.GetOrdinal("IDTipoPregunta")) ? DTR.GetInt32(DTR.GetOrdinal("IDTipoPregunta")) : 0; string Aux = !DTR.IsDBNull(DTR.GetOrdinal("TablaRespuestas")) ? DTR.GetString(DTR.GetOrdinal("TablaRespuestas")) : string.Empty; Item.IDRespuestaContestada = !DTR.IsDBNull(DTR.GetOrdinal("Respuesta")) ? DTR.GetString(DTR.GetOrdinal("Respuesta")) : string.Empty; Aux = string.Format("<Main>{0}</Main>", Aux); XmlDocument xm = new XmlDocument(); xm.LoadXml(Aux); XmlNodeList Registros = xm.GetElementsByTagName("Main"); XmlNodeList Lista = ((XmlElement)Registros[0]).GetElementsByTagName("E"); List <RR_NuevaRespuesta> ListaRespuesta = new List <RR_NuevaRespuesta>(); RR_NuevaRespuesta ItemAux; foreach (XmlElement Nodo in Lista) { ItemAux = new RR_NuevaRespuesta(); XmlNodeList IDRespuesta = Nodo.GetElementsByTagName("IDRespuesta"); XmlNodeList ClaveRespuesta = Nodo.GetElementsByTagName("ClaveRespuesta"); XmlNodeList Respuesta = Nodo.GetElementsByTagName("Respuesta"); ItemAux.IDRespuesta = IDRespuesta[0].InnerText; ItemAux.ClvRespuesta = ClaveRespuesta[0].InnerText; ItemAux.Respuesta = Respuesta[0].InnerText; Item.ListaRespuesta.Add(ItemAux); } ListaPreguntas.Add(Item); } Datos.ListaPregunta = ListaPreguntas; } } return(Datos); } catch (Exception ex) { throw ex; } }
public void EliminarRespuestasXID(RR_NuevaRespuesta Datos) { try { RR_CatalogoDatos CD = new RR_CatalogoDatos(); CD.EliminarRespuestasXID(Datos); } catch (Exception ex) { throw ex; } }
public void AEncuestaContestadas(RR_NuevaRespuesta Datos) { try { RR_CatalogoDatos CD = new RR_CatalogoDatos(); CD.AEncuestaContestada(Datos); } catch (Exception ex) { throw ex; } }
public void ObtenerDetalleRespuestasXID(RR_NuevaRespuesta Datos) { try { RR_CatalogoDatos CD = new RR_CatalogoDatos(); CD.ObtenerDetalleRespuestasXID(Datos); } catch (Exception ex) { throw ex; } }
public List <RR_NuevaRespuesta> ObtenerRespuestas(RR_NuevaRespuesta Datos) { try { RR_CatalogoDatos CD = new RR_CatalogoDatos(); return(CD.ObtenerRespuestas(Datos)); } catch (Exception ex) { throw ex; } }
private void CargarDatos(RR_NuevaRespuesta DatosAux) { try { hf.Value = DatosAux.IDRespuesta; hf2.Value = DatosAux.IDPregunta; txtOrden.Value = Convert.ToString(DatosAux.Orden); } catch (Exception ex) { throw ex; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString["op"] != null) { if (Request.QueryString["op"] == "2") { if (Request.QueryString["id"] != null && Request.QueryString["id2"] != null && Request.QueryString["id3"] != null) { string ID = Request.QueryString["id"].ToString(); string IDPregu = Request.QueryString["id2"].ToString(); this.IDPregunta = IDPregu; string IDEncu = Request.QueryString["id3"].ToString(); this.IDEncuesta = IDEncu; //Obtener los datos y dibujarlos. RR_NuevaRespuesta DatosAux = new RR_NuevaRespuesta { Conexion = Comun.Conexion, IDRespuesta = ID, IDPregunta = IDPregu, IDEncuesta = IDEncu }; RR_CatalogosNegocio CN = new RR_CatalogosNegocio(); CN.ObtenerDetalleRespuestasXID(DatosAux); if (DatosAux.Completado) { this.CargarDatos(DatosAux); } else { //Ocurrió un error Response.Redirect("frmPorcentajePreguntaGrid.aspx?error=" + "Error al cargar los datos&nError=1"); } } else { Response.Redirect("frmEncuestas", false); } } else if (Request.QueryString["op"] == "1") { if (Request.QueryString["id"] != null && Request.QueryString["id2"] != null) { string ID = Request.QueryString["id"].ToString(); this.IDPregunta = ID.ToString(); string ID2 = Request.QueryString["id2"].ToString(); this.IDEncuesta = ID2.ToString(); if (Request.QueryString["id"].ToString() == ID) { this.IDEncuesta = ID2.ToString(); hf3.Value = ID2.ToString(); this.IDPregunta = ID.ToString(); hf2.Value = ID.ToString(); } else { Response.Redirect("frmPorcentajePregunta.aspx?op=0&id=" + this.IDPregunta.ToString(), false); } } else { Response.Redirect("frmEncuestas", false); } } else { Response.Redirect("frmEncuestas", false); } } else { this.IniciarDatos(); } } else { if (Request.Form.Count == 10) { string Descp = Request.Form["ctl00$cph_MasterBody$txtDescripcion"].ToString(); int Orden = 0; int.TryParse(Request.Form["ctl00$cph_MasterBody$txtOrden"].ToString(), out Orden); string Color = Request.Form["ctl00$cph_MasterBody$txtColor"].ToString(); try { string AuxID = Request.Form["ctl00$cph_MasterBody$hf"].ToString(); string AuxIDPregunta = Request.Form["ctl00$cph_MasterBody$hf2"].ToString(); string AuxIDEncuesta = Request.Form["ctl00$cph_MasterBody$hf3"].ToString(); //IDColaborador = AuxID; bool NuevoRegistro = string.IsNullOrEmpty(AuxID); this.Guardar(NuevoRegistro, AuxID, AuxIDPregunta, AuxIDEncuesta, Descp, Color, Orden); } catch (Exception ex) { Response.Redirect("ErrorPage.aspx?msjError=" + ex.Message); } } } }
protected void Page_Load(object sender, EventArgs e) { try { if (Request.QueryString["op"] != null && Request.QueryString["op"] == "0") { if (Request.QueryString["id"] != null && Request.QueryString["id2"] != null && Request.QueryString["id3"] != null) { string AuxID = Request.QueryString["id"].ToString(); string AuxID2 = Request.QueryString["id2"].ToString(); int.TryParse(Request.QueryString["id3"].ToString(), out IDTipoPregunta); RR_NuevaRespuesta Datos = new RR_NuevaRespuesta { Conexion = Comun.Conexion, IDPregunta = AuxID }; RR_CatalogosNegocio PN = new RR_CatalogosNegocio(); Lista = PN.ObtenerRespuestas(Datos); this.IDPregunta = AuxID; this.IDEncuesta = AuxID2; } } else if (Request.QueryString["op"] != null && Request.QueryString["op"] == "3") { if (Request.QueryString["id"] != null && Request.QueryString["id2"] != null && Request.QueryString["id3"] != null && Request.QueryString["id4"] != null) { string AuxID = ""; AuxID = Request.QueryString["id"].ToString(); string IDPregu = Request.QueryString["id2"].ToString(); this.IDPregunta = IDPregu; string IDEncu = Request.QueryString["id3"].ToString(); this.IDEncuesta = IDEncu; int.TryParse(Request.QueryString["id4"].ToString(), out IDTipoPregunta); RR_NuevaRespuesta Datos = new RR_NuevaRespuesta { Conexion = Comun.Conexion, IDRespuesta = AuxID, IDPregunta = IDPregu, IDEncuesta = IDEncu, IDTipoPre = IDTipoPregunta, IDUsuario = Comun.IDUsuario }; RR_CatalogosNegocio CN = new RR_CatalogosNegocio(); CN.EliminarRespuestasXID(Datos); if (Datos.Completado) { this.IDPregunta = Datos.IDPregunta; this.IDEncuesta = Datos.IDEncuesta; this.IDTipoPregunta = Datos.IDTipoPre; string ScriptError = DialogMessage.Show(TipoMensaje.Success, "Registro eliminado correctamente.", "Información", ShowMethod.FadeIn, HideMethod.FadeOut, ToastPosition.TopFullWidth, true); ScriptManager.RegisterStartupScript(this, typeof(Page), "popup", ScriptError, true); Response.Redirect("frmNuevaRespuestaGrid.aspx?op=0&id=" + Datos.IDPregunta.ToString() + "&id2=" + Datos.IDEncuesta.ToString() + "&id3=" + this.IDTipoPregunta, false); } else { string ScriptError = DialogMessage.Show(TipoMensaje.Error, "Error al eliminar el registro.", "Error", ShowMethod.FadeIn, HideMethod.FadeOut, ToastPosition.TopFullWidth, true); ScriptManager.RegisterStartupScript(this, typeof(Page), "popup", ScriptError, true); } } } if (!IsPostBack) { } else { } if (Request.QueryString["errorMessage"] != null) { string ScriptError = DialogMessage.Show(TipoMensaje.Error, "Error al cargar los datos. Intenté nuevamente", "Error", ShowMethod.FadeIn, HideMethod.FadeOut, ToastPosition.TopFullWidth, true); ScriptManager.RegisterStartupScript(this, typeof(Page), "popup", ScriptError, true); } } catch (Exception ex) { Response.Redirect("PageError.aspx?errorNumber=" + ex.HResult); } }
private void Guardar(bool Nuevoregistro, string IdRespuesta, string IDPre, string respuesa, string Clave, bool Grafica, int Orden, string IDEncuestas) { try { RR_NuevaRespuesta Datos = new RR_NuevaRespuesta() { NuevoRegistro = Nuevoregistro, IDRespuesta = IdRespuesta, IDPregunta = IDPre, ClvRespuesta = Clave, Respuesta = respuesa, EsMapa = Grafica, Resultado = Orden, IDEncuesta = IDEncuestas, Conexion = Comun.Conexion, IDUsuario = Comun.IDUsuario }; RR_CatalogosNegocio CN = new RR_CatalogosNegocio(); CN.ACRespuestas(Datos); if (Datos.Completado) { this.IDEncuesta = Datos.IDEncuesta; hf3.Value = Datos.IDEncuesta; this.IDPregunta = Datos.IDPregunta; hf2.Value = Datos.IDPregunta; hf4.Value = Convert.ToString(this.IDTipoPregunta.ToString()); Response.Redirect("frmNuevaRespuestaGrid.aspx?op=0&id=" + Datos.IDPregunta.ToString() + "&id2=" + Datos.IDEncuesta.ToString() + "&id3=" + this.IDTipoPregunta, false); } else { if (Datos.Resultado == 3) { this.IDEncuesta = Datos.IDEncuesta; hf3.Value = Datos.IDEncuesta; this.IDPregunta = Datos.IDPregunta; hf2.Value = Datos.IDPregunta; hf4.Value = Convert.ToString(this.IDTipoPregunta.ToString()); string ScriptError = DialogMessage.Show(TipoMensaje.Error, "El número de orden ya exite para la pregunta", "Error", ShowMethod.FadeIn, HideMethod.FadeOut, ToastPosition.TopFullWidth, true); ScriptManager.RegisterStartupScript(this, typeof(Page), "popup", ScriptError, true); } else if (Datos.Resultado == 2) { this.IDEncuesta = Datos.IDEncuesta; hf3.Value = Datos.IDEncuesta; this.IDPregunta = Datos.IDPregunta; hf2.Value = Datos.IDPregunta; hf4.Value = Convert.ToString(this.IDTipoPregunta.ToString()); string ScriptError = DialogMessage.Show(TipoMensaje.Error, "Verifique número de orden ya exite para esta pregunta.", "Error", ShowMethod.FadeIn, HideMethod.FadeOut, ToastPosition.TopFullWidth, true); ScriptManager.RegisterStartupScript(this, typeof(Page), "popup", ScriptError, true); } else { this.IDEncuesta = Datos.IDEncuesta; hf3.Value = Datos.IDEncuesta; this.IDPregunta = Datos.IDPregunta; hf2.Value = Datos.IDPregunta; hf4.Value = Convert.ToString(this.IDTipoPregunta.ToString()); string ScriptError = DialogMessage.Show(TipoMensaje.Error, "Error al guardar los datos.", "Error", ShowMethod.FadeIn, HideMethod.FadeOut, ToastPosition.TopFullWidth, true); ScriptManager.RegisterStartupScript(this, typeof(Page), "popup", ScriptError, true); } } } catch (Exception ex) { throw ex; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString["op"] != null) { if (Request.QueryString["op"] == "2") { if (Request.QueryString["id"] != null && Request.QueryString["id2"] != null && Request.QueryString["id3"] != null && Request.QueryString["id4"] != null) { string ID = Request.QueryString["id"].ToString(); string IDPregu = Request.QueryString["id2"].ToString(); this.IDPregunta = IDPregu; string IDEncu = Request.QueryString["id3"].ToString(); this.IDEncuesta = IDEncu; int.TryParse(Request.QueryString["id4"].ToString(), out IDTipoPregunta); //Obtener los datos y dibujarlos. RR_NuevaRespuesta DatosAux = new RR_NuevaRespuesta { Conexion = Comun.Conexion, IDRespuesta = ID, IDPregunta = IDPregu, IDEncuesta = IDEncu, IDTipoPre = IDTipoPregunta }; RR_CatalogosNegocio CN = new RR_CatalogosNegocio(); CN.ObtenerDetalleRespuestasXID(DatosAux); if (DatosAux.Completado) { this.CargarDatos(DatosAux); } else { //Ocurrió un error Response.Redirect("frmNuevaPreguntaGrid.aspx?error=" + "Error al cargar los datos&nError=1"); } } else { Response.Redirect("frmEncuestas", false); } } else if (Request.QueryString["op"] == "1") { if (Request.QueryString["id"] != null && Request.QueryString["id2"] != null && Request.QueryString["id3"] != null) { string ID = Request.QueryString["id"].ToString(); this.IDPregunta = ID.ToString(); string ID2 = Request.QueryString["id2"].ToString(); this.IDEncuesta = ID2.ToString(); int.TryParse(Request.QueryString["id3"].ToString(), out IDTipoPregunta); if (Request.QueryString["id"].ToString() == ID) { this.IDEncuesta = ID2.ToString(); hf3.Value = ID2.ToString(); this.IDPregunta = ID.ToString(); hf2.Value = ID.ToString(); hf4.Value = Convert.ToString(IDTipoPregunta.ToString()); } else { Response.Redirect("frmPreguntas.aspx?op=0&id=" + this.IDPregunta.ToString(), false); } } else { Response.Redirect("frmEncuestas", false); } } else { Response.Redirect("frmEncuestas", false); } } else { this.IniciarDatos(); } } else { if (Request.Form.Count == 12) { string ClavRespuesta = Request.Form["ctl00$cph_MasterBody$txtClaveRespuesta"].ToString(); string respuesta = Request.Form["ctl00$cph_MasterBody$txtRespuesta"].ToString(); int Orden = 0; int.TryParse(Request.Form["ctl00$cph_MasterBody$txtOrden"].ToString(), out Orden); Boolean cmbEsMapa; bool.TryParse(Request.Form["CmbGrafica"].ToString(), out cmbEsMapa); try { string AuxID = Request.Form["ctl00$cph_MasterBody$hf"].ToString(); string AuxIDPRegunta = Request.Form["ctl00$cph_MasterBody$hf2"].ToString(); string AuxIDEncuesta = Request.Form["ctl00$cph_MasterBody$hf3"].ToString(); int.TryParse(Request.Form["ctl00$cph_MasterBody$hf4"].ToString(), out IDTipoPregunta); //IDColaborador = AuxID; bool NuevoRegistro = AuxID == ""; this.Guardar(NuevoRegistro, AuxID, AuxIDPRegunta, respuesta, ClavRespuesta, cmbEsMapa, Orden, AuxIDEncuesta); } catch (Exception ex) { Response.Redirect("ErrorPage.aspx?msjError=" + ex.Message); } } else if (Request.Form.Count == 11) { string ClavRespuesta = ""; string respuesta = Request.Form["ctl00$cph_MasterBody$txtRespuestas"].ToString(); int Orden = 0; int.TryParse(Request.Form["ctl00$cph_MasterBody$txtOrdens"].ToString(), out Orden); Boolean cmbEsMapa; bool.TryParse(Request.Form["CmbGraficas"].ToString(), out cmbEsMapa); try { string AuxID = Request.Form["ctl00$cph_MasterBody$hf"].ToString(); string AuxIDPRegunta = Request.Form["ctl00$cph_MasterBody$hf2"].ToString(); string AuxIDEncuesta = Request.Form["ctl00$cph_MasterBody$hf3"].ToString(); int.TryParse(Request.Form["ctl00$cph_MasterBody$hf4"].ToString(), out IDTipoPregunta); //IDColaborador = AuxID; bool NuevoRegistro = AuxID == ""; this.Guardar(NuevoRegistro, AuxID, AuxIDPRegunta, respuesta, ClavRespuesta, cmbEsMapa, Orden, AuxIDEncuesta); } catch (Exception ex) { Response.Redirect("ErrorPage.aspx?msjError=" + ex.Message); } } } }
private void CargarDatos(RR_NuevaRespuesta DatosAux) { try { if (DatosAux.IDTipoPre == 1) { hf.Value = DatosAux.IDRespuesta; hf2.Value = DatosAux.IDPregunta; hf3.Value = DatosAux.IDEncuesta; hf4.Value = Convert.ToString(DatosAux.IDTipoPre.ToString()); txtClaveRespuesta.Value = DatosAux.ClvRespuesta; txtRespuesta.Value = DatosAux.Respuesta; txtOrden.Value = Convert.ToString(DatosAux.Orden); if (DatosAux.EsMapa == true) { string ScriptError = @" $( function($){ document.getElementById('CmbGrafica').value='true'; });"; ScriptManager.RegisterStartupScript(this, typeof(Page), "popup", ScriptError, true); } else { string ScriptError = @" $( function($){ document.getElementById('CmbGrafica').value='false'; });"; ScriptManager.RegisterStartupScript(this, typeof(Page), "popup", ScriptError, true); } Response.Cookies.Clear(); } else { hf.Value = DatosAux.IDRespuesta; hf2.Value = DatosAux.IDPregunta; hf3.Value = DatosAux.IDEncuesta; hf4.Value = Convert.ToString(DatosAux.IDTipoPre.ToString()); txtRespuestas.Value = DatosAux.Respuesta; txtOrdens.Value = Convert.ToString(DatosAux.Orden); if (DatosAux.EsMapa == true) { string ScriptError = @" $( function($){ document.getElementById('CmbGraficas').value='true'; });"; ScriptManager.RegisterStartupScript(this, typeof(Page), "popup", ScriptError, true); } else { string ScriptError = @" $( function($){ document.getElementById('CmbGraficas').value='false'; });"; ScriptManager.RegisterStartupScript(this, typeof(Page), "popup", ScriptError, true); } Response.Cookies.Clear(); } } catch (Exception ex) { throw ex; } }