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

            strSql.Append("insert into XH_AccountHoldTable_Flow(");
            strSql.Append("AccountHoldLogoId,AvailableAmount,FreezeAmount,CostPrice,BreakevenPrice,HoldAveragePrice,FlowTime)");

            strSql.Append(" values (");
            strSql.Append("@AccountHoldLogoId,@AvailableAmount,@FreezeAmount,@CostPrice,@BreakevenPrice,@HoldAveragePrice,@FlowTime)");
            strSql.Append(";select @@IDENTITY");
            //Database db = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "AccountHoldLogoId", DbType.Int32, model.AccountHoldLogoId);
            db.AddInParameter(dbCommand, "AvailableAmount", DbType.Decimal, model.AvailableAmount);
            db.AddInParameter(dbCommand, "FreezeAmount", DbType.Decimal, model.FreezeAmount);
            db.AddInParameter(dbCommand, "CostPrice", DbType.Decimal, model.CostPrice);
            db.AddInParameter(dbCommand, "BreakevenPrice", DbType.Decimal, model.BreakevenPrice);
            db.AddInParameter(dbCommand, "HoldAveragePrice", DbType.Decimal, model.HoldAveragePrice);
            db.AddInParameter(dbCommand, "FlowTime", DbType.DateTime, model.FlowTime);
            int    result;
            object obj = db.ExecuteScalar(dbCommand, transaction);

            if (!int.TryParse(obj.ToString(), out result))
            {
                return(0);
            }
            return(result);
        }
Exemple #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(XH_AccountHoldTable_FlowInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update XH_AccountHoldTable_Flow set ");
            strSql.Append("AccountHoldLogoId=@AccountHoldLogoId,");
            strSql.Append("AvailableAmount=@AvailableAmount,");
            strSql.Append("FreezeAmount=@FreezeAmount,");
            strSql.Append("CostPrice=@CostPrice,");
            strSql.Append("BreakevenPrice=@BreakevenPrice,");
            strSql.Append("HoldAveragePrice=@HoldAveragePrice,");
            strSql.Append("FlowTime=@FlowTime");
            strSql.Append(" where ID=@ID ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "ID", DbType.Int32, model.ID);
            db.AddInParameter(dbCommand, "AccountHoldLogoId", DbType.Int32, model.AccountHoldLogoId);
            db.AddInParameter(dbCommand, "AvailableAmount", DbType.Decimal, model.AvailableAmount);
            db.AddInParameter(dbCommand, "FreezeAmount", DbType.Decimal, model.FreezeAmount);
            db.AddInParameter(dbCommand, "CostPrice", DbType.Decimal, model.CostPrice);
            db.AddInParameter(dbCommand, "BreakevenPrice", DbType.Decimal, model.BreakevenPrice);
            db.AddInParameter(dbCommand, "HoldAveragePrice", DbType.Decimal, model.HoldAveragePrice);
            db.AddInParameter(dbCommand, "FlowTime", DbType.DateTime, model.FlowTime);
            db.ExecuteNonQuery(dbCommand);
        }
Exemple #3
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public XH_AccountHoldTable_FlowInfo ReaderBind(IDataReader dataReader)
        {
            XH_AccountHoldTable_FlowInfo model = new XH_AccountHoldTable_FlowInfo();
            object ojb;

            ojb = dataReader["ID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ID = (int)ojb;
            }
            ojb = dataReader["AccountHoldLogoId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.AccountHoldLogoId = (int)ojb;
            }
            ojb = dataReader["AvailableAmount"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.AvailableAmount = (decimal)ojb;
            }
            ojb = dataReader["FreezeAmount"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.FreezeAmount = (decimal)ojb;
            }
            ojb = dataReader["CostPrice"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.CostPrice = (decimal)ojb;
            }
            ojb = dataReader["BreakevenPrice"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.BreakevenPrice = (decimal)ojb;
            }
            ojb = dataReader["HoldAveragePrice"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.HoldAveragePrice = (decimal)ojb;
            }
            ojb = dataReader["FlowTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.FlowTime = (DateTime)ojb;
            }
            return(model);
        }
Exemple #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public XH_AccountHoldTable_FlowInfo GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ID,AccountHoldLogoId,AvailableAmount,FreezeAmount,CostPrice,BreakevenPrice,HoldAveragePrice,FlowTime from XH_AccountHoldTable_Flow ");
            strSql.Append(" where ID=@ID ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "ID", DbType.Int32, ID);
            XH_AccountHoldTable_FlowInfo model = null;

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }