public ActionResult Create_Class([Bind(Include = "GradeID,SchoolID,Grade, SubjectIDs")] ClassGrade classGrade) { string SchoolID = db.Teachers.Find(User.Identity.Name).SchoolID; classGrade.SchoolID = SchoolID; if (db.ClassGrades.Find(classGrade.GradeID) != null) { ModelState.AddModelError("GradeID", "Class ID already taken"); } if (ModelState.IsValid && db.ClassGrades.Find(classGrade.GradeID) == null) { if (classGrade.SubjectIDs != null) { foreach (string item in classGrade.SubjectIDs) { classGrade.Subjects.Add(db.Subjects.Find(item)); } } db.ClassGrades.Add(classGrade); db.SaveChanges(); return(RedirectToAction("Classes")); } ViewBag.SubjectIDs = new MultiSelectList(db.Subjects, "SubjectID", "Subject1"); return(View(classGrade)); }
public ActionResult Edit_Class([Bind(Include = "GradeID,SchoolID,Grade, SubjectIDs")] ClassGrade classGrade) { string SchoolID = db.Teachers.Find(User.Identity.Name).SchoolID; classGrade.SchoolID = SchoolID; if (ModelState.IsValid) { db.Entry(classGrade).State = EntityState.Modified; db.SaveChanges(); using (var sms = new SMSEntities()) { var Class = sms.ClassGrades.Where(c => c.GradeID.Equals(classGrade.GradeID)).FirstOrDefault(); Class.Subjects.Clear(); if (classGrade.SubjectIDs != null) { foreach (var item in classGrade.SubjectIDs.ToArray()) { Class.Subjects.Add(sms.Subjects.Where(c => c.SubjectID.Equals(item)).FirstOrDefault()); } } sms.SaveChanges(); } return(RedirectToAction("Classes")); } ViewBag.SubjectIDs = new MultiSelectList(db.Subjects, "SubjectID", "Subject1"); return(View(classGrade)); }
public StudentClass(ClassGrade grade, GradeChar gradeChar, List <Student> students, Teacher mainTeacher) { this.grade = grade; this.gradeChar = gradeChar; this.students = students; this.mainTeacher = mainTeacher; }
// GET: ClassGrades/Edit/5 public ActionResult Edit_Class(string id) { string SchoolID = db.Teachers.Find(User.Identity.Name).SchoolID; if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ClassGrade classGrade = db.ClassGrades.Find(id); if (classGrade == null) { return(HttpNotFound()); } List <string> subjects = new List <string>(); foreach (var item in classGrade.Subjects) { subjects.Add(item.SubjectID); } ViewBag.SubjectIDs = new MultiSelectList(db.Subjects, "SubjectID", "Subject1", subjects); return(View(classGrade)); }
public ClassGrade getClassGradeByID(string ClassGradeID) { using (ISession session = getSession()) { ClassGrade classGrade = (ClassGrade)session.Get(typeof(ClassGrade), ClassGradeID); return(classGrade); } }
public IList <EasyuiTree> getDepartmentTree() { using (ISession session = getSession()) { IList <EasyuiTree> resultList = new List <EasyuiTree>(); ICriteria ic = session.CreateCriteria(typeof(School)); IList <School> list = ic.List <School>(); foreach (School s in list) { Hashtable sht = new Hashtable(); sht.Add("type", "学校"); School s_get = session.Get <School>(s.Id); EasyuiTree SchoolNode = new EasyuiTree(s_get.Id, s_get.Name, "open", "icon-school", sht, null); IList <EasyuiTree> FacultyNodeList = new List <EasyuiTree>(); ISet <Faculty> facultyList = s_get.facultyList; foreach (Faculty f in facultyList) { Hashtable fht = new Hashtable(); fht.Add("type", "院系"); Faculty f_get = session.Get <Faculty>(f.Id); EasyuiTree FacultyNode = new EasyuiTree(f_get.Id, f_get.Name, "open", "icon-faculty", fht, null); IList <EasyuiTree> ProfessionNodeList = new List <EasyuiTree>(); ISet <Profession> professionList = f_get.professionList; foreach (Profession p in professionList) { Hashtable pht = new Hashtable(); pht.Add("type", "专业"); Profession p_get = session.Get <Profession>(p.Id); EasyuiTree ProfessionNode = new EasyuiTree(p_get.Id, p_get.Name, "open", "icon-profession", pht, null); IList <EasyuiTree> classGradeNodeList = new List <EasyuiTree>(); ISet <ClassGrade> classGradeList = p_get.classGradeList; foreach (ClassGrade c in classGradeList) { Hashtable cht = new Hashtable(); cht.Add("type", "班级"); ClassGrade c_get = session.Get <ClassGrade>(c.Id); EasyuiTree ClassGradeNode = new EasyuiTree(c_get.Id, c_get.Name, "open", "icon-classgrade", cht, null); classGradeNodeList.Add(ClassGradeNode); } ProfessionNode.children = classGradeNodeList; ProfessionNodeList.Add(ProfessionNode); } FacultyNode.children = ProfessionNodeList; FacultyNodeList.Add(FacultyNode); } SchoolNode.children = FacultyNodeList; resultList.Add(SchoolNode); } return(resultList); } }
public ActionResult Details_Class(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ClassGrade classGrade = db.ClassGrades.Find(id); if (classGrade == null) { return(HttpNotFound()); } return(View(classGrade)); }
public async Task <ClassGrade> Add() { var classGrade = new ClassGrade(); classGrade.Id = this.GetRandom(); await _storage.SaveAsync(classGrade); var grade = this._storage.AsQueryable <ClassGrade>().FirstOrDefault(s => s.Id == classGrade.Id); Xunit.Assert.True(_storage.AsQueryable <ClassGrade>() .Count(s => s.Id == classGrade.Id) == 1); Xunit.Assert.NotNull(grade); return(grade); }
public ClassGrade Add() { var classGrade = new ClassGrade(); classGrade.Id = Guid.NewGuid().ToString(); //此处设置了默认Id为10 _storage.Add(classGrade); var grade = this._storage.Find <ClassGrade>(classGrade.Id); Assert.True(_storage.AsQueryable <ClassGrade>() .Count(s => s.Id == classGrade.Id) == 1); Assert.NotNull(grade); return(grade); }
public void addStudent() { try { Student student = new Student(); setValue(student, context); HttpPostedFile hpf = context.Request.Files["headImgFile"]; if (hpf != null) { string serverPath = "/uploadFile/headImg/" + System.DateTime.Now.Ticks + "." + hpf.FileName.Split('.')[1]; string savePath = context.Server.MapPath(serverPath); //路径,相对于服务器当前的路径 hpf.SaveAs(savePath); //保存 student.HeadImage = serverPath; } string FacultyID = context.Request.Form.Get("Faculty"); DepartmentService ds = new DepartmentService(); string professionID = context.Request.Form.Get("Profession"); if (!string.IsNullOrEmpty(professionID)) { Profession profession = ds.getProfessionByID(professionID); if (profession != null) { student.Profession = profession; } } string ClassGradeID = context.Request.Form.Get("ClassGrade"); if (!string.IsNullOrEmpty(ClassGradeID)) { ClassGrade classGrade = ds.getClassGradeByID(ClassGradeID); if (classGrade != null) { student.ClassGrade = classGrade; } } StudentService s = new StudentService(); student.Password = student.Sn; s.save(student); context.Response.Write("1"); } catch (Exception e) { context.Response.Write("0"); } }
public void updateStudent() { try { Student student = new Student(); setValue(student, context); HttpPostedFile hpf = context.Request.Files["headImgFile"]; if (hpf != null) { string savepath = context.Server.MapPath("/uploadFile/headImg/" + student.Id + "." + hpf.GetType()); //路径,相对于服务器当前的路径 hpf.SaveAs(savepath); //保存 student.HeadImage = savepath; } DepartmentService ds = new DepartmentService(); string professionID = context.Request.Form.Get("Profession"); if (!string.IsNullOrEmpty(professionID)) { Profession profession = ds.getProfessionByID(professionID); if (profession != null) { student.Profession = profession; } } string ClassGradeID = context.Request.Form.Get("ClassGrade"); if (!string.IsNullOrEmpty(ClassGradeID)) { ClassGrade classGrade = ds.getClassGradeByID(ClassGradeID); if (classGrade != null) { student.ClassGrade = classGrade; } } StudentService s = new StudentService(); s.save(student); context.Response.Write("1"); } catch (Exception e) { context.Response.Write("0"); } }
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"); } }
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); }