Пример #1
0
 private void bgwSendOrder_DoWork(object sender, DoWorkEventArgs e)
 {
     string result = string.Empty;
     try
     {
         string text = this.tbPin.Text.Trim();
         AutoTradeMain autoTradeMain = new AutoTradeMain();
         autoTradeMain.Pack("DCA", this._commandDca);
         result = ApplicationInfo.WebAlertService.SendAutoTrade(autoTradeMain.ToMessage());
     }
     catch (Exception ex)
     {
         this.ShowError("bgwSendOrder_DoWork", ex);
         result = ex.Message;
     }
     e.Result = result;
 }
Пример #2
0
        private void btnSendOrder_Click(object sender, EventArgs e)
        {
            try
            {
                if (this._typeId == "ALG1")
                {

                    AutoTradeT1Command autoTradeT1Command = new AutoTradeT1Command();
                    autoTradeT1Command.UserId = ApplicationInfo.UserLoginID;
                    if (this.cbExpire.Text.ToLower().IndexOf("end") > -1)
                    {
                        autoTradeT1Command.ExpireDays = 1;
                    }
                    else if (this.cbExpire.Text.ToLower().IndexOf("30") > -1)
                    {
                        autoTradeT1Command.ExpireDays = 30;
                    }
                    else if (this.cbExpire.Text.ToLower().IndexOf("60") > -1)
                    {
                        autoTradeT1Command.ExpireDays = 60;
                    }
                    else if (this.cbExpire.Text.ToLower().IndexOf("90") > -1)
                    {
                        autoTradeT1Command.ExpireDays = 90;
                    }
                    else if (this.cbExpire.Text.ToLower().IndexOf("180") > -1)
                    {
                        autoTradeT1Command.ExpireDays = 180;
                    }
                    string text = string.Empty;
                    if (this.cb1Condition.Text.ToLower().IndexOf("sma") > 0)
                    {
                        text = "SMA";
                    }
                    else if (this.cb1Condition.Text.ToLower().IndexOf("break high") > 0)
                    {
                        text = "HHV";
                    }
                    else if (this.cb1Condition.Text.ToLower().IndexOf("break low") > 0)
                    {
                        text = "LLV";
                    }
                    else if (this.cb1Condition.Text.ToLower().IndexOf("last") > -1)
                    {
                        text = "LAST";
                    }
                    string text2 = this.cb1Stock.Text.Trim();
                    string text3 = this.cb1Price.Text.Trim();
                    long num = 0L;
                    long.TryParse(this.tb1Volume.Text.Replace(",", ""), out num);
                    int num2 = 0;
                    if (this.cb1Condition.Text.IndexOf(">=") > 0)
                    {
                        num2 = 1;
                    }
                    else if (this.cb1Condition.Text.IndexOf("<=") > 0)
                    {
                        num2 = 2;
                    }
                    else if (this.cb1Condition.Text.IndexOf(">") > 0)
                    {
                        num2 = 3;
                    }
                    else if (this.cb1Condition.Text.IndexOf("<") > 0)
                    {
                        num2 = 4;
                    }
                    decimal num3 = 0m;
                    decimal.TryParse(this.cb1Value.Text, out num3);
                    if (this._ordSide == string.Empty)
                    {
                        this.ShowMessageBox("Invalid order side", frmOrderFormConfirm.OpenStyle.Error, null);
                    }
                    else if (text2 == string.Empty)
                    {
                        this.ShowMessageBox("Invalid order symbol", frmOrderFormConfirm.OpenStyle.Error, this.cb1Stock);
                    }
                    else
                    {
                        StockList.StockInformation stockInformation = ApplicationInfo.StockInfo[text2];
                        if (stockInformation.Number <= 0)
                        {
                            this.ShowMessageBox("Invalid order symbol", frmOrderFormConfirm.OpenStyle.Error, this.cb1Stock);
                        }
                        else if (text == string.Empty)
                        {
                            this.ShowMessageBox("Invalid order condition", frmOrderFormConfirm.OpenStyle.Error, this.cb1Condition);
                        }
                        else if (num3 <= 0m)
                        {
                            this.ShowMessageBox("Invalid price condition", frmOrderFormConfirm.OpenStyle.Error, this.cb1Value);
                        }
                        else
                        {
                            decimal checkPrice;
                            if (text == "SMA" || text == "HHV" || text == "LLV")
                            {
                                if (!this.cb1Value.Items.Contains(num3.ToString()))
                                {
                                    this.ShowMessageBox("Invalid period condition", frmOrderFormConfirm.OpenStyle.Error, this.cb1Value);
                                    return;
                                }
                                checkPrice = -1m;
                            }
                            else
                            {
                                if (!this.IsValidPrice(this.cb1Value.Text, true, this.cb1Value))
                                {
                                    return;
                                }
                                checkPrice = num3;
                            }
                            string text4 = text3;
                            if (text4 != null)
                            {
                                if (text4 == "MP")
                                {
                                    goto IL_529;
                                }
                            }
                            if (!this.IsValidPrice(text3, true, this.cb1Price))
                            {
                                return;
                            }
                        IL_529:
                            if (num <= 0L)
                            {
                                this.ShowMessageBox("Invalid Volume [More than Zero]!", frmOrderFormConfirm.OpenStyle.Error, this.tb1Volume);
                            }
                            else if (autoTradeT1Command.ExpireDays < 1)
                            {
                                this.ShowMessageBox("Invalid Expire!", frmOrderFormConfirm.OpenStyle.Error, this.cbExpire);
                            }
                            else
                            {
                                autoTradeT1Command.Item = new AutoTradeItem(0L, 0, "ALG1", ApplicationInfo.UserLoginID, text2, text, num2, num3, checkPrice, ApplicationInfo.AccInfo.CurrentAccount, this._ordSide, num, text3, string.Empty, ApplicationInfo.AccInfo.Items[ApplicationInfo.AccInfo.CurrentAccount].PcFlag, "N");
                                this._commandMain = new AutoTradeMain();
                                this._commandMain.Pack("T1", autoTradeT1Command);
                                string text5 = "Last " + AutoTradeConstant.GetOperatorSymbol(num2) + " ";
                                if (text == "SMA")
                                {
                                    object obj = text5;
                                    text5 = string.Concat(new object[]
                                        {
                                            obj,
                                            "SMA (",
                                            num3,
                                            ")"
                                        });
                                }
                                else if (text == "HHV")
                                {
                                    object obj = text5;
                                    text5 = string.Concat(new object[]
                                        {
                                            obj,
                                            "Break High (",
                                            num3,
                                            ")"
                                        });
                                }
                                else if (text == "LLV")
                                {
                                    object obj = text5;
                                    text5 = string.Concat(new object[]
                                        {
                                            obj,
                                            "Break Low (",
                                            num3,
                                            ")"
                                        });
                                }
                                else
                                {
                                    text5 += num3;
                                }
                                string orderParam = string.Concat(new string[]
                                    {
                                        "Auto Trade :",
                                        " Account : ",
                                        ApplicationInfo.AccInfo.CurrentAccount,
                                        "\n",
                                        Utilities.GetOrderSideName(this._ordSide),
                                        "  ‘",
                                        text2,
                                        "’",
                                        "  Volume ",
                                        FormatUtil.VolumeFormat(num, true),
                                        "  Price ",
                                        text3,
                                        "\nCondition : ",
                                        text5
                                    });
                                this.ShowOrderFormConfirm("Confirm to send?", orderParam, frmOrderFormConfirm.OpenStyle.ConfirmSendNew);
                            }
                        }
                    }
                }
                else if (this._typeId == "ALG2")
                {
                    string text2 = this.cb1Stock.Text.Trim();
                    string isGroupRemove = this.chbGroupCancel.Checked ? "Y" : "N";
                    long num;
                    long.TryParse(this.tb2Volume.Text.Trim().Replace(",", ""), out num);
                    List<AutoTradeItem> list = new List<AutoTradeItem>();
                    AutoTradeT2Command autoTradeT2Command = new AutoTradeT2Command();
                    autoTradeT2Command.UserId = ApplicationInfo.UserLoginID;
                    autoTradeT2Command.Stock = text2;
                    autoTradeT2Command.Side = this._ordSide;
                    if (this.cbExpire.Text.ToLower().IndexOf("end") > -1)
                    {
                        autoTradeT2Command.ExpireDays = 1;
                    }
                    else if (this.cbExpire.Text.ToLower().IndexOf("30") > -1)
                    {
                        autoTradeT2Command.ExpireDays = 30;
                    }
                    else if (this.cbExpire.Text.ToLower().IndexOf("60") > -1)
                    {
                        autoTradeT2Command.ExpireDays = 60;
                    }
                    else if (this.cbExpire.Text.ToLower().IndexOf("90") > -1)
                    {
                        autoTradeT2Command.ExpireDays = 90;
                    }
                    else if (this.cbExpire.Text.ToLower().IndexOf("180") > -1)
                    {
                        autoTradeT2Command.ExpireDays = 180;
                    }
                    string text6 = "";
                    if (this._ordSide == string.Empty)
                    {
                        this.ShowMessageBox("Invalid order side", frmOrderFormConfirm.OpenStyle.Error, null);
                    }
                    else if (text2 == string.Empty)
                    {
                        this.ShowMessageBox("Invalid order symbol", frmOrderFormConfirm.OpenStyle.Error, this.cb1Stock);
                    }
                    else
                    {
                        StockList.StockInformation stockInformation = ApplicationInfo.StockInfo[text2];
                        if (stockInformation.Number <= 0)
                        {
                            this.ShowMessageBox("Invalid order symbol", frmOrderFormConfirm.OpenStyle.Error, this.cb1Stock);
                        }
                        else
                        {
                            if (this.chb2TakeProfitCond.Checked)
                            {
                                int num2 = 1;
                                decimal num3 = 0m;
                                decimal.TryParse(this.cb2ValueTakeProfit.Text, out num3);
                                string text3 = this.cb2PriceLast.Text.Trim();
                                if (num2 == -1)
                                {
                                    this.ShowMessageBox("Invalid operator condition", frmOrderFormConfirm.OpenStyle.Error, null);
                                    return;
                                }
                                if (num3 <= 0m)
                                {
                                    this.ShowMessageBox("Invalid price condition", frmOrderFormConfirm.OpenStyle.Error, this.cb2ValueTakeProfit);
                                    return;
                                }
                                string text4 = text3;
                                if (text4 != null)
                                {
                                    if (text4 == "MP")
                                    {
                                        goto IL_B1B;
                                    }
                                }
                                if (!this.IsValidPrice(text3, true, this.cb2PriceLast))
                                {
                                    return;
                                }
                            IL_B1B:
                                AutoTradeItem item = new AutoTradeItem(0L, 1, "ALG2", ApplicationInfo.UserLoginID, text2, "LAST", num2, num3, num3, ApplicationInfo.AccInfo.CurrentAccount, this._ordSide, num, text3, string.Empty, ApplicationInfo.AccInfo.Items[ApplicationInfo.AccInfo.CurrentAccount].PcFlag, isGroupRemove);
                                list.Add(item);
                                text6 = string.Concat(new object[]
                                {
                                    "Take Profit   : Last ",
                                    AutoTradeConstant.GetOperatorSymbol(num2),
                                    " ",
                                    num3
                                });
                            }
                            if (this.chb2TrailingStopCond.Checked)
                            {
                                int num2 = 4;
                                string text = string.Empty;
                                if (this.cb2OperTrailingStop.Text.IndexOf("SMA") > -1)
                                {
                                    text = "SMA";
                                }
                                else if (this.cb2OperTrailingStop.Text.IndexOf("Break") > -1)
                                {
                                    text = "LLV";
                                }
                                decimal num3 = 0m;
                                decimal.TryParse(this.cb2ValueTrailingStop.Text, out num3);
                                string text3 = this.cb2PriceSMA.Text.Trim();
                                if (num2 == -1)
                                {
                                    this.ShowMessageBox("Invalid operator condition", frmOrderFormConfirm.OpenStyle.Error, null);
                                    return;
                                }
                                if (num3 <= 0m)
                                {
                                    this.ShowMessageBox("Invalid price condition", frmOrderFormConfirm.OpenStyle.Error, this.cb2ValueTrailingStop);
                                    return;
                                }
                                if (!this.cb2ValueTrailingStop.Items.Contains(num3.ToString()))
                                {
                                    this.ShowMessageBox("Invalid preriod condition", frmOrderFormConfirm.OpenStyle.Error, this.cb2ValueTrailingStop);
                                    return;
                                }
                                string text4 = text3;
                                if (text4 != null)
                                {
                                    if (text4 == "MP")
                                    {
                                        goto IL_D36;
                                    }
                                }
                                if (!this.IsValidPrice(text3, true, this.cb2PriceSMA))
                                {
                                    return;
                                }
                            IL_D36:
                                AutoTradeItem item2 = new AutoTradeItem(0L, 2, "ALG2", ApplicationInfo.UserLoginID, text2, text, num2, num3, -1m, ApplicationInfo.AccInfo.CurrentAccount, this._ordSide, num, text3, string.Empty, ApplicationInfo.AccInfo.Items[ApplicationInfo.AccInfo.CurrentAccount].PcFlag, isGroupRemove);
                                list.Add(item2);
                                text6 = string.Concat(new object[]
                                {
                                    text6,
                                    (text6 != string.Empty) ? "\n" : "",
                                    "Trailing Stop : ",
                                    this.cb2OperTrailingStop.Text,
                                    " Period(",
                                    num3,
                                    ")"
                                });
                            }
                            if (this.chb2CutLossCond.Checked)
                            {
                                int num2 = 4;
                                decimal num3 = 0m;
                                decimal.TryParse(this.cb2ValueCutloss.Text, out num3);
                                string text3 = this.cb2PriceBreak.Text.Trim();
                                string text = string.Empty;
                                if (this.cb2OperCutloss.Text.ToLower().IndexOf("low") > -1)
                                {
                                    text = "LLV";
                                }
                                else if (this.cb2OperCutloss.Text.ToLower().IndexOf("last") > -1)
                                {
                                    text = "LAST";
                                }
                                if (num2 == -1)
                                {
                                    this.ShowMessageBox("Invalid operator condition", frmOrderFormConfirm.OpenStyle.Error, null);
                                    return;
                                }
                                if (num3 <= 0m)
                                {
                                    this.ShowMessageBox("Invalid price condition", frmOrderFormConfirm.OpenStyle.Error, this.cb2ValueCutloss);
                                    return;
                                }
                                if (text == "LLV")
                                {
                                    if (!this.cb2ValueCutloss.Items.Contains(num3.ToString()))
                                    {
                                        this.ShowMessageBox("Invalid preriod condition", frmOrderFormConfirm.OpenStyle.Error, this.cb2ValueCutloss);
                                        return;
                                    }
                                }
                                string text4 = text3;
                                if (text4 != null)
                                {
                                    if (text4 == "MP")
                                    {
                                        goto IL_FAB;
                                    }
                                }
                                if (!this.IsValidPrice(text3, true, this.cb2PriceBreak))
                                {
                                    return;
                                }
                            IL_FAB:
                                AutoTradeItem item3 = new AutoTradeItem(0L, 3, "ALG2", ApplicationInfo.UserLoginID, text2, text, num2, num3, -1m, ApplicationInfo.AccInfo.CurrentAccount, this._ordSide, num, text3, string.Empty, ApplicationInfo.AccInfo.Items[ApplicationInfo.AccInfo.CurrentAccount].PcFlag, isGroupRemove);
                                list.Add(item3);
                                text6 = text6 + ((text6 != string.Empty) ? "\n" : "") + ("Cut loss       : " + this.cb2OperCutloss.Text) + ((text == "LAST") ? (" " + num3) : (" Period(" + num3 + ")"));
                            }
                            if (autoTradeT2Command.ExpireDays < 1)
                            {
                                this.ShowMessageBox("Invalid Expire!", frmOrderFormConfirm.OpenStyle.Error, this.cbExpire);
                            }
                            else if (list.Count > 0)
                            {
                                if (num <= 0L)
                                {
                                    this.ShowMessageBox("Invalid Volume [More than Zero]!", frmOrderFormConfirm.OpenStyle.Error, this.tb2Volume);
                                }
                                else
                                {
                                    autoTradeT2Command.Items = list;
                                    this._commandMain = new AutoTradeMain();
                                    this._commandMain.Pack("T2", autoTradeT2Command);
                                    string orderParam = string.Concat(new string[]
                                    {
                                        "Auto Trade :",
                                        " Account : ",
                                        ApplicationInfo.AccInfo.CurrentAccount,
                                        "  ",
                                        Utilities.GetOrderSideName(this._ordSide),
                                        " : ‘",
                                        text2,
                                        "’",
                                        "  Volume : ",
                                        FormatUtil.VolumeFormat(num, true),
                                        "\nCondition : \n",
                                        text6
                                    });
                                    this.ShowOrderFormConfirm("Confirm to send?", orderParam, frmOrderFormConfirm.OpenStyle.ConfirmSendNew);
                                }
                            }
                            else
                            {
                                this.ShowMessageBox("Can not create command Please check the terms!", frmOrderFormConfirm.OpenStyle.Error, null);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                this.ShowError("btnSendOrder_Click", ex);
            }
        }
Пример #3
0
 private void btnPzCancel_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.gridPzMain.FocusItemIndex > -1 && AutoTradeConstant.GetStatusByName(this.gridPzMain.Records(this.gridPzMain.FocusItemIndex).Fields("status").Text.ToString(), this._typeId) == "ST")
         {
             RecordItem recordItem = this.gridPzMain.Records(this.gridPzMain.FocusItemIndex);
             long num;
             long.TryParse(recordItem.Fields("refno").Text.ToString(), out num);
             string text = recordItem.Fields("stock").Text.ToString();
             AutoTradePzCommand autoTradePzCommand = new AutoTradePzCommand();
             autoTradePzCommand.RefNo = num;
             autoTradePzCommand.Symbol = text;
             autoTradePzCommand.CommandType = "CANCEL";
             autoTradePzCommand.Items = new List<AutoTradePzItem>();
             this._commandMain = new AutoTradeMain();
             this._commandMain.Pack("PZ", autoTradePzCommand);
             string orderParam = string.Concat(new object[]
             {
                 "Pricing Zone :",
                 "Cancel Pricing Zone , Reference no ",
                 num,
                 "\nStock : ‘",
                 text,
                 "’"
             });
             this.ShowOrderFormConfirm("Do you want to cancel?\r\n", orderParam, frmOrderFormConfirm.OpenStyle.ConfirmCancel);
         }
         else
         {
             this.ShowMessageBox("Can not find the item you want to cancel.", frmOrderFormConfirm.OpenStyle.ShowBox, null);
         }
     }
     catch (Exception ex)
     {
         this.ShowError("btn3Cancel_Click", ex);
     }
 }
Пример #4
0
 private void CallCancelOrder()
 {
     if (base.InvokeRequired)
     {
         base.BeginInvoke(new MethodInvoker(this.CallCancelOrder));
     }
     else
     {
         try
         {
             AutoTradeCancelCommand autoTradeCancelCommand = new AutoTradeCancelCommand();
             autoTradeCancelCommand.UserId = ApplicationInfo.UserLoginID;
             autoTradeCancelCommand.CommandType = this._typeId;
             for (int i = 0; i < this.intzaOrder.Rows; i++)
             {
                 if (this.intzaOrder.Records(i).Fields("checkbox").Text.ToString() == "1")
                 {
                     autoTradeCancelCommand.Items.Add(new AutoTradeCancelCommand.CancelItem(Convert.ToInt64(this.intzaOrder.Records(i).Fields("ref_no").Text), this.intzaOrder.Records(i).Fields("stock").Text.ToString()));
                 }
             }
             if (autoTradeCancelCommand.Items.Count == 0 && this.intzaOrder.FocusItemIndex > -1)
             {
                 RecordItem recordItem = this.intzaOrder.Records(this.intzaOrder.FocusItemIndex);
                 if (recordItem.Fields("checkbox").Text.ToString() == "0")
                 {
                     autoTradeCancelCommand.Items.Add(new AutoTradeCancelCommand.CancelItem(Convert.ToInt64(recordItem.Fields("ref_no").Text), recordItem.Fields("stock").Text.ToString()));
                 }
             }
             if (autoTradeCancelCommand.Items.Count > 0)
             {
                 this._commandMain = new AutoTradeMain();
                 this._commandMain.Pack("AX", autoTradeCancelCommand);
                 this.ShowOrderFormConfirm("Do you want to cancel?", "", frmOrderFormConfirm.OpenStyle.ConfirmCancel);
             }
             else
             {
                 this.ShowMessageBox("Can not find the item you want to cancel.", frmOrderFormConfirm.OpenStyle.ShowBox, null);
             }
         }
         catch (Exception ex)
         {
             this.ShowError("CallCancelOrder", ex);
         }
     }
 }
Пример #5
0
 private void bgwSendOrder_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         if (ApplicationInfo.IsEquityAccount)
         {
             if (this._verifyResult_Pin)
             {
                 if (this._verifyResult)
                 {
                     if (this._commandType == "V")
                     {
                         try
                         {
                             if (this._dsSendOrder != null && this._dsSendOrder.Tables.Contains("verify_result") && this._dsSendOrder.Tables["verify_result"].Rows.Count > 0)
                             {
                                 int num = Convert.ToInt32(this._dsSendOrder.Tables["verify_result"].Rows[0]["result_code"]);
                                 string message = this._dsSendOrder.Tables["verify_result"].Rows[0]["result_message"].ToString();
                                 int num2 = 0;
                                 int.TryParse(this._dsSendOrder.Tables["verify_result"].Rows[0]["verify_code"].ToString(), out num2);
                                 if (num == 1)
                                 {
                                     StockList.StockInformation stockInfo = ApplicationInfo.StockInfo[this._OrdSymbol];
                                     this._retOrderMessage = string.Concat(new string[]
                                     {
                                         "Account : ",
                                         ApplicationInfo.AccInfo.CurrentAccount,
                                         "\n",
                                         Utilities.GetOrderSideName(this._OrdSide),
                                         " : ‘",
                                         this._OrdSymbol,
                                         "’",
                                         "\nVolume : ",
                                         FormatUtil.VolumeFormat(this._OrdVolume, true),
                                         "\nPrice : ",
                                         this._OrdPrice,
                                         (this._OrdTtf != 0) ? (" ,Trustee Id " + this._OrdTtf) : "",
                                         "\nTotal Amount :  ",
                                         this.CalculateValue(this._OrdVolume, this._OrdPrice, this._OrdSide, stockInfo),
                                         "   (Commission and VAT not included)"
                                     });
                                     if (ApplicationInfo.SupportOrderTimes && this._OrdTimes > 0)
                                     {
                                         this._currTimes = 1;
                                         message = string.Concat(new object[]
                                         {
                                             this._retOrderMessage,
                                             ", Times : ",
                                             this._currTimes,
                                             "/",
                                             this._OrdTimes
                                         });
                                     }
                                     this.ShowOrderFormConfirm("Confirm to send?" + ((this._currTimes + 1 <= this._OrdTimes) ? string.Concat(new object[]
                                     {
                                         " *** Times : ",
                                         this._currTimes,
                                         "/",
                                         this._OrdTimes
                                     }) : ""), this._retOrderMessage, this._dsSendOrder.Tables["verify_result"].Rows[0]["oss"].ToString(), this._dsSendOrder.Tables["verify_result"].Rows[0]["stock_threshold"].ToString());
                                 }
                                 else
                                 {
                                     this._objLastActive = this.cbPrice;
                                     this.ShowMessageInFormConfirm(message, frmOrderFormConfirm.OpenStyle.ShowBox);
                                 }
                                 this._dsSendOrder.Clear();
                             }
                             else
                             {
                                 this.ShowMessageInFormConfirm("An error is detected.", frmOrderFormConfirm.OpenStyle.ShowBox);
                                 this.DoClear();
                             }
                         }
                         catch (Exception ex)
                         {
                             this.ShowMessageInFormConfirm(ex.Message, frmOrderFormConfirm.OpenStyle.ShowBox);
                         }
                     }
                     else if (this._commandType == "S")
                     {
                         try
                         {
                             if (this._newOrderResult.OrderNo > 0L)
                             {
                                 this._returnOrderNumberFromServer = this._newOrderResult.OrderNo;
                                 if (ApplicationInfo.SupportFreewill)
                                 {
                                     this.ShowSplash(true, "New Order Reference no. " + this._newOrderResult.OrderNo, true);
                                 }
                                 else
                                 {
                                     this.ShowSplash(true, "New Order Number " + this._newOrderResult.OrderNo, true);
                                 }
                                 ApplicationInfo.AddOrderNoToAutoRefreshList(this._newOrderResult.OrderNo.ToString(), this._newOrderResult.IsFwOfflineOrder ? 3 : 1);
                                 if (this._newOrderResult.IsAutoStopLoss)
                                 {
                                     AutoTradeItem item = new AutoTradeItem("MM", ApplicationInfo.UserLoginID, this._OrdSymbol, "LAST", 2, this._OrdStopPrice, this._OrdStopPrice, ApplicationInfo.AccInfo.CurrentAccount, "S", Convert.ToInt64(this.tbMMVolume.Text.Replace(",", "")), "MP", ApplicationInfo.AccInfo.Items[ApplicationInfo.AccInfo.CurrentAccount].PcFlag, "N");
                                     AutoTradeMMCommand autoTradeMMCommand = new AutoTradeMMCommand();
                                     autoTradeMMCommand.IsCancel = false;
                                     autoTradeMMCommand.OrderNoPending = this._newOrderResult.OrderNo;
                                     autoTradeMMCommand.Item = item;
                                     AutoTradeMain autoTradeMain = new AutoTradeMain();
                                     string message2 = autoTradeMain.Pack("MM", autoTradeMMCommand);
                                     ApplicationInfo.WebAlertService.SendAutoTradeCompleted -= new SendAutoTradeCompletedEventHandler(this.WebAlertService_SendAutoTradeCompleted);
                                     ApplicationInfo.WebAlertService.SendAutoTradeCompleted += new SendAutoTradeCompletedEventHandler(this.WebAlertService_SendAutoTradeCompleted);
                                     ApplicationInfo.WebAlertService.SendAutoTradeAsync(message2);
                                 }
                             }
                             else
                             {
                                 this.ShowMessageInFormConfirm("Fail >> " + this._newOrderResult.ResultMessage, frmOrderFormConfirm.OpenStyle.ShowBox);
                             }
                             if (ApplicationInfo.SupportOrderTimes)
                             {
                                 if (this._currTimes + 1 <= this._OrdTimes)
                                 {
                                     if (ApplicationInfo.SupportFreewill)
                                     {
                                         return;
                                     }
                                     this._currTimes++;
                                     Thread thread = new Thread(new ThreadStart(this.threadSendTimes));
                                     thread.Start();
                                     return;
                                 }
                             }
                             this.DoClear();
                             this.cbStock.Focus();
                             this.cbStock.SelectAll();
                         }
                         catch (Exception ex)
                         {
                             this.ShowMessageInFormConfirm("SendNewOrder:" + ex.Message, frmOrderFormConfirm.OpenStyle.ShowBox);
                         }
                     }
                 }
             }
             else if (ApplicationInfo.UserPincodeWrongCount < ApplicationInfo.UserMaxRetryPincode)
             {
                 this.ShowMessageInFormConfirm(this._verifyResultStr_Pin, frmOrderFormConfirm.OpenStyle.ShowBox, this.tbPin);
                 this.tbPin.Focus();
             }
             else if (this._verifyResultStr_Pin == ApplicationInfo.PINCODE_TIMEOUT)
             {
                 this.ShowMessageInFormConfirm("*** Pincode timeout. ***\nPlease entry again!", frmOrderFormConfirm.OpenStyle.ShowBox, this.tbPin);
             }
             else
             {
                 this.ShowMessageInFormConfirm("*** Pincode Locked. ***\nPlease logout and login again!", frmOrderFormConfirm.OpenStyle.ShowBox);
             }
         }
         else
         {
             try
             {
                 if (this._commandType == "S")
                 {
                     if (this._dsSendOrderTfex != null && this._dsSendOrderTfex.Tables.Contains("Results") && this._dsSendOrderTfex.Tables["Results"].Rows.Count > 0)
                     {
                         DataRow dataRow = this._dsSendOrderTfex.Tables["Results"].Rows[0];
                         long num3 = 0L;
                         long.TryParse(dataRow["Code"].ToString(), out num3);
                         if (num3 > 0L)
                         {
                             this._returnOrderNumberFromServer_TFEX = num3;
                             ApplicationInfo.AddOrderNoToAutoRefreshList_TFEX(num3.ToString());
                         }
                         else
                         {
                             this.ShowMessageInFormConfirm(dataRow["message"].ToString(), frmOrderFormConfirm.OpenStyle.ShowBox);
                         }
                         this._dsSendOrderTfex.Clear();
                     }
                     else
                     {
                         this.ShowMessageInFormConfirm("Send new order Unsuccessful!!!", frmOrderFormConfirm.OpenStyle.ShowBox);
                     }
                     this.DoClear_TFEX();
                     this.tbSeries.Focus();
                     this.tbSeries.SelectAll();
                 }
             }
             catch (Exception ex)
             {
                 this.ShowError("bgwSendOrder_RunWorkerCompleted", ex);
             }
         }
     }
 }
Пример #6
0
 private void bgwSendOrder_DoWork(object sender, DoWorkEventArgs e)
 {
     string result = string.Empty;
     try
     {
         string text = this.tbPin.Text.Trim();
         if (text == string.Empty)
         {
             this._verifyResult_Pin = false;
             this._verifyResultStr_Pin = "Pincode is empty!!!";
             return;
         }
         if (ApplicationInfo.UserPincodeWrongCount < ApplicationInfo.UserMaxRetryPincode)
         {
             this._verifyResult_Pin = ApplicationInfo.VerifyPincode(text, ref this._verifyResultStr_Pin);
         }
         if (this._verifyResult_Pin)
         {
             AutoTradeMain autoTradeMain = new AutoTradeMain();
             autoTradeMain.Pack("PZ", this._commPz);
             result = ApplicationInfo.WebAlertService.SendAutoTrade(autoTradeMain.ToMessage());
         }
     }
     catch (Exception ex)
     {
         this.ShowError("bgwSendOrder_DoWork", ex);
         result = ex.Message;
     }
     e.Result = result;
 }