/// <summary>
        /// 
        /// </summary>
        /// <param name="TakeProfit"></param>
        /// <param name="StopLoss"></param>
        /// <param name="CommandOnlineID"></param>
        /// <returns></returns>
        internal bool UpdateTakeProfit(double TakeProfit, double StopLoss, int OnlineCommandID,string comment,double openPrice)
        {
            bool Result = false;
            System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection);
            DSTableAdapters.OnlineCommandTableAdapter adap = new DSTableAdapters.OnlineCommandTableAdapter();

            try
            {
                conn.Open();
                adap.Connection = conn;
                int NumberUpdate = adap.UpdateTakeProfit(StopLoss, TakeProfit, comment, openPrice, OnlineCommandID);
                if (NumberUpdate > 0)
                    Result = true;
            }
            catch (Exception ex)
            {
                return false;
            }
            finally
            {
                adap.Connection.Close();
                conn.Close();
            }

            return Result;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="listOpenTrade"></param>
        /// <returns></returns>
        internal bool MultipleUpdateOpenTrade(List<TradingServer.Business.OpenTrade> listOpenTrade,double stopLoss,double takeProfit)
        {
            List<string> listMessage = new List<string>();
            bool result = false;
            System.Data.SqlClient.SqlConnection conn = new SqlConnection(DBConnection.DBConnection.Connection);
            DSTableAdapters.OnlineCommandTableAdapter adapOnline = new DSTableAdapters.OnlineCommandTableAdapter();
            SqlTransaction tran;
            conn.Open();
            adapOnline.Connection = conn;
            tran = conn.BeginTransaction();
            adapOnline.Transaction = tran;

            try
            {
                if (listOpenTrade != null)
                {
                    int count = listOpenTrade.Count;
                    for (int i = 0; i < count; i++)
                    {
                        bool isBuy = false;
                        string commandType = "SellSpotCommand";
                        if (listOpenTrade[i].Type.ID == 1 || listOpenTrade[i].Type.ID == 11)
                        {
                            isBuy = true;
                            commandType = "BuySpotCommand";
                        }

                        double tempStopLoss = 0;
                        double tempTakeProfit = 0;
                        if (listOpenTrade[i].Type.ID == 2 || listOpenTrade[i].Type.ID == 12)
                        {
                            tempStopLoss = takeProfit;
                            tempTakeProfit = stopLoss;
                        }
                        else
                        {
                            tempStopLoss = stopLoss;
                            tempTakeProfit = takeProfit;
                        }

                        int resultUpdate = adapOnline.UpdateTakeProfit(tempStopLoss, tempTakeProfit, "[update s/l and t/p]", listOpenTrade[i].OpenPrice, listOpenTrade[i].ID);

                        if (resultUpdate > 0)
                        {
                            bool updateOnline = listOpenTrade[i].Investor.MultipleUpdateCommand(listOpenTrade[i], tempStopLoss, tempTakeProfit);

                            if (!updateOnline)
                            {
                                #region Map Command Server To Client
                                string Message = "UpdateCommand$False,Update Command UnComplete," + listOpenTrade[i].ID + "," +
                                    listOpenTrade[i].Investor.InvestorID + "," + listOpenTrade[i].Symbol.Name + "," + listOpenTrade[i].Size + "," +
                                    isBuy + "," + listOpenTrade[i].OpenTime + "," + listOpenTrade[i].OpenPrice + "," + tempStopLoss + "," +
                                    tempTakeProfit + "," + listOpenTrade[i].ClosePrice + "," + listOpenTrade[i].Commission + "," +
                                    listOpenTrade[i].Swap + "," + listOpenTrade[i].Profit + "," + "Comment," + listOpenTrade[i].ID + "," + commandType + "," + 1 + "," +
                                    listOpenTrade[i].ExpTime + "," + listOpenTrade[i].ClientCode + "," + listOpenTrade[i].CommandCode + "," +
                                    listOpenTrade[i].IsHedged + "," + listOpenTrade[i].Type.ID + "," + listOpenTrade[i].Margin + ",UpdatePendingOrder";

                                listMessage = new List<string>();
                                listMessage.Add(Message);
                                #endregion

                                tran.Rollback();
                                return false;
                            }
                            else
                            {
                                listOpenTrade[i].StopLoss = tempStopLoss;
                                listOpenTrade[i].TakeProfit = tempTakeProfit;

                                #region Map Command Server To Client
                                string Message = "UpdateCommand$True,Update Command Complete," + listOpenTrade[i].ID + "," +
                                    listOpenTrade[i].Investor.InvestorID + "," + listOpenTrade[i].Symbol.Name + "," + listOpenTrade[i].Size + "," +
                                    isBuy + "," + listOpenTrade[i].OpenTime + "," + listOpenTrade[i].OpenPrice + "," + tempStopLoss + "," +
                                    tempTakeProfit + "," + listOpenTrade[i].ClosePrice + "," + listOpenTrade[i].Commission + "," +
                                    listOpenTrade[i].Swap + "," + listOpenTrade[i].Profit + "," + "Comment," + listOpenTrade[i].ID + "," + commandType + "," + 1 + "," +
                                    listOpenTrade[i].ExpTime + "," + listOpenTrade[i].ClientCode + "," + listOpenTrade[i].CommandCode + "," +
                                    listOpenTrade[i].IsHedged + "," + listOpenTrade[i].Type.ID + "," + listOpenTrade[i].Margin + ",UpdatePendingOrder";

                                listMessage.Add(Message);
                                #endregion
                            }
                        }
                        else
                        {
                            tran.Rollback();
                            return false;
                        }
                    }
                }

                if (listMessage != null)
                {
                    int count = listMessage.Count;
                    for (int i = 0; i < count; i++)
                    {
                        listOpenTrade[0].Investor.ClientCommandQueue.Add(listMessage[i]);
                    }
                }

                if (listOpenTrade != null)
                {
                    int countCommand = listOpenTrade.Count;
                    for (int i = 0; i < countCommand; i++)
                    {
                        //SEND NOTIFY TO MANAGER
                        TradingServer.Facade.FacadeSendNoticeManagerRequest(1, listOpenTrade[i]);
                    }
                }

                tran.Commit();
                result = true;
            }
            catch (Exception ex)
            {
                tran.Rollback();
                return false;
            }
            finally
            {
                tran.Dispose();
                adapOnline.Connection.Close();
                conn.Close();
            }

            return result;
        }