7c03087fbbda735e6c70fb869c4dd0dbfd84facd.svn-base 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using DevExpress.XtraReports.UI;
  6. using iBemsDataService.Model;
  7. using System.Data.Entity;
  8. using System.Data.Entity.Infrastructure;
  9. using System.Linq;
  10. using System.Collections.Generic;
  11. using iBemsDataService.Util;
  12. namespace iBemsDataService.Report
  13. {
  14. public partial class PatrolReport : DevExpress.XtraReports.UI.XtraReport
  15. {
  16. private iBemsEntities db = new iBemsEntities();
  17. private int siteId;
  18. private DateTime startDate;
  19. private DateTime endDate;
  20. public PatrolReport()
  21. {
  22. InitializeComponent();
  23. }
  24. public PatrolReport(int siteId, DateTime startDate, DateTime endDate) : this()
  25. {
  26. this.siteId = siteId;
  27. this.startDate = startDate;
  28. this.endDate = endDate;
  29. }
  30. protected override void OnBeforePrint(System.Drawing.Printing.PrintEventArgs e)
  31. {
  32. base.OnBeforePrint(e);
  33. //xrLabelDate.Text = String.Format("순찰일자 : {0}", DateTime.Now.ToString("yyyy-MM-dd"));
  34. xrLabelDate.Text = String.Format("> 순찰일자 : {0}", startDate.ToString("yyyy-MM-dd"));
  35. List<CmPatrolHistory> pHList =
  36. (from x in db.CmPatrolHistory
  37. where x.SiteId == siteId &&
  38. x.startDate >= startDate && x.endDate != null && // 2016 09 20 hcLee 추가
  39. x.startDate <= endDate
  40. orderby x.startDate descending, x.endDate descending
  41. select x).ToList<CmPatrolHistory>();
  42. /*
  43. List<PatrolHistoryDataSource> patrolHistoryList =
  44. (from x in db.CmPatrolHistory
  45. where x.SiteId == siteId &&
  46. x.startDate >= startDate && x.endDate != null && // 2016 09 20 hcLee 추가
  47. x.startDate <= endDate
  48. orderby x.startDate descending, x.endDate descending
  49. select new PatrolHistoryDataSource
  50. {
  51. PatrolSheduleName = x.CmPatrolSchedule.Name,
  52. PatrolTeam = x.CmPatrolSchedule.CmPatrolPlan.CmPatrolGroup.Name,
  53. PatrolCourse = x.CmPatrolSchedule.CmPatrolPlan.CmPatrolCourse.Name,
  54. StartDate = x.startDate,
  55. EndDate = (System.DateTime)x.endDate,
  56. //Result = x.CmPatrolType.Name,
  57. Result = String.Format("{0}/{1}/{2}", x.resultPosCnt, x.resultNormalCnt, x.resultAbnormalCnt),
  58. //resultPosCnt = (int)x.resultPosCnt,
  59. //resultNormalCnt = (int)x.resultNormalCnt,
  60. //resultAbnormalCnt = (int) x.resultAbnormalCnt,
  61. ResultDesc = x.resultDesc
  62. }).ToList<PatrolHistoryDataSource>(); */
  63. List<PatrolHistoryDataSource> patrolHistoryList = new List<PatrolHistoryDataSource>();
  64. foreach (CmPatrolHistory x in pHList)
  65. {
  66. PatrolHistoryDataSource pdata = new PatrolHistoryDataSource();
  67. pdata.PatrolSheduleName = x.CmPatrolSchedule.Name;
  68. pdata.PatrolTeam = x.CmPatrolSchedule.CmPatrolPlan.CmPatrolGroup.Name;
  69. pdata.PatrolCourse = x.CmPatrolSchedule.CmPatrolPlan.CmPatrolCourse.Name;
  70. pdata.StartDate = x.startDate;
  71. pdata.EndDate = (System.DateTime)x.endDate;
  72. pdata.Result = String.Format("{0}/{1}/{2}", x.resultPosCnt, x.resultNormalCnt, x.resultAbnormalCnt);
  73. pdata.ResultDesc = x.resultDesc;
  74. patrolHistoryList.Add(pdata);
  75. }
  76. String resultDescs = String.Empty;
  77. int listCount = patrolHistoryList.Count;
  78. for (int i = 0; i < listCount; i++)
  79. {
  80. patrolHistoryList[i].No = patrolHistoryList.Count - i;
  81. resultDescs += String.Format("{0} : {1}\n", patrolHistoryList[i].PatrolSheduleName, patrolHistoryList[i].ResultDesc);
  82. }
  83. XRTable tablePatrolHistory = ReportTableHandler.CreateTableFromListWithColumnWidthPatrol(
  84. patrolHistoryList,
  85. //new float[] { 72.39f, 150f, 120f, 120f, 140f, 140f, 96.61f },
  86. new float[] { 69.02f, 143.03f, 114.41f, 114.41f, 133.49f, 133.49f, 92.15f },
  87. new String[] { "ResultDesc" });
  88. tablePatrolHistory.LocationF = new Point(20, 0);
  89. xrRichTextResultDesc.Text = resultDescs;
  90. if (tablePatrolHistory.Rows.Count > 0)
  91. {
  92. DetailPatrolReport.Controls.Clear();
  93. DetailPatrolReport.Controls.Add(tablePatrolHistory);
  94. }
  95. }
  96. public class PatrolHistoryDataSource
  97. {
  98. public int No { get; set; }
  99. public String PatrolSheduleName { get; set; }
  100. public String PatrolTeam { get; set; }
  101. public String PatrolCourse { get; set; }
  102. public DateTime StartDate { get; set; }
  103. public DateTime EndDate { get; set; }
  104. public String Result { get; set; }
  105. //public int resultPosCnt { get; set; }
  106. //public int resultNormalCnt { get; set; }
  107. //public int resultAbnormalCnt { get; set; }
  108. public String ResultDesc { get; set; }
  109. }
  110. }
  111. }