/// <summary> /// 得到一个对象实体 /// </summary> public ManagementCenter.Model.QH_FuturesTradeRules GetModel(int BreedClassID) { StringBuilder strSql = new StringBuilder(); strSql.Append( "select UnitMultiple,LeastChangePrice,IfContainCNewYear,AgreementDeliveryInstitution,FundDeliveryInstitution,BreedClassID,LastTradingDayID,ConsignQuantumID,IsSlew,HighLowStopScopeID,HighLowStopScopeValue,NewBreedFuturesPactHighLowStopValue,NewMonthFuturesPactHighLowStopValue,UnitsID,PriceUnit,MarketUnitID,FutruesCode,DeliveryMonthHighLowStopValue from QH_FuturesTradeRules "); strSql.Append(" where BreedClassID=@BreedClassID "); Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "BreedClassID", DbType.Int32, BreedClassID); ManagementCenter.Model.QH_FuturesTradeRules model = null; using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { model = ReaderBind(dataReader); } } return(model); }
/// <summary> /// 对象实体绑定数据 /// </summary> public ManagementCenter.Model.QH_FuturesTradeRules ReaderBind(IDataReader dataReader) { ManagementCenter.Model.QH_FuturesTradeRules model = new ManagementCenter.Model.QH_FuturesTradeRules(); object ojb; ojb = dataReader["UnitMultiple"]; if (ojb != null && ojb != DBNull.Value) { model.UnitMultiple = (decimal)ojb; } ojb = dataReader["LeastChangePrice"]; if (ojb != null && ojb != DBNull.Value) { model.LeastChangePrice = (decimal)ojb; } ojb = dataReader["IfContainCNewYear"]; if (ojb != null && ojb != DBNull.Value) { model.IfContainCNewYear = (int)ojb; } ojb = dataReader["AgreementDeliveryInstitution"]; if (ojb != null && ojb != DBNull.Value) { model.AgreementDeliveryInstitution = (int)ojb; } ojb = dataReader["FundDeliveryInstitution"]; if (ojb != null && ojb != DBNull.Value) { model.FundDeliveryInstitution = (int)ojb; } ojb = dataReader["BreedClassID"]; if (ojb != null && ojb != DBNull.Value) { model.BreedClassID = (int)ojb; } ojb = dataReader["LastTradingDayID"]; if (ojb != null && ojb != DBNull.Value) { model.LastTradingDayID = (int)ojb; } ojb = dataReader["ConsignQuantumID"]; if (ojb != null && ojb != DBNull.Value) { model.ConsignQuantumID = (int)ojb; } ojb = dataReader["IsSlew"]; if (ojb != null && ojb != DBNull.Value) { model.IsSlew = (int)ojb; } ojb = dataReader["HighLowStopScopeID"]; if (ojb != null && ojb != DBNull.Value) { model.HighLowStopScopeID = (int)ojb; } ojb = dataReader["HighLowStopScopeValue"]; if (ojb != null && ojb != DBNull.Value) { model.HighLowStopScopeValue = (decimal)ojb; } ojb = dataReader["NewBreedFuturesPactHighLowStopValue"]; if (ojb != null && ojb != DBNull.Value) { model.NewBreedFuturesPactHighLowStopValue = (decimal)ojb; } ojb = dataReader["NewMonthFuturesPactHighLowStopValue"]; if (ojb != null && ojb != DBNull.Value) { model.NewMonthFuturesPactHighLowStopValue = (decimal)ojb; } ojb = dataReader["UnitsID"]; if (ojb != null && ojb != DBNull.Value) { model.UnitsID = (int)ojb; } ojb = dataReader["PriceUnit"]; if (ojb != null && ojb != DBNull.Value) { model.PriceUnit = (int)ojb; } ojb = dataReader["MarketUnitID"]; if (ojb != null && ojb != DBNull.Value) { model.MarketUnitID = (int)ojb; } model.FutruesCode = dataReader["FutruesCode"].ToString(); ojb = dataReader["DeliveryMonthHighLowStopValue"]; if (ojb != null && ojb != DBNull.Value) { model.DeliveryMonthHighLowStopValue = (decimal)ojb; } return(model); }
/// <summary> /// 添加期货_品种_交易规则 /// </summary> /// <param name="model">期货_品种_交易规则实体</param> /// <returns></returns> public bool Add(ManagementCenter.Model.QH_FuturesTradeRules model) { return(Add(model, null, null)); }
/// <summary> /// 更新期货_品种_交易规则 /// </summary> /// <param name="model">期货_品种_交易规则实体</param> /// <returns></returns> public bool Update(ManagementCenter.Model.QH_FuturesTradeRules model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update QH_FuturesTradeRules set "); strSql.Append("UnitMultiple=@UnitMultiple,"); strSql.Append("LeastChangePrice=@LeastChangePrice,"); strSql.Append("IfContainCNewYear=@IfContainCNewYear,"); strSql.Append("AgreementDeliveryInstitution=@AgreementDeliveryInstitution,"); strSql.Append("FundDeliveryInstitution=@FundDeliveryInstitution,"); strSql.Append("LastTradingDayID=@LastTradingDayID,"); strSql.Append("ConsignQuantumID=@ConsignQuantumID,"); strSql.Append("IsSlew=@IsSlew,"); strSql.Append("HighLowStopScopeID=@HighLowStopScopeID,"); strSql.Append("HighLowStopScopeValue=@HighLowStopScopeValue,"); strSql.Append("NewBreedFuturesPactHighLowStopValue=@NewBreedFuturesPactHighLowStopValue,"); strSql.Append("NewMonthFuturesPactHighLowStopValue=@NewMonthFuturesPactHighLowStopValue,"); strSql.Append("UnitsID=@UnitsID,"); strSql.Append("PriceUnit=@PriceUnit,"); strSql.Append("MarketUnitID=@MarketUnitID,"); strSql.Append("FutruesCode=@FutruesCode,"); strSql.Append("DeliveryMonthHighLowStopValue=@DeliveryMonthHighLowStopValue"); strSql.Append(" where BreedClassID=@BreedClassID "); Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "UnitMultiple", DbType.Decimal, model.UnitMultiple); db.AddInParameter(dbCommand, "LeastChangePrice", DbType.Currency, model.LeastChangePrice); db.AddInParameter(dbCommand, "IfContainCNewYear", DbType.Int32, model.IfContainCNewYear); db.AddInParameter(dbCommand, "AgreementDeliveryInstitution", DbType.Int32, model.AgreementDeliveryInstitution); db.AddInParameter(dbCommand, "FundDeliveryInstitution", DbType.Int32, model.FundDeliveryInstitution); db.AddInParameter(dbCommand, "BreedClassID", DbType.Int32, model.BreedClassID); db.AddInParameter(dbCommand, "LastTradingDayID", DbType.Int32, model.LastTradingDayID); db.AddInParameter(dbCommand, "ConsignQuantumID", DbType.Int32, model.ConsignQuantumID); db.AddInParameter(dbCommand, "IsSlew", DbType.Int32, model.IsSlew); db.AddInParameter(dbCommand, "HighLowStopScopeID", DbType.Int32, model.HighLowStopScopeID); if (model.HighLowStopScopeValue == AppGlobalVariable.INIT_DECIMAL) { db.AddInParameter(dbCommand, "HighLowStopScopeValue", DbType.Decimal, DBNull.Value); } else { db.AddInParameter(dbCommand, "HighLowStopScopeValue", DbType.Decimal, model.HighLowStopScopeValue); } if (model.NewBreedFuturesPactHighLowStopValue == AppGlobalVariable.INIT_DECIMAL) { db.AddInParameter(dbCommand, "NewBreedFuturesPactHighLowStopValue", DbType.Decimal, DBNull.Value); } else { db.AddInParameter(dbCommand, "NewBreedFuturesPactHighLowStopValue", DbType.Decimal, model.NewBreedFuturesPactHighLowStopValue); } if (model.NewMonthFuturesPactHighLowStopValue == AppGlobalVariable.INIT_DECIMAL) { db.AddInParameter(dbCommand, "NewMonthFuturesPactHighLowStopValue", DbType.Decimal, DBNull.Value); } else { db.AddInParameter(dbCommand, "NewMonthFuturesPactHighLowStopValue", DbType.Decimal, model.NewMonthFuturesPactHighLowStopValue); } db.AddInParameter(dbCommand, "UnitsID", DbType.Int32, model.UnitsID); db.AddInParameter(dbCommand, "PriceUnit", DbType.Int32, model.PriceUnit); db.AddInParameter(dbCommand, "MarketUnitID", DbType.Int32, model.MarketUnitID); db.AddInParameter(dbCommand, "FutruesCode", DbType.String, model.FutruesCode); db.AddInParameter(dbCommand, "DeliveryMonthHighLowStopValue", DbType.Int32, model.DeliveryMonthHighLowStopValue); db.ExecuteNonQuery(dbCommand); return(true); }
/// <summary> /// 添加期货_品种_交易规则 /// </summary> /// <param name="model">期货_品种_交易规则实体</param> /// <param name="tran"></param> /// <param name="db"></param> /// <returns></returns> public bool Add(ManagementCenter.Model.QH_FuturesTradeRules model, DbTransaction tran, Database db) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into QH_FuturesTradeRules("); strSql.Append( "UnitMultiple,LeastChangePrice,IfContainCNewYear,AgreementDeliveryInstitution,FundDeliveryInstitution,BreedClassID,LastTradingDayID,ConsignQuantumID,IsSlew,HighLowStopScopeID,HighLowStopScopeValue,NewBreedFuturesPactHighLowStopValue,NewMonthFuturesPactHighLowStopValue,UnitsID,PriceUnit,MarketUnitID,FutruesCode,DeliveryMonthHighLowStopValue)"); strSql.Append(" values ("); strSql.Append( "@UnitMultiple,@LeastChangePrice,@IfContainCNewYear,@AgreementDeliveryInstitution,@FundDeliveryInstitution,@BreedClassID,@LastTradingDayID,@ConsignQuantumID,@IsSlew,@HighLowStopScopeID,@HighLowStopScopeValue,@NewBreedFuturesPactHighLowStopValue,@NewMonthFuturesPactHighLowStopValue,@UnitsID,@PriceUnit,@MarketUnitID,@FutruesCode,@DeliveryMonthHighLowStopValue)"); if (db == null) { db = DatabaseFactory.CreateDatabase(); } DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "UnitMultiple", DbType.Decimal, model.UnitMultiple); db.AddInParameter(dbCommand, "LeastChangePrice", DbType.Currency, model.LeastChangePrice); db.AddInParameter(dbCommand, "IfContainCNewYear", DbType.Int32, model.IfContainCNewYear); db.AddInParameter(dbCommand, "AgreementDeliveryInstitution", DbType.Int32, model.AgreementDeliveryInstitution); db.AddInParameter(dbCommand, "FundDeliveryInstitution", DbType.Int32, model.FundDeliveryInstitution); db.AddInParameter(dbCommand, "BreedClassID", DbType.Int32, model.BreedClassID); db.AddInParameter(dbCommand, "LastTradingDayID", DbType.Int32, model.LastTradingDayID); db.AddInParameter(dbCommand, "ConsignQuantumID", DbType.Int32, model.ConsignQuantumID); db.AddInParameter(dbCommand, "IsSlew", DbType.Int32, model.IsSlew); db.AddInParameter(dbCommand, "HighLowStopScopeID", DbType.Int32, model.HighLowStopScopeID); if (model.HighLowStopScopeValue == AppGlobalVariable.INIT_DECIMAL) { db.AddInParameter(dbCommand, "HighLowStopScopeValue", DbType.Decimal, DBNull.Value); } else { db.AddInParameter(dbCommand, "HighLowStopScopeValue", DbType.Decimal, model.HighLowStopScopeValue); } if (model.NewBreedFuturesPactHighLowStopValue == AppGlobalVariable.INIT_DECIMAL) { db.AddInParameter(dbCommand, "NewBreedFuturesPactHighLowStopValue", DbType.Decimal, DBNull.Value); } else { db.AddInParameter(dbCommand, "NewBreedFuturesPactHighLowStopValue", DbType.Decimal, model.NewBreedFuturesPactHighLowStopValue); } if (model.NewMonthFuturesPactHighLowStopValue == AppGlobalVariable.INIT_DECIMAL) { db.AddInParameter(dbCommand, "NewMonthFuturesPactHighLowStopValue", DbType.Decimal, DBNull.Value); } else { db.AddInParameter(dbCommand, "NewMonthFuturesPactHighLowStopValue", DbType.Decimal, model.NewMonthFuturesPactHighLowStopValue); } db.AddInParameter(dbCommand, "UnitsID", DbType.Int32, model.UnitsID); db.AddInParameter(dbCommand, "PriceUnit", DbType.Int32, model.PriceUnit); db.AddInParameter(dbCommand, "MarketUnitID", DbType.Int32, model.MarketUnitID); db.AddInParameter(dbCommand, "FutruesCode", DbType.String, model.FutruesCode); db.AddInParameter(dbCommand, "DeliveryMonthHighLowStopValue", DbType.Int32, model.DeliveryMonthHighLowStopValue); // db.ExecuteNonQuery(dbCommand); object obj; if (tran == null) { obj = db.ExecuteNonQuery(dbCommand); } else { obj = db.ExecuteNonQuery(dbCommand, tran); } return(true); }