public static int AddExt(GoodsClassInfo entity) { int num = GoodsClass.Add(entity); if (num > 0) { if (entity.ParentID.Equals(0)) { entity.RootID = num; entity.Depth = 1; entity.ChildCount = 0; } else { GoodsClassInfo dataById = GoodsClass.GetDataById(entity.ParentID); if (dataById != null) { entity.RootID = dataById.RootID; entity.Depth = dataById.Depth + 1; entity.ChildCount = 0; dataById.ChildCount++; GoodsClass.Update(dataById); } } entity.AutoID = num; GoodsClass.Update(entity); } return(num); }
public static bool DeleteExt(int intPrimaryKeyIDValue) { GoodsClassInfo dataById = GoodsClass.GetDataById(intPrimaryKeyIDValue); bool result; if (dataById != null) { if (GoodsClass.Delete(intPrimaryKeyIDValue)) { BizBase.dbo.UpdateTable("update shop_GoodsClass set ChildCount=ChildCount-1 where ChildCount>0 AND AutoID=" + dataById.ParentID); } result = true; } else { result = false; } return(result); }