예제 #1
0
 // Token: 0x0600003D RID: 61 RVA: 0x000059E8 File Offset: 0x00003BE8
 protected override void View()
 {
     this.sortinfo = SortBll.GetSortInfo(this.sortid);
     if (this.sortinfo.id == 0)
     {
         this.ShowErr("对不起,该试卷库不存在或已被删除。");
     }
     else
     {
         if (this.channelid == 0)
         {
             this.channelid = this.sortinfo.channelid;
         }
         if (this.ispost)
         {
             string @string = FPRequest.GetString("chkid");
             if (this.action == "delete")
             {
                 string examSorts = ExamBll.GetExamSorts(@string);
                 SortBll.UpdateSortPosts(examSorts, -1);
                 DbHelper.ExecuteDelete <ExamInfo>(@string);
                 SqlParam sqlParam = DbHelper.MakeAndWhere("examid", WhereType.In, @string);
                 DbHelper.ExecuteDelete <ExamTopic>(new SqlParam[]
                 {
                     sqlParam
                 });
             }
             else if (this.action == "sum")
             {
                 SqlParam        sqlParam2 = DbHelper.MakeAndWhere("id", WhereType.In, @string);
                 List <ExamInfo> list      = DbHelper.ExecuteList <ExamInfo>(new SqlParam[]
                 {
                     sqlParam2
                 });
                 string text = "";
                 foreach (ExamInfo examInfo in list)
                 {
                     int    num  = 0;
                     double num2 = 0.0;
                     if (examInfo.examdeparts == "" && examInfo.examuser == "" && examInfo.examroles == "")
                     {
                         SqlParam sqlParam3 = DbHelper.MakeAndWhere("examid", examInfo.id);
                         num = DbHelper.ExecuteCount <ExamResult>(new SqlParam[]
                         {
                             sqlParam3
                         });
                         num2 = FPUtils.StrToDouble(DbHelper.ExecuteSum <ExamResult>("score", new SqlParam[]
                         {
                             sqlParam3
                         }));
                     }
                     else
                     {
                         string text2 = "";
                         if (examInfo.examroles != "")
                         {
                             SqlParam        sqlParam4 = DbHelper.MakeAndWhere("roleid", WhereType.In, examInfo.examroles);
                             List <UserInfo> list2     = DbHelper.ExecuteList <UserInfo>(new SqlParam[]
                             {
                                 sqlParam4
                             });
                             foreach (UserInfo userInfo in list2)
                             {
                                 if (!FPUtils.InArray(userInfo.id, text2))
                                 {
                                     if (text2 != "")
                                     {
                                         text2 += ",";
                                     }
                                     text2 += userInfo.id;
                                     num++;
                                 }
                             }
                         }
                         if (examInfo.examdeparts != "")
                         {
                             SqlParam        sqlParam4 = DbHelper.MakeAndWhere("departid", WhereType.In, examInfo.examdeparts);
                             List <UserInfo> list2     = DbHelper.ExecuteList <UserInfo>(new SqlParam[]
                             {
                                 sqlParam4
                             });
                             foreach (UserInfo userInfo in list2)
                             {
                                 if (!FPUtils.InArray(userInfo.id, text2))
                                 {
                                     if (text2 != "")
                                     {
                                         text2 += ",";
                                     }
                                     text2 += userInfo.id;
                                     num++;
                                 }
                             }
                         }
                         if (examInfo.examuser != "")
                         {
                             SqlParam        sqlParam4 = DbHelper.MakeAndWhere("id", WhereType.In, examInfo.examuser);
                             List <UserInfo> list2     = DbHelper.ExecuteList <UserInfo>(new SqlParam[]
                             {
                                 sqlParam4
                             });
                             foreach (UserInfo userInfo in list2)
                             {
                                 if (!FPUtils.InArray(userInfo.id, text2))
                                 {
                                     if (text2 != "")
                                     {
                                         text2 += ",";
                                     }
                                     text2 += userInfo.id;
                                     num++;
                                 }
                             }
                         }
                         string sqlstring = string.Format("DELETE FROM [{0}Exam_ExamResult] WHERE [examid]={1} AND [uid] NOT IN({2})", DbConfigs.Prefix, examInfo.id, text2);
                         DbHelper.ExecuteSql(sqlstring);
                         SqlParam[] sqlparams = new SqlParam[]
                         {
                             DbHelper.MakeAndWhere("examid", examInfo.id),
                             DbHelper.MakeAndWhere("uid", WhereType.In, text2)
                         };
                         num2 = FPUtils.StrToDouble(DbHelper.ExecuteSum <ExamResult>("score", sqlparams));
                     }
                     List <ExamTopic> examTopicList = ExamBll.GetExamTopicList(examInfo.id, 1);
                     double           num3          = 0.0;
                     int num4 = 0;
                     foreach (ExamTopic examTopic in examTopicList)
                     {
                         num3 += examTopic.perscore * (double)examTopic.questions;
                         num4 += examTopic.questions;
                     }
                     if (text != "")
                     {
                         text += "|";
                     }
                     text += string.Format("UPDATE [{0}Exam_ExamInfo] SET [exams]={1},[score]={2},[questions]={3},[total]={4} WHERE [id]={5}", new object[]
                     {
                         DbConfigs.Prefix,
                         num,
                         num2,
                         num4,
                         num3,
                         examInfo.id
                     });
                 }
                 DbHelper.ExecuteSql(text);
             }
         }
         string          childSorts = SortBll.GetChildSorts(this.sortinfo);
         List <SqlParam> list3      = new List <SqlParam>();
         list3.Add(DbHelper.MakeAndWhere("sortid", WhereType.In, childSorts));
         if (this.keyword != "")
         {
             list3.Add(DbHelper.MakeAndWhere("name", WhereType.Like, this.keyword));
         }
         if (this.starttime != "" && this.isDate(this.starttime))
         {
             list3.Add(DbHelper.MakeAndWhere("islimit", 1));
             list3.Add(DbHelper.MakeAndWhere("starttime", WhereType.LessThanEqual, this.starttime));
         }
         if (this.endtime != "" && this.isDate(this.endtime))
         {
             list3.Add(DbHelper.MakeAndWhere("islimit", 1));
             list3.Add(DbHelper.MakeAndWhere("endtime", WhereType.GreaterThanEqual, this.endtime));
         }
         if (this.typeid > 0)
         {
             this.typeinfo = DbHelper.ExecuteModel <TypeInfo>(this.typeid);
             this.pagenav  = "|" + this.typeinfo.name + "," + this.rawurl;
             list3.Add(DbHelper.MakeAndWhere(string.Format("(','+[typeid]+',') LIKE '%,{0},%'", this.typeid), WhereType.Custom, ""));
         }
         this.examlist = DbHelper.ExecuteList <ExamInfo>(this.pager, list3.ToArray());
         base.SaveRightURL();
     }
 }
예제 #2
0
 // Token: 0x06000036 RID: 54 RVA: 0x00004444 File Offset: 0x00002644
 protected override void View()
 {
     this.examconfig = ExamConifgs.GetExamConfig();
     if (this.id > 0)
     {
         this.examinfo = DbHelper.ExecuteModel <ExamInfo>(this.id);
         if (this.examinfo.id == 0)
         {
             this.ShowErr("对不起,该试卷不存在或已被删除。");
             return;
         }
         this.sortid = this.examinfo.sortid;
     }
     this.sortinfo = SortBll.GetSortInfo(this.sortid);
     if (this.sortinfo.id == 0)
     {
         this.ShowErr("对不起,该栏目不存在或已被删除。");
     }
     else
     {
         if (this.examinfo.islimit == 0)
         {
             this.examinfo.starttime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
             this.examinfo.endtime   = this.examinfo.starttime.AddMinutes((double)this.examinfo.examtime);
         }
         if (this.ispost)
         {
             if (this.action == "saveas")
             {
                 this.examinfo.name  = this.examinfo.name + "_复制";
                 this.examinfo.score = 0.0;
                 this.examinfo.exams = 0;
                 int            examid   = DbHelper.ExecuteInsert <ExamInfo>(this.examinfo);
                 SqlParam       sqlParam = DbHelper.MakeAndWhere("examid", this.id);
                 List <ExpInfo> list     = DbHelper.ExecuteList <ExpInfo>(OrderBy.ASC, new SqlParam[]
                 {
                     sqlParam
                 });
                 int num = 0;
                 foreach (ExpInfo expInfo in list)
                 {
                     list[num].examid = examid;
                     DbHelper.ExecuteInsert <ExpInfo>(list[num]);
                     num++;
                 }
                 List <ExamTopic> list2 = DbHelper.ExecuteList <ExamTopic>(new SqlParam[]
                 {
                     sqlParam
                 });
                 num = 0;
                 foreach (ExamTopic examTopic in list2)
                 {
                     list2[num].examid = examid;
                     DbHelper.ExecuteInsert <ExamTopic>(list2[num]);
                     num++;
                 }
                 base.AddMsg("考试另存成功!");
             }
             else
             {
                 this.examinfo.islimit     = 0;
                 this.examinfo.showanswer  = 0;
                 this.examinfo.allowdelete = 0;
                 this.examinfo.iscopy      = 0;
                 this.examinfo.examtype    = 0;
                 this.examinfo.channelid   = this.sortinfo.channelid;
                 this.examinfo.examroles   = "";
                 this.examinfo             = FPRequest.GetModel <ExamInfo>(this.examinfo);
                 if (this.examinfo.name == "")
                 {
                     this.ShowErr("考试名称不能为空。");
                     return;
                 }
                 if (this.examinfo.papers <= 0)
                 {
                     this.examinfo.papers = 1;
                 }
                 if (this.examinfo.islimit == 1)
                 {
                     if (this.examinfo.endtime <= this.examinfo.starttime)
                     {
                         this.ShowErr("对不起,考试结束时间必须大于开始时间。");
                         return;
                     }
                     TimeSpan timeSpan  = new TimeSpan(this.examinfo.endtime.Ticks);
                     TimeSpan ts        = new TimeSpan(this.examinfo.starttime.Ticks);
                     TimeSpan timeSpan2 = timeSpan.Subtract(ts).Duration();
                     this.examinfo.examtime = Convert.ToInt32(timeSpan2.TotalMinutes);
                 }
                 if (this.examinfo.id > 0)
                 {
                     DbHelper.ExecuteUpdate <ExamInfo>(this.examinfo);
                     StringBuilder stringBuilder = new StringBuilder();
                     stringBuilder.AppendFormat("UPDATE [{0}Exam_ExamResult] SET [examname]='{1}' WHERE [examid]={2}|", DbConfigs.Prefix, DbUtils.RegEsc(this.examinfo.name), this.examinfo.id);
                     if (DbConfigs.DbType == DbType.Access)
                     {
                         stringBuilder.AppendFormat("UPDATE [{0}Exam_ExamResult] SET [passmark]={1},[examtime]={2},[examtype]={3},[showanswer]={4},[allowdelete]={5},[islimit]={6},[endtime]=#{7}# WHERE [examid]={8} AND [status]=0", new object[]
                         {
                             DbConfigs.Prefix,
                             this.examinfo.passmark,
                             this.examinfo.examtime,
                             this.examinfo.examtype,
                             this.examinfo.showanswer,
                             this.examinfo.allowdelete,
                             this.examinfo.islimit,
                             this.examinfo.endtime,
                             this.examinfo.id
                         });
                     }
                     else
                     {
                         stringBuilder.AppendFormat("UPDATE [{0}Exam_ExamResult] SET [passmark]={1},[examtime]={2},[examtype]={3},[showanswer]={4},[allowdelete]={5},[islimit]={6},[endtime]='{7}' WHERE [examid]={8} AND [status]=0", new object[]
                         {
                             DbConfigs.Prefix,
                             this.examinfo.passmark,
                             this.examinfo.examtime,
                             this.examinfo.examtype,
                             this.examinfo.showanswer,
                             this.examinfo.allowdelete,
                             this.examinfo.islimit,
                             this.examinfo.endtime,
                             this.examinfo.id
                         });
                     }
                     DbHelper.ExecuteSql(stringBuilder.ToString());
                     base.AddMsg("更新考试成功!");
                 }
                 else
                 {
                     this.examinfo.uid = this.userid;
                     this.examinfo.id  = DbHelper.ExecuteInsert <ExamInfo>(this.examinfo);
                     ExamBll.AddExamLarge(this.examinfo.id);
                     base.AddMsg("添加考试成功!");
                 }
                 int    num2 = 0;
                 double num3;
                 if (this.examinfo.examdeparts == "" && this.examinfo.examuser == "" && this.examinfo.examroles == "")
                 {
                     SqlParam sqlParam2 = DbHelper.MakeAndWhere("examid", this.examinfo.id);
                     num2 = DbHelper.ExecuteCount <ExamResult>(new SqlParam[]
                     {
                         sqlParam2
                     });
                     num3 = FPUtils.StrToDouble(DbHelper.ExecuteSum <ExamResult>("score", new SqlParam[]
                     {
                         sqlParam2
                     }));
                 }
                 else
                 {
                     string text = "";
                     if (this.examinfo.examroles != "")
                     {
                         SqlParam        sqlParam3 = DbHelper.MakeAndWhere("roleid", WhereType.In, this.examinfo.examroles);
                         List <UserInfo> list3     = DbHelper.ExecuteList <UserInfo>(new SqlParam[]
                         {
                             sqlParam3
                         });
                         foreach (UserInfo userInfo in list3)
                         {
                             if (!FPUtils.InArray(userInfo.id, text))
                             {
                                 if (text != "")
                                 {
                                     text += ",";
                                 }
                                 text += userInfo.id;
                                 num2++;
                             }
                         }
                     }
                     if (this.examinfo.examdeparts != "")
                     {
                         SqlParam        sqlParam3 = DbHelper.MakeAndWhere("departid", WhereType.In, this.examinfo.examdeparts);
                         List <UserInfo> list3     = DbHelper.ExecuteList <UserInfo>(new SqlParam[]
                         {
                             sqlParam3
                         });
                         foreach (UserInfo userInfo in list3)
                         {
                             if (!FPUtils.InArray(userInfo.id, text))
                             {
                                 if (text != "")
                                 {
                                     text += ",";
                                 }
                                 text += userInfo.id;
                                 num2++;
                             }
                         }
                     }
                     if (this.examinfo.examuser != "")
                     {
                         SqlParam        sqlParam3 = DbHelper.MakeAndWhere("id", WhereType.In, this.examinfo.examuser);
                         List <UserInfo> list3     = DbHelper.ExecuteList <UserInfo>(new SqlParam[]
                         {
                             sqlParam3
                         });
                         foreach (UserInfo userInfo in list3)
                         {
                             if (!FPUtils.InArray(userInfo.id, text))
                             {
                                 if (text != "")
                                 {
                                     text += ",";
                                 }
                                 text += userInfo.id;
                                 num2++;
                             }
                         }
                     }
                     string sqlstring = string.Format("DELETE FROM [{0}Exam_ExamResult] WHERE [examid]={1} AND [uid] NOT IN({2})", DbConfigs.Prefix, this.examinfo.id, text);
                     DbHelper.ExecuteSql(sqlstring);
                     SqlParam[] sqlparams = new SqlParam[]
                     {
                         DbHelper.MakeAndWhere("examid", this.examinfo.id),
                         DbHelper.MakeAndWhere("uid", WhereType.NotIn, text)
                     };
                     num3 = FPUtils.StrToDouble(DbHelper.ExecuteSum <ExamResult>("score", sqlparams));
                 }
                 string sqlstring2 = string.Format("UPDATE [{0}Exam_ExamInfo] SET [exams]={1},[score]={2} WHERE [id]={3}", new object[]
                 {
                     DbConfigs.Prefix,
                     num2,
                     num3,
                     this.examinfo.id
                 });
                 DbHelper.ExecuteSql(sqlstring2);
             }
             if (this.tabactive == 1)
             {
                 this.link = "exammanage.aspx?sortid=" + this.sortid;
             }
             else
             {
                 this.link = string.Concat(new object[]
                 {
                     "examadd.aspx?sortid=",
                     this.sortid,
                     "&tabactive=",
                     this.tabactive,
                     "&id=",
                     this.examinfo.id
                 });
             }
         }
         else
         {
             this.rolelist = DbHelper.ExecuteList <RoleInfo>();
             SqlParam     sqlParam4 = DbHelper.MakeAndWhere("id", WhereType.In, this.sortinfo.types);
             OrderByParam orderby   = DbHelper.MakeOrderBy("display", OrderBy.ASC);
             this.typelist = DbHelper.ExecuteList <TypeInfo>(orderby, new SqlParam[]
             {
                 sqlParam4
             });
             this.zNodes = this.GetDepartTree(0);
             base.SaveRightURL();
         }
     }
 }