TrendHFHtml.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using CB.Data;
  6. using CB.Entity;
  7. namespace CB.TrendChart.LotteryTrendChart
  8. {
  9. public class TrendHFHtml
  10. {
  11. /// <summary>
  12. /// 生成头部HTML代码
  13. /// </summary>
  14. /// <param name="chartId"></param>
  15. /// <param name="chartType"></param>
  16. /// <returns></returns>
  17. public static string CreateHeadHtml(int chartId, TrendChartType chartType)
  18. {
  19. StringBuilder sp = new StringBuilder(20000);
  20. //获取走势图项及配置数据
  21. var trendChartItem = TrendChartItemService.ToListByChartId(chartId, chartType);
  22. if (null == trendChartItem || 0 >= trendChartItem.Count)
  23. return "";
  24. sp.Append("<tr>");
  25. int i = 0;
  26. foreach (var item in trendChartItem)
  27. {
  28. if (item.ItemString.Length <= 1)
  29. {
  30. if (0 == i)
  31. sp.Append(string.Format("<th id=\"trend_sort\" class=\"sort_up\" rowspan=\"{0}\"><strong>{1}</strong></th>", 2, item.ChartItemName));
  32. else
  33. sp.Append(string.Format("<th rowspan=\"{0}\">{1}</th>", 2, item.ChartItemName));
  34. }
  35. else
  36. {
  37. sp.Append(string.Format("<th colspan=\"{0}\">{1}</th>", item.ItemString.Length, item.ChartItemName));
  38. }
  39. i++;
  40. }
  41. sp.Append("</tr>");
  42. sp.Append("<tr>");
  43. foreach (var item in trendChartItem)
  44. {
  45. if (item.ItemString.Length > 1)
  46. {
  47. foreach (var value in item.ItemString)
  48. {
  49. sp.Append(string.Format("<th>{0}</th>", value));
  50. }
  51. }
  52. }
  53. sp.Append("</tr>");
  54. return sp.ToString();
  55. }
  56. /// <summary>
  57. /// 生成尾部HTML代码
  58. /// </summary>
  59. /// <param name="chartId"></param>
  60. /// <param name="chartType"></param>
  61. /// <returns></returns>
  62. public static string CreateFootHtml(int chartId, TrendChartType chartType)
  63. {
  64. StringBuilder sp = new StringBuilder(20000);
  65. //获取走势图项及配置数据
  66. var trendChartItem = TrendChartItemService.ToListByChartId(chartId, chartType);
  67. if (null == trendChartItem || 0 >= trendChartItem.Count)
  68. return "";
  69. sp.Append("<tr>");
  70. foreach (var item in trendChartItem)
  71. {
  72. if (item.ItemString.Length <= 1)
  73. {
  74. sp.Append(string.Format("<th rowspan=\"{0}\">{1}</th>", 2, item.ChartItemName));
  75. }
  76. if (item.ItemString.Length > 1)
  77. {
  78. foreach (var value in item.ItemString)
  79. {
  80. sp.Append(string.Format("<th>{0}</th>", value));
  81. }
  82. }
  83. }
  84. sp.Append("</tr>");
  85. sp.Append("<tr>");
  86. foreach (var item in trendChartItem)
  87. {
  88. if (item.ItemString.Length > 1)
  89. {
  90. sp.Append(string.Format("<th colspan=\"{0}\">{1}</th>", item.ItemString.Length, item.ChartItemName));
  91. }
  92. }
  93. sp.Append("</tr>");
  94. return sp.ToString();
  95. }
  96. }
  97. }