Esempio n. 1
0
        protected void ProfesoresConsulta_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            GridViewRow gvRow    = (GridViewRow)ProfesoresConsulta.Rows[e.RowIndex];
            Label       Label1   = (Label)gvRow.FindControl("ProfesorId");
            int         id       = Convert.ToInt32(Label1.Text.Trim());
            string      Nombre   = ((TextBox)gvRow.Cells[2].Controls[0]).Text;
            string      Apellido = ((TextBox)gvRow.Cells[3].Controls[0]).Text;
            string      Tanda    = ((TextBox)gvRow.Cells[4].Controls[0]).Text;



            using (ColegioDb context = new ColegioDb())
            {
                var db = context.Profesore.Where(a => a.ProfesorId.Equals(id)).FirstOrDefault();
                if (db != null)
                {
                    db.Nombre   = Nombre;
                    db.Tanda    = Tanda;
                    db.Apellido = Apellido;
                }
                context.SaveChanges();
                ProfesoresConsulta.EditIndex = -1;
                LlenarGriw();
                Filtrar();
            }
        }
Esempio n. 2
0
        protected void AsignaturasConsulta_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            GridViewRow gvRow = (GridViewRow)AsignaturasConsulta.Rows[e.RowIndex];
            Label       lblId = (Label)gvRow.FindControl("AsignaturaId");
            int         id    = Convert.ToInt32(lblId.Text.Trim());

            using (ColegioDb Context = new ColegioDb())
            {
                var db = Context.Asignatura.Where(a => a.AsignaturaId.Equals(id)).FirstOrDefault();
                if (db != null)
                {
                    Context.Asignatura.Remove(db);
                    Context.SaveChanges();
                    LlenarGriw();
                }
            }
        }
Esempio n. 3
0
        protected void AsignaturasConsulta_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            GridViewRow gvRow   = (GridViewRow)AsignaturasConsulta.Rows[e.RowIndex];
            Label       Label1  = (Label)gvRow.FindControl("AsignaturaId");
            int         id      = Convert.ToInt32(Label1.Text.Trim());
            string      Nombre  = ((TextBox)gvRow.Cells[2].Controls[0]).Text;
            string      Seccion = ((TextBox)gvRow.Cells[3].Controls[0]).Text;


            using (ColegioDb context = new ColegioDb())
            {
                var db = context.Asignatura.Where(a => a.AsignaturaId.Equals(id)).FirstOrDefault();
                if (db != null)
                {
                    db.Nombre  = Nombre;
                    db.Seccion = Utilidades.TOINT(Seccion);
                }
                context.SaveChanges();
                AsignaturasConsulta.EditIndex = -1;
                LlenarGriw();
                Filtrar();
            }
        }
        protected void EstudiantesConsulta_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            GridViewRow gvRow    = (GridViewRow)EstudiantesConsulta.Rows[e.RowIndex];
            Label       lblId    = (Label)gvRow.FindControl("EstudianteId");
            int         id       = Convert.ToInt32(lblId.Text.Trim());
            string      Nombre   = ((TextBox)gvRow.Cells[2].Controls[0]).Text;
            string      Apellido = ((TextBox)gvRow.Cells[3].Controls[0]).Text;
            string      Email    = ((TextBox)gvRow.Cells[4].Controls[0]).Text;

            using (ColegioDb context = new ColegioDb())
            {
                var db = context.Estudiante.Where(a => a.EstudianteId.Equals(id)).FirstOrDefault();
                if (db != null)
                {
                    db.Nombre   = Nombre;
                    db.Apellido = Apellido;
                    db.Email    = Email;
                }
                context.SaveChanges();
                EstudiantesConsulta.EditIndex = -1;
                LlenarGriw();
            }
        }