protected void btn_Registrar_Click(object sender, EventArgs e) { //string docentes = ddl_Docentes.SelectedIndex.ToString(); entity = new TeachingModule(); long programaID = long.Parse(ddl_Programas.SelectedValue); int versionPrograma = int.Parse(ddl_Versiones.SelectedValue); long moduloID = long.Parse(ddl_Modulos.SelectedValue); long docenteID = long.Parse(ddl_Docentes.SelectedValue); long openingID = proxyOpening.GetOpeningID(programaID, versionPrograma); DateTime inicio = Calendar1.SelectedDate; DateTime fin = Calendar2.SelectedDate; try { entity.ModuleCode = moduloID; entity.Teacher = docenteID; entity.OpeningCode = openingID; entity.ModuleStartDate = inicio; entity.ModuleEndDate = fin; entity.Periods = 36; proxyTModule.InsertTeacherModule(entity); Label7.Text = "ÉXITO. Los datos han sido registrados !"; } catch (Exception ex) { Label7.Text = "ERROR. Los datos no han sido registrados"; } string programa = ddl_Programas.SelectedValue; //Label7.Text = "Programa = "+programaID+"; version = "+versionPrograma+"; Modulo = "+moduloID+"; Docente = "+docenteID+"; CodigoApertura = "+openingID+"; "+inicio+" "+fin; }
public void InsertTeacherModule(TeachingModule entity) { using (var context = new QualificationsDBEntities()) { context.TeachingModule.Attach(entity); context.ObjectStateManager.ChangeObjectState(entity, System.Data.EntityState.Added); context.SaveChanges(); } }