Ejemplo n.º 1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <Model.tbScore> DataTableToList(DataTable dt)
        {
            List <Model.tbScore> modelList = new List <Model.tbScore>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                Model.tbScore model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.tbScore();
                    if (dt.Rows[n]["id"].ToString() != "")
                    {
                        model.id = int.Parse(dt.Rows[n]["id"].ToString());
                    }
                    if (dt.Rows[n]["arrangeid"].ToString() != "")
                    {
                        model.arrangeid = int.Parse(dt.Rows[n]["arrangeid"].ToString());
                    }
                    if (dt.Rows[n]["userid"].ToString() != "")
                    {
                        model.userid = int.Parse(dt.Rows[n]["userid"].ToString());
                    }
                    if (dt.Rows[n]["hasshortanswer"].ToString() != "")
                    {
                        model.hasshortanswer = int.Parse(dt.Rows[n]["hasshortanswer"].ToString());
                    }
                    if (dt.Rows[n]["hascorrect"].ToString() != "")
                    {
                        model.hascorrect = int.Parse(dt.Rows[n]["hascorrect"].ToString());
                    }
                    if (dt.Rows[n]["score"].ToString() != "")
                    {
                        model.score = decimal.Parse(dt.Rows[n]["score"].ToString());
                    }
                    if (dt.Rows[n]["scorestatus"].ToString() != "")
                    {
                        model.scorestatus = int.Parse(dt.Rows[n]["scorestatus"].ToString());
                    }
                    if (dt.Rows[n]["createtime"].ToString() != "")
                    {
                        model.createtime = DateTime.Parse(dt.Rows[n]["createtime"].ToString());
                    }
                    if (dt.Rows[n]["starttime"].ToString() != "")
                    {
                        model.starttime = DateTime.Parse(dt.Rows[n]["starttime"].ToString());
                    }
                    if (dt.Rows[n]["endtime"].ToString() != "")
                    {
                        model.endtime = DateTime.Parse(dt.Rows[n]["endtime"].ToString());
                    }


                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.tbScore model)
 {
     return(dal.Update(model));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(Model.tbScore model)
 {
     return(dal.Add(model));
 }
Ejemplo n.º 4
0
    private void AddStudentRecord(int arrangeid, int userid, int subjectid, int hasShortAnswer)
    {
        //查询所有要进行该考试的学生
        String strSql = "select id from tbUser where classid in (select classid from tbGrant where userid=" + userid + " and subjectid=" + subjectid + ")";
        DataTable table = DbHelperSQL.Query(strSql).Tables[0];

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

        try
        {
            for (int i = 0; i < table.Rows.Count; i++)
            {
                tbScore score = new tbScore();
                score.arrangeid = arrangeid;
                score.userid = Convert.ToInt32(table.Rows[i][0]);
                score.createtime = DateTime.Now;
                score.starttime = DateTime.Now;
                score.endtime = DateTime.Now;
                score.hasshortanswer = hasShortAnswer;
                score.hascorrect = 0;//没有批改
                score.scorestatus = 1;//还没考试
                scoreDAL.AddTran(score, SqlTransaction);
            }
            SqlTransaction.Commit();
        }
        catch (Exception)
        {
            try
            {
                SqlTransaction.Rollback();
            }
            catch (Exception)
            {
                //事务回滚出错
            }
            throw;
        }
        finally
        {
            //关闭各种资源
            SqlTransaction.Dispose();
            conn.Close();
        }
    }
Ejemplo n.º 5
0
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<Model.tbScore> DataTableToList(DataTable dt)
		{
			List<Model.tbScore> modelList = new List<Model.tbScore>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				Model.tbScore model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new Model.tbScore();					
													if(dt.Rows[n]["id"].ToString()!="")
				{
					model.id=int.Parse(dt.Rows[n]["id"].ToString());
				}
																																if(dt.Rows[n]["arrangeid"].ToString()!="")
				{
					model.arrangeid=int.Parse(dt.Rows[n]["arrangeid"].ToString());
				}
																																if(dt.Rows[n]["userid"].ToString()!="")
				{
					model.userid=int.Parse(dt.Rows[n]["userid"].ToString());
				}
																																if(dt.Rows[n]["hasshortanswer"].ToString()!="")
				{
					model.hasshortanswer=int.Parse(dt.Rows[n]["hasshortanswer"].ToString());
				}
																																if(dt.Rows[n]["hascorrect"].ToString()!="")
				{
					model.hascorrect=int.Parse(dt.Rows[n]["hascorrect"].ToString());
				}
																																if(dt.Rows[n]["score"].ToString()!="")
				{
					model.score=decimal.Parse(dt.Rows[n]["score"].ToString());
				}
																																if(dt.Rows[n]["scorestatus"].ToString()!="")
				{
					model.scorestatus=int.Parse(dt.Rows[n]["scorestatus"].ToString());
				}
																																if(dt.Rows[n]["createtime"].ToString()!="")
				{
					model.createtime=DateTime.Parse(dt.Rows[n]["createtime"].ToString());
				}
																																if(dt.Rows[n]["starttime"].ToString()!="")
				{
					model.starttime=DateTime.Parse(dt.Rows[n]["starttime"].ToString());
				}
																																if(dt.Rows[n]["endtime"].ToString()!="")
				{
					model.endtime=DateTime.Parse(dt.Rows[n]["endtime"].ToString());
				}
																										
				
					modelList.Add(model);
				}
			}
			return modelList;
		}
Ejemplo n.º 6
0
    /// <summary>
    /// 交卷
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        //比较时间大小
        int scoreid = Convert.ToInt32(ViewState[Constant.ScoreID]);
        score = scoreBLL.GetModel(scoreid);

        PaperContent studentAnswer = CollectData();
        PaperContent standardAnswer = GetStandardAnswer(studentAnswer);

        if (arrange.arrangetype == 1)
        {
            //===============练习
            ShowCorrectAnswer(studentAnswer, standardAnswer);
            MyUtil.ExecuteJS(this, "clearInterval(timer);document.getElementById('timer').style.display='none';");
        }
        if (arrange.arrangetype == 2)
        {
            //===============考试
            score.endtime = DateTime.Now;
            if (DateTime.Compare(DateTime.Now, score.starttime.AddMinutes(paper.durationtime + 5)) > 0)
            {
                //超时
                MyUtil.ExecuteJS(this, "alert('交卷失败,超过指定时间!');top.closeExam();");
                score.scorestatus = 4;
                scoreBLL.Update(score);
                return;
            }
            score.score = Convert.ToDecimal(sum);
            if (paper.sa_count > 0)
            {
                //有简答题,等待批改
                score.scorestatus = 5;
            }
            else
            {
                //记录成绩
                score.scorestatus = 3;
            }
            scoreBLL.Update(score);
            //MyUtil.ExecuteJS(this, "alert('交卷成功!');top.closeExam();");
            Response.Write("<script type='text/javascript'>alert('交卷成功!');top.closeExam();</script>");
        }
        lbtnSubmit.Visible = false;
        lbtnBack.Visible = true;
    }