private void getDepartment() { string type = context.Request.Form.Get("type"); if (type == null) return; string id = context.Request.Form.Get("Id"); String json = ""; DepartmentService ds = new DepartmentService(); switch (type) { case "学校": School school = (School)ds.get(typeof(School), id); json = JsonConvert.SerializeObject(school); break; case "院系": Faculty faculty = (Faculty)ds.get(typeof(Faculty), id); json = JsonConvert.SerializeObject(faculty); break; case "专业": Profession profession = (Profession)ds.get(typeof(Profession), id); json = JsonConvert.SerializeObject(profession); break; case "班级": ClassGrade classGrade = (ClassGrade)ds.get(typeof(ClassGrade), id); json = JsonConvert.SerializeObject(classGrade); break; } context.Response.Write(json); }
private void saveDepartment() { try { string type = context.Request.Form.Get("type"); if (type == null) return; string pId = context.Request.Form.Get("pId"); DepartmentService ds = new DepartmentService(); switch (type) { case "学校": School school = (School)colectionParameter(typeof(School)); ds.save(school); break; case "院系": School s = (School)ds.get(typeof(School), pId); Faculty faculty = (Faculty)colectionParameter(typeof(Faculty)); faculty.School = s; ds.save(faculty); break; case "专业": Faculty f = (Faculty)ds.get(typeof(Faculty), pId); Profession profession = (Profession)colectionParameter(typeof(Profession)); profession.Faculty = f; ds.save(profession); break; case "班级": Profession p = (Profession)ds.get(typeof(Profession), pId); ClassGrade classGrade = (ClassGrade)colectionParameter(typeof(ClassGrade)); classGrade.Profession = p; ds.save(classGrade); break; } context.Response.Write("1"); } catch (Exception e) { context.Response.Write("0"); } }
private void deleteDepartment() { try { string type = context.Request.Form.Get("type"); if (type == null) return; string id = context.Request.Form.Get("Id"); DepartmentService ds = new DepartmentService(); switch (type) { case "学校": School school = (School)ds.get(typeof(School), id); ds.del(school); break; case "院系": Faculty faculty = (Faculty)ds.get(typeof(Faculty), id); ds.del(faculty); break; case "专业": Profession profession = (Profession)ds.get(typeof(Profession), id); ds.del(profession); break; case "班级": ClassGrade classGrade = (ClassGrade)ds.get(typeof(ClassGrade), id); ds.del(classGrade); break; } context.Response.Write("1"); } catch (Exception e) { context.Response.Write("0"); } }