Exemplo n.º 1
0
        protected void btndescPreguntas_Click(object sender, EventArgs e)
        {
            try
            {

                for (int i = 0; i < gvPreguntas.Rows.Count; i++)
                {
                    bool pei = false;
                    bool pmi = false;
                    bool manual = false;
                    bool planes = false;
                    bool otros = false;
                    bool dpp = false;
                    bool lectura = false;
                    bool participacion = false;
                    bool profesional = false;
                    bool estudiantes = false;
                    bool educadores = false;
                    bool directivos = false;
                    bool padres = false;

                    GridViewRow objRow = gvPreguntas.Rows[i];

                    Label idpregunta = (Label)objRow.FindControl("lblIdPregunta");
                    TextBox txtPregunta = (TextBox)objRow.FindControl("txtPregunta");
                    CheckBoxList clist = (CheckBoxList)objRow.FindControl("listDocuments");
                    CheckBoxList clistMe = (CheckBoxList)objRow.FindControl("listMedios");
                    TextBox txtDescripcion = (TextBox)objRow.FindControl("txtDescPre");
                    CheckBoxList clistActores = (CheckBoxList)objRow.FindControl("listActores");

                    if (clist.Items[0].Selected)
                        pei = true;
                    if (clist.Items[1].Selected)
                        pmi = true;
                    if (clist.Items[2].Selected)
                        manual = true;
                    if (clist.Items[3].Selected)
                        planes = true;
                    if (clist.Items[4].Selected)
                        dpp = true;
                    if (clist.Items[5].Selected)
                        otros = true;

                    if (clistMe.Items[0].Selected)
                        lectura = true;
                    if (clistMe.Items[1].Selected)
                        participacion = true;

                    if (clistActores.Items[0].Selected)
                        profesional = true;
                    if (clistActores.Items[1].Selected)
                        estudiantes = true;
                    if (clistActores.Items[2].Selected)
                        educadores = true;
                    if (clistActores.Items[3].Selected)
                        directivos = true;
                    if (clistActores.Items[4].Selected)
                        padres = true;

                    ESM.Model.ESMBDDataContext db = new Model.ESMBDDataContext();

                    var caybp = (from ayu in db.AyudaByPreguntas
                                 where ayu.IdPregunta == Convert.ToInt32(idpregunta.Text)
                                 select ayu).Count();
                    if (caybp == 0)
                    {

                        AyudaByPregunta objAyudaPreguntas = new AyudaByPregunta
                        {
                            IdPregunta = Convert.ToInt32(idpregunta.Text),
                            Descripcion = txtDescripcion.Text,
                            PEI = pei,
                            PMI = pmi,
                            Manual_de_Convivencia = manual,
                            Planes_de_Estudio = planes,
                            Otros = otros,
                            DPP = dpp,
                            Lectura = lectura,
                            Participacion = participacion
                        };
                        db.AyudaByPreguntas.InsertOnSubmit(objAyudaPreguntas);
                        db.SubmitChanges();

                    }

                    else
                    {
                        var aybp = (from ayu in db.AyudaByPreguntas
                                    where ayu.IdPregunta == Convert.ToInt32(idpregunta.Text)
                                    select ayu).Single();

                        aybp.Descripcion = txtDescripcion.Text;
                        aybp.PEI = pei;
                        aybp.PMI = pmi;
                        aybp.Manual_de_Convivencia = manual;
                        aybp.Planes_de_Estudio = planes;
                        aybp.DPP = dpp;
                        aybp.Otros = otros;
                        aybp.Lectura = lectura;
                        aybp.Participacion = participacion;

                        db.SubmitChanges();

                        var pre = (from pregun in db.Preguntas
                                   where pregun.IdPregunta == Convert.ToInt32(idpregunta.Text)
                                   select pregun).Single();

                        pre.Pregunta1 = txtPregunta.Text;
                        pre.Estudiante = estudiantes;
                        pre.Docente = educadores;
                        pre.Directivo = directivos;
                        pre.Padres = padres;
                        pre.Profesional = profesional;

                        db.SubmitChanges();
                    }

                }
                Response.Write("<script>alert('La Actualizacion se realizo correctamente.');</script>");
                //Alert.CreateMessageAlertInUpdatePanel(UpdatePanel1, "La actualización se realizo correctamente");
                //ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "scriptok", "alert('Actualizado Correctamente')", true);
            }
            catch (Exception)
            {
                //Alert.CreateMessageAlertInUpdatePanel(UpdatePanel1, "Se produjo un error inesperado.");
            }
        }
Exemplo n.º 2
0
 partial void DeleteAyudaByPregunta(AyudaByPregunta instance);
Exemplo n.º 3
0
 partial void InsertAyudaByPregunta(AyudaByPregunta instance);
Exemplo n.º 4
0
 partial void UpdateAyudaByPregunta(AyudaByPregunta instance);
Exemplo n.º 5
0
		private void detach_AyudaByPreguntas(AyudaByPregunta entity)
		{
			this.SendPropertyChanging();
			entity.Pregunta = null;
		}