public static List<CategoryInfo> GetCategoryListEntity(IDataReader reader) { List<CategoryInfo> categorylist = new List<CategoryInfo>(); while (reader.Read()) { CategoryInfo cinfo = new CategoryInfo(); cinfo.Cid = TypeConverter.ObjectToInt(reader["cid"], 0); cinfo.Name = reader["name"].ToString(); cinfo.Parentid = TypeConverter.ObjectToInt(reader["parentid"].ToString(), 0); cinfo.Parentlist = reader["parentlist"].ToString(); cinfo.Cg_img = reader["cg_img"].ToString(); cinfo.Sort = TypeConverter.ObjectToInt(reader["sort"].ToString(), 0); cinfo.Cg_prefix = reader["cg_prefix"].ToString(); cinfo.Cg_status = TypeConverter.ObjectToInt(reader["cg_status"].ToString(), 0); cinfo.Displayorder = TypeConverter.ObjectToInt(reader["displayorder"].ToString(), 0); cinfo.Haschild = reader["haschild"].ToString() == "True" ? 1 : 0; cinfo.Cg_relatetype = reader["cg_relatetype"].ToString(); cinfo.Cg_relateclass = reader["cg_relateclass"].ToString(); cinfo.Cg_relatebrand = reader["cg_relatebrand"].ToString(); cinfo.Cg_desc = reader["cg_desc"].ToString(); cinfo.Cg_keyword = reader["cg_keyword"].ToString(); cinfo.Goodcount = TypeConverter.ObjectToInt(reader["goodcount"].ToString(), 0); categorylist.Add(cinfo); } reader.Close(); return categorylist; }
private void AddCategoryInfo_Click(object sender, EventArgs e) { CategoryInfo cinfo = new CategoryInfo(); cinfo.Name = Utils.RemoveHtml(cname.Text.Trim()); cinfo.Displayorder = TypeConverter.ObjectToInt(displayorder.Text, 0); cinfo.Cg_status = TypeConverter.ObjectToInt(available.SelectedValue, 0); cinfo.Parentid = parentid; cinfo.Cg_relateclass = SASRequest.GetString("TargetFID"); cinfo.Parentlist = "0"; cinfo.Goodcount = 0; cinfo.Sort = 0; cinfo.Haschild = 0; if (parentid > 0) { CategoryInfo parentinfo = tbp.GetCategoryInfo(parentid); if (parentinfo == null) { base.RegisterStartupScript("", "<script>alert('上级类别异常,请与管理员联系!');window.location.href='taobao_categorygrid.aspx';</script>"); return; } cinfo.Sort = parentinfo.Sort + 1; if (parentinfo.Parentlist.Trim() == "0") { cinfo.Parentlist = parentinfo.Cid.ToString(); } else { cinfo.Parentlist = parentinfo.Parentlist + "," + parentinfo.Cid; } if (tbp.CreateCategoryInfo(cinfo) > 0) { parentinfo.Haschild = 1; tbp.UpdateCategoryInfo(parentinfo); SAS.Cache.SASCache.GetCacheService().RemoveObject("/SAS/CategoryList"); base.RegisterStartupScript("PAGE", "window.location.href='taobao_categorygrid.aspx';"); } else { base.RegisterStartupScript("pagetemplate", "父类更新失败!"); return; } } else { if (tbp.CreateCategoryInfo(cinfo) > 0) { SAS.Cache.SASCache.GetCacheService().RemoveObject("/SAS/CategoryList"); base.RegisterStartupScript("PAGE", "window.location.href='taobao_categorygrid.aspx';"); } else { base.RegisterStartupScript("pagetemplate", "类别添加失败!"); return; } } }
/// <summary> /// 创建商品类别 /// </summary> public int CreateCategoryInfo(CategoryInfo cinfo) { DbParameter[] parms = { DbHelper.MakeInParam("@name", (DbType)SqlDbType.NVarChar,50, cinfo.Name), DbHelper.MakeInParam("@parentid", (DbType)SqlDbType.Int,4, cinfo.Parentid), DbHelper.MakeInParam("@parentlist", (DbType)SqlDbType.NVarChar,50, cinfo.Parentlist), DbHelper.MakeInParam("@cg_img", (DbType)SqlDbType.VarChar,50, cinfo.Cg_img), DbHelper.MakeInParam("@sort", (DbType)SqlDbType.Int,4, cinfo.Sort), DbHelper.MakeInParam("@cg_prefix", (DbType)SqlDbType.VarChar,50, cinfo.Cg_prefix), DbHelper.MakeInParam("@cg_status", (DbType)SqlDbType.Int,4, cinfo.Cg_status), DbHelper.MakeInParam("@displayorder", (DbType)SqlDbType.Int,4, cinfo.Displayorder), DbHelper.MakeInParam("@haschild", (DbType)SqlDbType.Bit,1, cinfo.Haschild), DbHelper.MakeInParam("@cg_relatetype", (DbType)SqlDbType.Text,0, cinfo.Cg_relatetype), DbHelper.MakeInParam("@cg_relateclass", (DbType)SqlDbType.Text,0, cinfo.Cg_relateclass), DbHelper.MakeInParam("@cg_relatebrand", (DbType)SqlDbType.Text,0, cinfo.Cg_relatebrand), DbHelper.MakeInParam("@cg_desc", (DbType)SqlDbType.Text,0, cinfo.Cg_desc), DbHelper.MakeInParam("@cg_keyword", (DbType)SqlDbType.VarChar,200, cinfo.Cg_keyword), DbHelper.MakeInParam("@goodcount", (DbType)SqlDbType.Int,4, cinfo.Goodcount) }; string commandText = String.Format("INSERT INTO [{0}category] ([name],[parentid],[parentlist],[cg_img],[sort],[cg_prefix],[cg_status],[displayorder],[haschild],[cg_relatetype],[cg_relateclass],[cg_relatebrand],[cg_desc],[cg_keyword],[goodcount]) VALUES (@name,@parentid,@parentlist,@cg_img,@sort,@cg_prefix,@cg_status,@displayorder,@haschild,@cg_relatetype,@cg_relateclass,@cg_relatebrand,@cg_desc,@cg_keyword,@goodcount);SELECT SCOPE_IDENTITY() AS cid", BaseConfigs.GetTablePrefix); return TypeConverter.ObjectToInt(DbHelper.ExecuteScalar(CommandType.Text, commandText, parms), -1); }
/// <summary> /// 修改商品类别 /// </summary> public void UpdateCategoryInfo(CategoryInfo cinfo) { DbParameter[] parms = { DbHelper.MakeInParam("@cid",(DbType)SqlDbType.Int,4,cinfo.Cid), DbHelper.MakeInParam("@name", (DbType)SqlDbType.NVarChar,50, cinfo.Name), DbHelper.MakeInParam("@parentid", (DbType)SqlDbType.Int,4, cinfo.Parentid), DbHelper.MakeInParam("@parentlist", (DbType)SqlDbType.NVarChar,50, cinfo.Parentlist), DbHelper.MakeInParam("@cg_img", (DbType)SqlDbType.VarChar,50, cinfo.Cg_img), DbHelper.MakeInParam("@sort", (DbType)SqlDbType.Int,4, cinfo.Sort), DbHelper.MakeInParam("@cg_prefix", (DbType)SqlDbType.VarChar,50, cinfo.Cg_prefix), DbHelper.MakeInParam("@cg_status", (DbType)SqlDbType.Int,4, cinfo.Cg_status), DbHelper.MakeInParam("@displayorder", (DbType)SqlDbType.Int,4, cinfo.Displayorder), DbHelper.MakeInParam("@haschild", (DbType)SqlDbType.Bit,1, cinfo.Haschild), DbHelper.MakeInParam("@cg_relatetype", (DbType)SqlDbType.Text,0, cinfo.Cg_relatetype), DbHelper.MakeInParam("@cg_relateclass", (DbType)SqlDbType.Text,0, cinfo.Cg_relateclass), DbHelper.MakeInParam("@cg_relatebrand", (DbType)SqlDbType.Text,0, cinfo.Cg_relatebrand), DbHelper.MakeInParam("@cg_desc", (DbType)SqlDbType.Text,0, cinfo.Cg_desc), DbHelper.MakeInParam("@cg_keyword", (DbType)SqlDbType.VarChar,200, cinfo.Cg_keyword), DbHelper.MakeInParam("@goodcount", (DbType)SqlDbType.Int,4, cinfo.Goodcount) }; string commandText = String.Format("Update [{0}category] SET [name] = @name,[parentid] = @parentid,[parentlist] = @parentlist,[cg_img] = @cg_img,[sort] = @sort,[cg_prefix] = @cg_prefix,[cg_status] = @cg_status,[displayorder] = @displayorder,[haschild] = @haschild,[cg_relatetype] = @cg_relatetype,[cg_relateclass] = @cg_relateclass,[cg_relatebrand] = @cg_relatebrand,[cg_desc] = @cg_desc,[cg_keyword] = @cg_keyword,[goodcount] = @goodcount WHERE [cid]=@cid ", BaseConfigs.GetTablePrefix); DbHelper.ExecuteNonQuery(CommandType.Text, commandText, parms); }
private void MoveSubCategory(CategoryInfo parentgc, DataTable dt) { DataRow[] datarow = dt.Select("parentid=" + parentgc.Cid.ToString()); if (datarow.Length == 0) return; foreach (DataRow dr in datarow) { CategoryInfo gc = tpb.GetCategoryInfo(int.Parse(dr["cid"].ToString())); gc.Parentlist = parentgc.Parentlist + "," + parentgc.Cid; gc.Sort = parentgc.Sort + 1; tpb.UpdateCategoryInfo(gc); MoveSubCategory(gc, dt); } }
/// <summary> /// 创建商品类别 /// </summary> public abstract int CreateCategoryInfo(CategoryInfo cinfo);
/// <summary> /// 修改商品类别 /// </summary> public abstract void UpdateCategoryInfo(CategoryInfo cinfo);
/// <summary> /// 修改商品类别 /// </summary> public static void UpdateCategoryInfo(CategoryInfo cinfo) { Data.DbProvider.GetInstance().UpdateCategoryInfo(cinfo); }
/// <summary> /// 获取商记首页用商品 /// </summary> public static List<TempGoodsWithCat> GetShangjiGoods() { List<TempGoodsWithCat> tempgoods = new List<TempGoodsWithCat>(); string cachekey = "/SAS/ShangjiGoods"; SAS.Cache.SASCache cache = SAS.Cache.SASCache.GetCacheService(); tempgoods = cache.RetrieveObject(cachekey) as List<TempGoodsWithCat>; if (tempgoods == null) { tempgoods = new List<TempGoodsWithCat>(); List<TaobaokeItem> tklist = GetRecommendProduct(Convert.ToInt16(TaoChanel.Shangji), 0); int tgwcID = 1; string numiidsarray = ""; foreach (TaobaokeItem tkinfo in tklist) { TempGoodsWithCat tgwcInfo = new TempGoodsWithCat(); if (tgwcID > 12) break; if (tgwcID > 3) { numiidsarray += tkinfo.NumIid.ToString() + ","; } else { tgwcInfo.ID = tgwcID; tgwcInfo.GoodID = tkinfo.NumIid.ToString(); tgwcInfo.GoodName = tkinfo.Title; tgwcInfo.PicUrl = tkinfo.PicUrl; tempgoods.Add(tgwcInfo); } tgwcID++; } List<TaobaokeItemDetail> tkdlist = GetTaoBaoKeItemListDetail(numiidsarray); if (tkdlist != null && tkdlist.Count > 0) { tgwcID = 4; foreach (TaobaokeItemDetail tkdinfo in tkdlist) { TempGoodsWithCat tgwcInfo = new TempGoodsWithCat(); Item iteminfo = tkdinfo.Item; CategoryInfo cinfo = new CategoryInfo(); tgwcInfo.ID = tgwcID; tgwcInfo.GoodID = iteminfo.NumIid.ToString(); tgwcInfo.GoodName = iteminfo.Title; tgwcInfo.PicUrl = iteminfo.PicUrl; cinfo = GetCategoryInfoByCache(iteminfo.Cid.ToString()); if (cinfo != null) { tgwcInfo.CatID = cinfo.Cid; tgwcInfo.CatName = cinfo.Name; } tempgoods.Add(tgwcInfo); tgwcID++; } } } cache.AddObject(cachekey, tempgoods); return tempgoods; }
/// <summary> /// 创建商品类别 /// </summary> public static int CreateCateInfo(CategoryInfo cinfo) { return Data.DbProvider.GetInstance().CreateCategoryInfo(cinfo); }