コード例 #1
0
        public int DeleteClassByShop(int ClassID, int ShopID)
        {
            GoodsNumber         bllGN  = new GoodsNumber();
            GoodsClassAuthority bllGCA = new GoodsClassAuthority();
            GoodsClassDiscount  bllGCD = new GoodsClassDiscount();
            GoodsClass          bllGC  = new GoodsClass();
            Goods bllG = new Goods();

            Chain.Model.GoodsClass modelGC = bllGC.GetModel(ClassID);
            int result;

            if (modelGC == null)
            {
                result = -100;
            }
            else
            {
                if (modelGC.ParentID == 0)
                {
                    int childClassCount = bllGCA.GetClassCountByParentID(modelGC.ClassID);
                    if (childClassCount > 0)
                    {
                        int childClassCountInShop = bllGCA.GetClassCountByParentID(modelGC.ClassID, ShopID);
                        if (childClassCountInShop > 0)
                        {
                            result = -2;
                            return(result);
                        }
                        if (bllGN.GetGoodsCount(ClassID, ShopID) == 0)
                        {
                            bllGCA.DeleteAuthority(ClassID, ShopID);
                            result = 1;
                            return(result);
                        }
                        result = -1;
                        return(result);
                    }
                }
                int goodsCount = bllGN.GetGoodsCount(ClassID, ShopID);
                if (goodsCount == 0)
                {
                    bllGCA.DeleteAuthority(ClassID, ShopID);
                    bllGCD.DeleteDiscount(ClassID, ShopID);
                    DataTable dt           = bllGCA.GetShopIDListByClass(ClassID).Tables[0];
                    bool      isClassShare = false;
                    foreach (DataRow item in dt.Rows)
                    {
                        if (Convert.ToInt32(item["ShopID"]) != ShopID)
                        {
                            isClassShare = true;
                            break;
                        }
                    }
                    if (!isClassShare)
                    {
                        bllGC.Delete(ClassID);
                    }
                    result = 1;
                }
                else
                {
                    result = -1;
                }
            }
            return(result);
        }