private static string AttrFor(DataColumn dc, ReportColumn.ColourDelegate bgColour, string theValue) { string sAttr = ""; if (dc != null) { if (dc.DataType == Type.GetType("System.Decimal") || dc.DataType == Type.GetType("System.Int32")) { sAttr = "ALIGN='RIGHT'"; } if (dc.DataType != null && dc.DataType.Equals(Type.GetType("System.String"))) { sAttr = "ALIGN='CENTER'"; } if (bgColour != null) { if ((!string.IsNullOrEmpty(theValue))) { var numberSpot = theValue.IndexOf(":"); if (numberSpot > -1) { var numberPart = theValue.Substring(0, numberSpot); if (numberPart.Equals("-")) { numberPart = theValue.Substring(0, 2); } if (!string.IsNullOrEmpty(numberPart)) { if (!numberPart.Equals(":")) { sAttr += " BGCOLOR=" + bgColour(Int32.Parse(numberPart)); } } } } } } return(sAttr + " VALIGN='TOP'"); }
private SimpleTableReport DefineSte() { ReportColumn.ColourDelegate totalColourDelegateIn = PickTotalColourDelegate(); var str = new SimpleTableReport(Heading) { ColumnHeadings = true, DoRowNumbers = true }; str.AddColumn(new ReportColumn("Team", "TEAM", "{0,-20}")); str.AddColumn(new ReportColumn("Total", "TOTAL", "{0:0.00}", typeof(decimal), tally: true, colourDelegateIn: totalColourDelegateIn)); var startAt = Constants.K_WEEKS_IN_REGULAR_SEASON; for (var w = startAt; w > 0; w--) { var header = string.Format("Week {0}", w); var fieldName = string.Format(FieldFormat, w); ReportColumn.ColourDelegate colourDelegateIn = PickColourDelegate(); str.AddColumn(new ReportColumn(header, fieldName, "{0,5}", colourDelegateIn)); } return(str); }
private static string AttrFor( DataColumn dc, ReportColumn.ColourDelegate bgColour, string theValue) { var sAttr = ""; if (dc != null) { if (dc.DataType == Type.GetType("System.Decimal") || dc.DataType == Type.GetType("System.Int32")) { sAttr = "ALIGN='RIGHT'"; } //sAttr = "class='num'"; if (dc.DataType != null && dc.DataType == Type.GetType("System.String")) { sAttr = "ALIGN='CENTER'"; } if (bgColour != null) { if ((!string.IsNullOrEmpty(theValue))) { // look for data with a colon in it (we only need to use the number) var numberSpot = theValue.IndexOf( ":", StringComparison.Ordinal); if (numberSpot > -1) { var numberPart = theValue.Substring(0, numberSpot); if (numberPart.Equals("-")) { numberPart = theValue.Substring(0, 2); } if (!string.IsNullOrEmpty(numberPart)) { if (!numberPart.Equals(":")) { sAttr += " BGCOLOR=" + bgColour( Int32.Parse(numberPart)); } } } else { if (theValue.Contains('(')) { int rankNo = GetRankNo(theValue); sAttr += " BGCOLOR=" + bgColour(rankNo); } else { if (Decimal.TryParse( theValue, out decimal parsedVal)) { sAttr += " BGCOLOR=" + bgColour(( int )parsedVal); } else { var decimalString = GetInnerText(theValue); if (Decimal.TryParse(decimalString, out decimal parsedStringVal)) { sAttr += " BGCOLOR=" + bgColour(( int )parsedStringVal); } } } } } } } return(sAttr + " VALIGN='TOP'"); }