Exemplo n.º 1
0
        /////
        #region 9.0 取消发布试卷 +ActionResult CancelPubPaper()
        /// <summary>
        /// 6.0 发布试卷
        /// </summary>
        public ActionResult CancelPubPaper()
        {
            //当前页码
            int pageIndex = int.Parse(Request.Params["pageIndex"]);
            //试卷ID
            int paperId = int.Parse(Request.Params["paperId"]);

            MODEL.T_Paper list =
                OperateContext.Current.BLLSession
                .IPaperBLL.GetListBy(p => p.ID == paperId).First();
            int id = list.typeId;

            MODEL.T_Paper listid = OperateContext.Current.BLLSession.IPaperBLL.GetListBy(p => p.typeId == id && p.IsPublished == true).FirstOrDefault();
            if (listid != null)
            {
                listid.IsPublished = false;
                OperateContext.Current.BLLSession.IPaperBLL.Modify(listid, "IsPublished");
            }

            MODEL.T_Paper model =
                OperateContext.Current.BLLSession
                .IPaperBLL.GetListBy(p => p.ID == paperId && p.typeId == id).First();
            //修改为发布状态并更新到数据库
            model.IsPublished = true;
            OperateContext.Current.BLLSession.IPaperBLL.Modify(model, "IsPublished");


            return(Redirect("/JoinUs/PaperManage/Index?pageid=" + pageIndex));
        }
Exemplo n.º 2
0
        /////
        #region 3.0 删除试卷 +ActionResult Del(int id)
        /// <summary>
        /// 3.0 删除试卷
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Del()
        {
            int    id           = int.Parse(Request.Params["id"]);
            string pageIndexNow = Request.Params["pageIndexNow"];

            //1.0 删除试卷
            //根据id查找对应记录
            MODEL.T_Paper model =
                OperateContext.Current.BLLSession
                .IPaperBLL.GetListBy(q => q.ID == id).FirstOrDefault();
            //设置IsDel标记为true
            model.IsDel = true;
            OperateContext.Current.BLLSession.IPaperBLL.Modify(model, "IsDel");
            //2.0 删除该试卷与题目的映射
            List <MODEL.T_PaperQuestion> list =
                OperateContext.Current.BLLSession
                .IPaperQuestionBLL.GetListBy(pq => pq.PaperID == id).ToList();

            //foreach (MODEL.T_PaperQuestion p in list)
            //{
            //    OperateContext.Current.BLLSession.IPaperQuestionBLL.Del(p);
            //}
            //删除成功后跳转到原来的页面
            return(Redirect("/JoinUs/PaperManage/Index?pageid=" + pageIndexNow));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 1.0 根据id找到指定试卷的"整理试卷界面"
        /// </summary>
        public ActionResult Index()
        {
            int pageIndex = int.Parse(Request.Params["pageIndex"]);
            //试卷Id
            int paperId = int.Parse(Request.Params["paperId"]);
            //查询所有记录
            List <MODEL.T_Question> list =
                OperateContext.Current.BLLSession.IQuestionBLL.GetListBy(q => q.IsDel == false).ToList();
            //默认页容量为10
            int recordCount = list.Count;
            //计算总页数
            int pageCount;

            if (recordCount % 10 == 0)
            {
                pageCount = recordCount / 10;
            }
            else
            {
                pageCount = recordCount / 10 + 1;
            }
            //如果页码越界,则默认访问尾页
            if (pageIndex > pageCount)
            {
                ViewData["pageIndex"] = pageCount;
            }
            else
            {
                ViewData["pageIndex"] = pageIndex;
            }
            ViewData["paperId"] = paperId;
            //查找试卷名称
            MODEL.T_Paper model = OperateContext.Current
                                  .BLLSession.IPaperBLL.GetListBy(p => p.ID == paperId).FirstOrDefault();
            List <MODEL.T_PaperQuestion> listid =
                OperateContext.Current.BLLSession.IPaperQuestionBLL.GetListBy(p => p.PaperID == paperId).OrderBy(p => p.QuestionID).ToList();
            List <MODEL.DTOModel.T_PaperQuestionDTO> listDTO = new List <MODEL.DTOModel.T_PaperQuestionDTO>();

            List <string> arr = new List <string>();

            foreach (MODEL.T_PaperQuestion q in listid)
            {
                arr.Add(q.QuestionID.ToString());
                arr.Add(",");
            }

            ViewData["count"]        = listid.Count;
            ViewData["paperIdcount"] = arr;
            ViewData["paperName"]    = model.PaperName;
            return(View());
        }
 /// <summary>
 /// 4.2 确认新增
 /// </summary>
 /// <returns></returns>
 public ActionResult ConfirmAdd()
 {
     string paperName = Request.Form["paperName"];
     string producerId = Request.Form["Name"];
     int typeId = int.Parse(Request.Form["typeId"]);
     MODEL.T_Paper model = new MODEL.T_Paper()
     {
         AddDate = DateTime.Now,
         PaperName = paperName,
         PaperProducerID = producerId,
         typeId=typeId
     };
     int result = OperateContext.Current.BLLSession.IPaperBLL.Add(model);
     return Redirect("/JoinUs/PaperManage/Index");
 }
Exemplo n.º 5
0
        /////
        #region 4.2 确认新增 +ActionResult ConfirmAdd()
        /// <summary>
        /// 4.2 确认新增
        /// </summary>
        /// <returns></returns>
        public ActionResult ConfirmAdd()
        {
            string paperName  = Request.Form["paperName"];
            string producerId = Request.Form["Name"];
            int    typeId     = int.Parse(Request.Form["typeId"]);

            MODEL.T_Paper model = new MODEL.T_Paper()
            {
                AddDate         = DateTime.Now,
                PaperName       = paperName,
                PaperProducerID = producerId,
                typeId          = typeId
            };
            int result = OperateContext.Current.BLLSession.IPaperBLL.Add(model);

            return(Redirect("/JoinUs/PaperManage/Index"));
        }
Exemplo n.º 6
0
        /////
        #region 6.0 发布试卷 +ActionResult PubPaper()
        /// <summary>
        /// 6.0 发布试卷
        /// </summary>
        public ActionResult PubPaper()
        {
            //当前页码
            int pageIndex = int.Parse(Request.Params["pageIndex"]);
            //试卷ID
            int paperId = int.Parse(Request.Params["paperId"]);

            MODEL.T_Paper list =
                OperateContext.Current.BLLSession
                .IPaperBLL.GetListBy(p => p.ID == paperId).First();
            int id = list.typeId;

            MODEL.T_Paper listid = OperateContext.Current.BLLSession.IPaperBLL.GetListBy(p => p.typeId == id && p.IsPublished == true).FirstOrDefault();
            if (listid != null)
            {
                listid.IsPublished = false;
                OperateContext.Current.BLLSession.IPaperBLL.Modify(listid, "IsPublished");
            }
            ////修改之前发布中的试卷状态为“false”
            //MODEL.T_Paper modelBefore =
            //    OperateContext.Current.BLLSession
            //    .IT_PaperBLL.GetListBy(p => p.IsPublished == true).FirstOrDefault();
            //if (modelBefore != null)
            //{
            //    modelBefore.IsPublished = false;
            //    OperateContext.Current.BLLSession.IT_PaperBLL.Modify(modelBefore, "IsPublished");
            //}
            //根据id查找对应model
            List <MODEL.T_PaperQuestion> listp = OperateContext.Current.BLLSession.IPaperQuestionBLL.GetListBy(p => p.PaperID == paperId).ToList();

            if (listp.Count != 0)
            {
                MODEL.T_Paper model =
                    OperateContext.Current.BLLSession
                    .IPaperBLL.GetListBy(p => p.ID == paperId && p.typeId == id).First();
                //修改为发布状态并更新到数据库
                model.IsPublished = true;
                OperateContext.Current.BLLSession.IPaperBLL.Modify(model, "IsPublished");
                return(Redirect("/JoinUs/PaperManage/Index?pageid=" + pageIndex));
            }
            else
            {
                return(Redirect("/JoinUs/PaperManage/Index?IsNull=1&&pageid=" + pageIndex));
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 1.0 根据id找到指定试卷的"整理试卷界面"
        /// </summary>
        public ActionResult Indextype()
        {
            int    questionTypeId;
            string questioncontent;

            if (Request.Params["questionType"] != null)
            {
                string questionType          = Request.Params["questionType"];
                System.Web.HttpCookie cookie = new System.Web.HttpCookie("Type", questionType);
                Response.Cookies.Add(cookie);
                questionTypeId = int.Parse(Request.Params["questionType"]);
            }
            else
            {
                System.Web.HttpCookie cookie = Request.Cookies["Type"];
                questionTypeId = int.Parse(cookie.Value);
            }

            if (Request.Params["questioncontent"] != null)
            {
                string content = Request.Params["questioncontent"];
                System.Web.HttpCookie cookie1 = new System.Web.HttpCookie("content1", content);
                Response.Cookies.Add(cookie1);
                questioncontent = Request.Params["questioncontent"];
            }
            else
            {
                HttpCookie cookie1 = Request.Cookies["content1"];
                if (cookie1 == null)
                {
                    questioncontent = "";
                }
                else
                {
                    questioncontent = cookie1.Value;
                }
            }
            int pageIndex = int.Parse(Request.Params["pageIndex"]);
            //试卷Id
            int paperId = int.Parse(Request.Params["paperId"]);

            if (questionTypeId != 3)
            {
                //查询所有记录
                List <MODEL.T_Question> list =
                    OperateContext.Current.BLLSession.IQuestionBLL.GetListBy(q => q.IsDel == false && q.QuestionTypeID == questionTypeId && q.QuestionContent.Contains(questioncontent)).ToList();
                //默认页容量为10
                int recordCount = list.Count;
                //计算总页数
                int pageCount;
                if (recordCount % 10 == 0)
                {
                    pageCount = recordCount / 10;
                }
                else
                {
                    pageCount = recordCount / 10 + 1;
                }
                //如果页码越界,则默认访问尾页
                if (pageIndex > pageCount)
                {
                    ViewData["pageIndex"] = pageCount;
                }
                else
                {
                    ViewData["pageIndex"] = pageIndex;
                }
                ViewData["paperId"]         = paperId;
                ViewData["questionTypeId"]  = questionTypeId;
                ViewData["questioncontent"] = questioncontent;
                //查找试卷名称
                MODEL.T_Paper model = OperateContext.Current
                                      .BLLSession.IPaperBLL.GetListBy(p => p.ID == paperId).FirstOrDefault();
                List <MODEL.T_PaperQuestion> listid =
                    OperateContext.Current.BLLSession.IPaperQuestionBLL.GetListBy(p => p.PaperID == paperId).OrderBy(p => p.QuestionID).ToList();
                List <MODEL.DTOModel.T_PaperQuestionDTO> listDTO = new List <MODEL.DTOModel.T_PaperQuestionDTO>();

                List <string> arr = new List <string>();
                foreach (MODEL.T_PaperQuestion q in listid)
                {
                    arr.Add(q.QuestionID.ToString());
                    arr.Add(",");
                }

                ViewData["count"]        = listid.Count;
                ViewData["paperIdcount"] = arr;
                ViewData["paperName"]    = model.PaperName;
                return(View());
            }
            else if (questionTypeId == 3 && questioncontent != "")
            {
                //查询所有记录
                List <MODEL.T_Question> list =
                    OperateContext.Current.BLLSession.IQuestionBLL.GetListBy(q => q.IsDel == false && q.QuestionContent.Contains(questioncontent)).ToList();
                //默认页容量为10
                int recordCount = list.Count;
                //计算总页数
                int pageCount;
                if (recordCount % 10 == 0)
                {
                    pageCount = recordCount / 10;
                }
                else
                {
                    pageCount = recordCount / 10 + 1;
                }
                //如果页码越界,则默认访问尾页
                if (pageIndex > pageCount)
                {
                    ViewData["pageIndex"] = pageCount;
                }
                else
                {
                    ViewData["pageIndex"] = pageIndex;
                }
                ViewData["paperId"]         = paperId;
                ViewData["questionTypeId"]  = questionTypeId;
                ViewData["questioncontent"] = questioncontent;
                //查找试卷名称
                MODEL.T_Paper model = OperateContext.Current
                                      .BLLSession.IPaperBLL.GetListBy(p => p.ID == paperId).FirstOrDefault();
                List <MODEL.T_PaperQuestion> listid =
                    OperateContext.Current.BLLSession.IPaperQuestionBLL.GetListBy(p => p.PaperID == paperId).OrderBy(p => p.QuestionID).ToList();
                List <MODEL.DTOModel.T_PaperQuestionDTO> listDTO = new List <MODEL.DTOModel.T_PaperQuestionDTO>();

                List <string> arr = new List <string>();
                foreach (MODEL.T_PaperQuestion q in listid)
                {
                    arr.Add(q.QuestionID.ToString());
                    arr.Add(",");
                }

                ViewData["count"]        = listid.Count;
                ViewData["paperIdcount"] = arr;
                ViewData["paperName"]    = model.PaperName;
                return(View());
            }
            else
            {
                return(Redirect("/JoinUs/OrganizePaper/Index?paperId=" + paperId + "&pageIndex=" + pageIndex));
            }
        }