public IList<ExamResult> getExamResultByStudent(Student s) { using (ISession session = getSession()) { ICriteria ic = session.CreateCriteria(typeof(ExamResult)); ic.Add(Restrictions.Eq("Student", s)); IList<ExamResult> examResultList = ic.List<ExamResult>(); return examResultList; } }
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"); } }
public void getStudents() { try { StudentService service = new StudentService(); Student student = new Student(); setValue(student, context); string ProfessionID = context.Request.Form.Get("FacultyID"); string FacultyID = context.Request.Form.Get("ProfessionID"); IList<Profession> professionList = new List<Profession>(); DepartmentService ds = new DepartmentService(); if (!string.IsNullOrEmpty(ProfessionID)) { Profession profession = ds.getProfessionByID(ProfessionID); if (profession != null) professionList.Add(profession); } else if (!string.IsNullOrEmpty(FacultyID)) { Faculty faculty = ds.getFacultyByID(FacultyID); if (faculty != null && faculty.professionList != null) foreach (Profession p in faculty.professionList) professionList.Add(p); } student.ProfessionList = professionList; int rows = Convert.ToInt32(context.Request.Form["rows"]); int page = Convert.ToInt32(context.Request.Form["page"]); object[] data = service.getStudentList(student, rows, page); Hashtable ht = new Hashtable(); ht.Add("total", data[0]); ht.Add("rows", data[1]); String json = JsonConvert.SerializeObject(ht); context.Response.Write(json); } catch (Exception e) { } }
private void initStudentResult() { try { string ExamPlanID = context.Request.Form.Get("ExamPlanID"); PlanService planService = new PlanService(); ExamPlan examPlan = planService.getExamPlanByID(ExamPlanID); IList<ExamPlan> examPlanList = new List<ExamPlan>(); examPlanList.Add(examPlan); ExamResultService ers = new ExamResultService(); object[] obj = ers.searchExamResult(examPlanList, int.MaxValue, 1); if (obj[1] != null) { IList<ExamResult> examResultList = (IList<ExamResult>)obj[1]; foreach (ExamResult er in examResultList) { ers.del(er); } } Student student = new Student(); IList<Profession> professionList = new List<Profession>(); professionList.Add(examPlan.Profession); student.ProfessionList = professionList; StudentService ss = new StudentService(); object[] studentObjArr = ss.getStudentList(student, int.MaxValue, 1); if (studentObjArr[1] != null) { IList<Student> studentList = (IList<Student>)studentObjArr[1]; foreach (Student s in studentList) { ExamResult examResult = new ExamResult(); examResult.ExamPlan = examPlan; examResult.Student = s; ers.save(examPlan); IDictionary<string,string> map = new Dictionary<string,string>(); foreach (Coures c in examPlan.CouresSet) { map.Add(c.Name, "0"); } examResult.CouresScoreMap = map; ers.save(examResult); } } context.Response.Write("1"); } catch (Exception e) { context.Response.Write("0"); } }