예제 #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         int id = Convert.ToInt32(Request.QueryString["id"]);
         paper = paperBLL.GetModel(id);
         txtPaperTitle.Text = paper.papertitle;
         txtDuration.Text = paper.durationtime.ToString();
     }
 }
예제 #2
0
    protected void lbtnAdd_Click(object sender, EventArgs e)
    {
        int id = Convert.ToInt32(Request.QueryString["id"]);

        paper = paperBLL.GetModel(id);
        paper.papertitle = txtPaperTitle.Text.Trim();
        paper.durationtime = Convert.ToInt32(txtDuration.Text);
        paperBLL.Update(paper);

        lblInfo.Text = "编辑成功!";
        lblInfo.Visible = true;
        
    }
예제 #3
0
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<Model.tbPaper> DataTableToList(DataTable dt)
		{
			List<Model.tbPaper> modelList = new List<Model.tbPaper>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				Model.tbPaper model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new Model.tbPaper();					
													if(dt.Rows[n]["id"].ToString()!="")
				{
					model.id=int.Parse(dt.Rows[n]["id"].ToString());
				}
																																if(dt.Rows[n]["subjectid"].ToString()!="")
				{
					model.subjectid=int.Parse(dt.Rows[n]["subjectid"].ToString());
				}
																																if(dt.Rows[n]["userid"].ToString()!="")
				{
					model.userid=int.Parse(dt.Rows[n]["userid"].ToString());
				}
																																				model.papertitle= dt.Rows[n]["papertitle"].ToString();
																												if(dt.Rows[n]["diff"].ToString()!="")
				{
					model.diff=decimal.Parse(dt.Rows[n]["diff"].ToString());
				}
																																if(dt.Rows[n]["allscore"].ToString()!="")
				{
					model.allscore=int.Parse(dt.Rows[n]["allscore"].ToString());
				}
																																if(dt.Rows[n]["durationtime"].ToString()!="")
				{
					model.durationtime=int.Parse(dt.Rows[n]["durationtime"].ToString());
				}
																																if(dt.Rows[n]["createtime"].ToString()!="")
				{
					model.createtime=DateTime.Parse(dt.Rows[n]["createtime"].ToString());
				}
																																if(dt.Rows[n]["papertype"].ToString()!="")
				{
					model.papertype=int.Parse(dt.Rows[n]["papertype"].ToString());
				}
																																if(dt.Rows[n]["sr_count"].ToString()!="")
				{
					model.sr_count=int.Parse(dt.Rows[n]["sr_count"].ToString());
				}
																																if(dt.Rows[n]["sr_scoreofeach"].ToString()!="")
				{
					model.sr_scoreofeach=int.Parse(dt.Rows[n]["sr_scoreofeach"].ToString());
				}
																																if(dt.Rows[n]["sr_diff"].ToString()!="")
				{
					model.sr_diff=int.Parse(dt.Rows[n]["sr_diff"].ToString());
				}
																																				model.sr_chapterrange= dt.Rows[n]["sr_chapterrange"].ToString();
																																model.sr_countofeachchatper= dt.Rows[n]["sr_countofeachchatper"].ToString();
																												if(dt.Rows[n]["cb_count"].ToString()!="")
				{
					model.cb_count=int.Parse(dt.Rows[n]["cb_count"].ToString());
				}
																																if(dt.Rows[n]["cb_scoreofeach"].ToString()!="")
				{
					model.cb_scoreofeach=int.Parse(dt.Rows[n]["cb_scoreofeach"].ToString());
				}
																																if(dt.Rows[n]["cb_diff"].ToString()!="")
				{
					model.cb_diff=int.Parse(dt.Rows[n]["cb_diff"].ToString());
				}
																																				model.cb_chapterrange= dt.Rows[n]["cb_chapterrange"].ToString();
																																model.cb_countofeachchapter= dt.Rows[n]["cb_countofeachchapter"].ToString();
																												if(dt.Rows[n]["jd_count"].ToString()!="")
				{
					model.jd_count=int.Parse(dt.Rows[n]["jd_count"].ToString());
				}
																																if(dt.Rows[n]["jd_scoreofeach"].ToString()!="")
				{
					model.jd_scoreofeach=int.Parse(dt.Rows[n]["jd_scoreofeach"].ToString());
				}
																																if(dt.Rows[n]["jd_diff"].ToString()!="")
				{
					model.jd_diff=int.Parse(dt.Rows[n]["jd_diff"].ToString());
				}
																																				model.jd_chapterrange= dt.Rows[n]["jd_chapterrange"].ToString();
																																model.jd_countofeachchapter= dt.Rows[n]["jd_countofeachchapter"].ToString();
																												if(dt.Rows[n]["bf_count"].ToString()!="")
				{
					model.bf_count=int.Parse(dt.Rows[n]["bf_count"].ToString());
				}
																																if(dt.Rows[n]["bf_scoreofeach"].ToString()!="")
				{
					model.bf_scoreofeach=int.Parse(dt.Rows[n]["bf_scoreofeach"].ToString());
				}
																																if(dt.Rows[n]["bf_diff"].ToString()!="")
				{
					model.bf_diff=int.Parse(dt.Rows[n]["bf_diff"].ToString());
				}
																																				model.bf_chapterrange= dt.Rows[n]["bf_chapterrange"].ToString();
																																model.bf_countofeachchapter= dt.Rows[n]["bf_countofeachchapter"].ToString();
																												if(dt.Rows[n]["sa_count"].ToString()!="")
				{
					model.sa_count=int.Parse(dt.Rows[n]["sa_count"].ToString());
				}
																																if(dt.Rows[n]["sa_scoreofeach"].ToString()!="")
				{
					model.sa_scoreofeach=int.Parse(dt.Rows[n]["sa_scoreofeach"].ToString());
				}
																																if(dt.Rows[n]["sa_diff"].ToString()!="")
				{
					model.sa_diff=int.Parse(dt.Rows[n]["sa_diff"].ToString());
				}
																																				model.sa_chapterrange= dt.Rows[n]["sa_chapterrange"].ToString();
																																model.sa_countofeachchapter= dt.Rows[n]["sa_countofeachchapter"].ToString();
																																model.sr_list= dt.Rows[n]["sr_list"].ToString();
																																model.cb_list= dt.Rows[n]["cb_list"].ToString();
																																model.jd_list= dt.Rows[n]["jd_list"].ToString();
																																model.bf_list= dt.Rows[n]["bf_list"].ToString();
																																model.sa_list= dt.Rows[n]["sa_list"].ToString();
																						
				
					modelList.Add(model);
				}
			}
			return modelList;
		}
예제 #4
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(Model.tbPaper model)
 {
     return(dal.Add(model));
 }
예제 #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.tbPaper model)
 {
     return(dal.Update(model));
 }
예제 #6
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <Model.tbPaper> DataTableToList(DataTable dt)
        {
            List <Model.tbPaper> modelList = new List <Model.tbPaper>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                Model.tbPaper model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.tbPaper();
                    if (dt.Rows[n]["id"].ToString() != "")
                    {
                        model.id = int.Parse(dt.Rows[n]["id"].ToString());
                    }
                    if (dt.Rows[n]["subjectid"].ToString() != "")
                    {
                        model.subjectid = int.Parse(dt.Rows[n]["subjectid"].ToString());
                    }
                    if (dt.Rows[n]["userid"].ToString() != "")
                    {
                        model.userid = int.Parse(dt.Rows[n]["userid"].ToString());
                    }
                    model.papertitle = dt.Rows[n]["papertitle"].ToString();
                    if (dt.Rows[n]["diff"].ToString() != "")
                    {
                        model.diff = decimal.Parse(dt.Rows[n]["diff"].ToString());
                    }
                    if (dt.Rows[n]["allscore"].ToString() != "")
                    {
                        model.allscore = int.Parse(dt.Rows[n]["allscore"].ToString());
                    }
                    if (dt.Rows[n]["durationtime"].ToString() != "")
                    {
                        model.durationtime = int.Parse(dt.Rows[n]["durationtime"].ToString());
                    }
                    if (dt.Rows[n]["createtime"].ToString() != "")
                    {
                        model.createtime = DateTime.Parse(dt.Rows[n]["createtime"].ToString());
                    }
                    if (dt.Rows[n]["papertype"].ToString() != "")
                    {
                        model.papertype = int.Parse(dt.Rows[n]["papertype"].ToString());
                    }
                    if (dt.Rows[n]["sr_count"].ToString() != "")
                    {
                        model.sr_count = int.Parse(dt.Rows[n]["sr_count"].ToString());
                    }
                    if (dt.Rows[n]["sr_scoreofeach"].ToString() != "")
                    {
                        model.sr_scoreofeach = int.Parse(dt.Rows[n]["sr_scoreofeach"].ToString());
                    }
                    if (dt.Rows[n]["sr_diff"].ToString() != "")
                    {
                        model.sr_diff = int.Parse(dt.Rows[n]["sr_diff"].ToString());
                    }
                    model.sr_chapterrange       = dt.Rows[n]["sr_chapterrange"].ToString();
                    model.sr_countofeachchatper = dt.Rows[n]["sr_countofeachchatper"].ToString();
                    if (dt.Rows[n]["cb_count"].ToString() != "")
                    {
                        model.cb_count = int.Parse(dt.Rows[n]["cb_count"].ToString());
                    }
                    if (dt.Rows[n]["cb_scoreofeach"].ToString() != "")
                    {
                        model.cb_scoreofeach = int.Parse(dt.Rows[n]["cb_scoreofeach"].ToString());
                    }
                    if (dt.Rows[n]["cb_diff"].ToString() != "")
                    {
                        model.cb_diff = int.Parse(dt.Rows[n]["cb_diff"].ToString());
                    }
                    model.cb_chapterrange       = dt.Rows[n]["cb_chapterrange"].ToString();
                    model.cb_countofeachchapter = dt.Rows[n]["cb_countofeachchapter"].ToString();
                    if (dt.Rows[n]["jd_count"].ToString() != "")
                    {
                        model.jd_count = int.Parse(dt.Rows[n]["jd_count"].ToString());
                    }
                    if (dt.Rows[n]["jd_scoreofeach"].ToString() != "")
                    {
                        model.jd_scoreofeach = int.Parse(dt.Rows[n]["jd_scoreofeach"].ToString());
                    }
                    if (dt.Rows[n]["jd_diff"].ToString() != "")
                    {
                        model.jd_diff = int.Parse(dt.Rows[n]["jd_diff"].ToString());
                    }
                    model.jd_chapterrange       = dt.Rows[n]["jd_chapterrange"].ToString();
                    model.jd_countofeachchapter = dt.Rows[n]["jd_countofeachchapter"].ToString();
                    if (dt.Rows[n]["bf_count"].ToString() != "")
                    {
                        model.bf_count = int.Parse(dt.Rows[n]["bf_count"].ToString());
                    }
                    if (dt.Rows[n]["bf_scoreofeach"].ToString() != "")
                    {
                        model.bf_scoreofeach = int.Parse(dt.Rows[n]["bf_scoreofeach"].ToString());
                    }
                    if (dt.Rows[n]["bf_diff"].ToString() != "")
                    {
                        model.bf_diff = int.Parse(dt.Rows[n]["bf_diff"].ToString());
                    }
                    model.bf_chapterrange       = dt.Rows[n]["bf_chapterrange"].ToString();
                    model.bf_countofeachchapter = dt.Rows[n]["bf_countofeachchapter"].ToString();
                    if (dt.Rows[n]["sa_count"].ToString() != "")
                    {
                        model.sa_count = int.Parse(dt.Rows[n]["sa_count"].ToString());
                    }
                    if (dt.Rows[n]["sa_scoreofeach"].ToString() != "")
                    {
                        model.sa_scoreofeach = int.Parse(dt.Rows[n]["sa_scoreofeach"].ToString());
                    }
                    if (dt.Rows[n]["sa_diff"].ToString() != "")
                    {
                        model.sa_diff = int.Parse(dt.Rows[n]["sa_diff"].ToString());
                    }
                    model.sa_chapterrange       = dt.Rows[n]["sa_chapterrange"].ToString();
                    model.sa_countofeachchapter = dt.Rows[n]["sa_countofeachchapter"].ToString();
                    model.sr_list = dt.Rows[n]["sr_list"].ToString();
                    model.cb_list = dt.Rows[n]["cb_list"].ToString();
                    model.jd_list = dt.Rows[n]["jd_list"].ToString();
                    model.bf_list = dt.Rows[n]["bf_list"].ToString();
                    model.sa_list = dt.Rows[n]["sa_list"].ToString();


                    modelList.Add(model);
                }
            }
            return(modelList);
        }
예제 #7
0
 public PaperGenerateDAL(tbPaper paper, SqlTransaction SqlTransaction)
 {
     this.paper = paper;
     this.SqlTransaction = SqlTransaction;
     this.paperContent.paperID = paper.id;
 }
예제 #8
0
        /// <summary>
        /// 导入到数据库
        /// </summary>
        /// <param name="dt"></param>
        /// <returns>返回插入不成功的学号</returns>
        public static List<String> ExportToDB(DataTable dt)
        {
            List<String> list = new List<string>();

            tbPaper paper = new tbPaper();
            tbSingle single = new tbSingle();
            tbCheck check = new tbCheck();
            tbJudge judge = new tbJudge();
            tbBlank blank = new tbBlank();
            tbAnswer answer = new tbAnswer();

            tbPaperDAL paperDAL = new tbPaperDAL();
            tbSingleDAL singleDAL = new tbSingleDAL();
            tbCheckDAL checkDAL = new tbCheckDAL();
            tbJudgeDAL judgeDAL = new tbJudgeDAL();
            tbBlankDAL blankDAL = new tbBlankDAL();
            tbAnswerDAL answerDAL = new tbAnswerDAL();
            //取得数据库连接
            SqlConnection conn = SQLHelper.GetConnection();
            //打开数据库连接
            conn.Open();
            //创建事务
            SqlTransaction SqlTransaction = conn.BeginTransaction();

            try
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    String flag = dt.Rows[i][0].ToString();
                    String temp = dt.Rows[i][1].ToString();
                    switch (flag)
                    {
                        case "#科目#":
                            //获取科目id
                            try
                            {
                                int subjectid = (int)DbHelperSQL.GetSingle("select id from tbSubject where subjectname=@subjectname and id in" + MyUtil.GetMySubjectString(), new SqlParameter("@subjectname", dt.Rows[i][1].ToString()));
                                paper.subjectid = subjectid;
                            }
                            catch (Exception)
                            {
                                list.Add("科目不存在或者没有权限!");
                                continue;
                            }
                            break;
                        case "#标题#":
                            paper.papertitle = dt.Rows[i][1].ToString();
                            if (String.IsNullOrEmpty(paper.papertitle))
                            {
                                list.Add("标题设置不正确!");
                                continue;
                            }
                            break;
                        case "#时间#":
                            try
                            {
                                paper.durationtime = Convert.ToInt32(dt.Rows[i][1].ToString().TrimEnd('分'));
                            }
                            catch (Exception)
                            {
                                list.Add("时间格式不正确!");
                                continue;
                            }
                            break;
                        case "#单选分值#":
                            try
                            {
                                paper.sr_scoreofeach = Convert.ToInt32(dt.Rows[i][1].ToString().TrimEnd('分'));
                            }
                            catch (Exception)
                            {
                                list.Add("单选分值格式不正确!");
                                continue;
                            }
                            break;
                        case "#多选分值#":
                            try
                            {
                                paper.cb_scoreofeach = Convert.ToInt32(dt.Rows[i][1].ToString().TrimEnd('分'));
                            }
                            catch (Exception)
                            {
                                list.Add("多选分值格式不正确!");
                                continue;
                            }
                            break;
                        case "#判断分值#":
                            try
                            {
                                paper.jd_scoreofeach = Convert.ToInt32(dt.Rows[i][1].ToString().TrimEnd('分'));
                            }
                            catch (Exception)
                            {
                                list.Add("判断分值格式不正确!");
                                continue;
                            }
                            break;
                        case "#填空分值#":
                            try
                            {
                                paper.bf_scoreofeach = Convert.ToInt32(dt.Rows[i][1].ToString().TrimEnd('分'));
                            }
                            catch (Exception)
                            {
                                list.Add("填空分值格式不正确!");
                                continue;
                            }
                            break;
                        case "#简答分值#":
                            try
                            {
                                paper.sa_scoreofeach = Convert.ToInt32(dt.Rows[i][1].ToString().TrimEnd('分'));
                            }
                            catch (Exception)
                            {
                                list.Add("简答分值格式不正确!");
                                continue;
                            }
                            break;
                        case "#单选#":
                            single.chapterid = 0;//不属于任何章节
                            single.diff = 3;//默认难度一般
                            single.questype = 2;//固定类型
                            single.ques = dt.Rows[i][1].ToString();
                            single.option_a = dt.Rows[i][2].ToString();
                            single.option_b = dt.Rows[i][3].ToString();
                            single.option_c = dt.Rows[i][4].ToString();
                            single.option_d = dt.Rows[i][5].ToString();
                            single.ans = dt.Rows[i][6].ToString();
                            if (single.ans != "A" && single.ans != "B" && single.ans != "C" && single.ans != "D")
                            {
                                list.Add("行" + (i + 2) + "的单选答案不正确!");
                                continue;
                            }
                            int singleid = singleDAL.AddTran(single, SqlTransaction);
                            paper.sr_list += singleid + ",";
                            paper.sr_count += 1;
                            break;
                        case "#多选#":
                            check.chapterid = 0;//不属于任何章节
                            check.diff = 3;//默认难度一般
                            check.questype = 2;//固定类型
                            check.ques = dt.Rows[i][1].ToString();
                            check.option_a = dt.Rows[i][2].ToString();
                            check.option_b = dt.Rows[i][3].ToString();
                            check.option_c = dt.Rows[i][4].ToString();
                            check.option_d = dt.Rows[i][5].ToString();
                            check.option_e = dt.Rows[i][6].ToString();
                            check.option_f = dt.Rows[i][7].ToString();
                            check.option_g = dt.Rows[i][8].ToString();
                            check.ans = dt.Rows[i][9].ToString();
                            if (check.ans == "" || check.ans == null)
                            {
                                list.Add("行" + (i + 2) + "的多选答案不正确!");
                                continue;
                            }
                            int checkid = checkDAL.AddTran(check, SqlTransaction);
                            paper.cb_list += checkid + ",";
                            paper.cb_count += 1;
                            break;
                        case "#判断#":
                            judge.chapterid = 0;//不属于任何章节
                            judge.diff = 3;//默认难度一般
                            judge.questype = 2;//固定类型
                            judge.ques = dt.Rows[i][1].ToString();
                            judge.ans = dt.Rows[i][2].ToString();
                            if (judge.ans != "对" && judge.ans != "错")
                            {
                                list.Add("行" + (i + 2) + "的判断答案不正确!");
                                continue;
                            }
                            int judgeid = judgeDAL.AddTran(judge, SqlTransaction);
                            paper.jd_list += judgeid + ",";
                            paper.jd_count += 1;
                            break;
                        case "#填空#":
                            blank.chapterid = 0;//不属于任何章节
                            blank.diff = 3;//默认难度一般
                            blank.questype = 2;//固定类型
                            blank.ques = dt.Rows[i][1].ToString();
                            blank.ans = dt.Rows[i][2].ToString();
                            blank.blanklength = blank.ans.Length;
                            int blankid = blankDAL.AddTran(blank, SqlTransaction);
                            paper.bf_list += blankid + ",";
                            paper.bf_count += 1;
                            break;
                        case "#简答#":
                            answer.chapterid = 0;//不属于任何章节
                            answer.diff = 3;//默认难度一般
                            answer.questype = 2;//固定类型
                            answer.ques = dt.Rows[i][1].ToString();
                            answer.ans = dt.Rows[i][2].ToString();
                            int answerid = answerDAL.AddTran(answer, SqlTransaction);
                            paper.sa_list += answerid + ",";
                            paper.sa_count += 1;
                            break;
                    }
                }
                if (list.Count == 0)
                {
                    if (paper.sr_list.EndsWith(","))
                    {
                        paper.sr_list = paper.sr_list.TrimEnd(',');
                    }
                    if (paper.cb_list.EndsWith(","))
                    {
                        paper.cb_list = paper.cb_list.TrimEnd(',');
                    }
                    if (paper.jd_list.EndsWith(","))
                    {
                        paper.jd_list = paper.jd_list.TrimEnd(',');
                    }
                    if (paper.bf_list.EndsWith(","))
                    {
                        paper.bf_list = paper.bf_list.TrimEnd(',');
                    }
                    if (paper.sa_list.EndsWith(","))
                    {
                        paper.sa_list = paper.sa_list.TrimEnd(',');
                    }
                    paper.allscore = paper.sr_count * paper.sr_scoreofeach + paper.cb_count * paper.cb_scoreofeach + paper.jd_count * paper.jd_scoreofeach + paper.bf_count * paper.bf_scoreofeach + paper.sa_count * paper.sa_scoreofeach;
                    paper.papertype = 2;//固定试卷
                    paper.createtime = DateTime.Now;
                    paper.userid = ((tbUser)HttpContext.Current.Session[Constant.User]).id;
                    paperDAL.AddTran(paper, SqlTransaction);
                    SqlTransaction.Commit();
                }
            }
            catch (Exception)
            {
                try
                {
                    SqlTransaction.Rollback();
                }
                catch (Exception)
                {
                    //事务回滚出错
                }
            }
            finally
            {
                //关闭各种资源
                SqlTransaction.Dispose();
                conn.Close();
            }

            return list;
        }
예제 #9
0
    /// <summary>
    /// 收集各个Repeater中的数据,生成PaperSetting
    /// </summary>
    /// <returns>返回试卷详细设置对象</returns>
    protected tbPaper CollectPaperData()
    {
        tbPaper paper = new tbPaper();

        TextBox tempBox = null;
        HiddenField tempHf = null;
        try
        {
            paper.papertitle = txtPaperTitle.Text.Trim();
            paper.subjectid = Convert.ToInt32(ddlSubject.SelectedValue);
            paper.durationtime = Convert.ToInt32(ddlDurationTime.SelectedValue);
        }
        catch (Exception)
        {
            MyUtil.ShowMessage(this, "你填写的时间不正确!");
            return (tbPaper)null;
        }
        //遍历单选
        foreach (RepeaterItem item in rptSR.Items)
        {
            tempBox = (TextBox)(item.FindControl("txtSRChapterCount"));
            tempHf = (HiddenField)(item.FindControl("hfSRRange"));
            paper.sr_chapterrange += tempHf.Value + "|";
            paper.sr_countofeachchatper += tempBox.Text.Trim() + "|";
        }
        //去除最后一个“|”
        if (paper.sr_countofeachchatper != "" && paper.sr_countofeachchatper != null)
            paper.sr_countofeachchatper = paper.sr_countofeachchatper.TrimEnd('|');
        if (paper.sr_chapterrange != "" && paper.sr_chapterrange != null)
            paper.sr_chapterrange = paper.sr_chapterrange.TrimEnd('|');
        try
        {
            //填写数量
            paper.sr_count = Convert.ToInt32(txtSRCount.Text);
            //难度系数
            paper.sr_diff = Convert.ToInt32(ddlSRDiff.SelectedValue);
            //每题分数
            paper.sr_scoreofeach = Convert.ToInt32(ddlSRScore.SelectedValue);
        }
        catch (Exception)
        {
            MyUtil.ShowMessage(this, "你填写的单选题数据不正确!");
            return (tbPaper)null;
        }

        //遍历多选
        foreach (RepeaterItem item in rptCB.Items)
        {
            tempBox = (TextBox)(item.FindControl("txtCBChapterCount"));
            tempHf = (HiddenField)(item.FindControl("hfCBRange"));
            paper.cb_chapterrange += tempHf.Value + "|";
            paper.cb_countofeachchapter += tempBox.Text.Trim() + "|";
        }
        //去除最后一个“|”
        if (paper.cb_countofeachchapter != "" && paper.cb_countofeachchapter != null)
            paper.cb_countofeachchapter = paper.cb_countofeachchapter.TrimEnd('|');
        if (paper.cb_chapterrange != "" && paper.cb_chapterrange != null)
            paper.cb_chapterrange = paper.cb_chapterrange.TrimEnd('|');
        try
        {
            //填写数量
            paper.cb_count = Convert.ToInt32(txtCBCount.Text);
            //难度系数
            paper.cb_diff = Convert.ToInt32(ddlCBDiff.SelectedValue);
            //每题分数
            paper.cb_scoreofeach = Convert.ToInt32(ddlCBScore.SelectedValue);
        }
        catch (Exception)
        {
            MyUtil.ShowMessage(this, "你填写的多选题数据不正确!");
            return (tbPaper)null;
        }

        //遍历判断
        foreach (RepeaterItem item in rptJD.Items)
        {
            tempBox = (TextBox)(item.FindControl("txtJDChapterCount"));
            tempHf = (HiddenField)(item.FindControl("hfJDRange"));
            paper.jd_chapterrange += tempHf.Value + "|";
            paper.jd_countofeachchapter += tempBox.Text.Trim() + "|";
        }
        //去除最后一个“|”
        if (paper.jd_countofeachchapter != "" && paper.jd_countofeachchapter != null)
            paper.jd_countofeachchapter = paper.jd_countofeachchapter.TrimEnd('|');
        if (paper.jd_chapterrange != "" && paper.jd_chapterrange != null)
            paper.jd_chapterrange = paper.jd_chapterrange.TrimEnd('|');
        try
        {
            //填写数量
            paper.jd_count = Convert.ToInt32(txtJDCount.Text);
            //难度系数
            paper.jd_diff = Convert.ToInt32(ddlJDDiff.SelectedValue);
            //每题分数
            paper.jd_scoreofeach = Convert.ToInt32(ddlJDScore.SelectedValue);
        }
        catch (Exception)
        {
            MyUtil.ShowMessage(this, "你填写的判断题数据不正确!");
            return (tbPaper)null;
        }


        //遍历填空
        foreach (RepeaterItem item in rptBF.Items)
        {
            tempBox = (TextBox)(item.FindControl("txtBFChapterCount"));
            tempHf = (HiddenField)(item.FindControl("hfBFRange"));
            paper.bf_chapterrange += tempHf.Value + "|";
            paper.bf_countofeachchapter += tempBox.Text.Trim() + "|";
        }
        //去除最后一个“|”
        if (paper.bf_countofeachchapter != "" && paper.bf_countofeachchapter != null)
            paper.bf_countofeachchapter = paper.bf_countofeachchapter.TrimEnd('|');
        if (paper.bf_chapterrange != "" && paper.bf_chapterrange != null)
            paper.bf_chapterrange = paper.bf_chapterrange.TrimEnd('|');
        try
        {
            //填写数量
            paper.bf_count = Convert.ToInt32(txtBFCount.Text);
            //难度系数
            paper.bf_diff = Convert.ToInt32(ddlBFDiff.SelectedValue);
            //每题分数
            paper.bf_scoreofeach = Convert.ToInt32(ddlBFScore.SelectedValue);
        }
        catch (Exception)
        {
            MyUtil.ShowMessage(this, "你填写的填空题数据不正确!");
            return (tbPaper)null;
        }


        //遍历简答
        foreach (RepeaterItem item in rptSA.Items)
        {
            tempBox = (TextBox)(item.FindControl("txtSAChapterCount"));
            tempHf = (HiddenField)(item.FindControl("hfSARange"));
            paper.sa_chapterrange += tempHf.Value + "|";
            paper.sa_countofeachchapter += tempBox.Text.Trim() + "|";
        }
        //去除最后一个“|”
        if (paper.sa_countofeachchapter != "" && paper.sa_countofeachchapter != null)
            paper.sa_countofeachchapter = paper.sa_countofeachchapter.TrimEnd('|');
        if (paper.sa_chapterrange != "" && paper.sa_chapterrange != null)
            paper.sa_chapterrange = paper.sa_chapterrange.TrimEnd('|');
        try
        {
            //填写数量
            paper.sa_count = Convert.ToInt32(txtSACount.Text);
            //难度系数
            paper.sa_diff = Convert.ToInt32(ddlSADiff.SelectedValue);
            //每题分数
            paper.sa_scoreofeach = Convert.ToInt32(ddlSAScore.SelectedValue);
        }
        catch (Exception)
        {
            MyUtil.ShowMessage(this, "你填写的简答题数据不正确!");
            return (tbPaper)null;
        }
        return paper;
    }
예제 #10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        arrangeid = Convert.ToInt32(Request.QueryString["id"]);
        arrange = arrangeBLL.GetModel(arrangeid);
        paper = paperBLL.GetModel(arrange.paperid);
        subject = subjectBLL.GetModel(arrange.subjectid);

        if (!IsPostBack)
        {
            //取得数据库连接
            SqlConnection conn = SQLHelper.GetConnection();
            //打开数据库连接
            conn.Open();
            //创建事务
            SqlTransaction SqlTransaction = conn.BeginTransaction();

            try
            {
                PaperGenerateDAL pgd = new PaperGenerateDAL(paper, SqlTransaction);
                pc = pgd.GetPaperContent();
                SqlTransaction.Commit();
            }
            catch (Exception)
            {
                try
                {
                    SqlTransaction.Rollback();
                }
                catch (Exception)
                {
                    //事务回滚出错
                }
            }
            finally
            {
                //关闭各种资源
                SqlTransaction.Dispose();
                conn.Close();
            }
            if (arrange.arrangetype == 2)
            {
                //考试,记录考试时间,成绩状态
                tbUser user = (tbUser)Session[Constant.User];
                tbScore score = this.GetScore(arrangeid, user.id);
                score.starttime = DateTime.Now;
                score.scorestatus = 2;//正在考试
                scoreBLL.Update(score);

                //把scoreid存放在ViewState
                ViewState[Constant.ScoreID] = score.id;
            }
            if (pc.SRContent.Count != 0)
            {
                rptSR.DataSource = pc.SRContent;
                rptSR.DataBind();
            }

            if (pc.CBContent.Count != 0)
            {
                rptCB.DataSource = pc.CBContent;
                rptCB.DataBind();
            }

            if (pc.JDContent.Count != 0)
            {
                rptJD.DataSource = pc.JDContent;
                rptJD.DataBind();
            }

            if (pc.BFContent.Count != 0)
            {
                rptBF.DataSource = pc.BFContent;
                rptBF.DataBind();
            }

            if (pc.SAContent.Count != 0)
            {
                rptSA.DataSource = pc.SAContent;
                rptSA.DataBind();
            }
        }
    }