/// <summary>
        /// 根据柜台和交易员ID帐号类型获取交易员资金帐号
        /// </summary>
        public void Capitalaccount(int counterID, int trade)
        {
            string XHCapitalAccount   = ProductionAccount.FormationAccount(counterID, trade, 2);
            string HKCapitalAccount   = ProductionAccount.FormationAccount(counterID, trade, 8);
            string GZQHCapitalAccount = ProductionAccount.FormationAccount(counterID, trade, 6);
            string SPQHCapitalAccount = ProductionAccount.FormationAccount(counterID, trade, 4);

            ServerConfig.XHCapitalAccount   = XHCapitalAccount;
            ServerConfig.HKCapitalAccount   = HKCapitalAccount;
            ServerConfig.GZQHCapitalAccount = GZQHCapitalAccount;
            ServerConfig.SPQHCapitalAccount = SPQHCapitalAccount;
        }
        /// <summary>
        /// 添加交易员
        /// </summary>
        /// <param name="dt">权限列表</param>
        /// <param name="UserInfo">交易员实体</param>
        /// <param name="initfund">初始资金实体</param>
        /// <param name="mess"></param>
        /// <returns></returns>
        public bool AddTransaction(DataTable dt, UM_UserInfo UserInfo, InitFund initfund, out string mess)
        {
            try
            {
                List <AccountEntity> l_AccountEntity = new List <AccountEntity>();

                string BackAccount = string.Empty;
                int    UserID;

                Database     db   = DatabaseFactory.CreateDatabase();
                DbConnection Conn = db.CreateConnection();
                if (Conn.State != ConnectionState.Open)
                {
                    Conn.Open();
                }
                DbTransaction Tran = Conn.BeginTransaction();

                try
                {
                    //添加用户基本信息表
                    UserID = StaticDalClass.UserInfoDAL.Add(UserInfo, Tran, db);
                    if (UserID < 1)
                    {
                        mess = "GL-0200:添加用户基本信息失败"; //写调试信息
                        LogHelper.WriteDebug(mess);
                        return(false);
                    }
                    //添加用户交易品种权限表
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        UM_DealerTradeBreedClass DealerTradeBreedClass = new UM_DealerTradeBreedClass();
                        DealerTradeBreedClass.UserID       = UserID;
                        DealerTradeBreedClass.BreedClassID = int.Parse(dt.Rows[i]["BreedClassID"].ToString());
                        StaticDalClass.DealerTradeBreedClassDAL.Add(DealerTradeBreedClass, Tran, db);
                    }
                    //分配帐号列表
                    List <UM_AccountType> AccountType = StaticDalClass.AccountTypeDAL.GetListArray(string.Empty);
                    if (AccountType == null || AccountType.Count == 0)
                    {
                        mess = "GL-0201:获取帐号类型列表失败"; //写调试信息
                        LogHelper.WriteDebug(mess);
                        return(false);
                    }
                    //传加密后的密码给柜台开户
                    string DesPassWord = UtilityClass.DesEncrypt(UserInfo.Password, string.Empty);

                    foreach (UM_AccountType type in AccountType)
                    {
                        UM_DealerAccount DealerAccount = new UM_DealerAccount();
                        DealerAccount.AccountTypeID  = type.AccountTypeID;
                        DealerAccount.DealerAccoutID = ProductionAccount.FormationAccount((int)UserInfo.CouterID,
                                                                                          UserID,
                                                                                          (int)
                                                                                          DealerAccount.AccountTypeID);
                        DealerAccount.IsDo = true;
                        DealerAccount.AccountAttributionType = type.AccountAttributionType;
                        DealerAccount.UserID = UserID;
                        StaticDalClass.DealerAccountDAL.Add(DealerAccount, Tran, db);

                        //添加到调用柜台接口的参数类表
                        {
                            AccountEntity Element = new AccountEntity();
                            Element.Account             = DealerAccount.DealerAccoutID;
                            Element.AccountAAttribution = (int)DealerAccount.AccountAttributionType;
                            Element.AccountType         = (int)DealerAccount.AccountTypeID;
                            Element.CurrencyHK          = initfund.HK;
                            Element.CurrencyRMB         = initfund.RMB;
                            Element.CurrencyUS          = initfund.US;
                            Element.RoleNumber          = (int)GTA.VTS.Common.CommonObject.Types.UserId.Trader;
                            Element.TraderID            = UserID.ToString();
                            Element.TraderPassWord      = DesPassWord;
                            l_AccountEntity.Add(Element);
                        }
                        if (type.AccountAttributionType ==
                            (int)GTA.VTS.Common.CommonObject.Types.AccountAttributionType.BankAccount)
                        {
                            BackAccount = DealerAccount.DealerAccoutID;
                        }
                    }
                    //保存初始资金
                    if (!SaveFund(initfund, Tran, db, BackAccount))
                    {
                        mess = "GL-0202:初始化资金失败!"; //写调试信息
                        LogHelper.WriteDebug(mess);
                        return(false);
                    }
                    Tran.Commit();
                }
                catch (Exception ex)
                {
                    Tran.Rollback();
                    string      errCode = "GL-0203";
                    string      errMsg  = "添加交易员失败!";
                    VTException vte     = new VTException(errCode, errMsg, ex);
                    LogHelper.WriteError(vte.ToString(), vte.InnerException);
                    mess = vte.ToString();
                    return(false);
                }
                finally
                {
                    if (Conn.State == ConnectionState.Open)
                    {
                        Conn.Close();
                    }
                }

                //调用柜台开户方法
                string s;
                try
                {
                    CT_Counter T = StaticDalClass.CounterDAL.GetModel((int)UserInfo.CouterID);

                    if (
                        !ServiceIn.AccountManageServiceProxy.GetInstance().SingleTraderOpenAccount(T, l_AccountEntity, out s))
                    {
                        mess = "GL-0204:调用柜台开户方法SingleTraderOpenAccount失败!" + s; //写调试信息
                        LogHelper.WriteDebug(mess);

                        DelTransaction(UserID, out s);
                        return(false);
                    }
                }
                catch (VTException ex)
                {
                    mess = ex.ToString();
                    LogHelper.WriteError(ex.ToString(), ex.InnerException);
                    DelTransaction(UserID, out s);
                    //写错误信息
                    return(false);
                }
                mess = "GL-0232:开户成功!";
                return(true);
            }
            catch (Exception Ex)
            {
                string      errCode = "GL-0205";
                string      errMsg  = "数据库连接失败!";
                VTException vte     = new VTException(errCode, errMsg, Ex);
                LogHelper.WriteError(vte.ToString(), vte.InnerException);
                mess = vte.ToString();
                return(false);
            }
        }