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

            strSql.Append("update wx_message_list set ");
            strSql.Append("wid=@wid,");
            //strSql.Append("userName=@userName,");
            //strSql.Append("title=@title,");
            //strSql.Append("parentId=@parentId,");
            //strSql.Append("openId=@openId,");
            // strSql.Append("createDate=@createDate,");
            //strSql.Append("sort_id=@sort_id,");
            strSql.Append("hasSH=@hasSH");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@wid",   SqlDbType.Int, 4),
                //new SqlParameter("@userName", SqlDbType.VarChar,100),
                //new SqlParameter("@title", SqlDbType.VarChar,800),
                //new SqlParameter("@parentId", SqlDbType.Int,4),
                //new SqlParameter("@openId", SqlDbType.VarChar,100),
                //new SqlParameter("@createDate", SqlDbType.DateTime),
                //new SqlParameter("@sort_id", SqlDbType.Int,4),
                new SqlParameter("@hasSH", SqlDbType.Bit, 1),
                new SqlParameter("@id",    SqlDbType.Int, 4)
            };
            parameters[0].Value = model.wid;
            //parameters[1].Value = model.userName;
            //parameters[2].Value = model.title;
            //parameters[3].Value = model.parentId;
            //parameters[4].Value = model.openId;
            //parameters[5].Value = model.createDate;
            //parameters[6].Value = model.sort_id;
            parameters[1].Value = model.hasSH;
            parameters[2].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WeiXinPF.Model.wx_message_list DataRowToModel(DataRow row)
 {
     WeiXinPF.Model.wx_message_list model = new WeiXinPF.Model.wx_message_list();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["wid"] != null && row["wid"].ToString() != "")
         {
             model.wid = int.Parse(row["wid"].ToString());
         }
         if (row["userName"] != null)
         {
             model.userName = row["userName"].ToString();
         }
         if (row["title"] != null)
         {
             model.title = row["title"].ToString();
         }
         if (row["parentId"] != null && row["parentId"].ToString() != "")
         {
             model.parentId = int.Parse(row["parentId"].ToString());
         }
         if (row["openId"] != null)
         {
             model.openId = row["openId"].ToString();
         }
         if (row["createDate"] != null && row["createDate"].ToString() != "")
         {
             model.createDate = DateTime.Parse(row["createDate"].ToString());
         }
         if (row["sort_id"] != null && row["sort_id"].ToString() != "")
         {
             model.sort_id = int.Parse(row["sort_id"].ToString());
         }
     }
     return(model);
 }
コード例 #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WeiXinPF.Model.wx_message_list model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into wx_message_list(");
            strSql.Append("wid,userName,title,parentId,openId,createDate,sort_id,hasSH)");
            strSql.Append(" values (");
            strSql.Append("@wid,@userName,@title,@parentId,@openId,@createDate,@sort_id,@hasSH)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@wid",        SqlDbType.Int,         4),
                new SqlParameter("@userName",   SqlDbType.VarChar,   100),
                new SqlParameter("@title",      SqlDbType.VarChar,   800),
                new SqlParameter("@parentId",   SqlDbType.Int,         4),
                new SqlParameter("@openId",     SqlDbType.VarChar,   100),
                new SqlParameter("@createDate", SqlDbType.DateTime),
                new SqlParameter("@sort_id",    SqlDbType.Int,         4),
                new SqlParameter("@hasSH",      SqlDbType.Bit, 1)
            };
            parameters[0].Value = model.wid;
            parameters[1].Value = model.userName;
            parameters[2].Value = model.title;
            parameters[3].Value = model.parentId;
            parameters[4].Value = model.openId;
            parameters[5].Value = model.createDate;
            parameters[6].Value = model.sort_id;
            parameters[7].Value = model.hasSH;

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

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

            strSql.Append("select  top 1 id,wid,userName,title,parentId,openId,createDate,sort_id,hasSH  from wx_message_list ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

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