public override OPResult Save() { BillCannibalize cannibalize = VMGlobal.DistributionQuery.LinqOP.Search <BillCannibalize>(o => o.Code == Master.RefrenceBillCode).First(); cannibalize.Status = true; using (TransactionScope scope = new TransactionScope()) { try { base.SaveWithNoTran(); VMGlobal.DistributionQuery.LinqOP.Update <BillCannibalize>(cannibalize); Details.ForEach(d => BillLogic.AddStock(Master.StorageID, d.ProductID, d.Quantity)); scope.Complete(); } catch (Exception e) { return(new OPResult { IsSucceed = false, Message = e.Message }); } } return(new OPResult { IsSucceed = true }); }
public override OPResult Save() { var lp = VMGlobal.DistributionQuery.LinqOP; BillDelivery delivery = lp.Search <BillDelivery>(o => o.Code == Master.RefrenceBillCode).First(); delivery.Status = (int)BillDeliveryStatusEnum.已入库; //var uniqueCodes = GetSnapshotDetails(delivery.ID); using (TransactionScope scope = new TransactionScope()) { try { base.SaveWithNoTran(); lp.Update <BillDelivery>(delivery); Details.ForEach(d => BillLogic.AddStock(Master.StorageID, d.ProductID, d.Quantity)); //SaveUniqueCodes(uniqueCodes); scope.Complete(); } catch (Exception e) { return(new OPResult { IsSucceed = false, Message = e.Message }); } } return(new OPResult { IsSucceed = true }); }
public override OPResult Save() { BillGoodReturn goodreturn = VMGlobal.DistributionQuery.LinqOP.Search <BillGoodReturn>(o => o.Code == Master.RefrenceBillCode).First(); if (goodreturn.Status == (int)BillGoodReturnStatusEnum.已入库) { return new OPResult { IsSucceed = false, Message = "该单已入库" } } ; //var uniqueCodes = GetSnapshotDetails(goodreturn.ID); if (!OrganizationListVM.IsSelfRunShop(goodreturn.OrganizationID))//检查当初发这些货品的时候的发货价.另:非自营店不能退不是发给自己的货物 { //var index = goodreturn.Remark.LastIndexOf(':'); //if (index != -1) //{ ReturnMoney = goodreturn.TotalPrice;//Convert.ToDecimal(goodreturn.Remark.Substring(index + 1)); //} } goodreturn.Status = (int)BillGoodReturnStatusEnum.已入库; using (TransactionScope scope = new TransactionScope()) { try { base.SaveWithNoTran(); VMGlobal.DistributionQuery.LinqOP.Update <BillGoodReturn>(goodreturn); if (ReturnMoney != 0) { VMGlobal.DistributionQuery.LinqOP.Add <OrganizationFundAccount>( new OrganizationFundAccount { BrandID = Master.BrandID, OrganizationID = goodreturn.OrganizationID, //this.Master.OrganizationID, NeedIn = 0, AlreadyIn = ReturnMoney, CreatorID = VMGlobal.CurrentUser.ID, BillKind = (int)BillTypeEnum.BillGoodReturn, Remark = "退货入库生成,退货单号" + goodreturn.Code, RefrenceBillCode = this.Master.Code }); } Details.ForEach(d => BillLogic.AddStock(Master.StorageID, d.ProductID, d.Quantity)); //SaveUniqueCodes(uniqueCodes); scope.Complete(); } catch (Exception e) { return(new OPResult { IsSucceed = false, Message = e.Message }); } } return(new OPResult { IsSucceed = true }); }
public override OPResult Save() { var lp = VMGlobal.DistributionQuery.LinqOP; var bill = Master; bill.OrganizationID = VMGlobal.CurrentUser.OrganizationID; var details = this.Details = new List <BillStoringDetails>(); this.TraverseGridDataItems(product => { details.Add(new BillStoringDetails { ProductID = product.ProductID, Quantity = product.Quantity }); }); if (details.Count == 0) { return(new OPResult { IsSucceed = false, Message = "没有需要保存的数据" }); } bill.CreatorID = VMGlobal.CurrentUser.ID; bill.Code = this.GenerateBillCode(); //if (string.IsNullOrEmpty(bill.RefrenceBillCode)) bill.RefrenceBillCode = bill.Code;//假如没有相关单据号,则相关单据号就是入库单自身单据编号 bill.BillType = (int)BillTypeEnum.BillStoring; if (string.IsNullOrEmpty(bill.Remark)) { bill.Remark = "成品入库"; } //TransactionOptions transactionOption = new TransactionOptions(); ////设置事务隔离级别 //transactionOption.IsolationLevel = System.Transactions.IsolationLevel.Snapshot; using (TransactionScope scope = new TransactionScope()) { try { bill.ID = lp.Add <BillStoring, int>(bill, b => b.ID); details.ForEach(d => d.BillID = bill.ID); lp.Add <BillStoringDetails>(details); Details.ForEach(d => BillLogic.AddStock(bill.StorageID, d.ProductID, d.Quantity)); scope.Complete(); } catch (Exception e) { return(new OPResult { IsSucceed = false, Message = e.Message }); } } return(new OPResult { IsSucceed = true }); }
public override void SaveWithNoTran() { //加库存 Details.ForEach(d => BillLogic.AddStock(Master.StorageID, d.ProductID, d.Quantity)); base.SaveWithNoTran(); }