7a3f9ea9b621f69d8651d76ae869f5fccce7d280.svn-base 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758
  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. using Janus.Windows.GridEX.EditControls;
  12. namespace IControls_FireManager
  13. {
  14. public partial class Form_AddDevice : Form
  15. {
  16. //** CheckedComboBox_DeviceType콤보박스에 체크되어 있는 것만 알기 위해서 사용되는 ArrayList
  17. ArrayList DeviceType = new ArrayList();
  18. //** 어레이리스트를 만들어 시컨스 정보만 저장하여 가장 큰 Value를 찾아낸다
  19. ArrayList Sequence = new ArrayList();
  20. //** 나중에 DB에 출력그룹을 ADD할 때 수신기 ID도 알아야 한다
  21. string Receiver_ID = null;
  22. //** 어느 버튼에서 이 폼을 실행시켰는지 알기 위해서 저장
  23. string form_type = null;
  24. //** 현재폼이 생성될 때 In디바이스만 출력할 것인지 Out디바이스만 출력 할것인지 결정해준다
  25. // 그 디바이스 타입 정보를 받아서 저장하기 위해서 생성
  26. string device_type = null;
  27. public Form_AddDevice(string RECEIVER_ID, string Form_Type, string InOutType)
  28. {
  29. InitializeComponent();
  30. // 수신기 아이디 저장
  31. Receiver_ID = RECEIVER_ID;
  32. //** 어느 버튼에서 이 폼을 실행시켰는지 알기 위해서 저장
  33. form_type = Form_Type;
  34. //** 여기서 해당 디바이스 타입 정보를 저장
  35. device_type = InOutType;
  36. //** 폼 텍스트 변경
  37. if (device_type == "I")
  38. this.Text = "입력 회로조회";
  39. if (device_type == "O")
  40. this.Text = "출력 회로조회";
  41. //** 초기값 셋팅
  42. UI_Initialize();
  43. // 이전 값을 불러온다
  44. this.EditBox_Position.Text = _Data.Temp_Position;
  45. this.EditBox_DeviceName.Text = _Data.Temp_DeviceName;
  46. ///
  47. /// 폼이 생성되는 위치
  48. ///
  49. this.StartPosition = FormStartPosition.Manual;
  50. //this.Location = new System.Drawing.Point(MousePosition.X, MousePosition.X);
  51. this.Location = new System.Drawing.Point(550, 200);
  52. }
  53. //** 초기값 셋팅
  54. public void UI_Initialize()
  55. {
  56. // 해당 수신기를 수신기 콤보박스에 띄움
  57. UiComboBox_Board_Receiver.Text = Receiver_ID;
  58. UiComboBox_IO_Receiver.Text = Receiver_ID;
  59. // 입력 회로조회일 경우, 수신기 콤보박스를 disable 처리
  60. if (device_type == "I")
  61. {
  62. UiComboBox_Board_Receiver.Enabled = false;
  63. UiComboBox_IO_Receiver.Enabled = false;
  64. }
  65. // 출력 그룹에서 출력 디바이스를 추가할 경우, 수신기 콤보박스를 disable 처리
  66. if (device_type == "O" && form_type == "Group")
  67. {
  68. UiComboBox_Board_Receiver.Enabled = false;
  69. UiComboBox_IO_Receiver.Enabled = false;
  70. }
  71. //** CheckedComboBox_DeviceType 콤보박스 셋팅
  72. // 먼저 CheckedComboBox_DeviceType 콤보박스를 클리어시킴
  73. CheckedComboBox_DeviceType.Clear();
  74. // TB_DEVICE_TYPE테이블에 접근
  75. DataRowCollection DB_TABLE_DEVICE_TYPE = _Db.ExecuteRead_SqlDataAdapter(_Sql.SearchAll_Table_Value("TB_DEVICE_TYPE", null));
  76. if (DB_TABLE_DEVICE_TYPE != null && CheckedComboBox_DeviceType.DropDownList != null)
  77. {
  78. foreach (DataRow dr in DB_TABLE_DEVICE_TYPE)
  79. {
  80. // GridEx에 내용 채우기
  81. GridEXRow row;
  82. row = CheckedComboBox_DeviceType.DropDownList.AddItem();
  83. row.BeginEdit();
  84. row.Cells["Device_Type"].Value = dr["DEVICE_TYPE_NAME"].ToString();
  85. row.EndEdit();
  86. }
  87. }
  88. }
  89. //** 폼 클로우즈
  90. private void Form_AddDevice_FormClosed(object sender, FormClosedEventArgs e)
  91. {
  92. if (form_type == "Group")
  93. {
  94. //** 선택모드를 멀티로 전환하라고 맵설정 폼으로 보내줌
  95. _Event.Form_AddDevice_SendMessage_Write(DEVICE_EVENT.GROUP_SELECTIONMODE);
  96. }
  97. else if (form_type == "Map")
  98. {
  99. //** 선택모드를 멀티로 전환하라고 맵설정 폼으로 보내줌
  100. _Event.Form_AddDevice_SendMessage_Write(DEVICE_EVENT.MAP_SELECTIONMODE);
  101. }
  102. }
  103. //** 조회 버튼
  104. private void UiButton_Search_Click(object sender, EventArgs e)
  105. {
  106. // 이전 값을 저장해둔다
  107. _Data.Temp_Position = this.EditBox_Position.Text;
  108. _Data.Temp_DeviceName = this.EditBox_DeviceName.Text;
  109. //
  110. //** uiTabPage_board 탭이 선택되어 있을 경우
  111. //
  112. if (uiTabPage_board.Selected == true)
  113. {
  114. // 그리드이엑스 클리어 시키고 다시 조회
  115. GridEX_Device.ClearItems();
  116. // No.를 출력하기 위해서
  117. int i = 1;
  118. // 아래와 같이 하는 이유는 통신보드를 1~14까지만 조회하기 위해서다
  119. // 조회하려는 통신보드에 값이 없으면 if문을 타고 값이 있으면 else 문을 탄다. SQL문이 달라지는 것이다
  120. DataRowCollection DB_TABLE_DEVICE = null;
  121. if (UiComboBox_Board.Text.Length == 0)
  122. {
  123. // cyim 2016.12.05 : 수신기 모델별 내부 로직 변경
  124. if (((_RECEIVER)_Data.HASH_RECEIVER[Receiver_ID]).MODEL == "IFC3300")
  125. {
  126. DB_TABLE_DEVICE = _Db.ExecuteRead_SqlDataAdapter(_Sql.Search_DEVICETable_NoneBoardID_BigReceiver("1", device_type, _Data.UI_CH_TO_LOOP(UiComboBox_Channel.Text), UiComboBox_Repeater.Text, EditBox_Position.Text, "", EditBox_DeviceName.Text, UiComboBox_Board_Receiver.Text));
  127. }
  128. else
  129. {
  130. // 통신보드를 선택하지 않았으면, 15번 통신보드만 빼고 모든 통신보드의 디바이스를 다 보여준다
  131. DB_TABLE_DEVICE = _Db.ExecuteRead_SqlDataAdapter(_Sql.Search_DEVICETable("1", device_type, "15", _Data.UI_CH_TO_LOOP(UiComboBox_Channel.Text), UiComboBox_Repeater.Text, EditBox_Position.Text, "", EditBox_DeviceName.Text, UiComboBox_Board_Receiver.Text));
  132. }
  133. }
  134. else
  135. {
  136. // 통신보드를 선택했으면, 특정 통신보드의 디바이스를 다 보여준다
  137. DB_TABLE_DEVICE = _Db.ExecuteRead_SqlDataAdapter(_Sql.Search_DeviceTable("1", device_type, UiComboBox_Board.Text, _Data.UI_CH_TO_LOOP(UiComboBox_Channel.Text), UiComboBox_Repeater.Text, EditBox_Position.Text, "", EditBox_DeviceName.Text, UiComboBox_Board_Receiver.Text));
  138. }
  139. if (DB_TABLE_DEVICE != null)
  140. {
  141. foreach (DataRow dr in DB_TABLE_DEVICE)
  142. {
  143. try
  144. {
  145. if (_Convert.Exception_Into_object(dr[3], dr[4], dr[5], dr[6], dr[7]) == true)
  146. {
  147. // 디바이스 타입에 관계없이 모두 출력
  148. if (DeviceType.Count == 0)
  149. {
  150. // 매개변수 순서 => COMM_ID, BOARD_ID, LOOP_NO, REPEATER_ID, DEVICE_ID, INOUT_TYPE
  151. MskDeviceIDString dev_s = new MskDeviceIDString(
  152. _Convert.Null_to_IntZero(dr[3].ToString()),
  153. _Convert.Null_to_IntZero(dr[4].ToString()),
  154. _Convert.Null_to_IntZero(dr[5].ToString()),
  155. _Convert.Null_to_IntZero(dr[6].ToString()),
  156. _Convert.Null_to_IntZero(dr[7].ToString()),
  157. dr[8].ToString(), Receiver_ID); // cyim 2016.12.05 : 수신기 모델별 내부 로직 변경
  158. GridEXRow row;
  159. row = GridEX_Device.AddItem();
  160. row.BeginEdit();
  161. row.Cells["Number"].Value = i++;
  162. row.Cells["ID"].Value = dev_s.MskId;
  163. row.Cells["DeviceType"].Value = dr[0].ToString();
  164. row.Cells["Position"].Value = dr[1].ToString();
  165. row.Cells["DeviceName"].Value = dr[2].ToString();
  166. row.Cells["Receiver_ID"].Value = dr[9].ToString();
  167. row.EndEdit();
  168. }
  169. else // 조회문에 있는 디바이스 타입만 출력
  170. {
  171. if (DeviceType.Contains(dr[0].ToString()) == true)
  172. {
  173. // 매개변수 순서 => COMM_ID, BOARD_ID, LOOP_NO, REPEATER_ID, DEVICE_ID, INOUT_TYPE
  174. MskDeviceIDString dev_s = new MskDeviceIDString(
  175. _Convert.Null_to_IntZero(dr[3].ToString()),
  176. _Convert.Null_to_IntZero(dr[4].ToString()),
  177. _Convert.Null_to_IntZero(dr[5].ToString()),
  178. _Convert.Null_to_IntZero(dr[6].ToString()),
  179. _Convert.Null_to_IntZero(dr[7].ToString()),
  180. dr[8].ToString(), dr[9].ToString()); // cyim 2016.12.05 : 수신기 모델별 내부 로직 변경
  181. GridEXRow row;
  182. row = GridEX_Device.AddItem();
  183. row.BeginEdit();
  184. row.Cells["Number"].Value = i++;
  185. row.Cells["ID"].Value = dev_s.MskId;
  186. row.Cells["DeviceType"].Value = dr[0].ToString();
  187. row.Cells["Position"].Value = dr[1].ToString();
  188. row.Cells["DeviceName"].Value = dr[2].ToString();
  189. row.Cells["Receiver_ID"].Value = dr[9].ToString();
  190. row.EndEdit();
  191. }
  192. }
  193. }
  194. }
  195. catch (Exception Err1)
  196. {
  197. // LOG
  198. _Event.DebugView_SendMessage_Write(Err1.ToString());
  199. // 정보를 가지고 오는데 문제가 발생하였습니다
  200. _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.OK, 250, 150, _Text.ProblemMessage, 0);
  201. }
  202. }
  203. }
  204. }
  205. //
  206. // uiTabPage_IOboard 탭이 선택되어 있을 경우
  207. //
  208. if (uiTabPage_IOboard.Selected == true)
  209. {
  210. // 그리드이엑스 클리어 시키고 다시 조회
  211. GridEX_Device.ClearItems();
  212. // No.를 출력하기 위해서
  213. int i = 1;
  214. // UiComboBox_IOBoard 콤보박스의 텍스트가 null이면 전체조회
  215. if (UiComboBox_IOBoard.Text.Length == 0)
  216. {
  217. DataRowCollection DB_TABLE_DEVICE = null;
  218. // cyim 2016.12.05 : 수신기 모델별 내부 로직 변경
  219. if (((_RECEIVER)_Data.HASH_RECEIVER[Receiver_ID]).MODEL == "IFC3300")
  220. {
  221. DB_TABLE_DEVICE = _Db.ExecuteRead_SqlDataAdapter(_Sql.Search_DEVICETable_NoneBoardID_BigReceiver("3", device_type, "", "", "", "", "", UiComboBox_IO_Receiver.Text));
  222. }
  223. else
  224. {
  225. DB_TABLE_DEVICE = _Db.ExecuteRead_SqlDataAdapter(_Sql.Search_DEVICETable("3", device_type, "15", "", "", "", "", "", UiComboBox_IO_Receiver.Text));
  226. }
  227. if (DB_TABLE_DEVICE != null)
  228. {
  229. foreach (DataRow dr in DB_TABLE_DEVICE)
  230. {
  231. try
  232. {
  233. if (_Convert.Exception_Into_object(dr[3], dr[4], dr[5], dr[6], dr[7]) == true)
  234. {
  235. // 매개변수 순서 => COMM_ID, BOARD_ID, LOOP_NO, REPEATER_ID, DEVICE_ID, INOUT_TYPE
  236. MskDeviceIDString dev_s = new MskDeviceIDString(
  237. _Convert.Null_to_IntZero(dr[3].ToString()),
  238. _Convert.Null_to_IntZero(dr[4].ToString()),
  239. _Convert.Null_to_IntZero(dr[5].ToString()),
  240. _Convert.Null_to_IntZero(dr[6].ToString()),
  241. _Convert.Null_to_IntZero(dr[7].ToString()),
  242. dr[8].ToString(), dr[9].ToString()); // cyim 2016.12.05 : 수신기 모델별 내부 로직 변경
  243. GridEXRow row;
  244. row = GridEX_Device.AddItem();
  245. row.BeginEdit();
  246. row.Cells["Number"].Value = i++;
  247. row.Cells["ID"].Value = dev_s.MskId;
  248. row.Cells["DeviceType"].Value = dr[0].ToString();
  249. row.Cells["Position"].Value = dr[1].ToString();
  250. row.Cells["DeviceName"].Value = dr[2].ToString();
  251. row.Cells["Receiver_ID"].Value = dr[9].ToString();
  252. row.EndEdit();
  253. }
  254. }
  255. catch (Exception Err3)
  256. {
  257. // LOG
  258. _Event.DebugView_SendMessage_Write(Err3.ToString());
  259. // 정보를 가지고 오는데 문제가 발생하였습니다
  260. _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.OK, 250, 150, _Text.ProblemMessage, 0);
  261. }
  262. }
  263. }
  264. }
  265. // UiComboBox_IOBoard 콤보박스의 텍스트를 이용해 조회
  266. else
  267. {
  268. DataRowCollection DB_TABLE_DEVICE = _Db.ExecuteRead_SqlDataAdapter(_Sql.Search_DeviceTable("3", device_type, UiComboBox_IOBoard.Text, "", "", "", "", "", UiComboBox_IO_Receiver.Text));
  269. if (DB_TABLE_DEVICE != null)
  270. {
  271. foreach (DataRow dr in DB_TABLE_DEVICE)
  272. {
  273. try
  274. {
  275. if (_Convert.Exception_Into_object(dr[3], dr[4], dr[5], dr[6], dr[7]) == true)
  276. {
  277. // 매개변수 순서 => COMM_ID, BOARD_ID, LOOP_NO, REPEATER_ID, DEVICE_ID, INOUT_TYPE
  278. MskDeviceIDString dev_s = new MskDeviceIDString(
  279. _Convert.Null_to_IntZero(dr[3].ToString()),
  280. _Convert.Null_to_IntZero(dr[4].ToString()),
  281. _Convert.Null_to_IntZero(dr[5].ToString()),
  282. _Convert.Null_to_IntZero(dr[6].ToString()),
  283. _Convert.Null_to_IntZero(dr[7].ToString()),
  284. dr[8].ToString(), dr[9].ToString()); // cyim 2016.12.05 : 수신기 모델별 내부 로직 변경
  285. GridEXRow row;
  286. row = GridEX_Device.AddItem();
  287. row.BeginEdit();
  288. row.Cells["Number"].Value = i++;
  289. row.Cells["ID"].Value = dev_s.MskId;
  290. row.Cells["DeviceType"].Value = dr[0].ToString();
  291. row.Cells["Position"].Value = dr[1].ToString();
  292. row.Cells["DeviceName"].Value = dr[2].ToString();
  293. row.Cells["Receiver_ID"].Value = dr[9].ToString();
  294. row.EndEdit();
  295. }
  296. }
  297. catch (Exception Err4)
  298. {
  299. // LOG
  300. _Event.DebugView_SendMessage_Write(Err4.ToString());
  301. // 정보를 가지고 오는데 문제가 발생하였습니다
  302. _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.OK, 250, 150, _Text.ProblemMessage, 0);
  303. }
  304. }
  305. }
  306. }
  307. }
  308. }
  309. //** 디바이스 추가버튼
  310. private void UiButton_AddDevice_Click(object sender, EventArgs e)
  311. {
  312. int SelectRowCount = GridEX_Device.SelectedItems.Count;
  313. //** 선택한 행이 하나도 없다면....
  314. if (SelectRowCount == 0)
  315. {
  316. // 회로를 선택해 주세요
  317. _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.OK, 250, 150, _Text.DeviceNotChoice, 0);
  318. return;
  319. }
  320. // 프로젝트 수정
  321. _Data.ProJect_Save_Complete = false;
  322. for (int number = 0; number < SelectRowCount; number++)
  323. {
  324. GridEXRow row = GridEX_Device.SelectedItems[number].GetRow();
  325. string Real_RECEIVER_ID = row.Cells["Receiver_ID"].Value.ToString();
  326. string Device_ID = row.Cells["ID"].Value.ToString();
  327. // MI-##-#-###-# :M(구분 M-중계기,O-출력그룹)I,O(회로구분)-##(보드ID)-##(회로ID)
  328. MskDeviceIDString device_id = new MskDeviceIDString(Device_ID, Real_RECEIVER_ID); // cyim 2016.12.05 : 수신기 모델별 내부 로직 변경
  329. //
  330. //** 그룹설정에서 출력을 그룹으로 묶을때 사용
  331. //
  332. if (form_type == "Group")
  333. {
  334. //** 회로추가나 그룹추가폼을 띄워둔 상태에서 그룹명이나 맵명을 추가하거나 삭제하면 selected 된 행이 없어진다.
  335. // 하지만 회로추가나 그룹추가는 할 수 있으므로 이를 방지해야한다
  336. if (_Data.Group_ID != null)
  337. {
  338. // COMM_ID, BOARD_ID, LOOP_NO, REPEATER_ID, DEVICE_ID, INOUT_TYPE
  339. DataRowCollection DB_TABLE_GROUP_DEVICE = _Db.ExecuteRead_SqlDataAdapter(_Sql.SearchAll_Table_Value(
  340. "TB_GROUP_DEVICE", "GROUP_ID", _Data.Group_ID, "COMM_ID", device_id.Comm_id, "BOARD_ID", device_id.Board_id,
  341. "LOOP_NO", device_id.Loop_no, "REPEATER_ID", device_id.Repeater_id,
  342. "DEVICE_ID", device_id.Device_id, "INOUT_TYPE", device_id.Inout_type, "GROUP_RECEIVER_ID", Receiver_ID, Real_RECEIVER_ID));
  343. if (DB_TABLE_GROUP_DEVICE != null)
  344. {
  345. //** 저장되어 있지 않다면 DB에 ADD
  346. if (DB_TABLE_GROUP_DEVICE.Count == 0)
  347. {
  348. // "TB_GROUP"에 DB 삽입
  349. _Db.ADD("TB_GROUP_DEVICE",
  350. "GROUP_RECEIVER_ID=" + Receiver_ID +
  351. ";GROUP_ID=" + _Data.Group_ID +
  352. ";RECEIVER_ID=" + Real_RECEIVER_ID +
  353. ";COMM_ID=" + device_id.Comm_id +
  354. ";BOARD_ID=" + device_id.Board_id +
  355. ";LOOP_NO=" + device_id.Loop_no +
  356. ";REPEATER_ID=" + device_id.Repeater_id +
  357. ";DEVICE_ID=" + device_id.Device_id +
  358. ";INOUT_TYPE=" + device_id.Inout_type +
  359. ";USE_FLAG=" + "Y");
  360. }
  361. }
  362. ////** 해당 그룹의 디바이스 변경되었다고 알려줌
  363. //_Event.Form_AddDevice_SendMessage_Write(DEVICE_EVENT.GROUP);
  364. }
  365. else
  366. {
  367. // 그룹을 선택해 주세요
  368. _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.OK, 250, 150, _Text.GroupNameNotChoice, 0);
  369. return;
  370. }
  371. }
  372. //
  373. //** 연동설정에 있는 입력 및 출력회로를 추가 할때 사용
  374. //
  375. else if (form_type == "Map")
  376. {
  377. //** 회로추가나 그룹추가폼을 띄워둔 상태에서 그룹명이나 맵명을 추가하거나 삭제하면 selected 된 행이 없어진다.
  378. // 하지만 회로추가나 그룹추가는 할 수 있으므로 이를 방지해야한다
  379. if (_Data.Map_No != null)
  380. {
  381. int MaxValue = 1;
  382. // 시컨스 결정하기
  383. DataRowCollection DB_TABLE_MAP_PROCESS = _Db.ExecuteRead_SqlDataAdapter(_Sql.Search_MapProcess_MaxValue("TB_MAP_PROCESS", "MAP_NO", _Data.Map_No, "MAP_TYPE", device_type, Receiver_ID));
  384. if (DB_TABLE_MAP_PROCESS != null)
  385. {
  386. foreach (DataRow Record in DB_TABLE_MAP_PROCESS)
  387. {
  388. // 시컨스
  389. if (Record[0] == null || Record[0].ToString().Trim().Length == 0) MaxValue = 1;
  390. else MaxValue = Int32.Parse(Record[0].ToString()) + 1;
  391. }
  392. }
  393. // COMM_ID, BOARD_ID, LOOP_NO, REPEATER_ID, DEVICE_ID, INOUT_TYPE
  394. DataRowCollection DB_TABLE_GROUP_DEVICE = _Db.ExecuteRead_SqlDataAdapter(_Sql.SearchAll_Table_Value(
  395. "TB_MAP_PROCESS", "MAP_NO", _Data.Map_No, "COMM_ID", device_id.Comm_id, "BOARD_ID", device_id.Board_id,
  396. "LOOP_NO", device_id.Loop_no, "REPEATER_ID", device_id.Repeater_id,
  397. "DEVICE_ID", device_id.Device_id, "INOUT_TYPE", device_id.Inout_type, "MAP_RECEIVER_ID", Receiver_ID, Real_RECEIVER_ID));
  398. if (DB_TABLE_GROUP_DEVICE != null)
  399. {
  400. //** 저장되어 있지 않다면 DB에 ADD
  401. if (DB_TABLE_GROUP_DEVICE.Count == 0)
  402. {
  403. // "TB_GROUP"에 DB 삽입
  404. _Db.ADD("TB_MAP_PROCESS",
  405. "MAP_RECEIVER_ID=" + Receiver_ID +
  406. ";MAP_NO=" + _Data.Map_No +
  407. ";MAP_TYPE=" + device_type +
  408. ";SEQ_NO=" + MaxValue +
  409. ";PROCESS_TYPE=" + "D" +
  410. ";GROUP_ID=" + null +
  411. ";RECEIVER_ID=" + Real_RECEIVER_ID +
  412. ";COMM_ID=" + device_id.Comm_id +
  413. ";BOARD_ID=" + device_id.Board_id +
  414. ";LOOP_NO=" + device_id.Loop_no +
  415. ";REPEATER_ID=" + device_id.Repeater_id +
  416. ";DEVICE_ID=" + device_id.Device_id +
  417. ";INOUT_TYPE=" + device_id.Inout_type +
  418. ";USE_FLAG=" + "Y");
  419. }
  420. }
  421. ////** 해당 그룹의 디바이스 변경되었다고 알려줌
  422. //_Event.Form_AddDevice_SendMessage_Write(DEVICE_EVENT.MAP);
  423. }
  424. else
  425. {
  426. // 맵명을 선택해 주세요
  427. _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.OK, 250, 150, _Text.MapChoice, 0);
  428. return;
  429. }
  430. }
  431. }
  432. // 이벤트로 한번만 알려주면 된다(수정)
  433. if (SelectRowCount != 0)
  434. {
  435. if (form_type == "Group")
  436. {
  437. //** 해당 그룹의 디바이스 변경되었다고 알려줌
  438. _Event.Form_AddDevice_SendMessage_Write(DEVICE_EVENT.GROUP);
  439. }
  440. else if (form_type == "Map")
  441. {
  442. //** 해당 그룹의 디바이스 변경되었다고 알려줌
  443. _Event.Form_AddDevice_SendMessage_Write(DEVICE_EVENT.MAP);
  444. }
  445. }
  446. }
  447. //** CheckedComboBox_DeviceType콤보박스에 체크가 변경될때마다 발생하는 이벤트
  448. private void CheckedComboBox_DeviceType_CheckedValuesChanged(object sender, EventArgs e)
  449. {
  450. //** DeviceType을 ArrayList에 저장하기 위해서
  451. DeviceType.Clear();
  452. //** sender을 이용하는 이유는 clear를 했을때를 알기 위해서
  453. CheckedComboBox checkedcombobox = (CheckedComboBox)sender;
  454. //** 이렇게 하는 이유는 clear버튼을 사용해 텍스트를 클리어 했을 때에, 콤보박스는 이전에 선택했을 값을 가지고 있다고 여김
  455. // 그래서 아래의 속성으로 clear버튼을 클릭했을 때에는 해당 루틴을 타지 못하게 함
  456. if (checkedcombobox.Text.Length != 0)
  457. {
  458. // 아래와 같이 포커스를 주는 이유는 야누스 콤포넌트의 에러 때문이다
  459. UiButton_Search.Focus();
  460. // 콤보박스에 체크되어 있는 것만 알기 위해서
  461. GridEXRow[] GridEx_Rows = this.CheckedComboBox_DeviceType.DropDownList.GetRows();
  462. foreach (GridEXRow row in GridEx_Rows)
  463. {
  464. if (row.Cells["Check"].Value.ToString() == "True")
  465. DeviceType.Add(row.Cells["Device_Type"].Value.ToString());
  466. }
  467. }
  468. }
  469. //** 탭 전환시 발생하는 이벤트
  470. private void uiTab_Device_SelectedTabChanged(object sender, Janus.Windows.UI.Tab.TabEventArgs e)
  471. {
  472. // 그리드이엑스 클리어 시키고 다시 조회
  473. GridEX_Device.ClearItems();
  474. // 클리어
  475. // 통신보드
  476. UiComboBox_Board.Text = null;
  477. UiComboBox_Channel.Text = null;
  478. UiComboBox_Repeater.Text = null;
  479. EditBox_Position.Text = null;
  480. CheckedComboBox_DeviceType.Text = null;
  481. EditBox_DeviceName.Text = null;
  482. //IO보드
  483. UiComboBox_IOBoard.Text = null;
  484. }
  485. // 수신기 콤보박스를 드라핑다운
  486. private void UiComboBox_Board_Receiver_DroppingDown(object sender, CancelEventArgs e)
  487. {
  488. // 사용하는 수신기를 콤보박스에 추가한다
  489. UiComboBox_Board_Receiver.Items.Clear();
  490. UiComboBox_Board_Receiver.Items.Add(_Text.Null);
  491. foreach (string receive in _Data.LIST_XMLRECEIVER_ID)
  492. {
  493. UiComboBox_Board_Receiver.Items.Add(receive);
  494. }
  495. // 수신기를 선택했으니까 나머지는 다시 클리어
  496. UiComboBox_Board.Text = null;
  497. UiComboBox_Channel.Text = null;
  498. UiComboBox_Repeater.Text = null;
  499. }
  500. // 통신보드 콤보박스 드라핑다운
  501. private void UiComboBox_Board_DroppingDown(object sender, CancelEventArgs e)
  502. {
  503. // 일단 무조건 클리어
  504. UiComboBox_Board.Text = null;
  505. UiComboBox_Board.Items.Clear();
  506. // 수신기를 선택하지 않았으면 리턴
  507. if (UiComboBox_Board_Receiver.Text.Length == 0) return;
  508. UiComboBox_Board.Items.Clear();
  509. DataRowCollection DB_TABLE_BOARD = _Db.ExecuteRead_SqlDataAdapter(_Sql.Search_BoardTable("1", "", "Y", UiComboBox_Board_Receiver.Text));
  510. if (DB_TABLE_BOARD != null)
  511. {
  512. // 공백도 하나 넣어둠
  513. UiComboBox_Board.Items.Add("");
  514. foreach (DataRow dr in DB_TABLE_BOARD)
  515. {
  516. // UiComboBox_Board 콤보박스에 아이템 ADD
  517. UiComboBox_Board.Items.Add(dr["BOARD_ID"]);
  518. }
  519. }
  520. // 통신보드를 선택했으니까 나머지는 다시 클리어
  521. UiComboBox_Channel.Text = null;
  522. UiComboBox_Repeater.Text = null;
  523. }
  524. // 채널 콤보박스 드라핑다운
  525. private void UiComboBox_Channel_DroppingDown(object sender, CancelEventArgs e)
  526. {
  527. // 일단 무조건 클리어
  528. UiComboBox_Channel.Text = null;
  529. UiComboBox_Channel.Items.Clear();
  530. // 통신보드를 선택하지 않았으면 리턴
  531. if (UiComboBox_Board.Text.Length == 0) return;
  532. // 채널 콤보박스 클리어
  533. UiComboBox_Channel.Items.Clear();
  534. DataRowCollection DB_TABLE_BOARD = _Db.ExecuteRead_SqlDataAdapter(_Sql.Search_BoardTable("1", UiComboBox_Board.Text, "Y", UiComboBox_Board_Receiver.Text));
  535. if (DB_TABLE_BOARD != null)
  536. {
  537. // 공백도 하나 넣어둠
  538. if (UiComboBox_Channel.Items.Contains("") == false) UiComboBox_Channel.Items.Add("");
  539. foreach (DataRow dr in DB_TABLE_BOARD)
  540. {
  541. if (dr["LOOP0_USE_FLAG"].ToString() == "Y")
  542. {
  543. if (UiComboBox_Channel.Items.Contains("0") == false)
  544. UiComboBox_Channel.Items.Add("CH1");
  545. }
  546. if (dr["LOOP1_USE_FLAG"].ToString() == "Y")
  547. {
  548. if (UiComboBox_Channel.Items.Contains("1") == false)
  549. UiComboBox_Channel.Items.Add("CH2");
  550. }
  551. if (((_RECEIVER)_Data.HASH_RECEIVER[Receiver_ID]).MODEL == "IFC3300")
  552. {
  553. if (dr["LOOP2_USE_FLAG"].ToString() == "Y")
  554. {
  555. if (UiComboBox_Channel.Items.Contains("2") == false)
  556. UiComboBox_Channel.Items.Add("CH3");
  557. }
  558. if (dr["LOOP3_USE_FLAG"].ToString() == "Y")
  559. {
  560. if (UiComboBox_Channel.Items.Contains("3") == false)
  561. UiComboBox_Channel.Items.Add("CH4");
  562. }
  563. }
  564. }
  565. }
  566. // 채널을 선택했으니까 나머지는 다시 클리어
  567. UiComboBox_Repeater.Text = null;
  568. }
  569. // 중계기 콤보박스 드라핑다운
  570. private void UiComboBox_Repeater_DroppingDown(object sender, CancelEventArgs e)
  571. {
  572. // 일단 무조건 클리어
  573. UiComboBox_Repeater.Text = null;
  574. UiComboBox_Repeater.Items.Clear();
  575. // 채널을 선택하지 않았으면 리턴
  576. if (UiComboBox_Channel.Text.Length == 0) return;
  577. DataRowCollection DB_TABLE_TB_REPEATER = _Db.ExecuteRead_SqlDataAdapter(_Sql.Search_RepeaterTable("1", UiComboBox_Board.Text, _Data.UI_CH_TO_LOOP(UiComboBox_Channel.Text), UiComboBox_Board_Receiver.Text));
  578. if (DB_TABLE_TB_REPEATER != null)
  579. {
  580. // 공백도 하나 넣어둠
  581. if (UiComboBox_Repeater.Items.Contains("") == false) UiComboBox_Repeater.Items.Add("");
  582. foreach (DataRow dr in DB_TABLE_TB_REPEATER)
  583. {
  584. if (UiComboBox_Repeater.Items.Contains(dr["REPEATER_ID"].ToString()) == false)
  585. UiComboBox_Repeater.Items.Add(dr["REPEATER_ID"].ToString());
  586. }
  587. }
  588. }
  589. // 수신기 콤보박스를 드라핑다운
  590. private void UiComboBox_IO_Receiver_DroppingDown(object sender, CancelEventArgs e)
  591. {
  592. // 사용하는 수신기를 콤보박스에 추가한다
  593. UiComboBox_IO_Receiver.Items.Clear();
  594. UiComboBox_IO_Receiver.Items.Add(_Text.Null);
  595. foreach (string receive in _Data.LIST_XMLRECEIVER_ID)
  596. {
  597. UiComboBox_IO_Receiver.Items.Add(receive);
  598. }
  599. // 수신기를 선택했으니까 나머지는 다시 클리어
  600. UiComboBox_IOBoard.Text = null;
  601. }
  602. // IO보드 콤보박스 드라핑다운
  603. private void UiComboBox_IOBoard_DroppingDown(object sender, CancelEventArgs e)
  604. {
  605. // 일단 무조건 클리어
  606. UiComboBox_IOBoard.Text = null;
  607. UiComboBox_IOBoard.Items.Clear();
  608. // 수신기를 선택하지 않았으면 리턴
  609. if (UiComboBox_IO_Receiver.Text.Length == 0) return;
  610. DataRowCollection DB_TABLE_IOBOARD = _Db.ExecuteRead_SqlDataAdapter(_Sql.Search_BoardTable("3", "", "Y", UiComboBox_IO_Receiver.Text));
  611. if (DB_TABLE_IOBOARD != null)
  612. {
  613. // 공백도 하나 넣어둠
  614. UiComboBox_IOBoard.Items.Add("");
  615. foreach (DataRow dr in DB_TABLE_IOBOARD)
  616. {
  617. // cyim 2016.12.05 : 수신기 모델별 내부 로직 변경
  618. if (
  619. (((_RECEIVER)_Data.HASH_RECEIVER[Receiver_ID]).MODEL == "IFC3300" && dr["BOARD_ID"].ToString() != "0")
  620. || (((_RECEIVER)_Data.HASH_RECEIVER[Receiver_ID]).MODEL != "IFC3300" && dr["BOARD_ID"].ToString() != "15")
  621. )
  622. //if (dr["BOARD_ID"].ToString() != "0")
  623. {
  624. if (UiComboBox_IOBoard.Items.Contains(dr["BOARD_ID"].ToString()) == false)
  625. UiComboBox_IOBoard.Items.Add(dr["BOARD_ID"]);
  626. //// COMM_ID, BOARD_ID, LOOP_NO, REPEATER_ID, DEVICE_ID, INOUT_TYPE
  627. //DataRowCollection DB_TABLE_DEVICE = _Db.ExecuteRead_SqlDataAdapter(_Sql.SearchAll_Table_Value(
  628. // "TB_DEVICE", "COMM_ID", "3", "BOARD_ID", dr["BOARD_ID"].ToString(),
  629. // "LOOP_NO", "0", "REPEATER_ID", "0",
  630. // "INOUT_TYPE", device_type, Receiver_ID));
  631. //if (DB_TABLE_DEVICE != null)
  632. //{
  633. // //** 위의 조건에 만족하는 IO출력디바이스가 TB_DEVICE에 있으면 UiComboBox_IOBoard에 추가 할 수 있다
  634. // if (DB_TABLE_DEVICE.Count != 0)
  635. // {
  636. // // UiComboBox_Board 콤보박스에 아이템 ADD
  637. // UiComboBox_IOBoard.Items.Add(dr["BOARD_ID"]);
  638. // }
  639. //}
  640. }
  641. }
  642. }
  643. }
  644. //** 클리어 버튼
  645. private void UiButton_Clear_Click(object sender, EventArgs e)
  646. {
  647. // 통신보드
  648. UiComboBox_Board_Receiver.Text = null;
  649. UiComboBox_Board.Text = null;
  650. UiComboBox_Channel.Text = null;
  651. UiComboBox_Repeater.Text = null;
  652. EditBox_Position.Text = null;
  653. CheckedComboBox_DeviceType.Text = null;
  654. EditBox_DeviceName.Text = null;
  655. //IO보드
  656. UiComboBox_IO_Receiver.Text = null;
  657. UiComboBox_IOBoard.Text = null;
  658. }
  659. //** 닫기 버튼
  660. private void UiButton_Close_Click(object sender, EventArgs e)
  661. {
  662. this.Close();
  663. }
  664. }
  665. }