/// <summary>
        /// 
        /// </summary>
        /// <param name="RowNumber"></param>
        /// <returns></returns>
        internal List<Business.Investor> GetInvestorByStartEnd(int RowNumber,int Limit)
        {
            List<Business.Investor> Result = new List<Business.Investor>();
            System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection);
            DSTableAdapters.InvestorTableAdapter adap = new DSTableAdapters.InvestorTableAdapter();
            DSTableAdapters.InvestorProfileTableAdapter adapInvestorProfile = new DSTableAdapters.InvestorProfileTableAdapter();
            DS.InvestorDataTable tbInvestor = new DS.InvestorDataTable();
            DS.InvestorProfileDataTable tbInvestorProfile = new DS.InvestorProfileDataTable();

            try
            {
                conn.Open();
                adap.Connection = conn;
                adapInvestorProfile.Connection = conn;
                tbInvestor = adap.GetInvestorByStartEnd(RowNumber, Limit);
                if (tbInvestor != null)
                {
                    int count = tbInvestor.Count;
                    for (int i = 0; i < count; i++)
                    {
                        tbInvestorProfile = adapInvestorProfile.GetInvestorProfileByInvestorID(tbInvestor[i].InvestorID);

                        Business.Investor newInvestor = new Business.Investor();
                        newInvestor.InvestorID = tbInvestor[i].InvestorID;
                        newInvestor.AgentID = tbInvestor[i].AgentID;
                        //Fill Investor Group Instance
                        if (Business.Market.InvestorGroupList != null)
                        {
                            int countInvestorGroup = Business.Market.InvestorGroupList.Count;
                            for (int j = 0; j < countInvestorGroup; j++)
                            {
                                if (Business.Market.InvestorGroupList[j].InvestorGroupID == tbInvestor[i].InvestorGroupID)
                                {
                                    newInvestor.InvestorGroupInstance = Business.Market.InvestorGroupList[j];
                                    break;
                                }
                            }
                        }

                        //newInvestor.InvestorGroupInstance = TradingServer.Facade.FacadeGetInvestorGroupByInvestorGroupID(tbInvestor[i].InvestorGroupID);
                        newInvestor.InvestorStatusID = tbInvestor[i].InvestorStatusID;
                        newInvestor.Balance = tbInvestor[i].Balance;
                        newInvestor.Code = tbInvestor[i].Code;
                        newInvestor.Credit = tbInvestor[i].Credit;
                        newInvestor.IsDisable = tbInvestor[i].IsDisible;
                        newInvestor.TaxRate = tbInvestor[i].TaxRate;
                        newInvestor.Leverage = tbInvestor[i].Leverage;
                        newInvestor.PreviousLedgerBalance = tbInvestor[i].PreviousLedgerBalance;
                        newInvestor.UserConfig = tbInvestor[i].UserConfig;
                        newInvestor.RefInvestorID = tbInvestor[i].RefInvestorID;

                        //Add Data InvestorProfile To Result
                        if (tbInvestorProfile != null && tbInvestorProfile.Count > 0)
                        {
                            newInvestor.InvestorProfileID = tbInvestorProfile[0].InvestorProfileID;
                            newInvestor.Address = tbInvestorProfile[0].Address;
                            newInvestor.City = tbInvestorProfile[0].City;
                            newInvestor.InvestorComment = tbInvestorProfile[0].Comment;
                            newInvestor.Country = tbInvestorProfile[0].Country;
                            newInvestor.Email = tbInvestorProfile[0].Email;
                            newInvestor.NickName = tbInvestorProfile[0].NickName;
                            newInvestor.Phone = tbInvestorProfile[0].Phone;
                            newInvestor.RegisterDay = tbInvestorProfile[0].RegisterDay;
                            newInvestor.State = tbInvestorProfile[0].State;
                            newInvestor.ZipCode = tbInvestorProfile[0].ZipCode;
                            newInvestor.IDPassport = tbInvestorProfile[0].IDPassport;
                        }

                        Result.Add(newInvestor);
                    }
                }
            }
            catch (Exception ex)
            {
                return null;
            }
            finally
            {
                adap.Connection.Close();
                adapInvestorProfile.Connection.Close();
                conn.Close();
            }

            return Result;
        }
        /// <summary>
        /// Get Investor By Investor ID
        /// </summary>
        /// <param name="InvestorID">int InvestorID</param>
        /// <returns>Business.Investor</returns>
        internal Business.Investor GetInvestorByInvestorID(int InvestorID)
        {
            Business.Investor Result = new Business.Investor();
            System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection);
            DSTableAdapters.InvestorTableAdapter adap = new DSTableAdapters.InvestorTableAdapter();
            DS.InvestorDataTable tbInvestor = new DS.InvestorDataTable();
            DSTableAdapters.InvestorProfileTableAdapter adapInvestorProfile = new DSTableAdapters.InvestorProfileTableAdapter();
            DS.InvestorProfileDataTable tbInvestorProfile = new DS.InvestorProfileDataTable();

            try
            {
                conn.Open();
                adap.Connection = conn;
                adapInvestorProfile.Connection = conn;
                tbInvestor = adap.GetInvestorByInvestorID(InvestorID);

                if (tbInvestor != null)
                {
                    tbInvestorProfile = adapInvestorProfile.GetInvestorProfileByInvestorID(tbInvestor[0].InvestorID);

                    if (tbInvestorProfile != null)
                    {
                        //Add Data Investor To Result
                        Result.InvestorID = tbInvestor[0].InvestorID;
                        Result.AgentID = tbInvestor[0].AgentID;
                        //Result.InvestorGroupInstance = TradingServer.Facade.FacadeGetInvestorGroupByInvestorGroupID(tbInvestor[0].InvestorGroupID);

                        if (Business.Market.InvestorGroupList != null)
                        {
                            int countInvestorGroup = Business.Market.InvestorGroupList.Count;
                            for (int j = 0; j < countInvestorGroup; j++)
                            {
                                if (Business.Market.InvestorGroupList[j].InvestorGroupID == tbInvestor[0].InvestorGroupID)
                                {
                                    Result.InvestorGroupInstance = Business.Market.InvestorGroupList[j];

                                    break;
                                }
                            }
                        }
                        Result.InvestorStatusID = tbInvestor[0].InvestorStatusID;
                        Result.Balance = tbInvestor[0].Balance;
                        Result.Code = tbInvestor[0].Code;
                        Result.Credit = tbInvestor[0].Credit;
                        Result.IsDisable = tbInvestor[0].IsDisible;
                        Result.TaxRate = tbInvestor[0].TaxRate;
                        Result.Leverage = tbInvestor[0].Leverage;
                        Result.PreviousLedgerBalance = tbInvestor[0].PreviousLedgerBalance;
                        Result.UserConfig = tbInvestor[0].UserConfig;
                        Result.RefInvestorID = tbInvestor[0].RefInvestorID;

                        //Add Data InvestorProfile To Result
                        Result.Address = tbInvestorProfile[0].Address;
                        Result.City = tbInvestorProfile[0].City;
                        Result.InvestorComment = tbInvestorProfile[0].Comment;
                        Result.Country = tbInvestorProfile[0].Country;
                        Result.Email = tbInvestorProfile[0].Email;
                        Result.NickName = tbInvestorProfile[0].NickName;
                        Result.Phone = tbInvestorProfile[0].Phone;
                        Result.RegisterDay = tbInvestorProfile[0].RegisterDay;
                        Result.State = tbInvestorProfile[0].State;
                        Result.ZipCode = tbInvestorProfile[0].ZipCode;
                        Result.IDPassport = tbInvestorProfile[0].IDPassport;
                    }
                }
            }
            catch (Exception ex)
            {
                return null;
            }
            finally
            {
                adap.Connection.Close();
                conn.Close();
            }

            return Result;
        }
        /// <summary>
        /// Get All Investor Profile
        /// </summary>
        /// <returns>List<Business.InvestorProfile</returns>
        internal List<Business.Investor> GetAllInvestorProfile()
        {
            List<Business.Investor> Result = new List<Business.Investor>();
            System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection);
            DSTableAdapters.InvestorProfileTableAdapter adap = new DSTableAdapters.InvestorProfileTableAdapter();
            DS.InvestorProfileDataTable tbInvestorProfile = new DS.InvestorProfileDataTable();

            try
            {
                conn.Open();
                adap.Connection = conn;

                tbInvestorProfile = adap.GetData();
                if (tbInvestorProfile != null)
                {
                    int count = tbInvestorProfile.Count;
                    for (int i = 0; i < count; i++)
                    {
                        Business.Investor newInvestorProfile = new Business.Investor();
                        newInvestorProfile.InvestorID = tbInvestorProfile[i].InvestorID;
                        newInvestorProfile.Address = tbInvestorProfile[i].Address;
                        newInvestorProfile.Phone = tbInvestorProfile[i].Phone;
                        newInvestorProfile.City = tbInvestorProfile[i].City;
                        newInvestorProfile.Country = tbInvestorProfile[i].Country;
                        newInvestorProfile.Email = tbInvestorProfile[i].Email;
                        newInvestorProfile.ZipCode = tbInvestorProfile[i].ZipCode;
                        newInvestorProfile.RegisterDay = tbInvestorProfile[i].RegisterDay;
                        newInvestorProfile.InvestorComment = tbInvestorProfile[i].Comment;
                        newInvestorProfile.State = tbInvestorProfile[i].State;
                        newInvestorProfile.NickName = tbInvestorProfile[i].NickName;
                        newInvestorProfile.IDPassport = tbInvestorProfile[i].IDPassport;

                        Result.Add(newInvestorProfile);
                    }
                }
            }
            catch (Exception ex)
            {
                return null;
            }
            finally
            {
                adap.Connection.Close();
                conn.Close();
            }

            return Result;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="Code"></param>
        /// <returns></returns>
        internal Business.Investor SelectInvestorByCode(string Code)
        {
            Business.Investor newInvestor = new Business.Investor();
            System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection);
            DSTableAdapters.InvestorTableAdapter adap = new DSTableAdapters.InvestorTableAdapter();
            DS.InvestorDataTable tbInvestor = new DS.InvestorDataTable();
            DSTableAdapters.InvestorProfileTableAdapter adapProfile = new DSTableAdapters.InvestorProfileTableAdapter();
            DS.InvestorProfileDataTable tbInvestorProfile = new DS.InvestorProfileDataTable();

            try
            {
                conn.Open();
                adap.Connection = conn;
                adapProfile.Connection = conn;
                tbInvestor = adap.SelectInvestorByCode(Code);

                if (tbInvestor != null)
                {
                    tbInvestorProfile = adapProfile.GetInvestorProfileByInvestorID(tbInvestor[0].InvestorID);

                    if (tbInvestorProfile != null && tbInvestorProfile.Count > 0)
                    {
                        newInvestor.InvestorProfileID = tbInvestorProfile[0].InvestorProfileID;
                        newInvestor.Address = tbInvestorProfile[0].Address;
                        newInvestor.Phone = tbInvestorProfile[0].Phone;
                        newInvestor.City = tbInvestorProfile[0].City;
                        newInvestor.Country = tbInvestorProfile[0].Country;
                        newInvestor.Email = tbInvestorProfile[0].Email;
                        newInvestor.ZipCode = tbInvestorProfile[0].ZipCode;
                        newInvestor.RegisterDay = tbInvestorProfile[0].RegisterDay;
                        newInvestor.InvestorComment = tbInvestorProfile[0].Comment;
                        newInvestor.State = tbInvestorProfile[0].State;
                        newInvestor.NickName = tbInvestorProfile[0].NickName;
                        newInvestor.IDPassport = tbInvestorProfile[0].IDPassport;
                    }
                    else
                    {
                        newInvestor.InvestorProfileID = -1;
                        newInvestor.Address = "NaN";
                        newInvestor.Phone = "NaN";
                        newInvestor.City = "NaN";
                        newInvestor.Country = "NaN";
                        newInvestor.Email = "NaN";
                        newInvestor.ZipCode = "NaN";
                        newInvestor.RegisterDay = DateTime.Now;
                        newInvestor.InvestorComment = "NaN";
                        newInvestor.State = "NaN";
                        newInvestor.NickName = "NaN";
                        newInvestor.IDPassport = "";
                    }
                    newInvestor.InvestorID = tbInvestor[0].InvestorID;
                    newInvestor.InvestorStatusID = tbInvestor[0].InvestorStatusID;
                    //newInvestor.InvestorGroupInstance = TradingServer.Facade.FacadeGetInvestorGroupByInvestorGroupID(tbInvestor[0].InvestorGroupID);

                    if (Business.Market.InvestorGroupList != null)
                    {
                        int countInvestorGroup = Business.Market.InvestorGroupList.Count;
                        for (int j = 0; j < countInvestorGroup; j++)
                        {
                            if (Business.Market.InvestorGroupList[j].InvestorGroupID == tbInvestor[0].InvestorGroupID)
                            {
                                newInvestor.InvestorGroupInstance = Business.Market.InvestorGroupList[j];
                                break;
                            }
                        }
                    }

                    newInvestor.AgentID = tbInvestor[0].AgentID;
                    newInvestor.Balance = tbInvestor[0].Balance;
                    newInvestor.Credit = tbInvestor[0].Credit;
                    newInvestor.Code = tbInvestor[0].Code;
                    newInvestor.IsDisable = tbInvestor[0].IsDisible;
                    newInvestor.TaxRate = tbInvestor[0].TaxRate;
                    newInvestor.Leverage = tbInvestor[0].Leverage;
                    newInvestor.AllowChangePwd = tbInvestor[0].AllowChangePwd;
                    newInvestor.ReadOnly = tbInvestor[0].ReadOnly;
                    newInvestor.SendReport = tbInvestor[0].SendReport;
                    newInvestor.PreviousLedgerBalance = tbInvestor[0].PreviousLedgerBalance;
                    newInvestor.PhonePwd = tbInvestor[0].PhonePwd;
                }
            }
            catch (Exception ex)
            {
                return null;
            }
            finally
            {
                adap.Connection.Close();
                adapProfile.Connection.Close();
                conn.Close();
            }

            return newInvestor;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="code"></param>
        /// <param name="readPwd"></param>
        /// <returns></returns>
        internal Business.Investor LoginWithReadPwd(string code, string readPwd)
        {
            Business.Investor result = new Business.Investor();
            System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection);
            DSTableAdapters.InvestorTableAdapter adap = new DSTableAdapters.InvestorTableAdapter();
            DSTableAdapters.InvestorProfileTableAdapter adapInvestorProfile = new DSTableAdapters.InvestorProfileTableAdapter();
            DS.InvestorDataTable tbInvestor = new DS.InvestorDataTable();
            DS.InvestorProfileDataTable tbInvestorProfile = new DS.InvestorProfileDataTable();

            try
            {
                conn.Open();
                adap.Connection = conn;
                adapInvestorProfile.Connection = conn;
                tbInvestor = adap.LoginWithReadPwd(code, readPwd);

                //string hash = Model.ValidateCheck.GetEncodedString(Password);
                if (tbInvestor != null && tbInvestor.Count > 0)
                {
                    //Add Data From Table Investor To Result
                    result.InvestorID = tbInvestor[0].InvestorID;
                    result.AgentID = tbInvestor[0].AgentID;
                    result.Balance = tbInvestor[0].Balance;
                    result.Code = tbInvestor[0].Code;
                    result.Credit = tbInvestor[0].Credit;
                    //Result.IsOnline = true;
                    result.IsDisable = tbInvestor[0].IsDisible;
                    result.ReadOnly = tbInvestor[0].ReadOnly;
                    result.IsReadOnly = true;

                    if (Business.Market.InvestorGroupList != null)
                    {
                        int count = Business.Market.InvestorGroupList.Count;
                        for (int i = 0; i < count; i++)
                        {
                            if (Business.Market.InvestorGroupList[i].InvestorGroupID == tbInvestor[0].InvestorGroupID)
                            {
                                result.InvestorGroupInstance = Business.Market.InvestorGroupList[i];
                                break;
                            }
                        }
                    }

                    result.InvestorStatusID = tbInvestor[0].InvestorStatusID;
                    result.IsDisable = tbInvestor[0].IsDisible;
                    result.Leverage = tbInvestor[0].Leverage;
                    result.PreviousLedgerBalance = tbInvestor[0].PreviousLedgerBalance;

                    tbInvestorProfile = adapInvestorProfile.GetInvestorProfileByInvestorID(tbInvestor[0].InvestorID);
                    if (tbInvestorProfile != null && tbInvestorProfile.Count > 0)
                    {
                        //Add Data From Table InvestorProfile To Result
                        result.Address = tbInvestorProfile[0].Address;
                        result.City = tbInvestorProfile[0].City;
                        result.InvestorComment = tbInvestorProfile[0].Comment;
                        result.Country = tbInvestorProfile[0].Country;
                        result.Email = tbInvestorProfile[0].Email;
                        result.NickName = tbInvestorProfile[0].NickName;
                        result.Phone = tbInvestorProfile[0].Phone;
                        result.RegisterDay = tbInvestorProfile[0].RegisterDay;
                        result.State = tbInvestorProfile[0].State;
                        result.ZipCode = tbInvestorProfile[0].ZipCode;
                        result.InvestorProfileID = tbInvestorProfile[0].InvestorProfileID;
                        result.IDPassport = tbInvestorProfile[0].IDPassport;
                    }
                }
            }
            catch (Exception ex)
            {
                return null;
            }
            finally
            {
                adap.Connection.Close();
                conn.Close();
            }

            return result;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="InvestorProfileID"></param>
        /// <returns></returns>
        internal Business.Investor GetInvestorProfileByInvestorProfileID(int InvestorProfileID)
        {
            Business.Investor Result = new Business.Investor();
            System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection);
            DSTableAdapters.InvestorProfileTableAdapter adap = new DSTableAdapters.InvestorProfileTableAdapter();
            DS.InvestorProfileDataTable tbInvestorProfile = new DS.InvestorProfileDataTable();

            try
            {
                conn.Open();
                adap.Connection = conn;

                tbInvestorProfile = adap.GetInvestorProfileByInvestorProfileID(InvestorProfileID);

                if (tbInvestorProfile != null)
                {
                    int count = tbInvestorProfile.Count;
                    Result.Address = tbInvestorProfile[0].Address;
                    Result.City = tbInvestorProfile[0].City;
                    Result.InvestorComment = tbInvestorProfile[0].Comment;
                    Result.Country = tbInvestorProfile[0].Country;
                    Result.Email = tbInvestorProfile[0].Email;
                    Result.InvestorID = tbInvestorProfile[0].InvestorID;
                    Result.NickName = tbInvestorProfile[0].NickName;
                    Result.Phone = tbInvestorProfile[0].Phone;
                    Result.RegisterDay = tbInvestorProfile[0].RegisterDay;
                    Result.State = tbInvestorProfile[0].State;
                    Result.ZipCode = tbInvestorProfile[0].ZipCode;
                    Result.IDPassport = tbInvestorProfile[0].IDPassport;
                }
            }
            catch (Exception ex)
            {
                return null;
            }
            finally
            {
                adap.Connection.Close();
                conn.Close();
            }

            return Result;
        }