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

            strSql.Append("update wx_vote_item set ");
            strSql.Append("title=@title,");
            strSql.Append("sort_id=@sort_id,");
            strSql.Append("pic_url=@pic_url,");
            strSql.Append("pic_jump=@pic_jump,");
            strSql.Append("sid=@sid,");
            strSql.Append("createDate=@createDate,");
            strSql.Append("baseid=@baseid,");
            strSql.Append("tpTimes=@tpTimes");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@title",      SqlDbType.VarChar,   500),
                new SqlParameter("@sort_id",    SqlDbType.Int,         4),
                new SqlParameter("@pic_url",    SqlDbType.VarChar,   500),
                new SqlParameter("@pic_jump",   SqlDbType.VarChar,   500),
                new SqlParameter("@sid",        SqlDbType.Int,         4),
                new SqlParameter("@createDate", SqlDbType.DateTime),
                new SqlParameter("@baseid",     SqlDbType.Int,         4),
                new SqlParameter("@tpTimes",    SqlDbType.Int,         4),
                new SqlParameter("@id",         SqlDbType.Int, 4)
            };
            parameters[0].Value = model.title;
            parameters[1].Value = model.sort_id;
            parameters[2].Value = model.pic_url;
            parameters[3].Value = model.pic_jump;
            parameters[4].Value = model.sid;
            parameters[5].Value = model.createDate;
            parameters[6].Value = model.baseid;
            parameters[7].Value = model.tpTimes;
            parameters[8].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WeiXinPF.Model.wx_vote_item DataRowToModel(DataRow row)
 {
     WeiXinPF.Model.wx_vote_item model = new WeiXinPF.Model.wx_vote_item();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["title"] != null)
         {
             model.title = row["title"].ToString();
         }
         if (row["sort_id"] != null && row["sort_id"].ToString() != "")
         {
             model.sort_id = int.Parse(row["sort_id"].ToString());
         }
         if (row["pic_url"] != null)
         {
             model.pic_url = row["pic_url"].ToString();
         }
         if (row["pic_jump"] != null)
         {
             model.pic_jump = row["pic_jump"].ToString();
         }
         if (row["sid"] != null && row["sid"].ToString() != "")
         {
             model.sid = int.Parse(row["sid"].ToString());
         }
         if (row["createDate"] != null && row["createDate"].ToString() != "")
         {
             model.createDate = DateTime.Parse(row["createDate"].ToString());
         }
         if (row["baseid"] != null && row["baseid"].ToString() != "")
         {
             model.baseid = int.Parse(row["baseid"].ToString());
         }
         if (row["tpTimes"] != null && row["tpTimes"].ToString() != "")
         {
             model.tpTimes = int.Parse(row["tpTimes"].ToString());
         }
     }
     return(model);
 }
Beispiel #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WeiXinPF.Model.wx_vote_item model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into wx_vote_item(");
            strSql.Append("title,sort_id,pic_url,pic_jump,sid,createDate,baseid,tpTimes)");
            strSql.Append(" values (");
            strSql.Append("@title,@sort_id,@pic_url,@pic_jump,@sid,@createDate,@baseid,@tpTimes)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@title",      SqlDbType.VarChar,   500),
                new SqlParameter("@sort_id",    SqlDbType.Int,         4),
                new SqlParameter("@pic_url",    SqlDbType.VarChar,   500),
                new SqlParameter("@pic_jump",   SqlDbType.VarChar,   500),
                new SqlParameter("@sid",        SqlDbType.Int,         4),
                new SqlParameter("@createDate", SqlDbType.DateTime),
                new SqlParameter("@baseid",     SqlDbType.Int,         4),
                new SqlParameter("@tpTimes",    SqlDbType.Int, 4)
            };
            parameters[0].Value = model.title;
            parameters[1].Value = model.sort_id;
            parameters[2].Value = model.pic_url;
            parameters[3].Value = model.pic_jump;
            parameters[4].Value = model.sid;
            parameters[5].Value = model.createDate;
            parameters[6].Value = model.baseid;
            parameters[7].Value = model.tpTimes;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WeiXinPF.Model.wx_vote_item GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,title,sort_id,pic_url,pic_jump,sid,createDate,baseid,tpTimes  from wx_vote_item ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

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