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); }
protected void btnCopy_Click(object sender, EventArgs e) { Chain.BLL.SysShop bllShop = new Chain.BLL.SysShop(); Chain.BLL.GoodsClassAuthority bllGoodsClassAuthority = new Chain.BLL.GoodsClassAuthority(); Chain.BLL.GoodsClass bllGoodsClass = new Chain.BLL.GoodsClass(); DataTable dtShop = bllShop.GetList("ShopID>0 and ShopType=3 and IsMain=0 ").Tables[0]; DataTable dtGoodsClass = bllGoodsClass.GetList("CreateShopID=" + this._UserShopID).Tables[0]; for (int i = 0; i < dtShop.Rows.Count; i++) { int ShopID = int.Parse(dtShop.Rows[i]["ShopID"].ToString()); for (int j = 0; j < dtGoodsClass.Rows.Count; j++) { int ClassID = int.Parse(dtGoodsClass.Rows[j]["ClassID"].ToString()); Chain.Model.GoodsClassAuthority modelGoodsClassAuthority = new Chain.Model.GoodsClassAuthority(); modelGoodsClassAuthority.ClassID = ClassID; modelGoodsClassAuthority.ShopID = ShopID; int count = bllGoodsClassAuthority.GetRecordCount(string.Concat(new object[] { "ShopID=", ShopID, " and ClassID=", ClassID })); if (count == 0) { bllGoodsClassAuthority.Add(modelGoodsClassAuthority); } } } Chain.BLL.GoodsClassDiscount bllGoodsClassDiscount = new Chain.BLL.GoodsClassDiscount(); DataTable dtClassDiscount = bllGoodsClassDiscount.GetList("DiscountShopID=" + this._UserShopID).Tables[0]; for (int i = 0; i < dtShop.Rows.Count; i++) { int ShopID = int.Parse(dtShop.Rows[i]["ShopID"].ToString()); for (int j = 0; j < dtClassDiscount.Rows.Count; j++) { Chain.Model.GoodsClassDiscount modelGoodsClassDiscount = new Chain.Model.GoodsClassDiscount(); int ClassID = int.Parse(dtClassDiscount.Rows[j]["GoodsClassID"].ToString()); int MemLevelID = int.Parse(dtClassDiscount.Rows[j]["MemLevelID"].ToString()); modelGoodsClassDiscount.GoodsClassID = ClassID; modelGoodsClassDiscount.MemLevelID = MemLevelID; modelGoodsClassDiscount.DiscountShopID = ShopID; modelGoodsClassDiscount.ClassDiscountPercent = int.Parse(dtClassDiscount.Rows[j]["ClassDiscountPercent"].ToString()); modelGoodsClassDiscount.ClassPointPercent = int.Parse(dtClassDiscount.Rows[j]["ClassPointPercent"].ToString()); DataTable dtShopGoodsClassDiscount = bllGoodsClassDiscount.GetList(string.Concat(new object[] { "MemLevelID=", MemLevelID, " and DiscountShopID=", ShopID, " and GoodsClassID=", ClassID })).Tables[0]; if (dtShopGoodsClassDiscount.Rows.Count == 0) { bllGoodsClassDiscount.Add(modelGoodsClassDiscount); } else { modelGoodsClassDiscount.ClassDiscountID = int.Parse(dtShopGoodsClassDiscount.Rows[0]["ClassDiscountID"].ToString()); bllGoodsClassDiscount.Update(modelGoodsClassDiscount); } } } Chain.BLL.Goods bllGoods = new Chain.BLL.Goods(); DataTable dtGoods = bllGoods.GetGoodsList("CreateShopID=" + this._UserShopID).Tables[0]; Chain.BLL.GoodsNumber bllGoodsNumber = new Chain.BLL.GoodsNumber(); for (int i = 0; i < dtShop.Rows.Count; i++) { int ShopID = int.Parse(dtShop.Rows[i]["ShopID"].ToString()); for (int j = 0; j < dtGoods.Rows.Count; j++) { int GoodsID = int.Parse(dtGoods.Rows[j]["GoodsID"].ToString()); int count = bllGoodsNumber.GetRecordCount(string.Concat(new object[] { "GoodsID=", GoodsID, " and ShopID=", ShopID })); Chain.Model.GoodsNumber modelGoodsNumber = new Chain.Model.GoodsNumber(); modelGoodsNumber.GoodsID = GoodsID; modelGoodsNumber.Number = 0m; modelGoodsNumber.ShopID = ShopID; if (count == 0) { bllGoodsNumber.Add(modelGoodsNumber); } } } this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "message", "<Script Language='JavaScript' defer>art.dialog({title: '系统提示',time: 2,content:'同步成功',close: function () { location.href = 'GoodsList.aspx?PID=62'; }});</script>"); }