frmMapConfig.cs 86 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using System.Diagnostics;
  9. namespace FPER
  10. {
  11. public partial class frmMapConfig : Form
  12. {
  13. MDIParent mdi = null;
  14. delegate void deleFormInit();
  15. LogFileCreate LFC = new LogFileCreate();
  16. //선택 item
  17. // ListViewItem IGroup_selectItem;
  18. // QUERYMode IGroup_cmd;
  19. // ListViewItem IGroupDevice_selectItem;
  20. // QUERYMode IGroupDevice_cmd;
  21. //선택 item
  22. ListViewItem OGroup_selectItem;
  23. QUERYMode OGroup_cmd;
  24. ListViewItem OGroupDevice_selectItem;
  25. QUERYMode OGroupDevice_cmd;
  26. QUERYMode Map_cmd;
  27. ListViewItem Map_selectItem;
  28. public frmMapConfig()
  29. {
  30. InitializeComponent();
  31. // cyim 2013.7.12 디자인개선작업 : 맵설정
  32. this.button_Menu_Group.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_주황_100_30;
  33. }
  34. public void Form_Init()
  35. {
  36. try
  37. {
  38. }
  39. catch (Exception ex)
  40. {
  41. Util.UErrorMessage(ex, 0, 0);
  42. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.Source), Application.ProductName);
  43. }
  44. }
  45. string receiver_id = null; // cyim 2015.8.4 수신반을 위한 static 클래스 정리 : warning 제거
  46. private void frmMapConfig_Load(object sender, EventArgs e)
  47. {
  48. // cyim 2013.8.1 : 더블버퍼링 적용
  49. SetStyle(ControlStyles.UserPaint, true);
  50. //this.UpdateStyles();
  51. SetStyle(ControlStyles.AllPaintingInWmPaint, true);
  52. //this.UpdateStyles();
  53. SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
  54. this.UpdateStyles();
  55. try
  56. {
  57. mdi = (MDIParent)this.MdiParent;
  58. txtThisReceiverID.Text = string.Format("{0:00}", mdi.myReceiverID);
  59. // cyim 2015.8.4 수신반을 위한 static 클래스 정리 : warning 제거
  60. receiver_id = Int32.Parse(txtThisReceiverID.Text).ToString();
  61. /***********************************************************************/
  62. /* 입력그룹 */
  63. /***********************************************************************/
  64. //VIEW모드로 변경한다.
  65. /*
  66. Util.GroupUIChange(panelIGroup, UIMode.cancel);
  67. //그룹의 데이터를 초기화한다.
  68. IGroupSelectData(null);
  69. IGroup_getData();
  70. IGroupDevice_getData();
  71. */
  72. /***********************************************************************/
  73. /***********************************************************************/
  74. /* 출력그룹 */
  75. /***********************************************************************/
  76. //VIEW모드로 변경한다.
  77. Util.GroupUIChange(panelOGroup, UIMode.cancel);
  78. //그룹의 데이터를 초기화한다.
  79. OGroupSelectData(null);
  80. OGroup_getData();
  81. OGroupDevice_getData();
  82. /***********************************************************************/
  83. /***********************************************************************/
  84. /* 맵 */
  85. /***********************************************************************/
  86. //VIEW모드로 변경한다.
  87. Util.GroupUIChange(panelMap, UIMode.cancel);
  88. //맵 데이터를 초기화한다.
  89. MapSelectData(null);
  90. Map_getData();
  91. //IMap_getData();
  92. //OMap_getData();
  93. /***********************************************************************/
  94. }
  95. catch (Exception ex)
  96. {
  97. Util.UErrorMessage(ex, 0, 0);
  98. }
  99. }
  100. private void frmMapConfig_Activated(object sender, EventArgs e)
  101. {
  102. try
  103. {
  104. this.mdi.SelectMenuIndex = 2;
  105. }
  106. catch (Exception ex)
  107. {
  108. Util.UErrorMessage(ex, 0, 0);
  109. }
  110. }
  111. private void frmMapConfig_Disposed(object sender, EventArgs e)
  112. {
  113. try
  114. {
  115. this.mdi.SelectMenuIndex = 0;
  116. }
  117. catch (Exception ex)
  118. {
  119. Util.UErrorMessage(ex, 0, 0);
  120. }
  121. }
  122. /*******************************************************
  123. * [입력그룹] LISTVIEW에 데이터 불러오기
  124. ******************************************************/
  125. /*
  126. private void IGroup_getData()
  127. {
  128. try
  129. {
  130. IGroupSelectData(null);
  131. DacMap dacMap = new DacMap(mdi.myReceiverID);
  132. DataTable dt = dacMap.Group_Select(null,code_GroupIO.Input);
  133. ListViewIGroup.Items.Clear();
  134. if (dt.Rows.Count > 0)
  135. {
  136. foreach (DataRow dr in dt.Rows)
  137. {
  138. ListViewItem item = new ListViewItem(Convert.ToString(dr["GROUP_ID"]));
  139. item.SubItems.Add(dr["GROUP_NAME"].ToString());
  140. ListViewIGroup.Items.Add(item);
  141. }
  142. }
  143. }
  144. catch (Exception ex)
  145. {
  146. Util.UErrorMessage(ex,0,0);
  147. //MessageBox.Show(ex.Message, Application.ProductName);
  148. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  149. }
  150. }
  151. */
  152. /*
  153. //리스트VIEW에 그룹선택시
  154. private void ListViewIGroup_SelectedIndexChanged(object sender, EventArgs e)
  155. {
  156. try
  157. {
  158. ListView lv = (ListView)sender;
  159. if (lv.SelectedItems.Count > 0)
  160. {
  161. ListViewItem itm = lv.SelectedItems[0];
  162. IGroup_cmd = QUERYMode.update;
  163. //VIEW모드로 변경한다.[입력그룹]
  164. Util.GroupUIChange(panelIGroup, UIMode.input);
  165. IGroupSelectData(itm);
  166. IGroupDevice_getData();
  167. }
  168. else
  169. {
  170. IGroup_cmd = QUERYMode.select;
  171. //VIEW모드로 변경한다.
  172. Util.GroupUIChange(panelIGroup, UIMode.cancel);
  173. IGroupSelectData(null);
  174. }
  175. }
  176. catch (Exception ex)
  177. {
  178. Util.UErrorMessage(ex,0,0);
  179. //MessageBox.Show(ex.Message, Application.ProductName);
  180. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  181. }
  182. }
  183. */
  184. //그룹표시
  185. //입력그룹 데이터 표시
  186. /*
  187. private void IGroupSelectData(ListViewItem itm)
  188. {
  189. try {
  190. IGroup_selectItem = itm;
  191. if (itm == null)
  192. {
  193. txtIGroupID.Text = "";
  194. txtIGroupName.Text = "";
  195. if (IGroup_cmd == QUERYMode.insert)
  196. {
  197. txtIGroupID.ReadOnly = false;
  198. txtIGroupID.BackColor = Color.White;
  199. txtIGroupName.ReadOnly = false;
  200. btnIGroupOK.Enabled = true;
  201. }
  202. else
  203. {
  204. txtIGroupID.ReadOnly = true;
  205. txtIGroupID.BackColor = SystemColors.Control;
  206. btnIGroupAdd.Enabled = true;
  207. btnIGroupDel.Enabled = false;
  208. btnIGroupOK.Enabled = false;
  209. }
  210. btnIGroupDeviceAdd.Enabled = false;
  211. btnIGroupDeviceSearch.Enabled = false;
  212. }
  213. else
  214. {
  215. txtIGroupID.Text = itm.Text;
  216. txtIGroupID.BackColor = SystemColors.Control;
  217. txtIGroupName.Text = itm.SubItems[1].Text;
  218. txtIGroupID.ReadOnly = true;
  219. btnIGroupAdd.Enabled = true;
  220. btnIGroupDel.Enabled = true;
  221. btnIGroupOK.Enabled = true;
  222. btnIGroupDeviceAdd.Enabled = true;
  223. btnIGroupDeviceSearch.Enabled = true;
  224. }
  225. IGroupDeviceSelectData(null);
  226. }
  227. catch(Exception ex) {
  228. Util.UErrorMessage(ex,0,0);
  229. }
  230. }
  231. //그룹추가
  232. private void btnIGroupAdd_Click(object sender, EventArgs e)
  233. {
  234. try {
  235. //입력모드로 변경한다.
  236. IGroup_cmd = QUERYMode.insert;
  237. Util.GroupUIChange(panelIGroup, UIMode.input);
  238. IGroupSelectData(null);
  239. txtIGroupID.Text = "GI";
  240. txtIGroupID.Focus();
  241. btnIGroupAdd.Enabled = false;
  242. btnIGroupDel.Enabled = false;
  243. btnIGroupCancel.Visible = true;
  244. btnIGroupOK.Enabled = true;
  245. }
  246. catch(Exception ex) {
  247. Util.UErrorMessage(ex,0,0);
  248. }
  249. }
  250. //그룹저장
  251. private void btnIGroupOK_Click(object sender, EventArgs e)
  252. {
  253. try
  254. {
  255. if (IGroup_cmd == QUERYMode.insert || IGroup_cmd == QUERYMode.update)
  256. {
  257. Util.ChkTxtBox(txtIGroupID, "입력그룹ID");
  258. Util.ChkTxtBox(txtIGroupName, "입력그룹명");
  259. String GroupID = txtIGroupID.Text.Trim();
  260. String GroupName = txtIGroupName.Text.Trim();
  261. DacMap dacMap = new DacMap(mdi.myReceiverID);
  262. dacMap.Group_Update(IGroup_cmd, GroupID, code_GroupIO.Input, GroupName);
  263. }
  264. IGroup_cmd = QUERYMode.select;
  265. //VIEW모드로 변경한다.
  266. Util.GroupUIChange(panelIGroup, UIMode.cancel);
  267. //데이터 불러오기
  268. IGroup_getData();
  269. IGroupDevice_getData();
  270. IGroupSelectData(null);
  271. btnIGroupCancel.Visible = false;
  272. }
  273. catch (Exception ex)
  274. {
  275. Util.UErrorMessage(ex,0,0);
  276. //MessageBox.Show(ex.Message, Application.ProductName);
  277. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  278. }
  279. }
  280. //그룹삭제
  281. private void btnIGroupDel_Click(object sender, EventArgs e)
  282. {
  283. try
  284. {
  285. IGroup_cmd = QUERYMode.delete;
  286. String GroupID = txtIGroupID.Text.Trim();
  287. String GroupName = txtIGroupName.Text.Trim();
  288. String msg = string.Format("{0}[{1}]을/를 삭제하시겠습니까?", GroupName, GroupID);
  289. if (MessageBox.Show(msg, Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)
  290. {
  291. DacMap dacMap = new DacMap(mdi.myReceiverID);
  292. dacMap.Group_Update(QUERYMode.delete, GroupID, code_GroupIO.Input, GroupName);
  293. }
  294. //VIEW모드로 변경한다.
  295. IGroup_cmd = QUERYMode.select;
  296. Util.GroupUIChange(panelIGroup, UIMode.cancel);
  297. //입력 CLEAR
  298. IGroupSelectData(null);
  299. //데이터 불러오기
  300. IGroup_getData();
  301. IGroupDevice_getData();
  302. }
  303. catch (Exception ex)
  304. {
  305. Util.UErrorMessage(ex,0,0);
  306. //MessageBox.Show(ex.Message, Application.ProductName);
  307. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  308. }
  309. }
  310. private void txtIGroupID_TextChanged(object sender, EventArgs e)
  311. {
  312. try {
  313. Util.ToUpper(txtIGroupID);
  314. }
  315. catch (Exception ex) {
  316. Util.UErrorMessage(ex, 0, 0);
  317. }
  318. }
  319. private void mskIGroupDeviceID_TextChanged(object sender, EventArgs e)
  320. {
  321. try
  322. {
  323. String dev_id_s = mskIGroupDeviceID.Text.Trim();
  324. if (dev_id_s.Length == 13)
  325. {
  326. String GroupID = txtIGroupID.Text.Trim();
  327. //MI-##-#-###-# :M(구분 M-중계기,I-입력그룹)I,O(회로구분)-##(보드ID)-##(회로ID)
  328. MskDeviceIDString dev_id = new MskDeviceIDString(dev_id_s);
  329. if (dev_id.Comm_id == 3)
  330. {
  331. DacIODeviceConfig dacIODeviceConfig = new DacIODeviceConfig();
  332. DataTable dt = dacIODeviceConfig.Device_Select(mdi.MyReceiverID
  333. , dev_id.Board_id,dev_id.Device_id, dev_id.Inout_type);
  334. if (dt.Rows.Count > 0)
  335. {
  336. DataRow dr = dt.Rows[0];
  337. txtIGroupDeviceTypeCode.Text = dr["DEVICE_TYPE"].ToString();
  338. txtIGroupDeviceTypeName.Text = dr["DEVICE_TYPE_NAME"].ToString();
  339. txtIGroupDeviceMemo.Text = dr["DEVICE_NAME"].ToString();
  340. txtIGroupPositionCode.Text = dr["POSITION_CODE"].ToString();
  341. txtIGroupPositionName.Text = dr["POSITION_NAME"].ToString();
  342. }
  343. }
  344. else
  345. {
  346. DacDeviceConfig dacDeviceConfig = new DacDeviceConfig();
  347. DataTable dt = dacDeviceConfig.Device_Select(mdi.MyReceiverID
  348. , dev_id.Board_id, dev_id.Loop_no, dev_id.Repeater_id, dev_id.Device_id, dev_id.Inout_type);
  349. if (dt.Rows.Count > 0)
  350. {
  351. DataRow dr = dt.Rows[0];
  352. txtIGroupDeviceTypeCode.Text = dr["DEVICE_TYPE"].ToString();
  353. txtIGroupDeviceTypeName.Text = dr["DEVICE_TYPE_NAME"].ToString();
  354. txtIGroupDeviceMemo.Text = dr["DEVICE_NAME"].ToString();
  355. txtIGroupPositionCode.Text = dr["POSITION_CODE"].ToString();
  356. txtIGroupPositionName.Text = dr["POSITION_NAME"].ToString();
  357. }
  358. }
  359. }
  360. }
  361. catch (Exception ex)
  362. {
  363. Util.UErrorMessage(ex,0,0);
  364. //MessageBox.Show(ex.Message, Application.ProductName);
  365. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  366. }
  367. }
  368. */
  369. /*******************************************************
  370. * [입력그룹 회로정보] LISTVIEW에 데이터 불러오기
  371. ******************************************************/
  372. /*
  373. private void IGroupDevice_getData()
  374. {
  375. try
  376. {
  377. IGroupDeviceSelectData(null);
  378. String GroupID = txtIGroupID.Text.Trim();
  379. DacMap dacMap = new DacMap(mdi.myReceiverID);
  380. DataTable dt = dacMap.Group_Device_Select(GroupID, mdi.MyReceiverID);
  381. ListViewIGroupDevice.Items.Clear();
  382. if (dt.Rows.Count > 0)
  383. {
  384. foreach (DataRow dr in dt.Rows)
  385. {
  386. //MI-##-#-###-# :M(구분 M-중계기,I-입력그룹)I,O(회로구분)-##(보드ID)-##(회로ID)
  387. String dev_id = dr["DEVICE_ID"].ToString();
  388. MskDeviceIDString dev_s = new MskDeviceIDString(int.Parse(dr["COMM_ID"].ToString()), int.Parse(dr["BOARD_ID"].ToString()), int.Parse(dr["LOOP_NO"].ToString())
  389. , int.Parse(dr["REPEATER_ID"].ToString()), int.Parse(dr["DEVICE_ID"].ToString()), dr["INOUT_TYPE"].ToString());
  390. ListViewItem item = new ListViewItem(dev_s.MskId);
  391. item.SubItems.Add(dr["DEVICE_TYPE"].ToString() + "-" + dr["DEVICE_TYPE_NAME"].ToString());
  392. item.SubItems.Add(dr["POSITION_CODE"].ToString() + "-" + dr["POSITION_NAME"].ToString());
  393. item.SubItems.Add(dr["DEVICE_NAME"].ToString());
  394. ListViewIGroupDevice.Items.Add(item);
  395. }
  396. }
  397. }
  398. catch (Exception ex)
  399. {
  400. Util.UErrorMessage(ex,0,0);
  401. //MessageBox.Show(ex.Message, Application.ProductName);
  402. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  403. }
  404. }
  405. //입력그룹 회로 데이터 표시
  406. private void IGroupDeviceSelectData(ListViewItem itm)
  407. {
  408. try {
  409. IGroupDevice_selectItem = itm;
  410. if (itm == null)
  411. {
  412. mskIGroupDeviceID.Text = "";
  413. txtIGroupDeviceTypeCode.Text = "";
  414. txtIGroupDeviceTypeName.Text = "";
  415. txtIGroupDeviceMemo.Text = "";
  416. txtIGroupPositionCode.Text = "";
  417. txtIGroupPositionName.Text = "";
  418. if (IGroupDevice_cmd == QUERYMode.insert)
  419. {
  420. //mskIGroupDeviceID.ReadOnly = false;
  421. //mskIGroupDeviceID.BackColor = Color.White;
  422. btnIGroupDeviceOK.Enabled = true;
  423. btnIGroupDeviceSearch.Enabled = true;
  424. }
  425. else
  426. {
  427. //mskIGroupDeviceID.ReadOnly = true;
  428. //mskIGroupDeviceID.BackColor = SystemColors.Control;
  429. //btnIGroupDeviceAdd.Enabled = true;
  430. btnIGroupDeviceDel.Enabled = false;
  431. btnIGroupDeviceOK.Enabled = false;
  432. btnIGroupDeviceSearch.Enabled = false;
  433. }
  434. }
  435. else
  436. {
  437. String dev_id_s = itm.Text;
  438. dev_id_s = dev_id_s.Replace("-", "");
  439. if (dev_id_s.Substring(0, 1).Equals("I"))
  440. {
  441. //IO보드
  442. mskIGroupDeviceID.Mask = "A-A-00-00";
  443. }
  444. else
  445. {
  446. //중계기>AA-00-0-000-0
  447. mskIGroupDeviceID.Mask = ">AA-00-0-000-0";
  448. }
  449. mskIGroupDeviceID.Text = dev_id_s;
  450. //mskIGroupDeviceID.BackColor = SystemColors.Control;
  451. String GroupDeviceType = itm.SubItems[1].Text;
  452. if (GroupDeviceType.Length > 0)
  453. {
  454. int pos = GroupDeviceType.IndexOf("-");
  455. if (pos != -1)
  456. {
  457. txtIGroupDeviceTypeCode.Text = GroupDeviceType.Substring(0, pos);
  458. txtIGroupDeviceTypeName.Text = GroupDeviceType.Substring(pos+1);
  459. }
  460. }
  461. String GroupPostion = itm.SubItems[2].Text;
  462. if (GroupPostion.Length > 0)
  463. {
  464. int pos = GroupPostion.IndexOf("-");
  465. if (pos != -1)
  466. {
  467. txtIGroupPositionCode.Text = GroupPostion.Substring(0, pos);
  468. txtIGroupPositionName.Text = GroupPostion.Substring(pos + 1);
  469. }
  470. }
  471. txtIGroupDeviceMemo.Text = itm.SubItems[3].Text;
  472. //mskIGroupDeviceID.ReadOnly = true;
  473. //btnIGroupDeviceAdd.Enabled = true;
  474. btnIGroupDeviceSearch.Enabled = false;
  475. btnIGroupDeviceDel.Enabled = true;
  476. btnIGroupDeviceOK.Enabled = true;
  477. }
  478. }
  479. catch(Exception ex) {
  480. Util.UErrorMessage(ex,0,0);
  481. }
  482. }
  483. private void btnIGroupCancel_Click(object sender, EventArgs e)
  484. {
  485. try {
  486. //VIEW모드로 변경한다.
  487. IGroup_cmd = QUERYMode.select;
  488. Util.GroupUIChange(panelIGroup, UIMode.cancel);
  489. IGroupSelectData(null);
  490. btnIGroupCancel.Visible = false;
  491. }
  492. catch(Exception ex) {
  493. Util.UErrorMessage(ex,0,0);
  494. }
  495. }
  496. private void btnIGroupDeviceAdd_Click(object sender, EventArgs e)
  497. {
  498. try {
  499. //입력모드로 변경한다.
  500. IGroupDevice_cmd = QUERYMode.insert;
  501. //Util.GroupControlChange(panelIGroupDevice, UIMode.input);
  502. //mskIGroupDeviceID.ReadOnly = false;
  503. IGroupDeviceSelectData(null);
  504. btnIGroupDeviceSearch.Focus();
  505. btnIGroupDeviceAdd.Enabled = false;
  506. btnIGroupDeviceDel.Enabled = false;
  507. btnIGroupDeviceCancel.Visible = true;
  508. btnIGroupDeviceOK.Enabled = true;
  509. }
  510. catch(Exception ex) {
  511. Util.UErrorMessage(ex,0,0);
  512. }
  513. }
  514. private void btnIGroupDeviceDel_Click(object sender, EventArgs e)
  515. {
  516. try
  517. {
  518. String GroupID = txtIGroupID.Text.Trim();
  519. String dev_id_s = mskIGroupDeviceID.Text.Trim();
  520. //MI-##-#-###-# :M(구분 M-중계기,I-입력그룹)I,O(회로구분)-##(보드ID)-#(회로ID)
  521. MskDeviceIDString dev_id = new MskDeviceIDString(dev_id_s);
  522. String msg = string.Format("{0}을/를 삭제하시겠습니까?", dev_id_s);
  523. IGroupDevice_cmd = QUERYMode.delete;
  524. if (MessageBox.Show(msg, Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)
  525. {
  526. DacMap dacMap = new DacMap(mdi.myReceiverID);
  527. dacMap.Group_Device_Update(IGroupDevice_cmd, GroupID, mdi.MyReceiverID, dev_id.Comm_id,
  528. dev_id.Board_id, dev_id.Loop_no, dev_id.Repeater_id, dev_id.Device_id, dev_id.Inout_type);
  529. }
  530. //VIEW모드로 변경한다.
  531. IGroupDevice_cmd = QUERYMode.select;
  532. //Util.GroupControlChange(panelIGroupDevice, UIMode.cancel);
  533. //mskIGroupDeviceID.ReadOnly = true;
  534. //입력 CLEAR
  535. IGroupDeviceSelectData(null);
  536. //데이터 불러오기
  537. IGroupDevice_getData();
  538. }
  539. catch (Exception ex)
  540. {
  541. Util.UErrorMessage(ex,0,0);
  542. //MessageBox.Show(ex.Message, Application.ProductName);
  543. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  544. }
  545. }
  546. private void btnIGroupDeviceCancel_Click(object sender, EventArgs e)
  547. {
  548. try {
  549. //VIEW모드로 변경한다.
  550. IGroupDevice_cmd = QUERYMode.select;
  551. //Util.GroupControlChange(panelIGroupDevice, UIMode.cancel);
  552. //mskIGroupDeviceID.ReadOnly = true;
  553. IGroupDeviceSelectData(null);
  554. btnIGroupDeviceCancel.Visible = false;
  555. btnIGroupDeviceAdd.Enabled = true;
  556. btnIGroupDeviceSearch.Enabled = true;
  557. }
  558. catch(Exception ex) {
  559. Util.UErrorMessage(ex,0,0);
  560. }
  561. }
  562. private void btnIGroupDeviceOK_Click(object sender, EventArgs e)
  563. {
  564. try
  565. {
  566. if (IGroupDevice_cmd == QUERYMode.insert || IGroupDevice_cmd == QUERYMode.update)
  567. {
  568. Util.ChkTxtBox(mskIGroupDeviceID, "회로번호");
  569. String GroupID = txtIGroupID.Text.Trim();
  570. String dev_id_s = mskIGroupDeviceID.Text;
  571. //MI-##-#-##### :M(구분 M-중계기,I-입력그룹)I,O(회로구분)-##(보드ID)-#(회로ID)
  572. MskDeviceIDString dev_id = new MskDeviceIDString(dev_id_s);
  573. DacMap dacMap = new DacMap(mdi.myReceiverID);
  574. dacMap.Group_Device_Update(IGroupDevice_cmd, GroupID, mdi.MyReceiverID, dev_id.Comm_id,
  575. dev_id.Board_id, dev_id.Loop_no, dev_id.Repeater_id, dev_id.Device_id, dev_id.Inout_type);
  576. }
  577. IGroupDevice_cmd = QUERYMode.select;
  578. //VIEW모드로 변경한다.
  579. //Util.GroupControlChange(panelIGroupDevice, UIMode.cancel);
  580. //mskIGroupDeviceID.ReadOnly = true;
  581. //데이터 불러오기
  582. IGroupDevice_getData();
  583. IGroupDeviceSelectData(null);
  584. btnIGroupDeviceAdd.Enabled = true;
  585. btnIGroupDeviceCancel.Visible = false;
  586. }
  587. catch (Exception ex)
  588. {
  589. Util.UErrorMessage(ex,0,0);
  590. //MessageBox.Show(ex.Message, Application.ProductName);
  591. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  592. }
  593. }
  594. private void ListViewIGroupDevice_SelectedIndexChanged(object sender, EventArgs e)
  595. {
  596. try
  597. {
  598. ListView lv = (ListView)sender;
  599. if (lv.SelectedItems.Count > 0)
  600. {
  601. ListViewItem itm = lv.SelectedItems[0];
  602. IGroupDevice_cmd = QUERYMode.update;
  603. //VIEW모드로 변경한다.[입력그룹]
  604. //Util.GroupControlChange(panelIGroupDevice, UIMode.input);
  605. //mskIGroupDeviceID.ReadOnly = false;
  606. IGroupDeviceSelectData(itm);
  607. }
  608. else
  609. {
  610. IGroupDevice_cmd = QUERYMode.select;
  611. //VIEW모드로 변경한다.
  612. //Util.GroupControlChange(panelIGroupDevice, UIMode.cancel);
  613. //mskIGroupDeviceID.ReadOnly = true;
  614. IGroupDeviceSelectData(null);
  615. }
  616. }
  617. catch (Exception ex)
  618. {
  619. Util.UErrorMessage(ex,0,0);
  620. //MessageBox.Show(ex.Message, Application.ProductName);
  621. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  622. }
  623. }
  624. //회로검색버튼 클릭시
  625. private void btnIGroupDeviceSearch_Click(object sender, EventArgs e)
  626. {
  627. try
  628. {
  629. frmModalDeviceList frm = new frmModalDeviceList();
  630. SearchCodeVo vo = new SearchCodeVo(null);
  631. InputIDVo inputVo = new InputIDVo();
  632. inputVo.ReceiverID = this.mdi.MyReceiverID;
  633. inputVo.InoutType = code_InOutType.Input;
  634. String dev_id_s = mskIGroupDeviceID.Text.Trim();
  635. if (dev_id_s.Length == 13)
  636. {
  637. //MI-##-#-###-# :M(구분 M-중계기,I-입력그룹)I,O(회로구분)-##(보드ID)-##(회로ID)
  638. MskDeviceIDString dev_id = new MskDeviceIDString(dev_id_s);
  639. inputVo.BoardID = dev_id.Board_id;
  640. inputVo.CommID = dev_id.Comm_id;
  641. inputVo.LoopNo = dev_id.Loop_no;
  642. inputVo.DeviceID = dev_id.Device_id;
  643. }
  644. frm.SearchCode = vo;
  645. frm.InputVo = inputVo;
  646. frm.ShowDialog();
  647. vo = frm.SearchCode;
  648. //선택한 코드가 있다면
  649. if (vo.SearchOK)
  650. {
  651. InputIDVo[] inputVos = (InputIDVo[])vo.SelectObject;
  652. if (inputVos.Length > 0)
  653. {
  654. //if (inputVos.Length == 1)
  655. //{
  656. // MskDeviceIDString dev_id = new MskDeviceIDString(inputVos[0].CommID, inputVos[0].BoardID
  657. // , inputVos[0].LoopNo, inputVos[0].RepeaterID
  658. // , inputVos[0].DeviceID, inputVos[0].InoutType);
  659. // mskIGroupDeviceID.Text = dev_id.MskId;
  660. //}
  661. //else
  662. //{
  663. String GroupID = txtIGroupID.Text.Trim();
  664. DacMap dacMap = new DacMap(mdi.myReceiverID);
  665. for (int i = 0; i < inputVos.Length; i++)
  666. {
  667. //String dev_id_s = mskIGroupDeviceID.Text;
  668. ////MI-##-#-##### :M(구분 M-중계기,I-입력그룹)I,O(회로구분)-##(보드ID)-#(회로ID)
  669. //MskDeviceIDString dev_id = new MskDeviceIDString(dev_id_s);
  670. MskDeviceIDString dev_id = new MskDeviceIDString(inputVos[i].CommID, inputVos[i].BoardID
  671. , inputVos[i].LoopNo, inputVos[i].RepeaterID
  672. , inputVos[i].DeviceID, inputVos[i].InoutType);
  673. dacMap.Group_Device_Update(IGroupDevice_cmd, GroupID, mdi.MyReceiverID, dev_id.Comm_id,
  674. dev_id.Board_id, dev_id.Loop_no, dev_id.Repeater_id, dev_id.Device_id, dev_id.Inout_type);
  675. }
  676. IGroupDevice_cmd = QUERYMode.select;
  677. //VIEW모드로 변경한다.
  678. //Util.GroupControlChange(panelIGroupDevice, UIMode.cancel);
  679. //mskIGroupDeviceID.ReadOnly = true;
  680. //데이터 불러오기
  681. IGroupDevice_getData();
  682. IGroupDeviceSelectData(null);
  683. btnIGroupDeviceAdd.Enabled = true;
  684. //btnIGroupDeviceCancel.Visible = false;
  685. //}
  686. }
  687. }
  688. }
  689. catch (Exception ex)
  690. {
  691. Util.UErrorMessage(ex,0,0);
  692. //MessageBox.Show(ex.Message, Application.ProductName);
  693. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  694. }
  695. }
  696. /*******************************************************
  697. * [출력그룹] LISTVIEW에 데이터 불러오기
  698. ******************************************************/
  699. private void OGroup_getData()
  700. {
  701. try
  702. {
  703. OGroupSelectData(null);
  704. DacMap dacMap = new DacMap(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  705. // cyim 2014.8.14 그룹정보는 수신기아이디에 따라 출력됨
  706. //DataTable dt = dacMap.Group_Select(null, code_GroupIO.Output);
  707. DataTable dt = dacMap.Group_Select(null, code_GroupIO.Output, receiver_id); // cyim 2015.8.4 수신반을 위한 static 클래스 정리
  708. ListViewOGroup.Items.Clear();
  709. if (dt.Rows.Count > 0)
  710. {
  711. foreach (DataRow dr in dt.Rows)
  712. {
  713. ListViewItem item = new ListViewItem(Convert.ToString(dr["GROUP_ID"]));
  714. item.SubItems.Add(dr["GROUP_NAME"].ToString());
  715. ListViewOGroup.Items.Add(item);
  716. }
  717. }
  718. }
  719. catch (Exception ex)
  720. {
  721. Util.UErrorMessage(ex, 0, 0);
  722. //MessageBox.Show(ex.Message, Application.ProductName);
  723. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  724. }
  725. }
  726. //리스트VIEW에 그룹선택시
  727. private void ListViewOGroup_SelectedIndexChanged(object sender, EventArgs e)
  728. {
  729. try
  730. {
  731. ListView lv = (ListView)sender;
  732. if (lv.SelectedItems.Count > 0)
  733. {
  734. ListViewItem itm = lv.SelectedItems[0];
  735. OGroup_cmd = QUERYMode.update;
  736. //VIEW모드로 변경한다.[출력그룹]
  737. Util.GroupUIChange(panelOGroup, UIMode.input);
  738. OGroupSelectData(itm);
  739. OGroupDevice_getData();
  740. }
  741. else
  742. {
  743. OGroup_cmd = QUERYMode.select;
  744. //VIEW모드로 변경한다.
  745. Util.GroupUIChange(panelOGroup, UIMode.cancel);
  746. OGroupSelectData(null);
  747. }
  748. }
  749. catch (Exception ex)
  750. {
  751. Util.UErrorMessage(ex, 0, 0);
  752. //MessageBox.Show(ex.Message, Application.ProductName);
  753. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  754. }
  755. }
  756. //그룹표시
  757. //출력그룹 데이터 표시
  758. private void OGroupSelectData(ListViewItem itm)
  759. {
  760. try
  761. {
  762. OGroup_selectItem = itm;
  763. if (itm == null)
  764. {
  765. txtOGroupID.Text = "";
  766. txtOGroupName.Text = "";
  767. if (OGroup_cmd == QUERYMode.insert)
  768. {
  769. txtOGroupID.ReadOnly = false;
  770. txtOGroupID.BackColor = Color.White;
  771. txtOGroupName.ReadOnly = false;
  772. btnOGroupOK.Enabled = true;
  773. }
  774. else
  775. {
  776. txtOGroupID.ReadOnly = true;
  777. txtOGroupID.BackColor = SystemColors.Control;
  778. btnOGroupAdd.Enabled = true;
  779. btnOGroupDel.Enabled = false;
  780. btnOGroupOK.Enabled = false;
  781. }
  782. btnOGroupDeviceAdd.Enabled = false;
  783. btnOGroupDeviceSearch.Enabled = false;
  784. }
  785. else
  786. {
  787. txtOGroupID.Text = itm.Text;
  788. txtOGroupID.BackColor = SystemColors.Control;
  789. txtOGroupName.Text = itm.SubItems[1].Text;
  790. txtOGroupID.ReadOnly = true;
  791. btnOGroupAdd.Enabled = true;
  792. btnOGroupDel.Enabled = true;
  793. btnOGroupOK.Enabled = true;
  794. btnOGroupDeviceAdd.Enabled = true;
  795. btnOGroupDeviceSearch.Enabled = true;
  796. }
  797. OGroupDeviceSelectData(null);
  798. }
  799. catch (Exception ex)
  800. {
  801. Util.UErrorMessage(ex, 0, 0);
  802. }
  803. }
  804. //그룹추가
  805. private void btnOGroupAdd_Click(object sender, EventArgs e)
  806. {
  807. try
  808. {
  809. //출력모드로 변경한다.
  810. OGroup_cmd = QUERYMode.insert;
  811. Util.GroupUIChange(panelOGroup, UIMode.input);
  812. OGroupSelectData(null);
  813. txtOGroupID.Text = "GO";
  814. txtOGroupID.Focus();
  815. btnOGroupAdd.Enabled = false;
  816. btnOGroupDel.Enabled = false;
  817. btnOGroupCancel.Visible = true;
  818. btnOGroupOK.Enabled = true;
  819. }
  820. catch (Exception ex)
  821. {
  822. Util.UErrorMessage(ex, 0, 0);
  823. }
  824. }
  825. //그룹저장
  826. private void btnOGroupOK_Click(object sender, EventArgs e)
  827. {
  828. try
  829. {
  830. if (OGroup_cmd == QUERYMode.insert || OGroup_cmd == QUERYMode.update)
  831. {
  832. Util.ChkTxtBox(txtOGroupID, "출력그룹ID");
  833. Util.ChkTxtBox(txtOGroupName, "출력그룹명");
  834. String GroupID = txtOGroupID.Text.Trim();
  835. String GroupName = txtOGroupName.Text.Trim();
  836. DacMap dacMap = new DacMap(mdi.myReceiverID);// cyim 2015.7.30 데이타베이스 접속 루틴 변경
  837. dacMap.Group_Update(OGroup_cmd, GroupID, code_GroupIO.Output, GroupName);
  838. }
  839. OGroup_cmd = QUERYMode.select;
  840. //VIEW모드로 변경한다.
  841. Util.GroupUIChange(panelOGroup, UIMode.cancel);
  842. //데이터 불러오기
  843. OGroup_getData();
  844. OGroupDevice_getData();
  845. OGroupSelectData(null);
  846. btnOGroupCancel.Visible = false;
  847. }
  848. catch (Exception ex)
  849. {
  850. Util.UErrorMessage(ex, 0, 0);
  851. //MessageBox.Show(ex.Message, Application.ProductName);
  852. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  853. }
  854. }
  855. //그룹삭제
  856. private void btnOGroupDel_Click(object sender, EventArgs e)
  857. {
  858. try
  859. {
  860. OGroup_cmd = QUERYMode.delete;
  861. String GroupID = txtOGroupID.Text.Trim();
  862. String GroupName = txtOGroupName.Text.Trim();
  863. String msg = string.Format("{0}[{1}]을/를 삭제하시겠습니까?", GroupName, GroupID);
  864. if (MessageBox.Show(msg, Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)
  865. {
  866. DacMap dacMap = new DacMap(mdi.myReceiverID);// cyim 2015.7.30 데이타베이스 접속 루틴 변경
  867. dacMap.Group_Update(QUERYMode.delete, GroupID, code_GroupIO.Output, GroupName);
  868. }
  869. //VIEW모드로 변경한다.
  870. OGroup_cmd = QUERYMode.select;
  871. Util.GroupUIChange(panelOGroup, UIMode.cancel);
  872. //출력 CLEAR
  873. OGroupSelectData(null);
  874. //데이터 불러오기
  875. OGroup_getData();
  876. OGroupDevice_getData();
  877. }
  878. catch (Exception ex)
  879. {
  880. Util.UErrorMessage(ex, 0, 0);
  881. //MessageBox.Show(ex.Message, Application.ProductName);
  882. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  883. }
  884. }
  885. private void txtOGroupID_TextChanged(object sender, EventArgs e)
  886. {
  887. try
  888. {
  889. Util.ToUpper(txtOGroupID);
  890. }
  891. catch (Exception ex)
  892. {
  893. Util.UErrorMessage(ex, 0, 0);
  894. }
  895. }
  896. private void mskOGroupDeviceID_TextChanged(object sender, EventArgs e)
  897. {
  898. try
  899. {
  900. String dev_id_s = mskOGroupDeviceID.Text.Trim();
  901. if (dev_id_s.Length == 13)
  902. {
  903. String GroupID = txtOGroupID.Text.Trim();
  904. //MI-##-#-###-# :M(구분 M-중계기,I-출력그룹)I,O(회로구분)-##(보드ID)-##(회로ID)
  905. MskDeviceIDString dev_id = new MskDeviceIDString(dev_id_s);
  906. if (dev_id.Comm_id == 3)
  907. {
  908. DacIODeviceConfig dacIODeviceConfig = new DacIODeviceConfig(mdi.myReceiverID);// cyim 2015.7.30 데이타베이스 접속 루틴 변경
  909. DataTable dt = dacIODeviceConfig.Device_Select(mdi.myReceiverID
  910. , dev_id.Board_id, dev_id.Device_id, dev_id.Inout_type);
  911. if (dt.Rows.Count > 0)
  912. {
  913. DataRow dr = dt.Rows[0];
  914. txtOGroupDeviceTypeCode.Text = dr["DEVICE_TYPE"].ToString();
  915. txtOGroupDeviceTypeName.Text = dr["DEVICE_TYPE_NAME"].ToString();
  916. txtOGroupDeviceMemo.Text = dr["DEVICE_NAME"].ToString();
  917. txtOGroupPositionCode.Text = dr["POSITION_CODE"].ToString();
  918. txtOGroupPositionName.Text = dr["POSITION_NAME"].ToString();
  919. }
  920. }
  921. else
  922. {
  923. DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(mdi.myReceiverID);// cyim 2015.7.30 데이타베이스 접속 루틴 변경
  924. DataTable dt = dacDeviceConfig.Device_Select(mdi.myReceiverID
  925. , dev_id.Board_id, dev_id.Loop_no, dev_id.Repeater_id, dev_id.Device_id, dev_id.Inout_type);
  926. if (dt.Rows.Count > 0)
  927. {
  928. DataRow dr = dt.Rows[0];
  929. txtOGroupDeviceTypeCode.Text = dr["DEVICE_TYPE"].ToString();
  930. txtOGroupDeviceTypeName.Text = dr["DEVICE_TYPE_NAME"].ToString();
  931. txtOGroupDeviceMemo.Text = dr["DEVICE_NAME"].ToString();
  932. txtOGroupPositionCode.Text = dr["POSITION_CODE"].ToString();
  933. txtOGroupPositionName.Text = dr["POSITION_NAME"].ToString();
  934. }
  935. }
  936. }
  937. }
  938. catch (Exception ex)
  939. {
  940. Util.UErrorMessage(ex, 0, 0);
  941. //MessageBox.Show(ex.Message, Application.ProductName);
  942. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  943. }
  944. }
  945. /*******************************************************
  946. * [출력그룹 회로정보] LISTVIEW에 데이터 불러오기
  947. ******************************************************/
  948. private void OGroupDevice_getData()
  949. {
  950. try
  951. {
  952. OGroupDeviceSelectData(null);
  953. String GroupID = txtOGroupID.Text.Trim();
  954. DacMap dacMap = new DacMap(mdi.myReceiverID);// cyim 2015.7.30 데이타베이스 접속 루틴 변경
  955. DataTable dt = dacMap.Group_Device_Select(GroupID, mdi.myReceiverID);
  956. ListViewOGroupDevice.Items.Clear();
  957. if (dt.Rows.Count > 0)
  958. {
  959. foreach (DataRow dr in dt.Rows)
  960. {
  961. //MI-##-#-###-# :M(구분 M-중계기,I-출력그룹)I,O(회로구분)-##(보드ID)-##(회로ID)
  962. String dev_id = dr["DEVICE_ID"].ToString();
  963. MskDeviceIDString dev_s = new MskDeviceIDString(int.Parse(dr["COMM_ID"].ToString()), int.Parse(dr["BOARD_ID"].ToString()), int.Parse(dr["LOOP_NO"].ToString())
  964. , int.Parse(dr["REPEATER_ID"].ToString()), int.Parse(dr["DEVICE_ID"].ToString()), dr["INOUT_TYPE"].ToString());
  965. ListViewItem item = new ListViewItem(dr["RECEIVER_ID"].ToString() + ":" + dev_s.MskId); // cyim 2014.8.12 수신기 아이디까지 회로번호로 보이도록 수정
  966. item.SubItems.Add(dr["DEVICE_TYPE"].ToString() + "-" + dr["DEVICE_TYPE_NAME"].ToString());
  967. item.SubItems.Add(dr["POSITION_CODE"].ToString() + "-" + dr["POSITION_NAME"].ToString());
  968. item.SubItems.Add(dr["DEVICE_NAME"].ToString());
  969. ListViewOGroupDevice.Items.Add(item);
  970. }
  971. }
  972. }
  973. catch (Exception ex)
  974. {
  975. Util.UErrorMessage(ex, 0, 0);
  976. //MessageBox.Show(ex.Message, Application.ProductName);
  977. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  978. }
  979. }
  980. //출력그룹 회로 데이터 표시
  981. private void OGroupDeviceSelectData(ListViewItem itm)
  982. {
  983. try
  984. {
  985. OGroupDevice_selectItem = itm;
  986. if (itm == null)
  987. {
  988. mskOGroupDeviceID.Text = "";
  989. txtOGroupDeviceTypeCode.Text = "";
  990. txtOGroupDeviceTypeName.Text = "";
  991. txtOGroupDeviceMemo.Text = "";
  992. txtOGroupPositionCode.Text = "";
  993. txtOGroupPositionName.Text = "";
  994. if (OGroupDevice_cmd == QUERYMode.insert)
  995. {
  996. //mskOGroupDeviceID.ReadOnly = false;
  997. //mskOGroupDeviceID.BackColor = Color.White;
  998. btnOGroupDeviceOK.Enabled = true;
  999. btnOGroupDeviceSearch.Enabled = true;
  1000. }
  1001. else
  1002. {
  1003. //mskOGroupDeviceID.ReadOnly = true;
  1004. //mskOGroupDeviceID.BackColor = SystemColors.Control;
  1005. //btnOGroupDeviceAdd.Enabled = true;
  1006. btnOGroupDeviceDel.Enabled = false;
  1007. btnOGroupDeviceOK.Enabled = false;
  1008. btnOGroupDeviceSearch.Enabled = false;
  1009. }
  1010. }
  1011. else
  1012. {
  1013. String dev_id_s = itm.Text;
  1014. dev_id_s = dev_id_s.Replace("-", "");
  1015. if (dev_id_s.Substring(0, 1).Equals("I"))
  1016. {
  1017. //IO보드
  1018. mskOGroupDeviceID.Mask = "A-A-00-00";
  1019. }
  1020. else
  1021. {
  1022. //중계기>AA-00-0-000-0
  1023. mskOGroupDeviceID.Mask = ">AA-00-0-000-0";
  1024. }
  1025. mskOGroupDeviceID.Text = dev_id_s;
  1026. //mskOGroupDeviceID.BackColor = SystemColors.Control;
  1027. String GroupDeviceType = itm.SubItems[1].Text;
  1028. if (GroupDeviceType.Length > 0)
  1029. {
  1030. int pos = GroupDeviceType.IndexOf("-");
  1031. if (pos != -1)
  1032. {
  1033. txtOGroupDeviceTypeCode.Text = GroupDeviceType.Substring(0, pos);
  1034. txtOGroupDeviceTypeName.Text = GroupDeviceType.Substring(pos + 1);
  1035. }
  1036. }
  1037. String GroupPostion = itm.SubItems[2].Text;
  1038. if (GroupPostion.Length > 0)
  1039. {
  1040. int pos = GroupPostion.IndexOf("-");
  1041. if (pos != -1)
  1042. {
  1043. txtOGroupPositionCode.Text = GroupPostion.Substring(0, pos);
  1044. txtOGroupPositionName.Text = GroupPostion.Substring(pos + 1);
  1045. }
  1046. }
  1047. txtOGroupDeviceMemo.Text = itm.SubItems[3].Text;
  1048. //mskOGroupDeviceID.ReadOnly = true;
  1049. //btnOGroupDeviceAdd.Enabled = true;
  1050. btnOGroupDeviceSearch.Enabled = false;
  1051. btnOGroupDeviceDel.Enabled = true;
  1052. btnOGroupDeviceOK.Enabled = true;
  1053. }
  1054. }
  1055. catch (Exception ex)
  1056. {
  1057. Util.UErrorMessage(ex, 0, 0);
  1058. }
  1059. }
  1060. private void btnOGroupCancel_Click(object sender, EventArgs e)
  1061. {
  1062. try
  1063. {
  1064. //VIEW모드로 변경한다.
  1065. OGroup_cmd = QUERYMode.select;
  1066. Util.GroupUIChange(panelOGroup, UIMode.cancel);
  1067. OGroupSelectData(null);
  1068. btnOGroupCancel.Visible = false;
  1069. }
  1070. catch (Exception ex)
  1071. {
  1072. Util.UErrorMessage(ex, 0, 0);
  1073. }
  1074. }
  1075. private void btnOGroupDeviceAdd_Click(object sender, EventArgs e)
  1076. {
  1077. try
  1078. {
  1079. //출력모드로 변경한다.
  1080. OGroupDevice_cmd = QUERYMode.insert;
  1081. //Util.GroupControlChange(panelOGroupDevice, UIMode.Output);
  1082. //mskOGroupDeviceID.ReadOnly = false;
  1083. OGroupDeviceSelectData(null);
  1084. btnOGroupDeviceSearch.Focus();
  1085. btnOGroupDeviceAdd.Enabled = false;
  1086. btnOGroupDeviceDel.Enabled = false;
  1087. btnOGroupDeviceCancel.Visible = true;
  1088. btnOGroupDeviceOK.Enabled = true;
  1089. }
  1090. catch (Exception ex)
  1091. {
  1092. Util.UErrorMessage(ex, 0, 0);
  1093. }
  1094. }
  1095. private void btnOGroupDeviceDel_Click(object sender, EventArgs e)
  1096. {
  1097. try
  1098. {
  1099. String GroupID = txtOGroupID.Text.Trim();
  1100. String dev_id_s = mskOGroupDeviceID.Text.Trim();
  1101. //MI-##-#-###-# :M(구분 M-중계기,I-출력그룹)I,O(회로구분)-##(보드ID)-#(회로ID)
  1102. MskDeviceIDString dev_id = new MskDeviceIDString(dev_id_s);
  1103. String msg = string.Format("{0}을/를 삭제하시겠습니까?", dev_id_s);
  1104. OGroupDevice_cmd = QUERYMode.delete;
  1105. if (MessageBox.Show(msg, Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)
  1106. {
  1107. DacMap dacMap = new DacMap(mdi.myReceiverID);// cyim 2015.7.30 데이타베이스 접속 루틴 변경
  1108. dacMap.Group_Device_Update(OGroupDevice_cmd, GroupID, mdi.myReceiverID, dev_id.Comm_id,
  1109. dev_id.Board_id, dev_id.Loop_no, dev_id.Repeater_id, dev_id.Device_id, dev_id.Inout_type);
  1110. }
  1111. //VIEW모드로 변경한다.
  1112. OGroupDevice_cmd = QUERYMode.select;
  1113. //Util.GroupControlChange(panelOGroupDevice, UIMode.cancel);
  1114. //mskOGroupDeviceID.ReadOnly = true;
  1115. //출력 CLEAR
  1116. OGroupDeviceSelectData(null);
  1117. //데이터 불러오기
  1118. OGroupDevice_getData();
  1119. }
  1120. catch (Exception ex)
  1121. {
  1122. Util.UErrorMessage(ex, 0, 0);
  1123. //MessageBox.Show(ex.Message, Application.ProductName);
  1124. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  1125. }
  1126. }
  1127. private void btnOGroupDeviceCancel_Click(object sender, EventArgs e)
  1128. {
  1129. try
  1130. {
  1131. //VIEW모드로 변경한다.
  1132. OGroupDevice_cmd = QUERYMode.select;
  1133. //Util.GroupControlChange(panelOGroupDevice, UIMode.cancel);
  1134. //mskOGroupDeviceID.ReadOnly = true;
  1135. OGroupDeviceSelectData(null);
  1136. btnOGroupDeviceCancel.Visible = false;
  1137. btnOGroupDeviceAdd.Enabled = true;
  1138. btnOGroupDeviceSearch.Enabled = true;
  1139. }
  1140. catch (Exception ex)
  1141. {
  1142. Util.UErrorMessage(ex, 0, 0);
  1143. }
  1144. }
  1145. private void btnOGroupDeviceOK_Click(object sender, EventArgs e)
  1146. {
  1147. try
  1148. {
  1149. if (OGroupDevice_cmd == QUERYMode.insert || OGroupDevice_cmd == QUERYMode.update)
  1150. {
  1151. Util.ChkTxtBox(mskOGroupDeviceID, "회로번호");
  1152. String GroupID = txtOGroupID.Text.Trim();
  1153. String dev_id_s = mskOGroupDeviceID.Text;
  1154. //MI-##-#-##### :M(구분 M-중계기,I-출력그룹)I,O(회로구분)-##(보드ID)-#(회로ID)
  1155. MskDeviceIDString dev_id = new MskDeviceIDString(dev_id_s);
  1156. DacMap dacMap = new DacMap(mdi.myReceiverID);// cyim 2015.7.30 데이타베이스 접속 루틴 변경
  1157. dacMap.Group_Device_Update(OGroupDevice_cmd, GroupID, mdi.myReceiverID, dev_id.Comm_id,
  1158. dev_id.Board_id, dev_id.Loop_no, dev_id.Repeater_id, dev_id.Device_id, dev_id.Inout_type);
  1159. }
  1160. OGroupDevice_cmd = QUERYMode.select;
  1161. //VIEW모드로 변경한다.
  1162. //Util.GroupControlChange(panelOGroupDevice, UIMode.cancel);
  1163. //mskOGroupDeviceID.ReadOnly = true;
  1164. //데이터 불러오기
  1165. OGroupDevice_getData();
  1166. OGroupDeviceSelectData(null);
  1167. btnOGroupDeviceAdd.Enabled = true;
  1168. btnOGroupDeviceCancel.Visible = false;
  1169. }
  1170. catch (Exception ex)
  1171. {
  1172. Util.UErrorMessage(ex, 0, 0);
  1173. //MessageBox.Show(ex.Message, Application.ProductName);
  1174. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  1175. }
  1176. }
  1177. private void ListViewOGroupDevice_SelectedIndexChanged(object sender, EventArgs e)
  1178. {
  1179. try
  1180. {
  1181. ListView lv = (ListView)sender;
  1182. if (lv.SelectedItems.Count > 0)
  1183. {
  1184. ListViewItem itm = lv.SelectedItems[0];
  1185. OGroupDevice_cmd = QUERYMode.update;
  1186. //VIEW모드로 변경한다.[출력그룹]
  1187. //Util.GroupControlChange(panelOGroupDevice, UIMode.Output);
  1188. //mskOGroupDeviceID.ReadOnly = false;
  1189. OGroupDeviceSelectData(itm);
  1190. }
  1191. else
  1192. {
  1193. OGroupDevice_cmd = QUERYMode.select;
  1194. //VIEW모드로 변경한다.
  1195. //Util.GroupControlChange(panelOGroupDevice, UIMode.cancel);
  1196. //mskOGroupDeviceID.ReadOnly = true;
  1197. OGroupDeviceSelectData(null);
  1198. }
  1199. }
  1200. catch (Exception ex)
  1201. {
  1202. Util.UErrorMessage(ex, 0, 0);
  1203. //MessageBox.Show(ex.Message, Application.ProductName);
  1204. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  1205. }
  1206. }
  1207. //회로검색버튼 클릭시
  1208. private void btnOGroupDeviceSearch_Click(object sender, EventArgs e)
  1209. {
  1210. try
  1211. {
  1212. frmModalDeviceList frm = new frmModalDeviceList(mdi); // cyim 2016.12.07 : 수신기 모델별 내부 로직 변경
  1213. SearchCodeVo vo = new SearchCodeVo(null);
  1214. InputIDVo inputVo = new InputIDVo();
  1215. inputVo.ReceiverID = this.mdi.myReceiverID;
  1216. inputVo.InoutType = code_InOutType.Output;
  1217. String dev_id_s = mskOGroupDeviceID.Text.Trim();
  1218. if (dev_id_s.Length == 13)
  1219. {
  1220. //MI-##-#-###-# :M(구분 M-중계기,I-출력그룹)I,O(회로구분)-##(보드ID)-##(회로ID)
  1221. MskDeviceIDString dev_id = new MskDeviceIDString(dev_id_s);
  1222. inputVo.BoardID = dev_id.Board_id;
  1223. inputVo.CommID = dev_id.Comm_id;
  1224. inputVo.LoopNo = dev_id.Loop_no;
  1225. inputVo.DeviceID = dev_id.Device_id;
  1226. }
  1227. frm.SearchCode = vo;
  1228. frm.InputVo = inputVo;
  1229. frm.ShowDialog();
  1230. vo = frm.SearchCode;
  1231. //선택한 코드가 있다면
  1232. if (vo.SearchOK)
  1233. {
  1234. //inputVo = (InputIDVo)vo.SelectObject;
  1235. InputIDVo[] inputVos = (InputIDVo[])vo.SelectObject;
  1236. if (inputVos.Length > 0)
  1237. {
  1238. //if (inputVos.Length == 1)
  1239. //{
  1240. // MskDeviceIDString dev_id = new MskDeviceIDString(inputVos[0].CommID, inputVos[0].BoardID
  1241. // , inputVos[0].LoopNo, inputVos[0].RepeaterID
  1242. // , inputVos[0].DeviceID, inputVos[0].InoutType);
  1243. // mskOGroupDeviceID.Text = dev_id.MskId;
  1244. //}
  1245. //else
  1246. //{
  1247. //String dev_id_s = mskOGroupDeviceID.Text;
  1248. ////MI-##-#-##### :M(구분 M-중계기,I-출력그룹)I,O(회로구분)-##(보드ID)-#(회로ID)
  1249. //MskDeviceIDString dev_id = new MskDeviceIDString(dev_id_s);
  1250. String GroupID = txtOGroupID.Text.Trim();
  1251. DacMap dacMap = new DacMap(mdi.myReceiverID);// cyim 2015.7.30 데이타베이스 접속 루틴 변경
  1252. for (int i = 0; i < inputVos.Length; i++)
  1253. {
  1254. //String dev_id_s = mskIGroupDeviceID.Text;
  1255. ////MI-##-#-##### :M(구분 M-중계기,I-입력그룹)I,O(회로구분)-##(보드ID)-#(회로ID)
  1256. //MskDeviceIDString dev_id = new MskDeviceIDString(dev_id_s);
  1257. MskDeviceIDString dev_id = new MskDeviceIDString(inputVos[i].CommID, inputVos[i].BoardID
  1258. , inputVos[i].LoopNo, inputVos[i].RepeaterID
  1259. , inputVos[i].DeviceID, inputVos[i].InoutType);
  1260. dacMap.Group_Device_Update(OGroupDevice_cmd, GroupID, mdi.myReceiverID, dev_id.Comm_id,
  1261. dev_id.Board_id, dev_id.Loop_no, dev_id.Repeater_id, dev_id.Device_id, dev_id.Inout_type);
  1262. }
  1263. OGroupDevice_cmd = QUERYMode.select;
  1264. //VIEW모드로 변경한다.
  1265. //Util.GroupControlChange(panelOGroupDevice, UIMode.cancel);
  1266. //mskOGroupDeviceID.ReadOnly = true;
  1267. //데이터 불러오기
  1268. OGroupDevice_getData();
  1269. OGroupDeviceSelectData(null);
  1270. btnOGroupDeviceAdd.Enabled = true;
  1271. btnOGroupDeviceCancel.Visible = false;
  1272. //}
  1273. }
  1274. //MskDeviceIDString dev_id = new MskDeviceIDString(inputVo.CommID, inputVo.BoardID
  1275. // , inputVo.LoopNo, inputVo.RepeaterID
  1276. // , inputVo.DeviceID, inputVo.InoutType);
  1277. //mskOGroupDeviceID.Text = dev_id.MskId;
  1278. }
  1279. }
  1280. catch (Exception ex)
  1281. {
  1282. Util.UErrorMessage(ex, 0, 0);
  1283. //MessageBox.Show(ex.Message, Application.ProductName);
  1284. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  1285. }
  1286. }
  1287. //------------------------------------------------
  1288. /*******************************************************
  1289. * [맵] LISTVIEW에 데이터 불러오기
  1290. ******************************************************/
  1291. private void Map_getData()
  1292. {
  1293. try
  1294. {
  1295. MapSelectData(null);
  1296. DacMap dacMap = new DacMap(mdi.myReceiverID);// cyim 2015.7.30 데이타베이스 접속 루틴 변경
  1297. DataTable dt = dacMap.Map_Select(0);
  1298. ListViewMap.Items.Clear();
  1299. if (dt.Rows.Count > 0)
  1300. {
  1301. foreach (DataRow dr in dt.Rows)
  1302. {
  1303. ListViewItem item = new ListViewItem(Convert.ToString(dr["MAP_NO"]));
  1304. item.SubItems.Add(dr["MAP_ID"].ToString());
  1305. item.SubItems.Add(dr["MAP_NAME"].ToString());
  1306. ListViewMap.Items.Add(item);
  1307. }
  1308. }
  1309. ListViewIMap.Items.Clear();
  1310. ListViewOMap.Items.Clear();
  1311. }
  1312. catch (Exception ex)
  1313. {
  1314. Util.UErrorMessage(ex, 0, 0);
  1315. //MessageBox.Show(ex.Message, Application.ProductName);
  1316. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  1317. }
  1318. }
  1319. //리스트VIEW에 맵선택시
  1320. private void ListViewMap_SelectedIndexChanged(object sender, EventArgs e)
  1321. {
  1322. try
  1323. {
  1324. ListView lv = (ListView)sender;
  1325. if (lv.SelectedItems.Count > 0)
  1326. {
  1327. ListViewItem itm = lv.SelectedItems[0];
  1328. Map_cmd = QUERYMode.update;
  1329. //VIEW모드로 변경한다.[맵]
  1330. Util.GroupUIChange(panelMap, UIMode.input);
  1331. MapSelectData(itm);
  1332. IMap_getData();
  1333. OMap_getData();
  1334. }
  1335. else
  1336. {
  1337. Map_cmd = QUERYMode.select;
  1338. //VIEW모드로 변경한다.
  1339. Util.GroupUIChange(panelMap, UIMode.cancel);
  1340. MapSelectData(null);
  1341. }
  1342. }
  1343. catch (Exception ex)
  1344. {
  1345. Util.UErrorMessage(ex, 0, 0);
  1346. //MessageBox.Show(ex.Message, Application.ProductName);
  1347. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  1348. }
  1349. }
  1350. //맵표시
  1351. //맵 데이터 표시
  1352. private void MapSelectData(ListViewItem itm)
  1353. {
  1354. try
  1355. {
  1356. Map_selectItem = itm;
  1357. if (itm == null)
  1358. {
  1359. txtMapNo.Text = "";
  1360. txtMapID.Text = "";
  1361. txtMapName.Text = "";
  1362. if (Map_cmd == QUERYMode.insert)
  1363. {
  1364. txtMapNo.ReadOnly = false;
  1365. txtMapNo.BackColor = Color.White;
  1366. txtMapID.ReadOnly = false;
  1367. txtMapName.ReadOnly = false;
  1368. btnMapOK.Enabled = true;
  1369. }
  1370. else
  1371. {
  1372. txtMapNo.ReadOnly = true;
  1373. txtMapNo.BackColor = SystemColors.Control;
  1374. btnMapAdd.Enabled = true;
  1375. btnMapDel.Enabled = false;
  1376. btnMapOK.Enabled = false;
  1377. }
  1378. btnIMapGroupAdd.Enabled = false;
  1379. btnIMapDeviceAdd.Enabled = false;
  1380. btnIMapDel.Enabled = false;
  1381. btnOMapGroupAdd.Enabled = false;
  1382. btnOMapDeviceAdd.Enabled = false;
  1383. btnOMapDel.Enabled = false;
  1384. }
  1385. else
  1386. {
  1387. txtMapNo.Text = itm.Text;
  1388. txtMapNo.BackColor = SystemColors.Control;
  1389. txtMapID.Text = itm.SubItems[1].Text;
  1390. txtMapName.Text = itm.SubItems[2].Text;
  1391. txtMapNo.ReadOnly = true;
  1392. btnMapAdd.Enabled = true;
  1393. btnMapDel.Enabled = true;
  1394. btnMapOK.Enabled = true;
  1395. btnIMapGroupAdd.Enabled = true;
  1396. btnIMapDeviceAdd.Enabled = true;
  1397. btnIMapDel.Enabled = false;
  1398. btnOMapGroupAdd.Enabled = true;
  1399. btnOMapDeviceAdd.Enabled = true;
  1400. btnOMapDel.Enabled = false;
  1401. }
  1402. }
  1403. catch (Exception ex)
  1404. {
  1405. Util.UErrorMessage(ex, 0, 0);
  1406. }
  1407. }
  1408. //맵추가
  1409. private void btnMapAdd_Click(object sender, EventArgs e)
  1410. {
  1411. try
  1412. {
  1413. //입력모드로 변경한다.
  1414. Map_cmd = QUERYMode.insert;
  1415. Util.GroupUIChange(panelMap, UIMode.input);
  1416. MapSelectData(null);
  1417. DacMap dacMap = new DacMap(mdi.myReceiverID);// cyim 2015.7.30 데이타베이스 접속 루틴 변경
  1418. txtMapNo.Text = string.Format("{0}", dacMap.Map_Max_Select());
  1419. txtMapID.Text = "MAP";
  1420. txtMapID.Focus();
  1421. btnMapAdd.Enabled = false;
  1422. btnMapDel.Enabled = false;
  1423. btnMapCancel.Visible = true;
  1424. btnMapOK.Enabled = true;
  1425. }
  1426. catch (Exception ex)
  1427. {
  1428. Util.UErrorMessage(ex, 0, 0);
  1429. }
  1430. }
  1431. //맵저장
  1432. private void btnMapOK_Click(object sender, EventArgs e)
  1433. {
  1434. try
  1435. {
  1436. if (Map_cmd == QUERYMode.insert || Map_cmd == QUERYMode.update)
  1437. {
  1438. Util.ChkTxtBox(txtMapNo, "맵No");
  1439. Util.ChkTxtBox(txtMapID, "맵ID");
  1440. Util.ChkTxtBox(txtMapName, "맵명");
  1441. int MapNo = Util.StrToInt(txtMapNo.Text, 0);
  1442. String MapID = txtMapID.Text.Trim();
  1443. String MapName = txtMapName.Text.Trim();
  1444. DacMap dacMap = new DacMap(mdi.myReceiverID);// cyim 2015.7.30 데이타베이스 접속 루틴 변경
  1445. dacMap.Map_Update(Map_cmd, MapNo, MapID, MapName);
  1446. }
  1447. Map_cmd = QUERYMode.select;
  1448. //VIEW모드로 변경한다.
  1449. Util.GroupUIChange(panelMap, UIMode.cancel);
  1450. //데이터 불러오기
  1451. Map_getData();
  1452. IMap_getData();
  1453. OMap_getData();
  1454. MapSelectData(null);
  1455. btnMapCancel.Visible = false;
  1456. }
  1457. catch (Exception ex)
  1458. {
  1459. Util.UErrorMessage(ex, 0, 0);
  1460. //MessageBox.Show(ex.Message, Application.ProductName);
  1461. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  1462. }
  1463. }
  1464. //맵삭제
  1465. private void btnMapDel_Click(object sender, EventArgs e)
  1466. {
  1467. try
  1468. {
  1469. Map_cmd = QUERYMode.delete;
  1470. int MapNo = Util.StrToInt(txtMapNo.Text, 0);
  1471. String MapID = txtMapID.Text.Trim();
  1472. String MapName = txtMapName.Text.Trim();
  1473. String msg = string.Format("{0}[{1}]을/를 삭제하시겠습니까?", MapName, MapID);
  1474. if (MessageBox.Show(msg, Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)
  1475. {
  1476. DacMap dacMap = new DacMap(mdi.myReceiverID);// cyim 2015.7.30 데이타베이스 접속 루틴 변경
  1477. dacMap.Map_Update(QUERYMode.delete, MapNo, MapID, MapName);
  1478. }
  1479. //VIEW모드로 변경한다.
  1480. Map_cmd = QUERYMode.select;
  1481. Util.GroupUIChange(panelMap, UIMode.cancel);
  1482. //맵 CLEAR
  1483. MapSelectData(null);
  1484. //데이터 불러오기
  1485. Map_getData();
  1486. IMap_getData();
  1487. OMap_getData();
  1488. }
  1489. catch (Exception ex)
  1490. {
  1491. Util.UErrorMessage(ex, 0, 0);
  1492. //MessageBox.Show(ex.Message, Application.ProductName);
  1493. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  1494. }
  1495. }
  1496. private void txMapID_TextChanged(object sender, EventArgs e)
  1497. {
  1498. try
  1499. {
  1500. Util.ToUpper(txtMapID);
  1501. }
  1502. catch (Exception ex)
  1503. {
  1504. Util.UErrorMessage(ex, 0, 0);
  1505. }
  1506. }
  1507. private void btnMapCancel_Click(object sender, EventArgs e)
  1508. {
  1509. try
  1510. {
  1511. //VIEW모드로 변경한다.
  1512. Map_cmd = QUERYMode.select;
  1513. Util.GroupUIChange(panelMap, UIMode.cancel);
  1514. MapSelectData(null);
  1515. btnMapCancel.Visible = false;
  1516. }
  1517. catch (Exception ex)
  1518. {
  1519. Util.UErrorMessage(ex, 0, 0);
  1520. }
  1521. }
  1522. /*******************************************************
  1523. * [입력맵 회로정보] LISTVIEW에 데이터 불러오기
  1524. ******************************************************/
  1525. private void IMap_getData()
  1526. {
  1527. try
  1528. {
  1529. int MapNo = Util.StrToInt(txtMapNo.Text, 0);
  1530. DacMap dacMap = new DacMap(mdi.myReceiverID);// cyim 2015.7.30 데이타베이스 접속 루틴 변경
  1531. DataTable dt = dacMap.Map_Process_Select(MapNo, code_GroupIO.Input, 0);
  1532. ListViewIMap.Items.Clear();
  1533. if (dt.Rows.Count > 0)
  1534. {
  1535. foreach (DataRow dr in dt.Rows)
  1536. {
  1537. //MI-##-#-###-# :M(구분 M-중계기,I-입력맵)I,O(회로구분)-##(보드ID)-##(회로ID)
  1538. String process_type = dr["PROCESS_TYPE"].ToString();
  1539. string process_id = "";
  1540. if (process_type.Equals("D"))
  1541. {
  1542. MskDeviceIDString dev_s = new MskDeviceIDString(int.Parse(dr["COMM_ID"].ToString()), int.Parse(dr["BOARD_ID"].ToString()), int.Parse(dr["LOOP_NO"].ToString())
  1543. , int.Parse(dr["REPEATER_ID"].ToString()), int.Parse(dr["DEVICE_ID"].ToString()), dr["INOUT_TYPE"].ToString());
  1544. process_id = dev_s.MskId;
  1545. }
  1546. else
  1547. {
  1548. process_id = dr["GROUP_ID"].ToString();
  1549. }
  1550. ListViewItem item = new ListViewItem(dr["SEQ_NO"].ToString());
  1551. item.SubItems.Add(dr["RECEIVER_ID"].ToString() + ":" + process_id); // cyim 2014.8.12 수신기 아이디까지 회로번호로 보이도록 수정
  1552. item.SubItems.Add(dr["PROCESS_NAME"].ToString());
  1553. ListViewIMap.Items.Add(item);
  1554. }
  1555. }
  1556. }
  1557. catch (Exception ex)
  1558. {
  1559. Util.UErrorMessage(ex, 0, 0);
  1560. //MessageBox.Show(ex.Message, Application.ProductName);
  1561. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  1562. }
  1563. }
  1564. private void ListViewIMap_SelectedIndexChanged(object sender, EventArgs e)
  1565. {
  1566. try
  1567. {
  1568. ListView lv = (ListView)sender;
  1569. if (lv.SelectedItems.Count > 0)
  1570. {
  1571. ListViewItem itm = lv.SelectedItems[0];
  1572. //VIEW모드로 변경한다.[입력맵]
  1573. btnIMapDel.Enabled = true;
  1574. }
  1575. else
  1576. {
  1577. //VIEW모드로 변경한다.
  1578. btnIMapDel.Enabled = false;
  1579. }
  1580. }
  1581. catch (Exception ex)
  1582. {
  1583. Util.UErrorMessage(ex, 0, 0);
  1584. //MessageBox.Show(ex.Message, Application.ProductName);
  1585. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  1586. }
  1587. }
  1588. private void btnIMapDel_Click(object sender, EventArgs e)
  1589. {
  1590. try
  1591. {
  1592. if (ListViewIMap.SelectedItems.Count > 0)
  1593. {
  1594. ListViewItem itm = ListViewIMap.SelectedItems[0];
  1595. int seq_no = Util.StrToInt(itm.Text, 0);
  1596. String process_id = itm.SubItems[1].Text;
  1597. String process_name = itm.SubItems[2].Text;
  1598. String msg = string.Format("{0}[{1}]을/를 삭제하시겠습니까?", process_name, process_id);
  1599. if (MessageBox.Show(msg, Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)
  1600. {
  1601. int map_no = Util.StrToInt(txtMapNo.Text, 0);
  1602. DacMap dacMap = new DacMap(mdi.myReceiverID);// cyim 2015.7.30 데이타베이스 접속 루틴 변경
  1603. dacMap.Map_Process_Update(QUERYMode.delete, map_no, code_GroupIO.Input, seq_no,
  1604. "", null, 0, 0, 0, 0, 0, 0, null);
  1605. btnIMapDel.Enabled = false;
  1606. }
  1607. }
  1608. //데이터 불러오기
  1609. IMap_getData();
  1610. }
  1611. catch (Exception ex)
  1612. {
  1613. Util.UErrorMessage(ex, 0, 0);
  1614. //MessageBox.Show(ex.Message, Application.ProductName);
  1615. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  1616. }
  1617. }
  1618. private void btnIMapGroupAdd_Click(object sender, EventArgs e)
  1619. {
  1620. try
  1621. {
  1622. frmModalGroupList frm = new frmModalGroupList(mdi.myReceiverID);// cyim 2015.7.30 데이타베이스 접속 루틴 변경
  1623. SearchCodeVo vo = new SearchCodeVo(code_GroupIO.Input);
  1624. frm.SearchCode = vo;
  1625. frm.ShowDialog();
  1626. vo = frm.SearchCode;
  1627. //선택한 코드가 있다면
  1628. if (vo.SearchOK)
  1629. {
  1630. int map_no = Util.StrToInt(txtMapNo.Text, 0);
  1631. DacMap dacMap = new DacMap(mdi.myReceiverID);// cyim 2015.7.30 데이타베이스 접속 루틴 변경
  1632. int seq_no = dacMap.Map_Process_Seq_Max_Select(map_no, code_GroupIO.Input);
  1633. dacMap.Map_Process_Update(QUERYMode.InsertAndUpdate, map_no, code_GroupIO.Input, seq_no,
  1634. "G", vo.Code, this.mdi.myReceiverID, -1, -1, -1, -1, -1, null);
  1635. IMap_getData();
  1636. }
  1637. }
  1638. catch (Exception ex)
  1639. {
  1640. Util.UErrorMessage(ex, 0, 0);
  1641. //MessageBox.Show(ex.Message, Application.ProductName);
  1642. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  1643. }
  1644. }
  1645. private void btnIMapDeviceAdd_Click(object sender, EventArgs e)
  1646. {
  1647. try
  1648. {
  1649. frmModalDeviceList frm = new frmModalDeviceList(mdi); // cyim 2016.12.07 : 수신기 모델별 내부 로직 변경
  1650. SearchCodeVo vo = new SearchCodeVo(null);
  1651. InputIDVo inputVo = new InputIDVo();
  1652. inputVo.ReceiverID = this.mdi.myReceiverID;
  1653. inputVo.InoutType = code_InOutType.Input;
  1654. frm.SearchCode = vo;
  1655. frm.InputVo = inputVo;
  1656. frm.ShowDialog();
  1657. vo = frm.SearchCode;
  1658. //선택한 코드가 있다면
  1659. if (vo.SearchOK)
  1660. {
  1661. int map_no = Util.StrToInt(txtMapNo.Text, 0);
  1662. InputIDVo[] inputVos = (InputIDVo[])vo.SelectObject;
  1663. if (inputVos.Length > 0)
  1664. {
  1665. DacMap dacMap = new DacMap(mdi.myReceiverID);// cyim 2015.7.30 데이타베이스 접속 루틴 변경
  1666. for (int i = 0; i < inputVos.Length; i++)
  1667. {
  1668. int seq_no = dacMap.Map_Process_Seq_Max_Select(map_no, code_GroupIO.Input);
  1669. dacMap.Map_Process_Update(QUERYMode.InsertAndUpdate, map_no, code_GroupIO.Input, seq_no,
  1670. "D", null, inputVos[i].ReceiverID, inputVos[i].CommID, inputVos[i].BoardID
  1671. , inputVos[i].LoopNo, inputVos[i].RepeaterID, inputVos[i].DeviceID, inputVos[i].InoutType);
  1672. }
  1673. IMap_getData();
  1674. }
  1675. //inputVo = (InputIDVo)vo.SelectObject;
  1676. //ListViewItem item = new ListViewItem(seq_no);
  1677. //MskDeviceIDString dev_id = new MskDeviceIDString(inputVo.CommID, inputVo.BoardID
  1678. // , inputVo.LoopNo, inputVo.RepeaterID
  1679. // , inputVo.DeviceID, inputVo.InoutType);
  1680. //item.SubItems.Add(dev_id.MskId);
  1681. //ListViewIMap.Items.Add(item);
  1682. }
  1683. }
  1684. catch (Exception ex)
  1685. {
  1686. Util.UErrorMessage(ex, 0, 0);
  1687. //MessageBox.Show(ex.Message, Application.ProductName);
  1688. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  1689. }
  1690. }
  1691. /*******************************************************
  1692. * [출력맵 회로정보] LISTVIEW에 데이터 불러오기
  1693. ******************************************************/
  1694. private void OMap_getData()
  1695. {
  1696. try
  1697. {
  1698. int MapNo = Util.StrToInt(txtMapNo.Text, 0);
  1699. DacMap dacMap = new DacMap(mdi.myReceiverID);// cyim 2015.7.30 데이타베이스 접속 루틴 변경
  1700. DataTable dt = dacMap.Map_Process_Select(MapNo, code_GroupIO.Output, 0);
  1701. ListViewOMap.Items.Clear();
  1702. if (dt.Rows.Count > 0)
  1703. {
  1704. foreach (DataRow dr in dt.Rows)
  1705. {
  1706. //MI-##-#-###-# :M(구분 M-중계기,I-입력맵)I,O(회로구분)-##(보드ID)-##(회로ID)
  1707. String process_type = dr["PROCESS_TYPE"].ToString();
  1708. string process_id = "";
  1709. if (process_type.Equals("D"))
  1710. {
  1711. MskDeviceIDString dev_s = new MskDeviceIDString(int.Parse(dr["COMM_ID"].ToString()), int.Parse(dr["BOARD_ID"].ToString()), int.Parse(dr["LOOP_NO"].ToString())
  1712. , int.Parse(dr["REPEATER_ID"].ToString()), int.Parse(dr["DEVICE_ID"].ToString()), dr["INOUT_TYPE"].ToString());
  1713. process_id = dev_s.MskId;
  1714. }
  1715. else
  1716. {
  1717. process_id = dr["GROUP_ID"].ToString();
  1718. }
  1719. ListViewItem item = new ListViewItem(dr["SEQ_NO"].ToString());
  1720. item.SubItems.Add(dr["RECEIVER_ID"].ToString() + ":" + process_id); // cyim 2014.8.12 수신기 아이디까지 회로번호로 보이도록 수정
  1721. item.SubItems.Add(dr["PROCESS_NAME"].ToString());
  1722. ListViewOMap.Items.Add(item);
  1723. }
  1724. }
  1725. }
  1726. catch (Exception ex)
  1727. {
  1728. Util.UErrorMessage(ex, 0, 0);
  1729. //MessageBox.Show(ex.Message, Application.ProductName);
  1730. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  1731. }
  1732. }
  1733. private void ListViewOMap_SelectedIndexChanged(object sender, EventArgs e)
  1734. {
  1735. try
  1736. {
  1737. ListView lv = (ListView)sender;
  1738. if (lv.SelectedItems.Count > 0)
  1739. {
  1740. ListViewItem itm = lv.SelectedItems[0];
  1741. //VIEW모드로 변경한다.[출력맵]
  1742. btnOMapDel.Enabled = true;
  1743. }
  1744. else
  1745. {
  1746. //VIEW모드로 변경한다.
  1747. btnOMapDel.Enabled = false;
  1748. }
  1749. }
  1750. catch (Exception ex)
  1751. {
  1752. Util.UErrorMessage(ex, 0, 0);
  1753. //MessageBox.Show(ex.Message, Application.ProductName);
  1754. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  1755. }
  1756. }
  1757. private void btnOMapDel_Click(object sender, EventArgs e)
  1758. {
  1759. try
  1760. {
  1761. if (ListViewOMap.SelectedItems.Count > 0)
  1762. {
  1763. ListViewItem itm = ListViewOMap.SelectedItems[0];
  1764. int seq_no = Util.StrToInt(itm.Text, 0);
  1765. String process_id = itm.SubItems[1].Text;
  1766. String process_name = itm.SubItems[2].Text;
  1767. String msg = string.Format("{0}[{1}]을/를 삭제하시겠습니까?", process_name, process_id);
  1768. if (MessageBox.Show(msg, Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)
  1769. {
  1770. int map_no = Util.StrToInt(txtMapNo.Text, 0);
  1771. DacMap dacMap = new DacMap(mdi.myReceiverID);// cyim 2015.7.30 데이타베이스 접속 루틴 변경
  1772. dacMap.Map_Process_Update(QUERYMode.delete, map_no, code_GroupIO.Output, seq_no,
  1773. "", null, 0, 0, 0, 0, 0, 0, null);
  1774. btnOMapDel.Enabled = false;
  1775. }
  1776. }
  1777. //데이터 불러오기
  1778. OMap_getData();
  1779. }
  1780. catch (Exception ex)
  1781. {
  1782. Util.UErrorMessage(ex, 0, 0);
  1783. //MessageBox.Show(ex.Message, Application.ProductName);
  1784. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  1785. }
  1786. }
  1787. private void btnOMapGroupAdd_Click(object sender, EventArgs e)
  1788. {
  1789. try
  1790. {
  1791. frmModalGroupList frm = new frmModalGroupList(mdi.myReceiverID);// cyim 2015.7.30 데이타베이스 접속 루틴 변경
  1792. SearchCodeVo vo = new SearchCodeVo(code_GroupIO.Output);
  1793. frm.SearchCode = vo;
  1794. frm.ShowDialog();
  1795. vo = frm.SearchCode;
  1796. //선택한 코드가 있다면
  1797. if (vo.SearchOK)
  1798. {
  1799. int map_no = Util.StrToInt(txtMapNo.Text, 0);
  1800. DacMap dacMap = new DacMap(mdi.myReceiverID);// cyim 2015.7.30 데이타베이스 접속 루틴 변경
  1801. int seq_no = dacMap.Map_Process_Seq_Max_Select(map_no, code_GroupIO.Output);
  1802. dacMap.Map_Process_Update(QUERYMode.InsertAndUpdate, map_no, code_GroupIO.Output, seq_no,
  1803. "G", vo.Code, this.mdi.myReceiverID, -1, -1, -1, -1, -1, null);
  1804. OMap_getData();
  1805. }
  1806. }
  1807. catch (Exception ex)
  1808. {
  1809. Util.UErrorMessage(ex, 0, 0);
  1810. //MessageBox.Show(ex.Message, Application.ProductName);
  1811. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  1812. }
  1813. }
  1814. private void btnOMapDeviceAdd_Click(object sender, EventArgs e)
  1815. {
  1816. try
  1817. {
  1818. frmModalDeviceList frm = new frmModalDeviceList(mdi); // cyim 2016.12.07 : 수신기 모델별 내부 로직 변경
  1819. SearchCodeVo vo = new SearchCodeVo(null);
  1820. InputIDVo inputVo = new InputIDVo();
  1821. inputVo.ReceiverID = this.mdi.myReceiverID;
  1822. inputVo.InoutType = code_InOutType.Output;
  1823. frm.SearchCode = vo;
  1824. frm.InputVo = inputVo;
  1825. frm.ShowDialog();
  1826. vo = frm.SearchCode;
  1827. //선택한 코드가 있다면
  1828. if (vo.SearchOK)
  1829. {
  1830. int map_no = Util.StrToInt(txtMapNo.Text, 0);
  1831. InputIDVo[] inputVos = (InputIDVo[])vo.SelectObject;
  1832. if (inputVos.Length > 0)
  1833. {
  1834. DacMap dacMap = new DacMap(mdi.myReceiverID);// cyim 2015.7.30 데이타베이스 접속 루틴 변경
  1835. for (int i = 0; i < inputVos.Length; i++)
  1836. {
  1837. int seq_no = dacMap.Map_Process_Seq_Max_Select(map_no, code_GroupIO.Output);
  1838. dacMap.Map_Process_Update(QUERYMode.InsertAndUpdate, map_no, code_GroupIO.Output, seq_no,
  1839. "D", null, inputVos[i].ReceiverID, inputVos[i].CommID, inputVos[i].BoardID
  1840. , inputVos[i].LoopNo, inputVos[i].RepeaterID, inputVos[i].DeviceID, inputVos[i].InoutType);
  1841. }
  1842. OMap_getData();
  1843. }
  1844. //inputVo = (InputIDVo)vo.SelectObject;
  1845. //DacMap dacMap = new DacMap(mdi.myReceiverID);
  1846. //int seq_no = dacMap.Map_Process_Seq_Max_Select(map_no, code_GroupIO.Output);
  1847. //dacMap.Map_Process_Update(QUERYMode.InsertAndUpdate, map_no, code_GroupIO.Output, seq_no,
  1848. // "D", null, inputVo.ReceiverID, inputVo.CommID, inputVo.BoardID, inputVo.LoopNo, inputVo.RepeaterID, inputVo.DeviceID, inputVo.InoutType);
  1849. //OMap_getData();
  1850. //ListViewItem item = new ListViewItem(seq_no);
  1851. //MskDeviceIDString dev_id = new MskDeviceIDString(inputVo.CommID, inputVo.BoardID
  1852. // , inputVo.LoopNo, inputVo.RepeaterID
  1853. // , inputVo.DeviceID, inputVo.InoutType);
  1854. //item.SubItems.Add(dev_id.MskId);
  1855. //ListViewOMap.Items.Add(item);
  1856. }
  1857. }
  1858. catch (Exception ex)
  1859. {
  1860. Util.UErrorMessage(ex, 0, 0);
  1861. //MessageBox.Show(ex.Message, Application.ProductName);
  1862. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  1863. }
  1864. }
  1865. private void btnReset_Click(object sender, EventArgs e)
  1866. {
  1867. try
  1868. {
  1869. ////설정정보가 변경되었다면 다시 읽어라~~~~~~
  1870. //if (ThisReceiverConfig_Change_Flag)
  1871. //{
  1872. this.Cursor = Cursors.WaitCursor;
  1873. LFC.Log("타입: 수신기 조작 로그, 메세지: 맵설정-연동맵 적용");
  1874. mdi.ui.ReceiverDBRead(); //설정정보 변경
  1875. mdi.FireReset_Process(); //데몬 RESET 명령
  1876. //}
  1877. }
  1878. catch (Exception ex)
  1879. {
  1880. Util.UErrorMessage(ex, 0, 0);
  1881. throw ex;
  1882. }
  1883. finally
  1884. {
  1885. this.Cursor = Cursors.Default;
  1886. }
  1887. }
  1888. private void btnWinClose_Click(object sender, EventArgs e)
  1889. {
  1890. try
  1891. {
  1892. this.Close();
  1893. }
  1894. catch (Exception ex)
  1895. {
  1896. Util.UErrorMessage(ex, 0, 0);
  1897. }
  1898. }
  1899. //
  1900. // cyim 2013.7.12 디자인개선작업 : 맵설정
  1901. //
  1902. private void button_Menu_Group_Click(object sender, EventArgs e)
  1903. {
  1904. button_Menu_Color_Init();
  1905. this.tabControl1.SelectTab(0);
  1906. this.button_Menu_Group.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_주황_100_30;
  1907. this.panel_Menu.Focus();
  1908. }
  1909. private void button_Menu_OperSet_Click(object sender, EventArgs e)
  1910. {
  1911. button_Menu_Color_Init();
  1912. this.tabControl1.SelectTab(1);
  1913. this.button_Menu_OperSet.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_주황_100_30;
  1914. this.panel_Menu.Focus();
  1915. }
  1916. private void button_Menu_Color_Init()
  1917. {
  1918. this.button_Menu_Group.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_회색_100_30;
  1919. this.button_Menu_OperSet.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_회색_100_30;
  1920. }
  1921. }
  1922. }