Beispiel #1
0
        /// <summary>
        /// 根据帐户类型和交易员ID找出对应的帐户和帐户所属类型
        /// </summary>
        /// <param name="freeTransfer">转帐实体</param>
        /// <param name="outMessage"></param>
        public static bool AccountTransferEntityChange(ref FreeTransferEntity freeTransfer, ref string outMessage)
        {
            string where = string.Format("UserID = '{0}' AND AccountTypeLogo= '{1}'", freeTransfer.TraderID, freeTransfer.FromCapitalAccountType);
            UA_UserAccountAllocationTableDal         dal             = new UA_UserAccountAllocationTableDal();
            List <UA_UserAccountAllocationTableInfo> AccountListFrom = dal.GetListArray(where);

            if (AccountListFrom == null || AccountListFrom.Count < 1)
            {
                outMessage = "转出资金帐号不存在";
                return(false);
            }
            if (AccountListFrom[0].WhetherAvailable == false)
            {
                outMessage = "转出资金帐户被冻结,不能转帐";
                return(false);
            }

            where = string.Format("UserID = '{0}' AND AccountTypeLogo= '{1}'", freeTransfer.TraderID, freeTransfer.ToCapitalAccountType);
            List <UA_UserAccountAllocationTableInfo> AccountListTo = dal.GetListArray(where);

            if (AccountListTo == null || AccountListTo.Count < 1)
            {
                outMessage = "转入资金帐号不存在";
                return(false);
            }
            if (AccountListTo[0].WhetherAvailable == false)
            {
                outMessage = "转入资金帐户被冻结,不能转帐";
                return(false);
            }

            BD_AccountTypeDal  acTypeDal         = new BD_AccountTypeDal();
            BD_AccountTypeInfo FrombdAccountType = acTypeDal.GetModel(freeTransfer.FromCapitalAccountType);
            BD_AccountTypeInfo TobdAccountType   = acTypeDal.GetModel(freeTransfer.ToCapitalAccountType);

            if (FrombdAccountType == null || TobdAccountType == null)
            {
                outMessage = "帐号所属类型匹配失败";
                return(false);
            }
            freeTransfer.FromCapitalAccount = AccountListFrom[0].UserAccountDistributeLogo;
            freeTransfer.ToCapitalAccount   = AccountListTo[0].UserAccountDistributeLogo;
            //freeTransfer.FromCapitalAccountType = (int)FrombdAccountType.ATCId;
            //freeTransfer.ToCapitalAccountType = (int)TobdAccountType.ATCId;
            return(true);
        }
        /*
         * /// <summary>
         * /// 增加一条数据
         * /// </summary>
         * public void Add(BD_AccountTypeInfo model)
         * {
         *  StringBuilder strSql=new StringBuilder();
         *  strSql.Append("insert into BD_AccountType(");
         *  strSql.Append("AccountTypeLogo,AccountTypeName,Remarks,ATCId,RelationAccountId)");
         *
         *  strSql.Append(" values (");
         *  strSql.Append("@AccountTypeLogo,@AccountTypeName,@Remarks,@ATCId,@RelationAccountId)");
         *  Database db = DatabaseFactory.CreateDatabase();
         *  DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
         *  db.AddInParameter(dbCommand, "AccountTypeLogo", DbType.Int32, model.AccountTypeLogo);
         *  db.AddInParameter(dbCommand, "AccountTypeName", DbType.AnsiString, model.AccountTypeName);
         *  db.AddInParameter(dbCommand, "Remarks", DbType.AnsiString, model.Remarks);
         *  db.AddInParameter(dbCommand, "ATCId", DbType.Int32, model.ATCId);
         *  db.AddInParameter(dbCommand, "RelationAccountId", DbType.Int32, model.RelationAccountId);
         *  db.ExecuteNonQuery(dbCommand);
         * }
         * /// <summary>
         * /// 更新一条数据
         * /// </summary>
         * public void Update(BD_AccountTypeInfo model)
         * {
         *  StringBuilder strSql=new StringBuilder();
         *  strSql.Append("update BD_AccountType set ");
         *  strSql.Append("AccountTypeName=@AccountTypeName,");
         *  strSql.Append("Remarks=@Remarks,");
         *  strSql.Append("ATCId=@ATCId,");
         *  strSql.Append("RelationAccountId=@RelationAccountId");
         *  strSql.Append(" where AccountTypeLogo=@AccountTypeLogo ");
         *  Database db = DatabaseFactory.CreateDatabase();
         *  DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
         *  db.AddInParameter(dbCommand, "AccountTypeLogo", DbType.Int32, model.AccountTypeLogo);
         *  db.AddInParameter(dbCommand, "AccountTypeName", DbType.AnsiString, model.AccountTypeName);
         *  db.AddInParameter(dbCommand, "Remarks", DbType.AnsiString, model.Remarks);
         *  db.AddInParameter(dbCommand, "ATCId", DbType.Int32, model.ATCId);
         *  db.AddInParameter(dbCommand, "RelationAccountId", DbType.Int32, model.RelationAccountId);
         *  db.ExecuteNonQuery(dbCommand);
         *
         * }
         *
         * /// <summary>
         * /// 删除一条数据
         * /// </summary>
         * public void Delete(int AccountTypeLogo)
         * {
         *
         *  StringBuilder strSql=new StringBuilder();
         *  strSql.Append("delete from BD_AccountType ");
         *  strSql.Append(" where AccountTypeLogo=@AccountTypeLogo ");
         *  Database db = DatabaseFactory.CreateDatabase();
         *  DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
         *  db.AddInParameter(dbCommand, "AccountTypeLogo", DbType.Int32,AccountTypeLogo);
         *  db.ExecuteNonQuery(dbCommand);
         *
         * }*/

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        /// <param name="AccountTypeLogo">账户类型主键ID</param>
        /// <returns>账户类型实体</returns>
        public BD_AccountTypeInfo GetModel(int AccountTypeLogo)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select AccountTypeLogo,AccountTypeName,Remarks,ATCId,RelationAccountId from BD_AccountType ");
            strSql.Append(" where AccountTypeLogo=@AccountTypeLogo ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "AccountTypeLogo", DbType.Int32, AccountTypeLogo);
            BD_AccountTypeInfo model = null;

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        /// <param name="dataReader">IDataReader实例</param>
        /// <returns>账户类型实体</returns>
        public BD_AccountTypeInfo ReaderBind(IDataReader dataReader)
        {
            BD_AccountTypeInfo model = new BD_AccountTypeInfo();
            object             ojb;

            ojb = dataReader["AccountTypeLogo"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.AccountTypeLogo = (int)ojb;
            }
            model.AccountTypeName = dataReader["AccountTypeName"].ToString();
            model.Remarks         = dataReader["Remarks"].ToString();
            ojb = dataReader["ATCId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ATCId = (int)ojb;
            }
            ojb = dataReader["RelationAccountId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.RelationAccountId = (int)ojb;
            }
            return(model);
        }
Beispiel #4
0
        /// <summary>
        /// Create by:李健华
        /// Create date:2010-06-08
        /// Desc.: 初始货配对资金账号与持仓账号
        /// </summary>
        /// <param name="capitalAccountType"></param>
        /// <param name="userID">交易员ID</param>
        public static List <AccountPair> InitializeAccountPair(BD_AccountTypeInfo capitalAccountType)
        {
            List <AccountPair> AccountPairList = new List <AccountPair>();

            try
            {
                List <UA_UserBasicInformationTableInfo> userBasicList = new List <UA_UserBasicInformationTableInfo>();
                UA_UserBasicInformationTableDal         ubDal         = new UA_UserBasicInformationTableDal();
                userBasicList = ubDal.GetAll();
                if (userBasicList == null)
                {
                    return(AccountPairList);
                }
                UA_UserAccountAllocationTableDal dal = new UA_UserAccountAllocationTableDal();
                foreach (var item in userBasicList)
                {
                    string where = string.Format("UserID = '{0}' AND AccountTypeLogo= '{1}'", item.UserID, capitalAccountType.AccountTypeLogo);

                    List <UA_UserAccountAllocationTableInfo> capitalAccountList = dal.GetListArray(where);

                    if (Utils.IsNullOrEmpty(capitalAccountList))
                    {
                        continue;
                    }

                    //对应资金账户类型的只能有一个资金交易账户
                    UA_UserAccountAllocationTableInfo capitalAccount = capitalAccountList[0];

                    #region  查找对应的持仓交易账户
                    //查找对应的持仓交易账户
                    int?relationID = capitalAccountType.RelationAccountId;
                    if (!relationID.HasValue)
                    {
                        continue;
                    }

                    int holdAccountTypeID = relationID.Value;
                    where = string.Format("UserID = '{0}' AND AccountTypeLogo= '{1}'", item.UserID, holdAccountTypeID);

                    List <UA_UserAccountAllocationTableInfo> HoldAccountList = dal.GetListArray(where);

                    if (Utils.IsNullOrEmpty(HoldAccountList))
                    {
                        //IsInitializeSuccess = false;
                        continue;
                    }

                    //对应持仓账户类型的只能有一个持仓交易账户
                    UA_UserAccountAllocationTableInfo holdAccount = HoldAccountList[0];
                    #endregion

                    AccountPair accountPair = new AccountPair {
                        CapitalAccount = capitalAccount, HoldAccount = holdAccount
                    };
                    AccountPairList.Add(accountPair);
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteError("期货盘前检查初始货配对资金账号与持仓账号异常" + ex.Message, ex);
                AccountPairList = null;
            }
            return(AccountPairList);
        }