コード例 #1
0
        protected void borraFolio()
        {
            try
            {
                pcorpo = int.Parse(HttpContext.Current.Session["scorpo"].ToString());
                photel = HttpContext.Current.Session["shotel"].ToString();
                ptipo  = HttpContext.Current.Session["stipo"].ToString();
                pfolio = HttpContext.Current.Session["sfolio"].ToString();


                using (CuestionarioEntities context = new CuestionarioEntities())
                {
                    var respDel = context.O_Respuestas_Cuestionario_Huespedes.Where(a =>
                                                                                    a.Corporativo == pcorpo &&
                                                                                    a.Hotel == photel &&
                                                                                    a.Tipo_Cuestionario == ptipo &&
                                                                                    a.Id == pfolio).ToList();
                    foreach (O_Respuestas_Cuestionario_Huespedes resHues in respDel)
                    {
                        context.O_Respuestas_Cuestionario_Huespedes.Remove(resHues);
                    }
                    context.SaveChanges();
                }
            }
            catch (Exception e)
            {
                Response.Redirect("http://" + ppagreinicio + "/");
            }
        }
コード例 #2
0
        public static void insRespuesta(string idrespuesta, string valor)
        {
            int    pcorpo = int.Parse(HttpContext.Current.Session["scorpo"].ToString());
            string photel = HttpContext.Current.Session["shotel"].ToString();
            string ptipo  = HttpContext.Current.Session["stipo"].ToString();
            string pfolio = HttpContext.Current.Session["sfolio"].ToString();
            int    nr     = 0;
            string tp     = idrespuesta.Substring(0, 5);
            int    ip     = idrespuesta.IndexOf("_");
            int    ic     = idrespuesta.IndexOf("#");
            int    np     = int.Parse(idrespuesta.Substring(5, ip - 5));

            if (ic < 0)
            {
                nr = int.Parse(idrespuesta.Substring(ip + 1));
            }
            else
            {
                nr = int.Parse(idrespuesta.Substring(ip + 1, ic - ip - 1));
            }

            int cal = 0;

            if (ic > 0)
            {
                cal = int.Parse(idrespuesta.Substring(ic + 1));
            }

            using (CuestionarioEntities context = new CuestionarioEntities())
            {
                List <O_Respuestas_Cuestionario_Huespedes> respuesta = PopulateResp(pcorpo, photel, ptipo, np, pfolio, nr, tp);

                if (tp == "Opcio" && respuesta.Count > 0)
                {
                    O_Respuestas_Cuestionario_Huespedes respDel = context.O_Respuestas_Cuestionario_Huespedes.First(a =>
                                                                                                                    a.Corporativo == pcorpo &&
                                                                                                                    a.Hotel == photel &&
                                                                                                                    a.Tipo_Cuestionario == ptipo &&
                                                                                                                    a.No_Pregunta == np &&
                                                                                                                    a.Id == pfolio);
                    context.O_Respuestas_Cuestionario_Huespedes.Remove(respDel);
                    context.SaveChanges();
                }
                else if ((tp == "Calif" || tp == "Abier") && respuesta.Count > 0)
                {
                    O_Respuestas_Cuestionario_Huespedes respDel = context.O_Respuestas_Cuestionario_Huespedes.First(a =>
                                                                                                                    a.Corporativo == pcorpo &&
                                                                                                                    a.Hotel == photel &&
                                                                                                                    a.Tipo_Cuestionario == ptipo &&
                                                                                                                    a.No_Pregunta == np &&
                                                                                                                    a.Id == pfolio &&
                                                                                                                    a.No_Respuesta == nr);
                    context.O_Respuestas_Cuestionario_Huespedes.Remove(respDel);
                    context.SaveChanges();
                }
                else if (tp == "Selec" && respuesta.Count > 0)
                {
                    O_Respuestas_Cuestionario_Huespedes respDel = context.O_Respuestas_Cuestionario_Huespedes.First(a =>
                                                                                                                    a.Corporativo == pcorpo &&
                                                                                                                    a.Hotel == photel &&
                                                                                                                    a.Tipo_Cuestionario == ptipo &&
                                                                                                                    a.No_Pregunta == np &&
                                                                                                                    a.Id == pfolio &&
                                                                                                                    a.No_Respuesta == nr);
                    context.O_Respuestas_Cuestionario_Huespedes.Remove(respDel);
                    context.SaveChanges();
                    return;
                }

                O_Respuestas_Cuestionario_Huespedes resp = new O_Respuestas_Cuestionario_Huespedes();
                resp.Corporativo       = pcorpo;
                resp.Hotel             = photel;
                resp.Tipo_Cuestionario = ptipo;
                resp.No_Pregunta       = np;
                resp.Id           = pfolio;
                resp.No_Respuesta = nr;
                resp.Calificacion = cal;
                resp.Texto        = valor == "on" ? "" : valor;
                context.O_Respuestas_Cuestionario_Huespedes.Add(resp);
                context.SaveChanges();
            }
        }