public void InsertTeachingMethods(TeachingMethods entity) { using (var context = new QualificationsDBEntities()) { context.TeachingMethods.Attach(entity); context.ObjectStateManager.ChangeObjectState(entity, System.Data.EntityState.Added); context.SaveChanges(); } }
protected void Button1_Click(object sender, EventArgs e) { entity = new TeachingMethods(); long globalplanId = 0; long teachmodId = long.Parse((string)Session["TeachingModule"]); globalplanId = proxy.GetGlobalPlan(teachmodId); Session["GlobalPlanID"] = globalplanId; if (txt_Método.Text != "") { if (txt_Justificacion.Text != "") { if (txt_description.Text != "") { try { //lbl_Mensaje.Text = ""+globalplanId; entity.MethodName = txt_Método.Text; entity.Justification = txt_Justificacion.Text; entity.Description = txt_Método.Text; entity.PlanGlobal = globalplanId; proxy.InsertTeachingMethods(entity); lbl_Mensaje.Text = "ÉXITO. El método se ha guardado en la Base de Datos"; txt_description.Text = ""; txt_Justificacion.Text = ""; txt_Método.Text = ""; Componentes1(false); Componentes2(true); } catch (Exception ex) { lbl_Mensaje.Text = "ERROR. El método no se ha guardado en la Base de Datos"; } } else { lbl_Mensaje.Text = "Escriba la Descripción"; } } else { lbl_Mensaje.Text = "Excriba la Justificación"; } } else { lbl_Mensaje.Text = "Escriba el nombre del Método"; } }