예제 #1
0
        public int Insert(KaoShi kaoshi)
        {
            string sql = "insert into KaoShi values(@PageID,@UserID)";

            SqlParameter[] sp = new SqlParameter[]
            {
                new SqlParameter("@PageID", kaoshi.PageID),
                new SqlParameter("@UserID", kaoshi.UserID)
            };
            return(DBHelper.GetExcuteNonQuery(sql, sp));
        }
예제 #2
0
        //分页
        public KaoShi NewsZXfenye(int page, int size)
        {
            SqlParameter sqlParameter = new SqlParameter("@count", System.Data.SqlDbType.Int)
            {
                Direction = System.Data.ParameterDirection.Output
            };
            KaoShi kao = new KaoShi();

            SqlParameter[] sqlParameters = new SqlParameter[]
            {
                new SqlParameter("@page", page),
                new SqlParameter("@size", size),
                sqlParameter
            };
            var       dt  = DBHelper.ExecuteQuery("NnewZYfenye", sqlParameters, System.Data.CommandType.StoredProcedure);
            string    str = JsonConvert.SerializeObject(dt);
            List <KS> z   = JsonConvert.DeserializeObject <List <KS> >(str);

            kao.ks      = z;
            kao.KScount = Convert.ToInt32(sqlParameter.Value);
            return(kao);
        }
예제 #3
0
        protected void Button1_ServerClick1(object sender, EventArgs e)
        {
            //获取考卷ID
            int KaoJuanId  = int.Parse(Request.QueryString["id"].ToString());
            int sum        = 0;                                                                //初始化对的信息 默认为0个
            int Score      = 0;                                                                //初始化分数的信息 默认为0分
            int singlemark = int.Parse(((Label)GridView1.Rows[0].FindControl("Label4")).Text); //每一道单选题的分数

            foreach (GridViewRow dr in GridView1.Rows)

            //遍历每一行的数据
            {
                string str = "";
                if (((RadioButton)dr.FindControl("RadioButton1")).Checked)
                {
                    str = "A";
                }
                else if (((RadioButton)dr.FindControl("RadioButton2")).Checked)
                {
                    str = "B";
                }
                else if (((RadioButton)dr.FindControl("RadioButton3")).Checked)
                {
                    str = "C";
                }
                else if (((RadioButton)dr.FindControl("RadioButton4")).Checked)
                {
                    str = "D";
                }
                //逐个 判断 某一个单选框是否选中 即  选择的答案 ABCD  哪一个
                if (((Label)dr.FindControl("Label3")).Text.Trim() == str)
                //用户选择的答案 和正确答案 对比
                {
                    sum   = sum + 1;
                    Score = Score + singlemark;
                    //分数 增加
                    string   title = ((Label)dr.FindControl("Label2")).Text.Trim();
                    int      fid   = int.Parse(((Label)dr.FindControl("Label111")).Text.Trim());
                    UserPage up    = new UserPage();
                    up.Fid       = fid;
                    up.Title     = title;
                    up.UserID    = int.Parse(Session["UserID"].ToString());
                    up.KaoJuanID = KaoJuanId;
                    up.UserAns   = str;
                    UserPageService.Insert(up);
                    //将信息再插入到 用户试卷题目表里
                }
                else
                {
                    string   title = ((Label)dr.FindControl("Label2")).Text.Trim();
                    int      fid   = int.Parse(((Label)dr.FindControl("Label111")).Text.Trim());
                    UserPage up    = new UserPage();
                    up.Fid       = fid;
                    up.Title     = title;
                    up.UserID    = int.Parse(Session["UserID"].ToString());
                    up.KaoJuanID = KaoJuanId;
                    up.UserAns   = str;
                    UserPageService.Insert(up);
                    Mistakes Mt = new Mistakes();
                    Mt.UserID  = int.Parse(Session["UserID"].ToString());
                    Mt.ObID    = fid;
                    Mt.MisTime = DateTime.Now;
                    MistakesService.Insert(Mt);
                    //将信息再插入到 用户试卷题目表和错题表里
                }
                int id = int.Parse(Request.QueryString["id"].ToString());
                Session["KaoshiID"] = id;
                string UserName = Session["UserName"].ToString();
                //插入到 分数表 和 学生考试表
                Score sc = new Score();
                sc.UserID    = int.Parse(Session["UserID"].ToString());
                sc.KaoJuanID = id;
                sc.Scores    = Score;
                sc.UserName  = UserName;
                sc.Sum       = sum;
                int    j  = ScoreService.Insert(sc);
                KaoShi ks = new KaoShi();
                ks.PageID = id;
                ks.UserID = int.Parse(Session["UserID"].ToString());
                int i = KaoShiService.Insert(ks);
                if (i >= 1 && j >= 1)
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "true", "<script>alert('答题成功!查看成绩!!');location='ExamResult.aspx'</script>");
                }
            }
        }
예제 #4
0
 public static int Insert(KaoShi kaoshi)
 {
     return(ikaoshi.Insert(kaoshi));
 }