/// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(ManagementCenter.Model.UM_UserInfo model, DbTransaction tran, Database db)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into UM_UserInfo(");
            strSql.Append("UserName,LoginName,Password,CertificateStyle,Postalcode,RoleID,CertificateNo,Telephone,Address,Email,QuestionID,Answer,CouterID,Remark,AddType,AddTime)");

            strSql.Append(" values (");
            strSql.Append("@UserName,@LoginName,@Password,@CertificateStyle,@Postalcode,@RoleID,@CertificateNo,@Telephone,@Address,@Email,@QuestionID,@Answer,@CouterID,@Remark,@AddType,@AddTime)");
            strSql.Append(";select @@IDENTITY");

            if (db == null)
            {
                db = DatabaseFactory.CreateDatabase();
            }

            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "UserName", DbType.String, model.UserName);
            db.AddInParameter(dbCommand, "LoginName", DbType.String, model.LoginName);
            db.AddInParameter(dbCommand, "Password", DbType.String, UtilityClass.DesEncrypt(model.Password, string.Empty));
            db.AddInParameter(dbCommand, "CertificateStyle", DbType.Int32, model.CertificateStyle);
            db.AddInParameter(dbCommand, "Postalcode", DbType.String, model.Postalcode);
            db.AddInParameter(dbCommand, "RoleID", DbType.Int32, model.RoleID);
            db.AddInParameter(dbCommand, "CertificateNo", DbType.String, model.CertificateNo);
            db.AddInParameter(dbCommand, "Telephone", DbType.String, model.Telephone);
            db.AddInParameter(dbCommand, "Address", DbType.String, model.Address);
            db.AddInParameter(dbCommand, "Email", DbType.String, model.Email);
            db.AddInParameter(dbCommand, "QuestionID", DbType.Int32, model.QuestionID);
            db.AddInParameter(dbCommand, "Answer", DbType.String, model.Answer);
            db.AddInParameter(dbCommand, "CouterID", DbType.Int32, model.CouterID);
            db.AddInParameter(dbCommand, "Remark", DbType.String, model.Remark);
            db.AddInParameter(dbCommand, "AddType", DbType.Int32, model.AddType);
            db.AddInParameter(dbCommand, "AddTime", DbType.DateTime, System.DateTime.Now);
            int    result;
            object obj;

            if (tran == null)
            {
                obj = db.ExecuteScalar(dbCommand);
            }
            else
            {
                obj = db.ExecuteScalar(dbCommand, tran);
            }
            if (!int.TryParse(obj.ToString(), out result))
            {
                return(0);
            }
            return(result);
        }
        /// <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>
 /// 确定按钮事件 btn_OK_Click
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btn_OK_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.txt_LoginName.Text == string.Empty)
         {
             ShowMessageBox.ShowInformation("登陆名称不能为空!");
             return;
         }
         if (this.txt_PassWord.Text == string.Empty)
         {
             ShowMessageBox.ShowInformation("密码不能为空!");
             return;
         }
         UM_UserInfoBLL UserInfoBLL = new UM_UserInfoBLL();
         UM_UserInfo    UserInfo    = UserInfoBLL.ManagerLoginConfirm(this.txt_LoginName.Text, UtilityClass.DesEncrypt(this.txt_PassWord.Text, string.Empty),
                                                                      (int)Types.AddTpyeEnum.BackManager);
         if (UserInfo != null)
         {
             ParameterSetting.Mananger = UserInfo;
             DialogResult = DialogResult.OK;
             this.Close();
         }
         else
         {
             ShowMessageBox.ShowInformation("用户名或密码错误,请重新输入!");
         }
     }
     catch (Exception ex)
     {
         ShowMessageBox.ShowInformation(ex.Message.ToString());
         return;
     }
     this.txt_LoginName.Focus();
 }