/// <summary> /// 更新一条数据 /// </summary> public void Update(ManagementCenter.Model.XH_MaxLeaveQuantityRangeValue model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update XH_MaxLeaveQuantityRangeValue set "); strSql.Append("Value=@Value"); strSql.Append(" where BreedClassID=@BreedClassID and FieldRangeID=@FieldRangeID "); Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "Value", DbType.Decimal, model.Value); db.AddInParameter(dbCommand, "BreedClassID", DbType.Int32, model.BreedClassID); db.AddInParameter(dbCommand, "FieldRangeID", DbType.Int32, model.FieldRangeID); db.ExecuteNonQuery(dbCommand); }
/// <summary> /// 增加一条数据 /// </summary> public void Add(ManagementCenter.Model.XH_MaxLeaveQuantityRangeValue model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into XH_MaxLeaveQuantityRangeValue("); strSql.Append("Value,BreedClassID,FieldRangeID)"); strSql.Append(" values ("); strSql.Append("@Value,@BreedClassID,@FieldRangeID)"); Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "Value", DbType.Decimal, model.Value); db.AddInParameter(dbCommand, "BreedClassID", DbType.Int32, model.BreedClassID); db.AddInParameter(dbCommand, "FieldRangeID", DbType.Int32, model.FieldRangeID); db.ExecuteNonQuery(dbCommand); }
/// <summary> /// 得到一个对象实体 /// </summary> public ManagementCenter.Model.XH_MaxLeaveQuantityRangeValue GetModel(int BreedClassID, int FieldRangeID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select Value,BreedClassID,FieldRangeID from XH_MaxLeaveQuantityRangeValue "); 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_MaxLeaveQuantityRangeValue model = null; using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { model = ReaderBind(dataReader); } } return(model); }
/// <summary> /// 对象实体绑定数据 /// </summary> public ManagementCenter.Model.XH_MaxLeaveQuantityRangeValue ReaderBind(IDataReader dataReader) { ManagementCenter.Model.XH_MaxLeaveQuantityRangeValue model = new ManagementCenter.Model.XH_MaxLeaveQuantityRangeValue(); 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); }