예제 #1
0
        /// <summary>
        /// 创建店铺分类
        /// </summary>
        /// <param name="shopcategoryinfo">店铺分类信息</param>
        /// <returns>创建店铺分类id</returns>
        public static int CreateShopCategory(Shopcategoryinfo shopCategoryInfo)
        {
            int returnval = DbProvider.GetInstance().CreateShopCategory(shopCategoryInfo);

            SetShopCategoryDispalyorder(shopCategoryInfo.Shopid);
            return(returnval);
        }
예제 #2
0
        /// <summary>
        /// 创建店铺分类
        /// </summary>
        /// <param name="shopcategoryinfo">店铺分类信息</param>
        /// <param name="targetshopcategoryinfo">要加入的目标分类信息</param>
        /// <param name="addtype">添加方式(1:作为同级分类 2:作为子分类 其它:根结店)</param>
        /// <returns>创建店铺分类id</returns>
        public static int CreateShopCategory(Shopcategoryinfo shopCategoryInfo, Shopcategoryinfo targetShopCategoryInfo, int addType)
        {
            switch (addType)
            {
            case 1:     //作为同级分类
            {
                shopCategoryInfo.Parentid     = targetShopCategoryInfo.Parentid;
                shopCategoryInfo.Parentidlist = targetShopCategoryInfo.Parentidlist;
                shopCategoryInfo.Layer        = targetShopCategoryInfo.Layer;
                break;
            }

            case 2:     //作为子分类
            {
                shopCategoryInfo.Parentid     = targetShopCategoryInfo.Categoryid;
                shopCategoryInfo.Parentidlist = targetShopCategoryInfo.Parentidlist == "0" ? targetShopCategoryInfo.Categoryid.ToString() : targetShopCategoryInfo.Parentidlist + "," + targetShopCategoryInfo.Categoryid;
                shopCategoryInfo.Layer        = targetShopCategoryInfo.Layer + 1;
                break;
            }

            default:
            {
                shopCategoryInfo.Parentid     = 0;
                shopCategoryInfo.Parentidlist = "0";
                shopCategoryInfo.Layer        = 0;
                break;
            }
            }
            return(CreateShopCategory(shopCategoryInfo));
        }
예제 #3
0
            /// <summary>
            /// 获得店铺分类信息(DTO)
            /// </summary>
            /// <param name="__idatareader">要转换的数据表</param>
            /// <returns>返回店铺分类信息</returns>
            public static Shopcategoryinfo[] GetShopCategoryArray(DataTable dt)
            {
                if (dt == null || dt.Rows.Count == 0)
                {
                    return(null);
                }

                Shopcategoryinfo[] shopcategoryinfoarray = new Shopcategoryinfo[dt.Rows.Count];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    shopcategoryinfoarray[i]               = new Shopcategoryinfo();
                    shopcategoryinfoarray[i].Categoryid    = TypeConverter.ObjectToInt(dt.Rows[i]["categoryid"]);
                    shopcategoryinfoarray[i].Parentid      = TypeConverter.ObjectToInt(dt.Rows[i]["parentid"]);
                    shopcategoryinfoarray[i].Parentidlist  = dt.Rows[i]["parentidlist"].ToString().Trim();
                    shopcategoryinfoarray[i].Layer         = TypeConverter.ObjectToInt(dt.Rows[i]["layer"]);
                    shopcategoryinfoarray[i].Childcount    = TypeConverter.ObjectToInt(dt.Rows[i]["childcount"]);
                    shopcategoryinfoarray[i].Syscategoryid = TypeConverter.ObjectToInt(dt.Rows[i]["syscategoryid"]);
                    shopcategoryinfoarray[i].Name          = dt.Rows[i]["name"].ToString();
                    shopcategoryinfoarray[i].Categorypic   = dt.Rows[i]["categorypic"].ToString();
                    shopcategoryinfoarray[i].Shopid        = TypeConverter.ObjectToInt(dt.Rows[i]["shopid"]);
                    shopcategoryinfoarray[i].Displayorder  = TypeConverter.ObjectToInt(dt.Rows[i]["displayorder"]);
                }
                dt.Dispose();
                return(shopcategoryinfoarray);
            }
예제 #4
0
        /// <summary>
        /// 删除指定的店铺商品分类
        /// </summary>
        /// <param name="categoryid">要删除的店铺商品分类id</param>
        /// <returns>是否删除成功</returns>
        public static bool DeleteCategoryByCategoryId(Shopcategoryinfo shopCategoryInfo)
        {
            if (DbProvider.GetInstance().IsExistSubShopCategory(shopCategoryInfo))
            {
                return(false);
            }

            DbProvider.GetInstance().DeleteShopCategory(shopCategoryInfo);
            return(true);
        }
예제 #5
0
            /// <summary>
            /// 获得店铺分类信息(DTO)
            /// </summary>
            /// <param name="__idatareader">要转换的数据</param>
            /// <returns>返回店铺分类信息</returns>
            public static Shopcategoryinfo GetShopCategoryInfo(IDataReader reader)
            {
                Shopcategoryinfo shopCategoryInfo = null;

                if (reader.Read())
                {
                    shopCategoryInfo               = new Shopcategoryinfo();
                    shopCategoryInfo.Categoryid    = TypeConverter.ObjectToInt(reader["categoryid"]);
                    shopCategoryInfo.Parentid      = TypeConverter.ObjectToInt(reader["parentid"]);
                    shopCategoryInfo.Parentidlist  = reader["parentidlist"].ToString().Trim();
                    shopCategoryInfo.Layer         = TypeConverter.ObjectToInt(reader["layer"]);
                    shopCategoryInfo.Childcount    = TypeConverter.ObjectToInt(reader["childcount"]);
                    shopCategoryInfo.Syscategoryid = TypeConverter.ObjectToInt(reader["syscategoryid"]);
                    shopCategoryInfo.Name          = reader["name"].ToString().Trim();
                    shopCategoryInfo.Categorypic   = reader["categorypic"].ToString().Trim();
                    shopCategoryInfo.Shopid        = TypeConverter.ObjectToInt(reader["shopid"]);
                    shopCategoryInfo.Displayorder  = TypeConverter.ObjectToInt(reader["displayorder"]);

                    reader.Close();
                }
                return(shopCategoryInfo);
            }
예제 #6
0
 /// <summary>
 /// 更新店铺分类
 /// </summary>
 /// <param name="shopcategoryinfo">店铺分类信息</param>
 /// <returns>是否更新成功</returns>
 public static bool UpdateShopCategory(Shopcategoryinfo shopCategoryInfo)
 {
     return(DbProvider.GetInstance().UpdateShopCategory(shopCategoryInfo));
 }
예제 #7
0
 /// <summary>
 /// 移动商品分类
 /// </summary>
 /// <param name="shopcategoryinfo">源店铺商品分类</param>
 /// <param name="targetshopcategoryinfo">目标店铺商品分类</param>
 /// <param name="isaschildnode">是否作为子节点</param>
 /// <returns>是否移动成功</returns>
 public static bool MoveShopCategory(Shopcategoryinfo shopCategoryInfo, Shopcategoryinfo targetShopCategoryInfo, bool isAsChildNode)
 {
     DbProvider.GetInstance().MovingShopCategoryPos(shopCategoryInfo, targetShopCategoryInfo, isAsChildNode);
     SetShopCategoryDispalyorder(targetShopCategoryInfo.Shopid);
     return(true);
 }
예제 #8
0
        protected override void ShowPage()
        {
            if (userid == -1)
            {
                AddErrLine("你尚未登录");
                return;
            }
            if (config.Enablemall < 2)
            {
                AddErrLine("当前操作只有在开启商城(高级)模式时才可以使用!");
                return;
            }

            user     = Users.GetUserInfo(userid);
            shopinfo = Shops.GetShopByUserId(user.Uid);

            if (!DNTRequest.IsPost())
            {
                shopcategorydt       = ShopCategories.GetShopCategoryTable(shopinfo.Shopid);
                shopcategorydt_count = shopcategorydt.Rows.Count;
                shopcategorydata     = ShopCategories.GetShopCategoryJson(shopcategorydt);
                categoryoptions      = ShopCategories.GetShopCategoryOption(shopcategorydt, false);
            }
            else
            {
                if (ForumUtils.IsCrossSitePost())
                {
                    AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。");
                    return;
                }
                string operation = DNTRequest.GetFormString("operation");
                if (operation != "add")
                {
                    int shopcategoryid = DNTRequest.GetFormInt("categoryid", 0);
                    if (shopcategoryid <= 0)
                    {
                        AddErrLine("店铺商品分类参数无效<br />");
                        return;
                    }

                    shopcategoryinfo = ShopCategories.GetShopCategoryByCategoryId(shopcategoryid);
                }

                shopid = 0;
                item   = DNTRequest.GetString("item");

                switch (operation)
                {
                case "delete":     //删除分类
                {
                    if (shopcategoryinfo == null || shopcategoryinfo.Categoryid <= 0)
                    {
                        AddErrLine("要删除的店铺商品分类参数无效<br />");
                        return;
                    }
                    if (!ShopCategories.DeleteCategoryByCategoryId(shopcategoryinfo))
                    {
                        AddErrLine("对不起,当前节点下面还有子结点,因此不能删除<br />");
                        return;
                    }
                    break;
                }

                case "edit":     //编辑分类名称
                {
                    if (shopcategoryinfo == null || shopcategoryinfo.Categoryid <= 0)
                    {
                        AddErrLine("要修改的店铺商品分类参数无效<br />");
                        return;
                    }
                    string editname = DNTRequest.GetString("editcategoryname");
                    if (editname == "")
                    {
                        AddErrLine("店铺商品分类名称未变更或不能为空<br />");
                        return;
                    }
                    shopcategoryinfo.Name = editname;
                    ShopCategories.UpdateShopCategory(shopcategoryinfo);
                    break;
                }

                case "add":     //添加分类
                {
                    shopcategoryinfo        = new Shopcategoryinfo();
                    shopcategoryinfo.Name   = DNTRequest.GetFormString("addcategoryname");
                    shopcategoryinfo.Shopid = shopinfo.Shopid;

                    int addtype = DNTRequest.GetInt("addtype", 0);
                    if (addtype > 0 && addtype <= 2)
                    {
                        int targetcategoryid = DNTRequest.GetFormInt("selectcategoryid", 0);

                        if (targetcategoryid <= 0)
                        {
                            AddErrLine("要添加到的目标分类参数无效<br />");
                            return;
                        }

                        targetshopcategoryinfo = ShopCategories.GetShopCategoryByCategoryId(targetcategoryid);
                        if (targetshopcategoryinfo == null || targetshopcategoryinfo.Categoryid <= 0)
                        {
                            AddErrLine("要添加到的目标分类参数无效<br />");
                            return;
                        }
                    }

                    ShopCategories.CreateShopCategory(shopcategoryinfo, targetshopcategoryinfo, addtype);
                    break;
                }

                case "move":     //移动分类
                {
                    int targetcategoryid = DNTRequest.GetFormInt("targetcategoryid", 0);

                    if (targetcategoryid <= 0)
                    {
                        AddErrLine("要移动到的目标分类参数无效<br />");
                        return;
                    }

                    targetshopcategoryinfo = ShopCategories.GetShopCategoryByCategoryId(targetcategoryid);
                    if (targetshopcategoryinfo == null || targetshopcategoryinfo.Categoryid <= 0)
                    {
                        AddErrLine("要移动到的目标分类参数无效<br />");
                        return;
                    }
                    string target_parentidlist = "," + targetshopcategoryinfo.Parentidlist.Trim() + ",";
                    if (target_parentidlist.IndexOf("," + shopcategoryinfo.Categoryid.ToString() + ",") > 0)
                    {
                        AddErrLine("不能将当前分类移动到其子分类<br />");
                        return;
                    }
                    ShopCategories.MoveShopCategory(shopcategoryinfo, targetshopcategoryinfo, DNTRequest.GetInt("isaschildnode", 0) == 1 ? true : false);
                    break;
                }
                }

                SetUrl("usercpshopcategory.aspx?item=" + item);
                SetMetaRefresh();
                AddMsgLine("操作成功. <br />(<a href=\"usercpmygoods.aspx?item=" + item + "\">点击这里返回</a>)<br />");
            }
        }