コード例 #1
0
ファイル: CategoryBase.cs プロジェクト: locbet/stevenfolder
        public bool Insert(CategoryInfo categoryInfo)
        {
            StringBuilder sql=new StringBuilder();
            sql.Append("INSERT INTO");
            sql.Append(" [Tbl_Category](");
            sql.Append("[CateName],");
            sql.Append("[ParentID],");
            sql.Append("[LevelID],");
            sql.Append("[OrderID],");
            sql.Append("[FullPath],");
            sql.Append("[PageUrl]");
            sql.Append(") VALUES(");
            sql.Append("@CateName,");
            sql.Append("@ParentID,");
            sql.Append("@LevelID,");
            sql.Append("@OrderID,");
            sql.Append("@FullPath,");
            sql.Append("@PageUrl");
            sql.Append(");SELECT @@IDENTITY;");

            using(NetShopHelper dbhelper=new NetShopHelper())
            {
                IDbDataParameter[] p_Parms=new IDbDataParameter[]{
                    dbhelper.CreateParameter("@CateName",categoryInfo.CateName),
                    dbhelper.CreateParameter("@ParentID",categoryInfo.ParentID),
                    dbhelper.CreateParameter("@LevelID",categoryInfo.LevelID),
                    dbhelper.CreateParameter("@OrderID",categoryInfo.OrderID),
                    dbhelper.CreateParameter("@FullPath",categoryInfo.FullPath),
                    dbhelper.CreateParameter("@PageUrl",categoryInfo.PageUrl)
                };
            int ret=(int)dbhelper.ExecuteScalar(sql.ToString(),p_Parms);
            categoryInfo.Id=ret;
            return true;
            }
        }
コード例 #2
0
ファイル: CategoryBase.cs プロジェクト: locbet/stevenfolder
 public bool Update(CategoryInfo categoryInfo)
 {
     StringBuilder sql = new StringBuilder();
     sql.Append("UPDATE");
     sql.Append(" [Tbl_Category]");
     sql.Append(" SET");
     sql.Append(" [CateName]=@CateName,");
     sql.Append(" [ParentID]=@ParentID,");
     sql.Append(" [LevelID]=@LevelID,");
     sql.Append(" [OrderID]=@OrderID,");
     sql.Append(" [FullPath]=@FullPath,");
     sql.Append(" [PageUrl]=@PageUrl");
     sql.Append(" WHERE");
     sql.Append(" [ID]=@ID");
     using(NetShopHelper dbhelper=new NetShopHelper())
     {
       IDbDataParameter[] p_Parms = new IDbDataParameter[]{
         dbhelper.CreateParameter("@ID",categoryInfo.Id)
       };
      return 0 < dbhelper.ExecuteNonQuery(sql.ToString(),p_Parms);
     }
 }
コード例 #3
0
ファイル: CategoryInfo.cs プロジェクト: locbet/stevenfolder
        /// <summary>
        /// Convert IDataReader To CategoryInfo
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public static CategoryInfo SetValue(IDataReader reader)
        {
            CategoryInfo info = new CategoryInfo();

            int idIndex = reader.GetOrdinal("ID");
            int cateNameIndex = reader.GetOrdinal("CateName");
            int parentIDIndex = reader.GetOrdinal("ParentID");
            int levelIDIndex = reader.GetOrdinal("LevelID");
            int orderIDIndex = reader.GetOrdinal("OrderID");
            int fullPathIndex = reader.GetOrdinal("FullPath");
            int pageUrlIndex = reader.GetOrdinal("PageUrl");

            info.Id = reader.GetInt32(idIndex);
            info.CateName = reader.GetString(cateNameIndex);
            info.ParentID = reader.GetInt32(parentIDIndex);
            info.LevelID = reader.GetInt32(levelIDIndex);
            info.OrderID = reader.GetInt32(orderIDIndex);
            info.FullPath = reader.GetString(fullPathIndex);
            if(!reader.IsDBNull(pageUrlIndex))
            info.PageUrl = reader.GetString(pageUrlIndex);

            return info;
        }