Example #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Shop.Model.Question model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update t_question set ");
            strSql.Append("qquestion=@qquestion");
            strSql.Append(" where qid=@qid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@qquestion", SqlDbType.VarChar, 30),
                new SqlParameter("@qid",       SqlDbType.Int, 4)
            };
            parameters[0].Value = model.qquestion;
            parameters[1].Value = model.qid;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Shop.Model.Question model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into t_question(");
            strSql.Append("qquestion)");
            strSql.Append(" values (");
            strSql.Append("@qquestion)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@qquestion", SqlDbType.VarChar, 30)
            };
            parameters[0].Value = model.qquestion;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Example #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Shop.Model.Question DataRowToModel(DataRow row)
 {
     Shop.Model.Question model = new Shop.Model.Question();
     if (row != null)
     {
         if (row["qid"] != null && row["qid"].ToString() != "")
         {
             model.qid = int.Parse(row["qid"].ToString());
         }
         if (row["qquestion"] != null)
         {
             model.qquestion = row["qquestion"].ToString();
         }
     }
     return(model);
 }
Example #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Shop.Model.Question GetModel(int qid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 qid,qquestion from t_question ");
            strSql.Append(" where qid=@qid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@qid", SqlDbType.Int, 4)
            };
            parameters[0].Value = qid;

            Shop.Model.Question model = new Shop.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);
            }
        }