or
| AggregateCollection coll = e.Group.Aggregates; | |
| double max = 0, current = 0; | |
| foreach (Aggregate agg in coll) | |
| { | |
| switch (agg.FieldName) | |
| { | |
| case "max": | |
| max += Convert.ToDouble(agg.Value.ToString()); | |
| break; | |
| case "current": | |
| current += Convert.ToDouble(agg.Value.ToString()); | |
| break; | |
| } | |
| } | |
| double percentage = 0; | |
| if (max == 0 && current == 0) | |
| { | |
| percentage = 0; | |
| } | |
| else | |
| { | |
| if (max == 0 && current > 0) | |
| { | |
| percentage = 1.1; | |
| } | |
| else | |
| { | |
| percentage = current / max; | |
| } | |
| } | |
| if (percentage > 0) | |
| { | |
| e.Group.HeaderRow.GridViewInfo.GridViewElement.BackColor = Color.LightGreen; | |
| } | |
| if (percentage >= .6) // Indicate middle tier (yellow) | |
| { | |
| e.Group.HeaderRow.GridViewInfo.GridViewElement.BackColor = Color.Yellow; | |
| } | |
| if (percentage >= .8) // Indicate upper tier (red) | |
| { | |
| e.Group.HeaderRow.GridViewInfo.GridViewElement.BackColor = Color.Red; | |
| } | |
| if (percentage > 1.0) // Indicate overbooked (violet) | |
| { | |
| e.Group.HeaderRow.GridViewInfo.GridViewElement.BackColor = Color.Violet; | |
| } |