f6a3f62b07113abaade73c18362d5d8312c8bd89.svn-base 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using DataDynamics.ActiveReports;
  7. using DataDynamics.ActiveReports.Document;
  8. using System.Data;
  9. using System.Windows.Forms;
  10. using System.IO;
  11. using DataDynamics.ActiveReports.Design;
  12. using System.Reflection;
  13. namespace IControls_FireManager
  14. {
  15. /// <summary>
  16. /// 동적으로 데이타를 처리하는 레포트이다. 실제로 데이타베이스에서 가져오든, 혹은 사용자가 직접 생성한 데이타를 ArrayList 혹은 DataColection 으로 받고
  17. /// 그 데이타를 컬럼화 하여 직접 레포트를 구성하여 출력하도록 한다. 또한 데이타 추출을 위해 Reflection 을 적용하여 타입 및 클래스 멤버를 추출한다
  18. /// </summary>
  19. public partial class ActiveReport_Variable_Height : DataDynamics.ActiveReports.ActiveReport
  20. {
  21. // 출력 인덱스
  22. public int RowCounter = 0;
  23. // 결과 데이타의 (DataRow 혹은 Class) 집합
  24. public object ResultData_Info = null;
  25. // 컬럼 헤더 정보
  26. public ArrayList ColumnHeader_Info = new ArrayList();
  27. // 진행 팝업창
  28. public Form Popup_ReportCreate_Progress = new Form();
  29. public int Popup_ReportCreate_Progress_Count = 0; // 카운트
  30. // 생성자
  31. public ActiveReport_Variable_Height(
  32. Form ProgressbarPopup, // 진행바 팝업창
  33. object ResultData, // 실제로 레포트에 출력할 데이타를 전달받음
  34. ArrayList ColumnHeader, // 컬럼 텍스트명 및 길이 추출정보필드 (참고: _Report_Column_Info 타입의 클래스의 리스트 정보)
  35. string Title, // 제목
  36. string Summary, // 개요
  37. float ColumnHeight, // 컬럼 높이
  38. int FontSize) // 폰트 사이즈
  39. {
  40. //
  41. // Required for Windows Form Designer support
  42. //
  43. InitializeComponent();
  44. //
  45. // 이벤트
  46. //
  47. this.DataInitialize += new System.EventHandler(this.ActiveReport_Variable_DataInitialize);
  48. this.FetchData += new FetchEventHandler(ActiveReport_Variable_FetchData);
  49. //
  50. // 데이타 (결과가 어떤 타입인지에 따라 레포트 타입이 결정된다)
  51. //
  52. ResultData_Info = ResultData;
  53. //
  54. // UI
  55. //
  56. // 제목
  57. this.label_Header_Title.Text = Title;
  58. // 개요
  59. this.textBox_Header_Summary.Text = Summary;
  60. // 헤더정보
  61. ColumnHeader_Info = ColumnHeader;
  62. // 필드 생성 (디자이너의 TextBox 마다 지정되어 있는 필드와 매칭하기 위해서는 반드시 아래와 동일한 이름으로 추가해야 한다)
  63. _ActiveReport.Create_Column(this, this.pageHeader, this.detail, ColumnHeader_Info, ColumnHeight, FontSize);
  64. // 진행팝업창
  65. Popup_ReportCreate_Progress = ProgressbarPopup;
  66. }
  67. /// <summary>
  68. /// DataInitialize Event
  69. /// ActiveReports event that is called during the report initalization
  70. /// procedure. (after .Run is called on your report object) Normally used
  71. /// with unbound reporting to establish an active connection to your data
  72. /// to be used with the FetchData event, or to setup a bound report with a
  73. /// dynamic database connection at runtime.
  74. /// This is also where you should include any Fields values that you need to
  75. /// add for unbound reporting.
  76. /// </summary>
  77. private void ActiveReport_Variable_DataInitialize(object sender, System.EventArgs eArgs)
  78. {
  79. ;
  80. }
  81. /// <summary>
  82. /// FetchData Event
  83. /// ActiveReports event that is called during the report run once per
  84. /// row from the dataset. This event is usually only used in unbound reporting,
  85. /// you would set the Fields collection value to the value from your dataset and
  86. /// advance the next row. When you run out of data, you should set the
  87. /// FetchEventArgs argument's EOF field to true to tell the report that the report
  88. /// is done with the data.
  89. /// </summary>
  90. private void ActiveReport_Variable_FetchData(object sender, FetchEventArgs eArgs)
  91. {
  92. //
  93. // DataRowCollection
  94. //
  95. if (ResultData_Info.GetType() == typeof(DataRowCollection))
  96. {
  97. if (RowCounter == ((DataRowCollection)ResultData_Info).Count)
  98. {
  99. // 데이타를 다 읽었음
  100. eArgs.EOF = true;
  101. }
  102. else
  103. {
  104. // ColumnHeader_Info 의 경우 DataRowCollection 의 DataRow 변수명이 동일하다고 가정한다
  105. for (int i = 0; i < ColumnHeader_Info.Count; i++)
  106. {
  107. // 키값 조회
  108. string Key = ((_Report_Column_Info)ColumnHeader_Info[i]).Column_Key;
  109. // 예외 조건 확인후 레포트 데이타 삽입
  110. if (_ActiveReport.Exception_ReportPrint(this, Key, RowCounter, ((DataRow)((DataRowCollection)ResultData_Info)[RowCounter])) == false)
  111. this.Fields[Key].Value = ((DataRow)((DataRowCollection)ResultData_Info)[RowCounter])[Key].ToString();
  112. }
  113. // 진행바 카운터가 증가한다
  114. _Event.ProgressPopupCount_SendMessage(Popup_ReportCreate_Progress, ++Popup_ReportCreate_Progress_Count);
  115. // 인덱스 증가
  116. RowCounter++;
  117. // 데이타를 아직 덜읽었음
  118. eArgs.EOF = false;
  119. }
  120. }
  121. //
  122. // ArrayList
  123. //
  124. else if (ResultData_Info.GetType() == typeof(ArrayList))
  125. {
  126. if (RowCounter == ((ArrayList)ResultData_Info).Count)
  127. {
  128. // 데이타를 다 읽었음
  129. eArgs.EOF = true;
  130. }
  131. else
  132. {
  133. // ColumnHeader_Info 의 경우 ArrayList 의 클래스의 멤버명이 일치한다고 가정한다
  134. for (int i = 0; i < ColumnHeader_Info.Count; i++)
  135. {
  136. // 키값 조회
  137. string Key = ((_Report_Column_Info)ColumnHeader_Info[i]).Column_Key;
  138. // 레포트 데이타 타입
  139. this.Fields[Key].Value = _Reflection.GetMemberValue_ArrayList_ByClass(((ArrayList)ResultData_Info), RowCounter, Key);
  140. }
  141. // 진행바 카운터가 증가한다
  142. _Event.ProgressPopupCount_SendMessage(Popup_ReportCreate_Progress, ++Popup_ReportCreate_Progress_Count);
  143. // 인덱스 증가
  144. RowCounter++;
  145. // 데이타를 아직 덜읽었음
  146. eArgs.EOF = false;
  147. }
  148. }
  149. }
  150. }
  151. }