/// <summary> /// 增加一条数据 /// </summary> public bool Add(ManagementCenter.Model.XH_MinChangePriceValue model, DbTransaction tran, Database db) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into XH_MinChangePriceValue("); strSql.Append("Value,BreedClassID,FieldRangeID)"); strSql.Append(" values ("); strSql.Append("@Value,@BreedClassID,@FieldRangeID)"); if (db == null) { db = DatabaseFactory.CreateDatabase(); } DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "Value", DbType.Currency, model.Value); db.AddInParameter(dbCommand, "BreedClassID", DbType.Int32, model.BreedClassID); db.AddInParameter(dbCommand, "FieldRangeID", DbType.Int32, model.FieldRangeID); //db.ExecuteNonQuery(dbCommand); object obj; if (tran == null) { obj = db.ExecuteNonQuery(dbCommand); } else { obj = db.ExecuteNonQuery(dbCommand, tran); } return(true); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(ManagementCenter.Model.XH_MinChangePriceValue model, DbTransaction tran, Database db) { StringBuilder strSql = new StringBuilder(); strSql.Append("update XH_MinChangePriceValue set "); strSql.Append("Value=@Value"); strSql.Append(" where BreedClassID=@BreedClassID and FieldRangeID=@FieldRangeID "); if (db == null) { db = DatabaseFactory.CreateDatabase(); } DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "Value", DbType.Currency, model.Value); db.AddInParameter(dbCommand, "BreedClassID", DbType.Int32, model.BreedClassID); db.AddInParameter(dbCommand, "FieldRangeID", DbType.Int32, model.FieldRangeID); //db.ExecuteNonQuery(dbCommand); if (tran == null) { db.ExecuteNonQuery(dbCommand); } else { db.ExecuteNonQuery(dbCommand, tran); } return(true); }
/// <summary> /// 得到一个对象实体 /// </summary> public ManagementCenter.Model.XH_MinChangePriceValue GetModel(int BreedClassID, int FieldRangeID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select Value,BreedClassID,FieldRangeID from XH_MinChangePriceValue "); strSql.Append(" where BreedClassID=@BreedClassID and FieldRangeID=@FieldRangeID "); Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "BreedClassID", DbType.Int32, BreedClassID); db.AddInParameter(dbCommand, "FieldRangeID", DbType.Int32, FieldRangeID); ManagementCenter.Model.XH_MinChangePriceValue model = null; using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { model = ReaderBind(dataReader); } } return(model); }
/// <summary> /// 对象实体绑定数据 /// </summary> public ManagementCenter.Model.XH_MinChangePriceValue ReaderBind(IDataReader dataReader) { ManagementCenter.Model.XH_MinChangePriceValue model = new ManagementCenter.Model.XH_MinChangePriceValue(); object ojb; ojb = dataReader["Value"]; if (ojb != null && ojb != DBNull.Value) { model.Value = (decimal)ojb; } ojb = dataReader["BreedClassID"]; if (ojb != null && ojb != DBNull.Value) { model.BreedClassID = (int)ojb; } ojb = dataReader["FieldRangeID"]; if (ojb != null && ojb != DBNull.Value) { model.FieldRangeID = (int)ojb; } return(model); }
/// <summary> /// 更新交易规则_最小变动价位_范围_值 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool Update(ManagementCenter.Model.XH_MinChangePriceValue model) { return(Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(ManagementCenter.Model.XH_MinChangePriceValue model) { return(Add(model, null, null)); }