public void BindTree() { SubjectHandler sh = new SubjectHandler(); var tree = sh.GetSubjectsAsTree(); JavaScriptSerializer TheSerializer = new JavaScriptSerializer(); hdnTreeData.Value = TheSerializer.Serialize(tree); }
protected void btnAddSubject_Click(object sender, EventArgs e) { if (hdnNodeSubjectId.Value != "") { SubjectHandler h = new SubjectHandler(); Subject SelectedSubject = h.GetSubject(Convert.ToInt32(hdnNodeSubjectId.Value)); //Get All subjects with same mother as selected but with higher Order var updateSubjects = h.GetSubjectsFromMotherWhereOrderGreaterThan(SelectedSubject.Mother, SelectedSubject.SubjectOrder); //Increase Order by one to make room for new subject foreach (Subject s in updateSubjects) { s.SubjectOrder += 1; h.UpdateSubject(s); } Subject newSubject = new Subject(); newSubject.label = txtAddSubject.Text; newSubject.SubjectOrder = SelectedSubject.SubjectOrder + 1; newSubject.Mother = SelectedSubject.Mother; h.CreateSubject(newSubject); BindTree(); } }
protected void btnSaveSubjects_Click(object sender, EventArgs e) { JavaScriptSerializer js = new JavaScriptSerializer(); string json = hdnGetJosnResult.Value; var flatSubjects = js.Deserialize<Subject[]>(json).ToList(); SubjectHandler sh = new SubjectHandler(); //Todo: Finish Save }