/// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(HK_AcccountHoldFreezeInfo model, Database db, DbTransaction transaction)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into HK_AcccountHoldFreeze(");
            strSql.Append("FreezeTime,PrepareFreezeAmount,ThawTime,FreezeTypeID,AccountHoldLogo,EntrustNumber)");

            strSql.Append(" values (");
            strSql.Append("@FreezeTime,@prepareFreezeAmount,@ThawTime,@FreezeTypeID,@AccountHoldLogo,@EntrustNumber)");
            strSql.Append(";select @@IDENTITY");
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "FreezeTime", DbType.DateTime, model.FreezeTime);
            db.AddInParameter(dbCommand, "PrepareFreezeAmount", DbType.Int32, model.PrepareFreezeAmount);
            db.AddInParameter(dbCommand, "ThawTime", DbType.DateTime, model.ThawTime);
            db.AddInParameter(dbCommand, "FreezeTypeID", DbType.Int32, model.FreezeTypeID);
            db.AddInParameter(dbCommand, "AccountHoldLogo", DbType.Int32, model.AccountHoldLogo);
            db.AddInParameter(dbCommand, "EntrustNumber", DbType.AnsiString, model.EntrustNumber);
            int    result;
            object obj = db.ExecuteScalar(dbCommand, transaction);

            if (!int.TryParse(obj.ToString(), out result))
            {
                return(0);
            }
            return(result);
        }
コード例 #2
0
        /// <summary>
        /// 港股持仓冻结处理
        /// </summary>
        /// <param name="tm"></param>
        /// <returns></returns>
        private int PO_BuildHoldFreezeRecord(ReckoningTransaction tm)
        {
            LogHelper.WriteDebug("港股持仓冻结处理XHSellOrderLogicFlow.PO_ProcessXhHoldingAccountFreeze");

            HK_AcccountHoldFreezeInfo hahf = new HK_AcccountHoldFreezeInfo();

            hahf.AccountHoldLogo = HoldingAccountId; //港股持仓帐户标识
            hahf.EntrustNumber   = EntrustNumber;    //委托单号
            hahf.FreezeTime      = DateTime.Now;     //冻结时间
            hahf.ThawTime        = DateTime.Now;     //解冻时间

            //decimal unitMultiple = MCService.GetTradeUnitScale(stockorder.Code, stockorder.OrderUnitType);
            decimal orderAmount = Convert.ToDecimal(Request.OrderAmount);                    // *unitMultiple;

            hahf.PrepareFreezeAmount = Convert.ToInt32(orderAmount);                         //冻结数量
            hahf.FreezeTypeID        = (int)Entity.Contants.Types.FreezeType.DelegateFreeze; //冻结类型


            HK_AcccountHoldFreezeDal dal = new HK_AcccountHoldFreezeDal();

            try
            {
                return(dal.Add(hahf, tm.Database, tm.Transaction));
            }
            catch (Exception ex)
            {
                string txt = "AccountHoldLogo={0},EntrustNumber={1},FreezeTime={2},ThawTime={3},PrepareFreezeAmount={4},FreezeTypeID={5}";
                txt = string.Format(txt, hahf.AccountHoldLogo, hahf.EntrustNumber, hahf.FreezeTime, hahf.ThawTime, hahf.PrepareFreezeAmount, hahf.FreezeTypeID);
                LogHelper.WriteDebug("港股持仓冻结处理实体内容" + txt);
                throw ex;
            }
        }
        /// <summary>
        /// 得到一个对象实体
        /// <param name="HoldFreezeLogoId">港股持仓冻结标识</param>
        /// </summary>
        public HK_AcccountHoldFreezeInfo GetModel(int HoldFreezeLogoId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select HoldFreezeLogoId,EntrustNumber,PrepareFreezeAmount,FreezeTypeID,AccountHoldLogo,ThawTime,FreezeTime from HK_AcccountHoldFreeze ");
            strSql.Append(" where HoldFreezeLogoId=@HoldFreezeLogoId ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "HoldFreezeLogoId", DbType.Int32, HoldFreezeLogoId);
            HK_AcccountHoldFreezeInfo model = null;

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

            ojb = dataReader["HoldFreezeLogoId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.HoldFreezeLogoId = (int)ojb;
            }
            model.EntrustNumber = dataReader["EntrustNumber"].ToString();
            ojb = dataReader["PrepareFreezeAmount"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.PrepareFreezeAmount = (int)ojb;
            }
            ojb = dataReader["FreezeTypeID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.FreezeTypeID = (int)ojb;
            }
            ojb = dataReader["AccountHoldLogo"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.AccountHoldLogo = (int)ojb;
            }
            ojb = dataReader["ThawTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ThawTime = (DateTime)ojb;
            }
            ojb = dataReader["FreezeTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.FreezeTime = (DateTime)ojb;
            }
            return(model);
        }
        /// <summary>
        /// 带事物更新数据
        /// </summary>
        /// <param name="model">实体</param>
        /// <param name="db">Database</param>
        /// <param name="transaction">DbTransaction</param>
        public void Update(HK_AcccountHoldFreezeInfo model, Database db, DbTransaction transaction)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update HK_AcccountHoldFreeze set ");
            strSql.Append("FreezeTime=@FreezeTime,");
            strSql.Append("PrepareFreezeAmount=@prepareFreezeAmount,");
            strSql.Append("ThawTime=@ThawTime,");
            strSql.Append("FreezeTypeID=@FreezeTypeID,");
            strSql.Append("AccountHoldLogo=@AccountHoldLogo,");
            strSql.Append("EntrustNumber=@EntrustNumber");
            strSql.Append(" where HoldFreezeLogoId=@HoldFreezeLogoId ");
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "HoldFreezeLogoId", DbType.Int32, model.HoldFreezeLogoId);
            db.AddInParameter(dbCommand, "FreezeTime", DbType.DateTime, model.FreezeTime);
            db.AddInParameter(dbCommand, "PrepareFreezeAmount", DbType.Int32, model.PrepareFreezeAmount);
            db.AddInParameter(dbCommand, "ThawTime", DbType.DateTime, model.ThawTime);
            db.AddInParameter(dbCommand, "FreezeTypeID", DbType.Int32, model.FreezeTypeID);
            db.AddInParameter(dbCommand, "AccountHoldLogo", DbType.Int32, model.AccountHoldLogo);
            db.AddInParameter(dbCommand, "EntrustNumber", DbType.AnsiString, model.EntrustNumber);
            db.ExecuteNonQuery(dbCommand, transaction);
        }