/// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(kaoshiModel model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into kaoshi(");
            strSql.Append("nc_kaoshiId,nc_qid,nc_daanid,bit_isRight,nc_uid)");
            strSql.Append(" values (");
            strSql.Append("@nc_kaoshiId,@nc_qid,@nc_daanid,@bit_isRight,@nc_uid)");
            SqlParameter[] parameters = {
                    new SqlParameter("@nc_kaoshiId", SqlDbType.NChar,18),
                    new SqlParameter("@nc_qid", SqlDbType.NChar,10),
                    new SqlParameter("@nc_daanid", SqlDbType.NChar,12),
                    new SqlParameter("@bit_isRight", SqlDbType.Bit,1),
                    new SqlParameter("@nc_uid", SqlDbType.NChar,20)};
            parameters[0].Value = model.nc_kaoshiId;
            parameters[1].Value = model.nc_qid;
            parameters[2].Value = model.nc_daanid;
            parameters[3].Value = model.bit_isRight;
            parameters[4].Value = model.nc_uid;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public kaoshiModel DataRowToModel(DataRow row)
 {
     kaoshiModel model = new kaoshiModel();
     if (row != null)
     {
         if (row["nc_id"] != null)
         {
             model.nc_id = row["nc_id"].ToString();
         }
         if (row["nc_kaoshiId"] != null)
         {
             model.nc_kaoshiId = row["nc_kaoshiId"].ToString();
         }
         if (row["nc_qid"] != null)
         {
             model.nc_qid = row["nc_qid"].ToString();
         }
         if (row["nc_daanid"] != null)
         {
             model.nc_daanid = row["nc_daanid"].ToString();
         }
         if (row["bit_isRight"] != null && row["bit_isRight"].ToString() != "")
         {
             if ((row["bit_isRight"].ToString() == "1") || (row["bit_isRight"].ToString().ToLower() == "true"))
             {
                 model.bit_isRight = true;
             }
             else
             {
                 model.bit_isRight = false;
             }
         }
         if (row["nvc_chengji"] != null)
         {
             model.nvc_chengji = row["nvc_chengji"].ToString();
         }
         if (row["dt_shijian"] != null && row["dt_shijian"].ToString() != "")
         {
             model.dt_shijian = DateTime.Parse(row["dt_shijian"].ToString());
         }
         if (row["nc_uid"] != null)
         {
             model.nc_uid = row["nc_uid"].ToString();
         }
     }
     return model;
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        string uid = new SetCookie().WhetherOnline();
        if (!string.IsNullOrEmpty(uid))
        {
            int rightTimu = 0;
            #region 获取考试ID,总题数
            string kaoshiId = null;
            if (!string.IsNullOrEmpty(Request.Form["kaoshiId"]))//获取数据类型
            {
                kaoshiId = Request.Form["kaoshiId"];
            }
            int totalTimu = 0;
            if (!string.IsNullOrEmpty(Request.Form["totalTimu"]))//获取数据类型
            {
                totalTimu = int.Parse(Request.Form["totalTimu"]);
            }
            #endregion

            bool isok = false;
            for (int i = 1; i <= totalTimu; i++)
            {
                #region 获取数据
                string timuid = null;
                if (!string.IsNullOrEmpty(Request.Form["tihao" + i]))//获取数据类型
                {
                    timuid = Request.Form["tihao" + i];
                }
                string daanid = null;
                if (!string.IsNullOrEmpty(Request.Form["timudaan" + i]))//获取数据类型
                {
                    daanid = Request.Form["timudaan" + i];
                }
                bool isRight = false;
                if (!string.IsNullOrEmpty(Request.Form["isRight" + i]))//获取数据类型
                {
                    string ir = Request.Form["isRight" + i];
                    if (ir == "1")
                    {
                        isRight = true;
                        rightTimu++;
                    }
                    else
                    {
                        isRight = false;
                    }
                }
                #endregion

                #region 提交数据
                questionModel qm = new questionDAL().GetModel(timuid);
                //单选,判断
                if (qm.int_qtype == 1 || qm.int_qtype == 0)
                {
                    kaoshiModel ksm = new kaoshiModel();
                    ksm.nc_kaoshiId = kaoshiId;
                    ksm.nc_qid = timuid;
                    ksm.nc_daanid = daanid;
                    ksm.bit_isRight = isRight;
                    ksm.nc_uid = uid;
                    isok = new kaoshiDAL().Add(ksm);
                }
                //多选
                if (qm.int_qtype == 2)
                {
                    kaoshiModel ksm = new kaoshiModel();
                    ksm.nc_kaoshiId = kaoshiId;
                    ksm.nc_qid = timuid;
                    ksm.bit_isRight = isRight;
                    ksm.nc_uid = uid;
                    if (string.IsNullOrEmpty(daanid))
                    {
                        isok = new kaoshiDAL().Add(ksm);
                    }
                    else
                    {
                        daanid = daanid.Substring(0, daanid.Length - 1);
                        string[] arrayList = daanid.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (string opid in arrayList)
                        {
                            ksm.nc_daanid = opid;
                            isok = new kaoshiDAL().Add(ksm);
                        }
                    }
                }
                #endregion
            }

            #region 更改部分数据
            bool isupdatechengji = new kaoshiDAL().UpDateChengji(kaoshiId, rightTimu.ToString());
            bool isupdateShijian = new kaoshiDAL().UpDateShijian(kaoshiId);
            #endregion

            Response.Write("<script>javascript:if(window.confirm('交卷成功,考试成绩为" + rightTimu.ToString() + "分!是否重新考试?') == true){window.location.replace('kaoshi.aspx');}</script>");
        }
    }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(kaoshiModel model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update kaoshi set ");
            strSql.Append("nc_kaoshiId=@nc_kaoshiId,");
            strSql.Append("nc_qid=@nc_qid,");
            strSql.Append("nc_daanid=@nc_daanid,");
            strSql.Append("bit_isRight=@bit_isRight,");
            strSql.Append("nvc_chengji=@nvc_chengji,");
            strSql.Append("dt_shijian=@dt_shijian,");
            strSql.Append("nc_uid=@nc_uid");
            strSql.Append(" where nc_id=@nc_id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@nc_kaoshiId", SqlDbType.NChar,18),
                    new SqlParameter("@nc_qid", SqlDbType.NChar,10),
                    new SqlParameter("@nc_daanid", SqlDbType.NChar,12),
                    new SqlParameter("@bit_isRight", SqlDbType.Bit,1),
                    new SqlParameter("@nvc_chengji", SqlDbType.NVarChar,50),
                    new SqlParameter("@dt_shijian", SqlDbType.DateTime),
                    new SqlParameter("@nc_uid", SqlDbType.NChar,20),
                    new SqlParameter("@nc_id", SqlDbType.NChar,20)};
            parameters[0].Value = model.nc_kaoshiId;
            parameters[1].Value = model.nc_qid;
            parameters[2].Value = model.nc_daanid;
            parameters[3].Value = model.bit_isRight;
            parameters[4].Value = model.nvc_chengji;
            parameters[5].Value = model.dt_shijian;
            parameters[6].Value = model.nc_uid;
            parameters[7].Value = model.nc_id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public kaoshiModel GetModel(string nc_id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 nc_id,nc_kaoshiId,nc_qid,nc_daanid,bit_isRight,nvc_chengji,dt_shijian,nc_uid from kaoshi ");
            strSql.Append(" where nc_id=@nc_id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@nc_id", SqlDbType.NChar,20)			};
            parameters[0].Value = nc_id;

            kaoshiModel model = new kaoshiModel();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }