public void TestSelectPurchasingNoCompleteByGoodsId() { _stubPurchasing.SelectPurchasingNoCompleteByGoodsIdGuidListOfGuid = (guid, list) => true; _stubIGoodsInfoSao.GetRealGoodsIdsByGoodsIdGuid = guid => new List <Guid> { new Guid("7AE62AF0-EB1F-49C6-8FD1-128D77C84698") }; _purchasingManager = new PurchasingManager(_stubPurchasing, _stubIGoodsInfoSao, _stubIPurchasingDetail, null, null); var result = _purchasingManager.SelectPurchasingNoCompleteByGoodsId(new Guid("C1F14A7B-3119-4A3B-BDAB-782AC80359BA"), new List <Guid>()); Assert.IsTrue(result); }
//批量删除 protected void btn_Del_Click(object sender, EventArgs e) { if (Request["ckId"] != null) { IGoodsOrder goodsOrder = new GoodsOrder(GlobalConfig.DB.FromType.Read); var purchasingManager = new PurchasingManager(new Purchasing(GlobalConfig.DB.FromType.Read), _goodsCenterSao, null, null, null); IStorageRecordDao storageRecordDao = new StorageRecordDao(GlobalConfig.DB.FromType.Read); var errorMsg = new StringBuilder(); var goodsIdList = new List <Guid>(); var goodsIdsAndGoodsNamesAndGoodsAuditState = Request["ckId"].Split(','); List <int> stockStates = new List <int> { (int)StorageRecordState.WaitAudit, (int)StorageRecordState.Refuse, (int)StorageRecordState.Refuse, (int)StorageRecordState.Approved, (int)StorageRecordState.Finished }; foreach (var item in goodsIdsAndGoodsNamesAndGoodsAuditState) { var goodsId = new Guid(item.Split('&')[0]); string goodsName = item.Split('&')[1]; if (goodsOrder.SelectSemiStockAtOneYearByGoodsId(goodsId, null, null, 365, stockStates)) { errorMsg.Append("“").Append(goodsName).Append("”该商品1年内有进行过出入库记录,不允许删除!").Append("\\n"); continue; } if (purchasingManager.SelectPurchasingNoCompleteByGoodsId(goodsId, null)) { errorMsg.Append("“").Append(goodsName).Append("”该商品存在未完成的采购单,不允许删除!").Append("\\n"); continue; } if (storageRecordDao.IsExistNormalStorageRecord(goodsId, null)) { errorMsg.Append("“").Append(goodsName).Append("”该商品存在未审核的出入库单据,不允许删除!").Append("\\n"); continue; } if (CacheCollection.Filiale.GetHeadList().Where(f => f.FilialeTypes.Contains((int)FilialeType.EntityShop)).Any(source => StockSao.IsExistGoodsStock(source.ID, goodsId, new List <Guid>()))) { errorMsg.Append("“").Append(goodsName).Append("”此商品门店有库存,不允许删除!").Append("\\n"); continue; } goodsIdList.Add(goodsId); } if (!string.IsNullOrEmpty(errorMsg.ToString())) { MessageBox.Show(this, errorMsg.ToString()); } else { //删除主商品 string errorMessage; var personnel = CurrentSession.Personnel.Get(); var isSuccess = _goodManager.DeleteGoods(goodsIdList, personnel.RealName, personnel.PersonnelId, out errorMessage); if (isSuccess) { MessageBox.AppendScript(this, "setTimeout(function(){ refreshGrid(); }, " + GlobalConfig.PageAutoRefreshDelayTime + ");"); MessageBox.Show(this, "主商品删除成功!"); } else { MessageBox.Show(this, "主商品删除失败!"); } } } else { MessageBox.Show(this, "请选择相关数据!"); } }