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

            strSql.Append("update Question set ");
            strSql.Append("categoryID=@categoryID,");
            strSql.Append("question=@question,");
            strSql.Append("solution=@solution,");
            strSql.Append("time=@time");
            strSql.Append(" where questionID=@questionID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@categoryID", SqlDbType.Int,              4),
                new SqlParameter("@question",   SqlDbType.VarChar,        128),
                new SqlParameter("@solution",   SqlDbType.VarChar,        128),
                new SqlParameter("@time",       SqlDbType.SmallDateTime),
                new SqlParameter("@questionID", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.categoryID;
            parameters[1].Value = model.question;
            parameters[2].Value = model.solution;
            parameters[3].Value = model.time;
            parameters[4].Value = model.questionID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool  Add(UserFB.Model.Question model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Question(");
            strSql.Append("categoryID,question,solution,time)");
            strSql.Append(" values (");
            strSql.Append("@categoryID,@question,@solution,@time)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@categoryID", SqlDbType.Int,       4),
                new SqlParameter("@question",   SqlDbType.VarChar, 128),
                new SqlParameter("@solution",   SqlDbType.VarChar, 128),
                new SqlParameter("@time",       SqlDbType.SmallDateTime)
            };
            parameters[0].Value = model.categoryID;
            parameters[1].Value = model.question;
            parameters[2].Value = model.solution;
            parameters[3].Value = model.time;

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

            if (obj == null)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public UserFB.Model.Question DataRowToModel(DataRow row)
 {
     UserFB.Model.Question model = new UserFB.Model.Question();
     if (row != null)
     {
         if (row["questionID"] != null && row["questionID"].ToString() != "")
         {
             model.questionID = int.Parse(row["questionID"].ToString());
         }
         if (row["categoryID"] != null && row["categoryID"].ToString() != "")
         {
             model.categoryID = int.Parse(row["categoryID"].ToString());
         }
         if (row["question"] != null)
         {
             model.question = row["question"].ToString();
         }
         if (row["solution"] != null)
         {
             model.solution = row["solution"].ToString();
         }
         if (row["time"] != null && row["time"].ToString() != "")
         {
             model.time = DateTime.Parse(row["time"].ToString());
         }
     }
     return(model);
 }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public UserFB.Model.Question GetModel(int questionID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 questionID,categoryID,question,solution,time from Question ");
            strSql.Append(" where questionID=@questionID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@questionID", SqlDbType.Int, 4)
            };
            parameters[0].Value = questionID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(UserFB.Model.Question model)
 {
     return(dal.Update(model));
 }
Exemplo n.º 6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool  Add(UserFB.Model.Question model)
 {
     return(dal.Add(model));
 }