private void GridView_Source_UpdateRelatedDataGridHandler(UpdateDirection direction, int rowIndex, int columnIndex)
        {
            if (rowIndex < 0 || rowIndex >= _srcDataSource.Count)
            {
                return;
            }

            SourceHoldingItem selectedItem = _srcDataSource[rowIndex];

            switch (direction)
            {
            case UpdateDirection.Select:
            {
                GridView_Source_Select(selectedItem);
            }
            break;

            case UpdateDirection.UnSelect:
            {
                GridView_Source_UnSelect(selectedItem);
            }
            break;

            default:
                break;
            }

            this.srcGridView.Invalidate();
        }
        private void GridView_Source_Select(SourceHoldingItem selectedItem)
        {
            selectedItem.PriceType        = "lastprice";
            selectedItem.TransferedAmount = selectedItem.AvailableTransferedAmount;

            //TODO: update the price
            var targetItem = _secuList.Find(p => p.SecuCode.Equals(selectedItem.SecuCode));

            if (targetItem == null)
            {
                targetItem = SecurityInfoManager.Instance.Get(selectedItem.SecuCode, selectedItem.SecuType);
            }

            if (targetItem != null)
            {
                var marketData = QuoteCenter.Instance.GetMarketData(targetItem);
                if (marketData != null)
                {
                    selectedItem.TransferedPrice = marketData.CurrentPrice;
                }
            }
        }
        private void FillSrcGridView(SortableBindingList <SourceHoldingItem> dataSource, List <TradeInstanceSecurity> secuItems, TradeInstance tradeInstance)
        {
            foreach (var secuItem in secuItems)
            {
                SourceHoldingItem srcItem = new SourceHoldingItem
                {
                    SecuCode                  = secuItem.SecuCode,
                    CurrentAmount             = secuItem.PositionAmount,
                    AvailableTransferedAmount = secuItem.PositionAmount,
                    SecuType                  = secuItem.SecuType,
                    PositionType              = secuItem.PositionType,
                    PortfolioCode             = tradeInstance.PortfolioCode,
                    PortfolioName             = tradeInstance.PortfolioName
                };

                var findItem = SecurityInfoManager.Instance.Get(secuItem.SecuCode, secuItem.SecuType);
                if (findItem != null)
                {
                    srcItem.SecuName     = findItem.SecuName;
                    srcItem.ExchangeCode = findItem.ExchangeCode;
                }
                dataSource.Add(srcItem);
            }
        }
 private void GridView_Source_UnSelect(SourceHoldingItem selectedItem)
 {
     selectedItem.PriceType        = "";
     selectedItem.TransferedAmount = 0;
     selectedItem.TransferedPrice  = 0;
 }