bb9266fdf2cc2c28217fd81bb21d740fd9045a54.svn-base 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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_OperSet : 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_OperSet(
  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_DataInitialize);
  48. this.FetchData += new FetchEventHandler(ActiveReport_FetchData);
  49. //
  50. // 데이타 (결과가 어떤 타입인지에 따라 레포트 타입이 결정된다)
  51. //
  52. ResultData_Info = ResultData;
  53. //
  54. // UI
  55. //
  56. // 제목
  57. this.label_Header_Title.Text = Title;
  58. // 개요Z
  59. this.textBox_Header_Summary.Text = Summary;
  60. // 헤더정보
  61. ColumnHeader_Info = ColumnHeader;
  62. // 가변 레포트의 경우 아래 주석 복구
  63. // 필드 생성 (디자이너의 TextBox 마다 지정되어 있는 필드와 매칭하기 위해서는 반드시 아래와 동일한 이름으로 추가해야 한다)
  64. //_ActiveReport.Create_Column(this, this.pageHeader, this.detail, ColumnHeader_Info, ColumnHeight, FontSize);
  65. // 고정 레포트의 경우 필드명만 매칭
  66. foreach(string ColumnName in ColumnHeader_Info)
  67. this.Fields.Add(ColumnName);
  68. // 진행팝업창
  69. Popup_ReportCreate_Progress = ProgressbarPopup;
  70. }
  71. /// <summary>
  72. /// DataInitialize Event
  73. /// ActiveReports event that is called during the report initalization
  74. /// procedure. (after .Run is called on your report object) Normally used
  75. /// with unbound reporting to establish an active connection to your data
  76. /// to be used with the FetchData event, or to setup a bound report with a
  77. /// dynamic database connection at runtime.
  78. /// This is also where you should include any Fields values that you need to
  79. /// add for unbound reporting.
  80. /// </summary>
  81. private void ActiveReport_DataInitialize(object sender, System.EventArgs eArgs)
  82. {
  83. ;
  84. }
  85. /// <summary>
  86. /// FetchData Event
  87. /// ActiveReports event that is called during the report run once per
  88. /// row from the dataset. This event is usually only used in unbound reporting,
  89. /// you would set the Fields collection value to the value from your dataset and
  90. /// advance the next row. When you run out of data, you should set the
  91. /// FetchEventArgs argument's EOF field to true to tell the report that the report
  92. /// is done with the data.
  93. /// </summary>
  94. private void ActiveReport_FetchData(object sender, FetchEventArgs eArgs)
  95. {
  96. //
  97. // DataRowCollection
  98. //
  99. if (ResultData_Info.GetType() == typeof(DataRowCollection))
  100. {
  101. if (RowCounter == ((DataRowCollection)ResultData_Info).Count)
  102. {
  103. // 데이타를 다 읽었음
  104. eArgs.EOF = true;
  105. }
  106. else
  107. {
  108. // ColumnHeader_Info 의 경우 DataRowCollection 의 DataRow 변수명이 동일하다고 가정한다
  109. for (int i = 0; i < ColumnHeader_Info.Count; i++)
  110. {
  111. // 키값 조회
  112. string Key = ColumnHeader_Info[i].ToString();//((_Report_Column_Info)ColumnHeader_Info[i]).Column_Key;
  113. // 예외 조건 확인후 레포트 데이타 삽입
  114. if (_ActiveReport.Exception_ReportPrint(this, Key, RowCounter, ((DataRow)((DataRowCollection)ResultData_Info)[RowCounter])) == false)
  115. this.Fields[Key].Value = ((DataRow)((DataRowCollection)ResultData_Info)[RowCounter])[Key];
  116. }
  117. // 진행바 카운터가 증가한다
  118. _Event.ProgressPopupCount_SendMessage(Popup_ReportCreate_Progress, ++Popup_ReportCreate_Progress_Count);
  119. // 인덱스 증가
  120. RowCounter++;
  121. // 데이타를 아직 덜읽었음
  122. eArgs.EOF = false;
  123. }
  124. }
  125. //
  126. // ArrayList
  127. //
  128. else if (ResultData_Info.GetType() == typeof(ArrayList))
  129. {
  130. if (RowCounter == ((ArrayList)ResultData_Info).Count)
  131. {
  132. // 데이타를 다 읽었음
  133. eArgs.EOF = true;
  134. }
  135. else
  136. {
  137. // ColumnHeader_Info 의 경우 ArrayList 의 클래스의 멤버명이 일치한다고 가정한다
  138. for (int i = 0; i < ColumnHeader_Info.Count; i++)
  139. {
  140. // 키값 조회
  141. string Key = ColumnHeader_Info[i].ToString();//((_Report_Column_Info)ColumnHeader_Info[i]).Column_Key;
  142. // 레포트 데이타 타입
  143. this.Fields[Key].Value = _Reflection.GetMemberValue_ArrayList_ByClass(((ArrayList)ResultData_Info), RowCounter, Key);
  144. }
  145. // 진행바 카운터가 증가한다
  146. _Event.ProgressPopupCount_SendMessage(Popup_ReportCreate_Progress, ++Popup_ReportCreate_Progress_Count);
  147. // 인덱스 증가
  148. RowCounter++;
  149. // 데이타를 아직 덜읽었음
  150. eArgs.EOF = false;
  151. }
  152. }
  153. }
  154. }
  155. }