public bool InsertarGrupo(TblGrupo _TBL_Grupo) { bool respuesta = false; try { contexto.TblGrupo.InsertOnSubmit(_TBL_Grupo); contexto.SubmitChanges(); respuesta = true; } catch (Exception ex) { System.Console.WriteLine(ex.ToString()); respuesta = false; } return(respuesta); }
protected void btnaceptar_Click(object sender, EventArgs e) { var carrera = ddlCarrera.SelectedValue; var repetido = (from rep in contexto.TblGrupo where rep.idCarrera == Convert.ToInt32(ddlCarrera.SelectedValue) select rep.strNombre).FirstOrDefault(); if (repetido == txtNombre.Text.ToUpper()) { alertError.Visible = true; } else { TblGrupo grupo = new TblGrupo(); grupo.strNombre = txtNombre.Text.ToUpper(); grupo.strCapacidad = int.Parse(txtcapacidad.Text); grupo.idCarrera = int.Parse(carrera); ControllerGrupo ctrlGrupo = new ControllerGrupo(); ctrlGrupo.InsertarGrupo(grupo); alertBien.Visible = true; } Response.Redirect("./GruposAdmin.aspx", true); }