/// <summary>
        /// 解冻帐号
        /// </summary>
        /// <param name="DealerAccount">帐号表</param>
        /// <param name="ThawReason">解冻原因</param>
        /// <param name="mess"></param>
        /// <returns></returns>
        public bool ThawAccount(UM_DealerAccount DealerAccount, UM_ThawReason ThawReason, out string mess)
        {
            mess = string.Empty;
            CT_Counter T = GetCounterByUserID((int)DealerAccount.UserID);
            List <FindAccountEntity> l = new List <FindAccountEntity>();

            if (T == null)
            {
                mess = "GL-0227:交易员对应的柜台不存在!"; //写调试信息
                LogHelper.WriteDebug(mess);
                return(false);
            }
            try
            {
                FindAccountEntity FindAccountEntity = new FindAccountEntity();
                FindAccountEntity.AccountType = (int)DealerAccount.AccountTypeID;
                FindAccountEntity.UserID      = DealerAccount.UserID.ToString();
                l.Add(FindAccountEntity);
                if (!ServiceIn.AccountManageServiceProxy.GetInstance().ThawAccount(T, l, out mess))
                {
                    mess = "GL-0228:调用柜台解冻帐号方法ThawAccount()失败!" + mess; //写调试信息
                    LogHelper.WriteDebug(mess);
                    return(false);
                }
            }
            catch (VTException Ex)
            {
                mess = Ex.ToString();
                //写错误日志
                return(false);
            }
            try
            {
                StaticDalClass.DealerAccountDAL.Update(DealerAccount);
                StaticDalClass.ThawReasonDAL.Add(ThawReason);
            }
            catch (Exception ex)
            {
                ServiceIn.AccountManageServiceProxy.GetInstance().FreezeAccount(T, l, out mess);
                string      errCode = "GL-0229";
                string      errMsg  = "冻结帐号方法FreezeAccount()异常!" + ex.Message;
                VTException vte     = new VTException(errCode, errMsg, ex);
                LogHelper.WriteError(vte.ToString(), vte.InnerException);
                mess = vte.ToString();
                return(false);
            }
            return(true);
        }
 /// <summary>
 /// 根据账户ID获取柜台信息
 /// </summary>
 /// <param name="DealerAccoutID">账户ID</param>
 /// <returns></returns>
 public CT_Counter GetCounterByAccountID(string DealerAccoutID)
 {
     try
     {
         UM_DealerAccount DealerAccount = StaticDalClass.DealerAccountDAL.GetModel(DealerAccoutID);
         return(GetCounterByUserID(DealerAccount.UserID));
     }
     catch (Exception ex)
     {
         string      errCode = "GL-0218";
         string      errMsg  = "根据帐号得到柜台实体GetCounterByAccountID()方法异常!";
         VTException vte     = new VTException(errCode, errMsg, ex);
         LogHelper.WriteError(vte.ToString(), vte.InnerException);
         return(null);
     }
 }
        /// <summary>
        /// 解冻按纽事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_UnFreeze_Click(object sender, EventArgs e)
        {
            string mess;

            try
            {
                string AccountID = this.txt_Account.Text.Trim();
                if (!string.IsNullOrEmpty(AccountID))
                {
                    UM_DealerAccount DealerAccount = DealerAccountBLL.GetModel(string.Format(AccountID));

                    if (DealerAccount.UserID == int.Parse(this.txt_TranscationID.Text.Trim()) && DealerAccount.IsDo == false)
                    {
                        DealerAccount.IsDo = true;

                        UM_ThawReason ThawReason = new UM_ThawReason();
                        ThawReason.DealerAccoutID = DealerAccount.DealerAccoutID;
                        ThawReason.ThawReason     = this.txt_Reason.Text.Trim();
                        ThawReason.ThawReasonTime = System.DateTime.Now;

                        ManagementCenter.BLL.UserManage.TransactionManage tm = new ManagementCenter.BLL.UserManage.TransactionManage();
                        if (!tm.ThawAccount(DealerAccount, ThawReason, out mess))
                        {
                            ShowMessageBox.ShowInformation(mess);
                            return;
                        }

                        InitAccountListByUserID(DealerAccount.UserID, ViewAccount.FocusedRowHandle);
                    }
                }
            }
            catch (Exception ex)
            {
                string      errCode   = "GL-0356";
                string      errMsg    = "解冻失败!";
                VTException exception = new VTException(errCode, errMsg, ex);
                LogHelper.WriteError(exception.ToString(), ex);
                ShowMessageBox.ShowInformation(exception.ToString());
                return;
            }
        }
        /// <summary>
        /// 追加资金
        /// </summary>
        /// <param name="model">追加资金实体</param>
        /// <param name="mess"></param>
        /// <returns></returns>
        public bool AddFund(ManagementCenter.Model.UM_FundAddInfo model, out string mess)
        {
            mess = string.Empty;
            UM_UserInfo user = StaticDalClass.UserInfoDAL.GetModel((int)model.UserID);

            if (user == null || user.RoleID != (int)ManagementCenter.Model.CommonClass.Types.RoleTypeEnum.Transaction)
            {
                mess = "GL-0219:交易员编号不存在!"; //写调试信息
                LogHelper.WriteDebug(mess);
                return(false);
            }

            CT_Counter T = GetCounterByUserID((int)model.UserID);

            if (T == null)
            {
                mess = "GL-0220:交易员对应的柜台不存在!"; //写调试信息
                LogHelper.WriteDebug(mess);
                return(false);
            }
            UM_DealerAccount DealerAccount = StaticDalClass.DealerAccountDAL.GetModelByUserIDAndType((int)model.UserID,
                                                                                                     (int)
                                                                                                     GTA.VTS.Common.CommonObject.Types.
                                                                                                     AccountAttributionType
                                                                                                     .
                                                                                                     BankAccount);

            if (DealerAccount == null)
            {
                mess = "GL-0221:交易员对应的银行帐号不存在!"; //写调试信息
                LogHelper.WriteDebug(mess);
                return(false);
            }
            try
            {
                AddCapitalEntity AddCapitalEntity = new AddCapitalEntity();
                AddCapitalEntity.AddHKAmount        = (decimal)model.HKNumber;
                AddCapitalEntity.AddRMBAmount       = (decimal)model.RMBNumber;
                AddCapitalEntity.AddUSAmount        = (decimal)model.USNumber;
                AddCapitalEntity.TraderID           = model.UserID.ToString();
                AddCapitalEntity.BankCapitalAccount = DealerAccount.DealerAccoutID;
                if (!ServiceIn.AccountManageServiceProxy.GetInstance().AddCapital(T, AddCapitalEntity, out mess))
                {
                    mess = "GL-0222:调用柜台追加资金方法AddCapital()失败!" + mess; //写调试信
                    LogHelper.WriteDebug(mess);
                    return(false);
                }
            }
            catch (VTException Ex)
            {
                mess = Ex.ToString();
                //写错误日志
                return(false);
            }
            try
            {
                if (model.HKNumber == decimal.MaxValue)
                {
                    model.HKNumber = null;
                }
                if (model.RMBNumber == decimal.MaxValue)
                {
                    model.RMBNumber = null;
                }
                if (model.USNumber == decimal.MaxValue)
                {
                    model.USNumber = null;
                }
                StaticDalClass.FundAddInfoDAL.Add(model);
            }
            catch (Exception ex)
            {
                string      errCode = "GL-0223";
                string      errMsg  = "追加资金失败!";
                VTException vte     = new VTException(errCode, errMsg, ex);
                LogHelper.WriteError(vte.ToString(), vte.InnerException);
                mess = vte.ToString();
                return(false);
            }
            return(true);
        }
        /// <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);
            }
        }
        /// <summary>
        /// 冻结按纽事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Freeze_Click(object sender, EventArgs e)
        {
            string mess;

            try
            {
                string           AccountID     = this.txt_Account.Text.Trim();
                UM_DealerAccount DealerAccount = DealerAccountBLL.GetModel(AccountID);
                if (DealerAccount == null)
                {
                    return;
                }
                UM_DealerAccount Account =
                    DealerAccountBLL.GetModelByUserIDAndType(int.Parse(this.txt_TranscationID.Text.Trim()),
                                                             (int)GTA.VTS.Common.CommonObject.Types.AccountAttributionType.BankAccount);
                if (DealerAccount.DealerAccoutID == Account.DealerAccoutID)
                {
                    ShowMessageBox.ShowInformation("银行帐号不允许冻结!");
                    return;
                }
                if (DealerAccount.UserID == int.Parse(this.txt_TranscationID.Text.Trim()) && DealerAccount.IsDo == true)
                {
                    DealerAccount.IsDo = false;

                    UM_FreezeReason FreezeReason = new UM_FreezeReason();
                    FreezeReason.DealerAccoutID   = DealerAccount.DealerAccoutID;
                    FreezeReason.FreezeReason     = this.txt_Reason.Text.Trim();
                    FreezeReason.FreezeReasonTime = System.DateTime.Now;
                    if (chk_IsAutoRelieve.Enabled == true && this.chk_IsAutoRelieve.Checked == true)
                    {
                        if (this.dateEdit1.DateTime > System.DateTime.Now)
                        {
                            FreezeReason.IsAuto         = (int)Types.IsAutoUnFreezeEnum.Auto;
                            FreezeReason.ThawReasonTime = this.dateEdit1.DateTime;
                        }
                        else
                        {
                            ShowMessageBox.ShowInformation("时间设置有误,必须大于当前时间!");
                            return;
                        }
                    }

                    ManagementCenter.BLL.UserManage.TransactionManage tm = new ManagementCenter.BLL.UserManage.TransactionManage();
                    if (!tm.FreezeAccount(DealerAccount, FreezeReason, out mess))
                    {
                        ShowMessageBox.ShowInformation(mess);
                        return;
                    }

                    InitAccountListByUserID(DealerAccount.UserID, ViewAccount.FocusedRowHandle);
                }
            }
            catch (Exception ex)
            {
                string      errCode   = "GL-0355";
                string      errMsg    = "冻结失败!";
                VTException exception = new VTException(errCode, errMsg, ex);
                LogHelper.WriteError(exception.ToString(), ex);
                ShowMessageBox.ShowInformation(exception.ToString());
                return;
            }
        }