Esempio n. 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WechatBuilder.Model.wx_albums_sys model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into wx_albums_sys(");
            strSql.Append("wid,bannerPic,code,typeId,typeName)");
            strSql.Append(" values (");
            strSql.Append("@wid,@bannerPic,@code,@typeId,@typeName)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@wid",       SqlDbType.Int,        4),
                new SqlParameter("@bannerPic", SqlDbType.VarChar, 1000),
                new SqlParameter("@code",      SqlDbType.VarChar,  500),
                new SqlParameter("@typeId",    SqlDbType.Int,        4),
                new SqlParameter("@typeName",  SqlDbType.VarChar, 500)
            };
            parameters[0].Value = model.wid;
            parameters[1].Value = model.bannerPic;
            parameters[2].Value = model.code;
            parameters[3].Value = model.typeId;
            parameters[4].Value = model.typeName;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WechatBuilder.Model.wx_albums_sys DataRowToModel(DataRow row)
 {
     WechatBuilder.Model.wx_albums_sys model = new WechatBuilder.Model.wx_albums_sys();
     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["bannerPic"] != null)
         {
             model.bannerPic = row["bannerPic"].ToString();
         }
         if (row["code"] != null)
         {
             model.code = row["code"].ToString();
         }
         if (row["typeId"] != null && row["typeId"].ToString() != "")
         {
             model.typeId = int.Parse(row["typeId"].ToString());
         }
         if (row["typeName"] != null)
         {
             model.typeName = row["typeName"].ToString();
         }
     }
     return(model);
 }
Esempio n. 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WechatBuilder.Model.wx_albums_sys model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update wx_albums_sys set ");
            strSql.Append("wid=@wid,");
            strSql.Append("bannerPic=@bannerPic,");
            strSql.Append("code=@code,");
            strSql.Append("typeId=@typeId,");
            strSql.Append("typeName=@typeName");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@wid",       SqlDbType.Int,        4),
                new SqlParameter("@bannerPic", SqlDbType.VarChar, 1000),
                new SqlParameter("@code",      SqlDbType.VarChar,  500),
                new SqlParameter("@typeId",    SqlDbType.Int,        4),
                new SqlParameter("@typeName",  SqlDbType.VarChar,  500),
                new SqlParameter("@id",        SqlDbType.Int, 4)
            };
            parameters[0].Value = model.wid;
            parameters[1].Value = model.bannerPic;
            parameters[2].Value = model.code;
            parameters[3].Value = model.typeId;
            parameters[4].Value = model.typeName;
            parameters[5].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 4
0
        /*
         * /// <summary>
         * /// 分页获取数据列表
         * /// </summary>
         * public DataSet GetList(int PageSize,int PageIndex,string strWhere)
         * {
         *      SqlParameter[] parameters = {
         *                      new SqlParameter("@tblName", SqlDbType.VarChar, 255),
         *                      new SqlParameter("@fldName", SqlDbType.VarChar, 255),
         *                      new SqlParameter("@PageSize", SqlDbType.Int),
         *                      new SqlParameter("@PageIndex", SqlDbType.Int),
         *                      new SqlParameter("@IsReCount", SqlDbType.Bit),
         *                      new SqlParameter("@OrderType", SqlDbType.Bit),
         *                      new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
         *                      };
         *      parameters[0].Value = "wx_albums_sys";
         *      parameters[1].Value = "id";
         *      parameters[2].Value = PageSize;
         *      parameters[3].Value = PageIndex;
         *      parameters[4].Value = 0;
         *      parameters[5].Value = 0;
         *      parameters[6].Value = strWhere;
         *      return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
         * }*/

        #endregion  BasicMethod
        #region  ExtensionMethod



        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WechatBuilder.Model.wx_albums_sys GetModelByWid(int wid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,wid,bannerPic,code,typeId,typeName from wx_albums_sys ");
            strSql.Append(" where wid=@wid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@wid", SqlDbType.Int, 4)
            };
            parameters[0].Value = wid;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 5
0
		/*
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		{
			SqlParameter[] parameters = {
					new SqlParameter("@tblName", SqlDbType.VarChar, 255),
					new SqlParameter("@fldName", SqlDbType.VarChar, 255),
					new SqlParameter("@PageSize", SqlDbType.Int),
					new SqlParameter("@PageIndex", SqlDbType.Int),
					new SqlParameter("@IsReCount", SqlDbType.Bit),
					new SqlParameter("@OrderType", SqlDbType.Bit),
					new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
					};
			parameters[0].Value = "wx_albums_sys";
			parameters[1].Value = "id";
			parameters[2].Value = PageSize;
			parameters[3].Value = PageIndex;
			parameters[4].Value = 0;
			parameters[5].Value = 0;
			parameters[6].Value = strWhere;	
			return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
		}*/

		#endregion  BasicMethod
		#region  ExtensionMethod



        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WechatBuilder.Model.wx_albums_sys GetModelByWid(int wid)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 id,wid,bannerPic,code,typeId,typeName from wx_albums_sys ");
            strSql.Append(" where wid=@wid");
            SqlParameter[] parameters = {
					new SqlParameter("@wid", SqlDbType.Int,4)
			};
            parameters[0].Value = wid;

            WechatBuilder.Model.wx_albums_sys model = new WechatBuilder.Model.wx_albums_sys();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }
Esempio n. 6
0
		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public WechatBuilder.Model.wx_albums_sys DataRowToModel(DataRow row)
		{
			WechatBuilder.Model.wx_albums_sys model=new WechatBuilder.Model.wx_albums_sys();
			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["bannerPic"]!=null)
				{
					model.bannerPic=row["bannerPic"].ToString();
				}
				if(row["code"]!=null)
				{
					model.code=row["code"].ToString();
				}
				if(row["typeId"]!=null && row["typeId"].ToString()!="")
				{
					model.typeId=int.Parse(row["typeId"].ToString());
				}
				if(row["typeName"]!=null)
				{
					model.typeName=row["typeName"].ToString();
				}
			}
			return model;
		}