protected void Page_Load(object sender, EventArgs e)
 {
     Student s = (Student)Session["user"];
     if (s != null) {
         welcomeInfo.InnerHtml = "欢迎你," + s.Name;
         ExamResultService ers = new ExamResultService();
         IList<ExamResult> examResultList = ers.getExamResultByStudent(s);
         string content = "<center><h2>"+s.Name+" 同学成绩单</h2></center>";
         foreach (ExamResult er in examResultList) {
             content += "<h4>" + er.ExamPlan.Name + "</h4>";
             IDictionary<string,string> couresScoureMap = er.CouresScoreMap;
             string[] keys = new string[couresScoureMap.Keys.Count];
             content += "<table class='table table-striped table-bordered table-condensed'><thead><tr>";
             for (int i = 0; i < keys.Length; i++) {
                 String key = couresScoureMap.Keys.ElementAt(i);
                 keys[i] = key;
                 content += "<th>" + key + "</th>";
             }
             content += "</tr></thead><tbody><tr>";
             for (int i = 0; i < keys.Length; i++)
             {
                 String key = keys[i];
                 content += "<td>" + couresScoureMap[key] + "</td>";
             }
             content += "</tr></tbody></table>";
         }
         TableContent.InnerHtml = content;
     }
     else
     {
         Response.Redirect("login.aspx");
     }
 }
        private void searchExamResult()
        {
            DepartmentService ds = new DepartmentService();
            IList professionList = new ArrayList();
            string ProfessionID = context.Request.Form.Get("ProfessionID");
            string YearNo = context.Request.Form.Get("YearNo");
            string LevelNo = context.Request.Form.Get("LevelNo");
            if (!string.IsNullOrEmpty(ProfessionID))
            {
                Profession profession = ds.getProfessionByID(ProfessionID);
                professionList.Add(profession);
            }
            PlanService ps = new PlanService();
            object[] planObjArr = ps.searchPlan(professionList, YearNo, LevelNo,
            int.MaxValue, 1);
            if (planObjArr[1] != null)
            {
                IList<ExamPlan> examPlanList = (IList<ExamPlan>)planObjArr[1];
                if (examPlanList == null || examPlanList.Count == 0) return;
                ExamResultService ers = new ExamResultService();
                IList<ExamPlan> planList = new List<ExamPlan>();
                planList.Add(examPlanList[0]);
                object[] examResultObjArr = ers.searchExamResult(planList, int.MaxValue, 1);
                if (examResultObjArr[1] != null)
                {
                    IList<ExamResult> examResultList = (IList<ExamResult>)examResultObjArr[1];
                    IList<Hashtable> examRsultMapList = new List<Hashtable>();
                    foreach (ExamResult er in examResultList)
                    {
                        Hashtable cht = new Hashtable();
                        cht.Add("Id", er.Id);
                        cht.Add("StudentSN", er.StudentSN);
                        cht.Add("StudentName", er.StudentName);
                        cht.Add("ExamPlanName", er.ExamPlanName);

                        if (er.CouresScoreMap != null)
                        {
                            ArrayList newArrayList = new ArrayList();
                            foreach (Coures c in planList.ElementAt(0).CouresSet)
                            {
                                newArrayList.Add(c.Name);
                            }
                            newArrayList.Sort();
                            foreach (string key in newArrayList)
                            {
                                if (er.CouresScoreMap.ContainsKey(key)) {
                                    cht.Add(key, er.CouresScoreMap[key]);
                                }

                            }
                        }
                        examRsultMapList.Add(cht);
                    }
                    Hashtable ht = new Hashtable();
                    ht.Add("total", examResultObjArr[0]);
                    ht.Add("rows", examRsultMapList);
                    String json = JsonConvert.SerializeObject(ht);
                    context.Response.Write(json);
                }
            }
        }
 private void saveExamResult()
 {
     try{
         string[] keys = context.Request.Form.AllKeys;
         ExamResultService res = new ExamResultService();
         ExamResult er = res.getExamResultByID(context.Request.Form.Get("Id"));
         IDictionary<string, string> map = new Dictionary<string, string>();
         foreach (string s in keys)
         {
             if (!s.Equals("Id") && !s.Equals("StudentSN") && !s.Equals("StudentName") && !s.Equals("ExamPlanName")) {
                 map.Add(s, context.Request.Form.Get(s));
             }
         }
         er.CouresScoreMap = map;
         res.save(er);
         context.Response.Write("1");
     }
     catch (Exception e)
     {
         context.Response.Write("0");
     }
 }
        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");
            }
        }