85fdea2e6331d52edb553e0d13efd838ed5e4c90.svn-base 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using Janus.Windows.GridEX;
  10. using System.Collections;
  11. namespace IControls_FireManager
  12. {
  13. public partial class Form_AddGroup : Form
  14. {
  15. //** 어레이리스트를 만들어 시컨스 정보만 저장하여 가장 큰 Value를 찾아낸다
  16. ArrayList Sequence = new ArrayList();
  17. // 수신기 ID를 저장하기 위해서
  18. string Receiver_ID = null;
  19. public Form_AddGroup(string RECEIVER_ID)
  20. {
  21. InitializeComponent();
  22. // 수신기 아이디 저장
  23. Receiver_ID = RECEIVER_ID;
  24. // 수신기 아이디 콤보박스 추가
  25. UI_ComboBox_ReceiverID_Initialize();
  26. //** 폼로드시 출입그룹에 있는 GridEx 셋팅
  27. UI_OutDeviceGroup_GridEx_Initialize();
  28. // 이전 값을 불러온다
  29. this.EditBox_GroupName.Text = _Data.Temp_GroupName;
  30. ///
  31. /// 폼이 생성되는 위치
  32. ///
  33. this.StartPosition = FormStartPosition.Manual;
  34. this.Location = new System.Drawing.Point(MousePosition.X, MousePosition.Y);
  35. }
  36. // 폼로드시에 수신기 아이디도 고려할수 있도록 콤보박스 추가
  37. public void UI_ComboBox_ReceiverID_Initialize()
  38. {
  39. this.UiComboBox_ReceiverID.Items.Clear();
  40. this.UiComboBox_ReceiverID.Items.Add(_Text.Null);
  41. foreach (string receive in _Data.LIST_XMLRECEIVER_ID)
  42. {
  43. UiComboBox_ReceiverID.Items.Add(receive);
  44. }
  45. }
  46. //** 폼로드시 출입그룹에 있는 GridEx 셋팅
  47. public void UI_OutDeviceGroup_GridEx_Initialize()
  48. {
  49. //
  50. //** 폼로드 할 때, 먼저 GridEX_GroupList 클리어
  51. //
  52. // GridEX_GroupList 클리어
  53. GridEX_GroupList.ClearItems();
  54. // No.를 출력하기 위해서
  55. int i = 1;
  56. //** TB_GROUP 테이블에서 출력그룹을 모두 가지고 온다
  57. DataRowCollection DB_TABLE_DEVICE = _Db.ExecuteRead_SqlDataAdapter(_Sql.SearchAll_Table_Value("TB_GROUP", null)); // 네트워크 수신기에서 그룹 아이디는 유일하다
  58. if (DB_TABLE_DEVICE != null)
  59. {
  60. foreach (DataRow dr in DB_TABLE_DEVICE)
  61. {
  62. GridEXRow row;
  63. row = GridEX_GroupList.AddItem();
  64. row.BeginEdit();
  65. row.Cells["Number"].Value = i++;
  66. row.Cells["ReceiverID"].Value = dr[0].ToString(); // 그룹이 속해 있는 수신기 아이디
  67. row.Cells["ID"].Value = dr[1].ToString();
  68. row.Cells["Group"].Value = dr[2].ToString();
  69. row.EndEdit();
  70. }
  71. }
  72. }
  73. //** 조회버튼
  74. private void UiButton_Search_Group_Click(object sender, EventArgs e)
  75. {
  76. // 이전 값을 저장해둔다
  77. _Data.Temp_GroupName = this.EditBox_GroupName.Text;
  78. // GridEX_GroupList 클리어
  79. GridEX_GroupList.ClearItems();
  80. // No.를 출력하기 위해서
  81. int i = 1;
  82. //** TB_GROUP 테이블에서 출력그룹을 모두 가지고 온다
  83. DataRowCollection DB_TABLE_DEVICE = _Db.ExecuteRead_SqlDataAdapter(_Sql.Search_Table("TB_GROUP", "GROUP_ID", UiComboBox_GroupID.Text, "GROUP_NAME", EditBox_GroupName.Text, this.UiComboBox_ReceiverID.Text));
  84. if (DB_TABLE_DEVICE != null)
  85. {
  86. foreach (DataRow dr in DB_TABLE_DEVICE)
  87. {
  88. GridEXRow row;
  89. row = GridEX_GroupList.AddItem();
  90. row.BeginEdit();
  91. row.Cells["Number"].Value = i++;
  92. row.Cells["ReceiverID"].Value = dr[0].ToString(); // 그룹이 속해 있는 수신기 아이디
  93. row.Cells["ID"].Value = dr[1].ToString();
  94. row.Cells["Group"].Value = dr[2].ToString();
  95. row.EndEdit();
  96. }
  97. }
  98. }
  99. //** 추가버튼
  100. private void UiButton_AddDevice_Click(object sender, EventArgs e)
  101. {
  102. //** 회로추가나 그룹추가폼을 띄워둔 상태에서 그룹명이나 맵명을 추가하거나 삭제하면 selected 된 행이 없어진다.
  103. // 하지만 회로추가나 그룹추가는 할 수 있으므로 이를 방지해야한다
  104. if (_Data.Map_No != null)
  105. {
  106. //** 시컨스 클리어
  107. Sequence.Clear();
  108. int MaxValue = 0;
  109. int SelectRowCount = GridEX_GroupList.SelectedItems.Count;
  110. //** 선택한 행이 하나도 없다면....
  111. if (SelectRowCount == 0)
  112. {
  113. // 그룹을 선택해 주세요
  114. _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.OK, 250, 150, _Text.GroupNameNotChoice, 0);
  115. return;
  116. }
  117. for (int number = 0; number < SelectRowCount; number++)
  118. {
  119. GridEXRow row = GridEX_GroupList.SelectedItems[number].GetRow();
  120. string Group_ID = row.Cells["ID"].Value.ToString();
  121. //** 어레이리스트를 만들어 시컨스 정보만 저장하여 가장 큰 Value를 찾아낸다
  122. Sequence.Add("0");
  123. //DataRowCollection DB_TABLE_MAP_PROCESS = _Db.ExecuteRead_SqlDataAdapter(_Sql.SearchAll_Table_Value("TB_MAP_PROCESS", "MAP_NO", _Data.Map_No, "MAP_TYPE", "O", Receiver_ID));
  124. // 위와 같이 RECEIVER_ID 가 아닌 MAP_RECEIVER_ID으로 기준하여 쿼리해야한다
  125. DataRowCollection DB_TABLE_MAP_PROCESS = _Db.ExecuteRead_SqlDataAdapter(_Sql.SearchAll_Table_Value_MAP_RECEIVER_ID("TB_MAP_PROCESS", "MAP_NO", _Data.Map_No, "MAP_TYPE", "O", Receiver_ID));
  126. if (DB_TABLE_MAP_PROCESS != null)
  127. {
  128. foreach (DataRow dr in DB_TABLE_MAP_PROCESS)
  129. {
  130. if (dr[3] == null || dr[3].ToString().Trim().Length == 0)
  131. {
  132. ; // 오류
  133. }
  134. else
  135. Sequence.Add(dr[3].ToString());
  136. }
  137. }
  138. foreach (string Value in Sequence)
  139. {
  140. if (MaxValue <= Int32.Parse(Value))
  141. {
  142. MaxValue = Int32.Parse(Value) + 1;
  143. }
  144. }
  145. // COMM_ID, BOARD_ID, LOOP_NO, REPEATER_ID, DEVICE_ID, INOUT_TYPE
  146. DataRowCollection DB_TABLE_GROUP_DEVICE = _Db.ExecuteRead_SqlDataAdapter(_Sql.SearchAll_Table_Value("TB_MAP_PROCESS", "MAP_NO", _Data.Map_No, "GROUP_ID", Group_ID, null));// 맵연동 설정에서 확인하는 출력그룹은 오로지 그룹아이디로만 판단
  147. if (DB_TABLE_GROUP_DEVICE != null)
  148. {
  149. //** 저장되어 있지 않다면 DB에 ADD
  150. if (DB_TABLE_GROUP_DEVICE.Count == 0)
  151. {
  152. // "TB_GROUP"에 DB 삽입
  153. _Db.ADD("TB_MAP_PROCESS",
  154. "MAP_RECEIVER_ID=" + Receiver_ID + // 실제로 해당 내용을 사용하는 수신기 아이디, 이를 기준으로 데몬은 읽어들어야 한다
  155. ";MAP_NO=" + _Data.Map_No +
  156. ";MAP_TYPE=" + "O" +
  157. ";SEQ_NO=" + MaxValue +
  158. ";PROCESS_TYPE=" + "G" +
  159. ";GROUP_ID=" + Group_ID +
  160. ";RECEIVER_ID=" + row.Cells["ReceiverID"].Value.ToString() + // 출력해야되는 회로 혹은 그룹의 수신기 아이디 : 엑셀로 Import 할때는 그룹 정보가 반드시 수신기 아이디에 해당하지 않는 타 수신기에 그룹일수도 있다.
  161. ";COMM_ID=" + null +
  162. ";BOARD_ID=" + null +
  163. ";LOOP_NO=" + null +
  164. ";REPEATER_ID=" + null +
  165. ";DEVICE_ID=" + null +
  166. ";INOUT_TYPE=" + null +
  167. ";USE_FLAG=" + "Y");
  168. }
  169. }
  170. //** 해당 그룹의 디바이스 변경되었다고 알려줌
  171. _Event.Form_AddGroup_SendMessage_Write(DEVICE_EVENT.MAP);
  172. }
  173. // 프로젝트 수정
  174. _Data.ProJect_Save_Complete = false;
  175. }
  176. else
  177. {
  178. // 맵명을 선택해 주세요
  179. _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.OK, 250, 150, _Text.MapChoice, 0);
  180. return;
  181. }
  182. }
  183. //** 닫기버튼
  184. private void UiButton_Close_Click(object sender, EventArgs e)
  185. {
  186. this.Close();
  187. }
  188. //** 폼 클로우즈
  189. private void Form_AddGroup_FormClosed(object sender, FormClosedEventArgs e)
  190. {
  191. //** 선택모드를 멀티로 전환하라고 맵설정 폼으로 보내줌
  192. _Event.Form_AddGroup_SendMessage_Write(DEVICE_EVENT.MAP_SELECTIONMODE);
  193. }
  194. // 수신기 아이디를 지정해야만 그룹아이디를 출력하게 한다
  195. private void UiComboBox_GroupID_DroppingDown(object sender, CancelEventArgs e)
  196. {
  197. if (this.UiComboBox_ReceiverID.Text == null || this.UiComboBox_ReceiverID.Text.Length == 0)
  198. {
  199. _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.OK, 250, 150, _Text.ReceiverIDNotInput, 0);
  200. return;
  201. }
  202. this.UiComboBox_GroupID.Items.Clear();
  203. this.UiComboBox_GroupID.Items.Add(_Text.Null);
  204. //** TB_GROUP 테이블에서 출력그룹을 모두 가지고 온다
  205. DataRowCollection DB_TABLE_DEVICE = _Db.ExecuteRead_SqlDataAdapter(_Sql.SearchAll_Table_Value("TB_GROUP", this.UiComboBox_ReceiverID.Text));
  206. if (DB_TABLE_DEVICE != null && DB_TABLE_DEVICE.Count != 0)
  207. {
  208. foreach (DataRow dr in DB_TABLE_DEVICE)
  209. {
  210. //** 폼로드시 UiComboBox_GroupID 셋팅
  211. UiComboBox_GroupID.Items.Add(dr[1].ToString());
  212. }
  213. }
  214. }
  215. }
  216. }