コード例 #1
0
        /// <summary>
        /// 有效定单入库
        /// </summary>
        /// <param name="selectedMarketOrder">选中的某个有效定单</param>
        public void WarehousingMarketOrder(MarketOrderData selectedMarketOrder)
        {
            OrderChangedWindow wnd = new OrderChangedWindow(OrderChangedWindowType.Warehousing)
            {
                Owner = Application.Current.MainWindow,
                DataContext = selectedMarketOrder,
            };
            wnd.OrderChanged += (sender, args) =>
            {
                BackgroundWorker worker = new BackgroundWorker();
                worker.DoWork += (s, e) =>
                {
                    //这里应该先获取该定单对应的用户,然后进行平仓信息的验证,主要是平仓数量有效数据位的判断
                    //ValidationResult result = ChargebackOrderValidation( args.OrderChangedInfo, 先获取该定单对应的用户 );

                    int userType = ToUserType(_accType);
                    e.Result = _tradeService.WarehousingOrder(_loginID, userType, args.OrderChangedInfo);
                };
                worker.RunWorkerCompleted += (s, e) =>
                {
                    ErrType err = e.Result as ErrType;
                    if (err != GeneralErr.Success)
                    {
                        wnd.RevertWindowState();
                        MessageBox.Show(err.ErrMsg, err.ErrTitle, MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                    else
                    {
                        wnd.Close();
                        string msg = string.Format("入库操作成功,数量:{0}", args.OrderChangedInfo.Count);
                        MessageBox.Show(msg, "提示", MessageBoxButton.OK, MessageBoxImage.Information);

                        //根据结果对定单进行处理,如果定单数量为0,则移除该定单。
                        selectedMarketOrder.OrderQuantity -= args.OrderChangedInfo.Count;
                        if (selectedMarketOrder.OrderQuantity == 0)
                            RemoveMarketOrderData(selectedMarketOrder);
                    }
                };
                worker.RunWorkerAsync();
            };
            wnd.ShowDialog();
        }
コード例 #2
0
        /// <summary>
        /// 有效定单平仓
        /// </summary>
        /// <param name="selectedMarketOrder">选中的某个有效定单</param>
        public void ChargebackMarketOrder(MarketOrderData selectedMarketOrder)
        {
            OrderChangedWindow wnd = new OrderChangedWindow(OrderChangedWindowType.Chargeback)
            {
                Owner = Application.Current.MainWindow,
                DataContext = selectedMarketOrder,
                
            };
            wnd.OrderChanged += (sender, args) =>
            {
                BackgroundWorker worker = new BackgroundWorker();
                worker.DoWork += (s, e) =>
                {
                    //这里应该先获取该定单对应的用户,然后进行平仓信息的验证,主要是平仓数量有效数据位的判断
                    //ValidationResult result = ChargebackOrderValidation( args.OrderChangedInfo, 先获取该定单对应的用户 );

                    int userType = ToUserType(_accType);
                    e.Result = _tradeService.ChargebackOrder(_loginID, userType, args.OrderChangedInfo);
                };
                worker.RunWorkerCompleted += (s, e) =>
                {
                    ErrType err = e.Result as ErrType;
                    if (err != GeneralErr.Success)
                    {
                        MessageBox.Show(err.ErrMsg, err.ErrTitle, MessageBoxButton.OK, MessageBoxImage.Warning);
                        wnd.RevertWindowState();
                    }
                    else
                    {
                        wnd.Close();
                        StringBuilder sbStr = new StringBuilder();
                        string orderTypeStr = selectedMarketOrder.OrderType == TRANSACTION_TYPE.Order ? "买涨" : "买跌";
                        sbStr.Append("订单号\t\t\t商品\t类型\t订单价");
                        sbStr.Append(string.Format("{0}\t{1}\t{2}\t{3}", selectedMarketOrder.OrderID, selectedMarketOrder.ProductName, orderTypeStr, selectedMarketOrder.OrderPrice));
                        sbStr.Append("\r\n\r\n");
                        sbStr.Append(string.Format("平仓\t{0}\t于价位:{1}", args.OrderChangedInfo.Count,
                            args.OrderChangedInfo.RealTimePrice));
                        MessageBox.Show(sbStr.ToString(), "提示", MessageBoxButton.OK, MessageBoxImage.Information);

                        //根据结果对定单进行处理,如果定单数量为0,则移除该定单。
                        selectedMarketOrder.OrderQuantity -= args.OrderChangedInfo.Count;
                        if (selectedMarketOrder.OrderQuantity == 0)
                            RemoveMarketOrderData(selectedMarketOrder);
                    }
                };
                worker.RunWorkerAsync();
            };
            wnd.ShowDialog();
        }