Ejemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(OnLineTest.Model.VerifyStatus model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update VerifyStatus set ");
            strSql.Append("QuestionId=@QuestionId,");

            strSql.Append("UserId=@UserId,");

            strSql.Append("VerifyTimes=@VerifyTimes,");
            strSql.Append("IsPass=@IsPass,");

            strSql.Append("VerifyTime=@VerifyTime,");

            strSql.Append(" where VerifyStatusId=@VerifyStatusId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@QuestionId",  SqlDbType.Int),
                new SqlParameter("@UserId",      SqlDbType.Int),
                new SqlParameter("@VerifyTimes", SqlDbType.Int),
                new SqlParameter("@IsPass",      SqlDbType.Bit),
                new SqlParameter("@VerifyTime",  SqlDbType.DateTime),
            };
            parameters[0].Value = model.QuestionId;

            parameters[1].Value = model.UserId;

            parameters[2].Value = model.VerifyTimes;
            parameters[3].Value = model.IsPass;

            parameters[4].Value = model.VerifyTime;

            parameters[5].Value = model.VerifyStatusId;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public OnLineTest.Model.VerifyStatus DataRowToModel(DataRow row)
        {
            OnLineTest.Model.VerifyStatus model = new OnLineTest.Model.VerifyStatus();
            if (row != null)
            {
                if (row["VerifyStatusId"] != null && row["VerifyStatusId"].ToString() != "")
                {
                    model.VerifyStatusId = int.Parse(row["VerifyStatusId"].ToString());
                }
                if (row["QuestionId"] != null && row["QuestionId"].ToString() != "")
                {
                    model.QuestionId = int.Parse(row["QuestionId"].ToString());
                }

                if (row["UserId"] != null && row["UserId"].ToString() != "")
                {
                    model.UserId = int.Parse(row["UserId"].ToString());
                }

                if (row["VerifyTimes"] != null && row["VerifyTimes"].ToString() != "")
                {
                    model.VerifyTimes = int.Parse(row["VerifyTimes"].ToString());
                }
                if (row["IsPass"] != null && row["IsPass"].ToString() != "")
                {
                    if ((row["IsPass"].ToString() == "1") || (row["IsPass"].ToString().ToLower() == "true"))
                    {
                        model.IsPass = true;
                    }
                    else
                    {
                        model.IsPass = false;
                    }
                }

                if (row["VerifyTime"] != null && row["VerifyTime"].ToString() != "")
                {
                    model.VerifyTime = DateTime.Parse(row["VerifyTime"].ToString());
                }
            }
            return(model);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(OnLineTest.Model.VerifyStatus model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into VerifyStatus(");
            strSql.Append("QuestionId,UserId,VerifyTimes,IsPass,VerifyTime)");
            strSql.Append(" values (");
            strSql.Append("@QuestionId,@UserId,@VerifyTimes,@IsPass,@VerifyTime)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@QuestionId",  SqlDbType.Int,       4),
                new SqlParameter("@UserId",      SqlDbType.Int,       4),

                new SqlParameter("@VerifyTimes", SqlDbType.Int,       4),
                new SqlParameter("@IsPass",      SqlDbType.Bit,       1),
                new SqlParameter("@PassTime",    SqlDbType.DateTime),
                new SqlParameter("@VerifyTime",  SqlDbType.DateTime)
            };
            parameters[0].Value = model.QuestionId;

            parameters[1].Value = model.UserId;

            parameters[2].Value = model.VerifyTimes;
            parameters[3].Value = model.IsPass;

            parameters[4].Value = model.VerifyTime;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public OnLineTest.Model.VerifyStatus GetModel(int VerifyStatusId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 VerifyStatusId,QuestionId,UserId,VerifyTimes,IsPass,VerifyTime from VerifyStatus ");
            strSql.Append(" where VerifyStatusId=@VerifyStatusId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@VerifyStatusId", SqlDbType.Int, 4)
            };
            parameters[0].Value = VerifyStatusId;

            OnLineTest.Model.VerifyStatus model = new OnLineTest.Model.VerifyStatus();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }