예제 #1
0
        public void TestPurchasingUpdate()
        {
            _purchasingManager.PurchasingUpdate(Guid.NewGuid(), PurchasingState.Purchasing);
            Assert.IsTrue(true);

            _purchasingManager.PurchasingUpdate(Guid.NewGuid(), PurchasingState.Deleted);
            Assert.IsTrue(true);

            _purchasingManager.PurchasingUpdate(Guid.NewGuid(), PurchasingState.Refusing);
            Assert.IsTrue(true);
        }
        /// <summary>Grid操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void SemiStockGrid_OnItemCommand(object sender, GridCommandEventArgs e)
        {
            var item = e.Item as GridDataItem;

            if (item != null)
            {
                var dataItem    = item;
                var stockId     = new Guid(dataItem.GetDataKeyValue("StockId").ToString());
                var storageInfo = _storageRecordDao.GetStorageRecord(stockId);

                //作废
                if (e.CommandName == "Cancellation")
                {
                    #region --> Cancellation
                    var personnelInfo = CurrentSession.Personnel.Get();

                    if (storageInfo.StockType == (int)StorageRecordType.BorrowIn)
                    {
                        string description = "[借入单作废] " + personnelInfo.RealName + "[" +
                                             DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]";

                        var borrowLendInfo = _borrowLendDao.GetBorrowLendInfo(stockId);
                        if (borrowLendInfo != null)
                        {
                            var outStorageInfo = _storageRecordDao.GetStorageRecord(borrowLendInfo.BorrowLendId);
                            if (outStorageInfo != null)
                            {
                                //作废借入返回单
                                _storageManager.NewSetStateStorageRecord(outStorageInfo.StockId, StorageRecordState.Canceled,
                                                                         description);
                            }
                        }
                        //作废借入单
                        _storageManager.NewSetStateStorageRecord(stockId, StorageRecordState.Canceled, description);

                        //入库单作废操作记录添加
                        WebControl.AddOperationLog(personnelInfo.PersonnelId, personnelInfo.RealName, stockId,
                                                   storageInfo.TradeCode,
                                                   OperationPoint.StorageInManager.Cancel.GetBusinessInfo(), string.Empty);
                    }
                    else
                    {
                        Guid purid = _storageRecordDao.GetStorageRecord(stockId).LinkTradeID;

                        IList <PurchasingDetailInfo> dlist = _purchasingDetail.Select(purid);
                        var purchasingManager = new PurchasingManager(_purchasing, null, null, null, null);
                        using (var ts = new TransactionScope(TransactionScopeOption.Required))
                        {
                            if (dlist.Count > 0)
                            {
                                bool flag = true;
                                if (dlist.Any(dInfo => dInfo.RealityQuantity >= 1))
                                {
                                    purchasingManager.PurchasingUpdate(purid, PurchasingState.PartComplete);
                                    flag = false;
                                }
                                if (flag)
                                {
                                    purchasingManager.PurchasingUpdate(purid, PurchasingState.Purchasing);
                                }
                            }
                            string description = "[入库作废] " + CurrentSession.Personnel.Get().RealName + "[" +
                                                 DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]";
                            _storageManager.NewSetStateStorageRecord(stockId, StorageRecordState.Canceled, description);
                            //入库单作废操作记录添加
                            WebControl.AddOperationLog(personnelInfo.PersonnelId, personnelInfo.RealName, stockId,
                                                       storageInfo.TradeCode,
                                                       OperationPoint.StorageInManager.Cancel.GetBusinessInfo(), string.Empty);
                            ts.Complete();
                        }
                    }

                    #endregion
                }

                RAM.ResponseScripts.Add("setTimeout(function(){ refreshGrid(); }, " + GlobalConfig.PageAutoRefreshDelayTime + ");");
            }
        }