예제 #1
0
        private void BindGrid()
        {
            int employeeID = Convert.ToInt32(PrjPub.StudentID);

            hfEmployeeID.Value = PrjPub.StudentID.ToString();
            RandomExamStatisticBLL objBll = new RandomExamStatisticBLL();
            IList <RailExam.Model.RandomExamStatistic> objList =
                objBll.GetErrorItemInfoByEmployeeID(employeeID, DateTime.Today, DateTime.Today);

            examsGrid.DataSource = objList;
            examsGrid.DataBind();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ViewState["RandomExamItemID"] = Request.QueryString.Get("RandomExamItemID");
                ViewState["BookID"]           = Request.QueryString.Get("BookID");
                ViewState["ChapterID"]        = Request.QueryString.Get("ChapterID");
                ViewState["RangeType"]        = Request.QueryString.Get("RangeType");
                ViewState["Begin"]            = Request.QueryString.Get("BeginDate");
                ViewState["End"]        = Request.QueryString.Get("EndDate");
                ViewState["ExamID"]     = Request.QueryString.Get("ExamID");
                ViewState["EmployeeID"] = Request.QueryString.Get("EmployeeID");

                RandomExamBLL             objbll        = new RandomExamBLL();
                RailExam.Model.RandomExam objRandomExam = objbll.GetExam(Convert.ToInt32(ViewState["ExamID"]));
                int year = objRandomExam.BeginTime.Year;

                string strSql = "select a.*,GetBookChapterName(Chapter_ID) ChapterName from Random_Exam_Item_" + year + @" a
                            where Random_Exam_Item_ID=" +
                                ViewState["RandomExamItemID"];
                OracleAccess db = new OracleAccess();
                DataSet      ds = db.RunSqlDataSet(strSql);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    lblBookChapter.Text = ds.Tables[0].Rows[0]["ChapterName"].ToString();
                }

                int itemID     = Convert.ToInt32(ViewState["RandomExamItemID"].ToString());
                int bookID     = Convert.ToInt32(ViewState["BookID"].ToString());
                int chapterID  = Convert.ToInt32(ViewState["ChapterID"].ToString());
                int typeID     = Convert.ToInt32(ViewState["RangeType"].ToString());
                int examID     = Convert.ToInt32(ViewState["ExamID"].ToString());
                int employeeID = Convert.ToInt32(ViewState["EmployeeID"].ToString());

                RandomExamStatisticBLL objBll = new RandomExamStatisticBLL();
                IList <RailExam.Model.RandomExamStatistic> objList = null;
                if (typeID != 0 && employeeID == 0)
                {
                    int orgID = -1;
                    if (PrjPub.CurrentLoginUser.SuitRange == 1)
                    {
                        orgID = -1;
                    }
                    else
                    {
                        orgID = PrjPub.CurrentLoginUser.StationOrgID;
                    }

                    DateTime begin = Convert.ToDateTime(ViewState["Begin"].ToString());
                    DateTime end   = Convert.ToDateTime(ViewState["End"].ToString());
                    objList = objBll.GetErrorItemInfoByItemID(bookID, chapterID, typeID, examID, begin, end, orgID, -1, itemID);
                }
                else if (typeID == 0 && employeeID == 0)
                {
                    objList = objBll.GetErrorItemInfoByItemID(bookID, chapterID, typeID, examID, DateTime.Today, DateTime.Today, -1, -1, itemID);
                }
                else if (employeeID != 0)
                {
                    objList = objBll.GetErrorItemInfoByItemID(bookID, chapterID, typeID, examID, DateTime.Today, DateTime.Today, -1, employeeID, itemID);
                }

                foreach (RailExam.Model.RandomExamStatistic statistic in objList)
                {
                    if (statistic.Answer != "")
                    {
                        string[] str = statistic.Answer.Split('|');

                        string strAnswer = string.Empty;
                        for (int i = 0; i < str.Length; i++)
                        {
                            strAnswer += strAnswer == string.Empty ? intToString(Convert.ToInt32(str[i]) + 1) : "|" + intToString(Convert.ToInt32(str[i]) + 1);
                        }

                        statistic.Answer = strAnswer;
                    }

                    if (statistic.StandardAnswer != "")
                    {
                        string[] str = statistic.StandardAnswer.Split('|');

                        string strAnswer = string.Empty;
                        for (int i = 0; i < str.Length; i++)
                        {
                            strAnswer += strAnswer == string.Empty ? intToString(Convert.ToInt32(str[i]) + 1) : "|" + intToString(Convert.ToInt32(str[i]) + 1);
                        }

                        statistic.StandardAnswer = strAnswer;
                    }
                }

                examsGrid.DataSource = objList;
                examsGrid.DataBind();
            }
        }
        protected void btnSelect_Click(object sender, EventArgs e)
        {
            btnQuery.Enabled = false;
            int bookID     = 0;
            int chapterID  = 0;
            int typeID     = 0;
            int examID     = Convert.ToInt32(ViewState["ExamID"].ToString());
            int employeeID = Convert.ToInt32(ViewState["EmployeeID"].ToString());

            int orgID = 0;

            DateTime begin, end;

            try
            {
                begin         = Convert.ToDateTime(ddlYearSmall.SelectedValue + "-" + ddlMonthSmall.SelectedValue + "-" + "01");
                end           = Convert.ToDateTime(ddlYearBig.SelectedValue + "-" + ddlMonthBig.SelectedValue + "-" + "01").AddMonths(1);
                hfBegin.Value = begin.ToShortDateString();
                hfEnd.Value   = end.ToShortDateString();
            }
            catch
            {
                SessionSet.PageMessage = "日期选择不正确!";
                return;
            }

            if (rbnBook.Checked)
            {
                if (HfBookId.Value == "")
                {
                    SessionSet.PageMessage = "教材章节不能为空!";
                    return;
                }

                bookID    = Convert.ToInt32(HfBookId.Value);
                chapterID = Convert.ToInt32(HfChapterId.Value);
                typeID    = Convert.ToInt32(HfRangeType.Value);
                if (PrjPub.CurrentLoginUser.SuitRange == 1)
                {
                    orgID = -1;
                }
                else
                {
                    orgID = PrjPub.CurrentLoginUser.StationOrgID;
                }

                RandomExamStatisticBLL objBll = new RandomExamStatisticBLL();
                IList <RailExam.Model.RandomExamStatistic> objList =
                    objBll.GetErrorItemInfo(bookID, chapterID, typeID, examID == 0?-1:examID, begin, end, orgID);

                examsGrid.DataSource = objList;
                examsGrid.DataBind();
            }
            else if (rbnExam.Checked)
            {
                if (ViewState["ExamID"].ToString() == "0")
                {
                    SessionSet.PageMessage = "请选择考试!";
                    return;
                }
                bookID    = Convert.ToInt32(HfBookId.Value);
                chapterID = Convert.ToInt32(HfChapterId.Value);
                typeID    = Convert.ToInt32(HfRangeType.Value);
                if (PrjPub.CurrentLoginUser.SuitRange == 1)
                {
                    orgID = -1;
                }
                else
                {
                    orgID = PrjPub.CurrentLoginUser.StationOrgID;
                }

                RandomExamStatisticBLL objBll = new RandomExamStatisticBLL();
                IList <RailExam.Model.RandomExamStatistic> objList =
                    objBll.GetErrorItemInfo(bookID, chapterID, typeID, examID, begin, end, orgID);
                examsGrid.DataSource = objList;
                examsGrid.DataBind();
            }
            else if (rbnEmployee.Checked)
            {
                if (employeeID == 0)
                {
                    SessionSet.PageMessage = "请选择学员!";
                    return;
                }

                RandomExamStatisticBLL objBll = new RandomExamStatisticBLL();
                IList <RailExam.Model.RandomExamStatistic> objList =
                    objBll.GetErrorItemInfoByEmployeeID(employeeID, begin, end);
                examsGrid.DataSource = objList;
                examsGrid.DataBind();
            }
            if (examsGrid.DataSource != null)
            {
                Session["dtExamStatistic"] = examsGrid.DataSource;
                hfIsRef.Value = "true";
            }

            btnQuery.Enabled = true;
        }