protected void GridViewUF_SelectedIndexChanged(object sender, EventArgs e) { LabelTitolModal.Text = "Modificar"; //Rellenaras los datos. GridViewRow row = GridViewUF.SelectedRow; String id = row.Cells[2].Text; LabelIdModificar.Text = id; ufs uf = BD.ConsultaUF(Convert.ToInt32(id)); String nom = uf.nom.ToString(); TextBoxNomUF.Text = nom; String cicle = uf.moduls_prof.cursos.id_cicle.ToString(); DropDownList3.ClearSelection(); DropDownList3_CascadingDropDown.SelectedValue = cicle; String id_curs = uf.moduls_prof.id_curs.ToString(); DropDownList4.ClearSelection(); DropDownList4_CascadingDropDown.SelectedValue = id_curs; String id_modul = uf.id_modul_prof.ToString(); DropDownList5.ClearSelection(); DropDownList5_CascadingDropDown.SelectedValue = id_modul; ButtonNou_ModalPopupExtender.Show(); }
public static ufs ConsultaUF(int id) { var ufs = (from c in contexto.ufs where c.id == id select c).ToList(); ufs uf = ufs.First(); return(uf); }
public static string ModificarUF(int id, int id_modul, string nom) { string mensaje = ""; var ufs = (from c in contexto.ufs where c.id == id select c).ToList(); ufs uf = ufs.First(); uf.id_modul_prof = id_modul; uf.nom = nom; var comprobar = (from c in contexto.ufs where c.id_modul_prof == id_modul && c.nom == nom select c).ToList(); if (comprobar.Count() == 0) { try { contexto.SaveChanges(); } catch (DbUpdateException ex) { SqlException sqlEx = (SqlException)ex.InnerException.InnerException; mensaje = BDErrores.MensajeError(sqlEx); } } else { mensaje = "Ja existeix un registre amb el mateix nom"; } return(mensaje); }
public static string AltaUF(int id_modul, string nom) { string mensaje = ""; ufs h = new ufs(); h.id_modul_prof = id_modul; h.nom = nom; var comprobar = (from c in contexto.ufs where c.id_modul_prof == id_modul && c.nom == nom select c).ToList(); if (comprobar.Count() == 0) { contexto.ufs.Add(h); try { contexto.SaveChanges(); } catch (DbUpdateException ex) { SqlException sqlEx = (SqlException)ex.InnerException.InnerException; mensaje = BDErrores.MensajeError(sqlEx); contexto.ufs.Remove(h); } } else { mensaje = "Ja existeix un registre amb el mateix nom"; } return(mensaje); }