VMS0200MF.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. /****************************************************************************
  2. * @source :
  3. * @description :
  4. ****************************************************************************
  5. * DATE AUTHOR DESCRIPTION
  6. * --------------------------------------------------------------------------
  7. * 2016/07/24 정승호 최초작성
  8. *
  9. ****************************************************************************/
  10. //---------------------------------------------------------------------------
  11. #include <vcl.h>
  12. #include "AppGlobalF.h"
  13. #include "ITSSkinF.h"
  14. #include "ITSUtilF.h"
  15. #include "FrmVmsOprMainF.h"
  16. #include "ITSLangTransF.h"
  17. #pragma hdrstop
  18. #include "VMS0200MF.h"
  19. #include "VMSVIEWMF.h"
  20. //---------------------------------------------------------------------------
  21. #pragma package(smart_init)
  22. #pragma link "cxContainer"
  23. #pragma link "cxControls"
  24. #pragma link "cxEdit"
  25. #pragma link "cxGraphics"
  26. #pragma link "cxGroupBox"
  27. #pragma link "cxLabel"
  28. #pragma link "cxLookAndFeelPainters"
  29. #pragma link "cxLookAndFeels"
  30. #pragma link "cxPC"
  31. #pragma link "cxPCdxBarPopupMenu"
  32. #pragma link "cxSplitter"
  33. #pragma link "dxSkinBlack"
  34. #pragma link "dxSkinBlue"
  35. #pragma link "dxSkinCaramel"
  36. #pragma link "dxSkinCoffee"
  37. #pragma link "dxSkinDarkRoom"
  38. #pragma link "dxSkinDarkSide"
  39. #pragma link "dxSkinFoggy"
  40. #pragma link "dxSkinGlassOceans"
  41. #pragma link "dxSkiniMaginary"
  42. #pragma link "dxSkinLilian"
  43. #pragma link "dxSkinLiquidSky"
  44. #pragma link "dxSkinLondonLiquidSky"
  45. #pragma link "dxSkinMcSkin"
  46. #pragma link "dxSkinMoneyTwins"
  47. #pragma link "dxSkinOffice2007Black"
  48. #pragma link "dxSkinOffice2007Blue"
  49. #pragma link "dxSkinOffice2007Green"
  50. #pragma link "dxSkinOffice2007Pink"
  51. #pragma link "dxSkinOffice2007Silver"
  52. #pragma link "dxSkinOffice2010Black"
  53. #pragma link "dxSkinOffice2010Blue"
  54. #pragma link "dxSkinOffice2010Silver"
  55. #pragma link "dxSkinsCore"
  56. #pragma link "dxSkinscxPCPainter"
  57. #pragma link "dxSkinSeven"
  58. #pragma link "dxSkinSharp"
  59. #pragma link "dxSkinSilver"
  60. #pragma link "dxSkinStardust"
  61. #pragma link "cxClasses"
  62. #pragma link "cxCustomData"
  63. #pragma link "cxData"
  64. #pragma link "cxDataStorage"
  65. #pragma link "cxFilter"
  66. #pragma link "cxGrid"
  67. #pragma link "cxGridCustomTableView"
  68. #pragma link "cxGridCustomView"
  69. #pragma link "cxGridLevel"
  70. #pragma link "cxGridTableView"
  71. #pragma link "cxStyles"
  72. #pragma link "cxTextEdit"
  73. #pragma link "cxGridCardView"
  74. #pragma link "cxGridCustomLayoutView"
  75. #pragma link "cxCheckBox"
  76. #pragma link "cxDropDownEdit"
  77. #pragma link "cxImage"
  78. #pragma link "cxButtons"
  79. #pragma resource "*.dfm"
  80. TVMS0200M *VMS0200M = NULL;
  81. //---------------------------------------------------------------------------
  82. __fastcall TVMS0200M::TVMS0200M(TComponent* Owner)
  83. : TForm(Owner)
  84. {
  85. LangTrans->Translate(this, ITSDb_GetConnection());
  86. ITSSkin_Load(this);
  87. LoadLocalSkin();
  88. FMonitoringType = enMonitoringScenario;
  89. TsList01->TabVisible = false;
  90. if (FormStyle != fsMDIChild) CMM_LoadForm(g_sFormsDir, this);
  91. FListForm = new TList;
  92. FSelVmsObj= NULL;
  93. FSelForm = NULL;
  94. //PgVmsState->Properties->HideTabs = true;
  95. //PgVmsIfscTraf->Properties->HideTabs = true;
  96. FReady = false;
  97. }
  98. //---------------------------------------------------------------------------
  99. void __fastcall TVMS0200M::CommClose()
  100. {
  101. try
  102. {
  103. ClearFormList();
  104. SAFE_DELETE(FListForm);
  105. if (FormStyle != fsMDIChild) CMM_SaveForm(g_sFormsDir, this);
  106. }
  107. catch(...)
  108. {
  109. }
  110. }
  111. //---------------------------------------------------------------------------
  112. void __fastcall TVMS0200M::ClearFormList()
  113. {
  114. try
  115. {
  116. LockWindowUpdate(Handle);
  117. try
  118. {
  119. for(int ii = 0; ii < FListForm->Count; ii++)
  120. {
  121. TVMS0201M *pForm = (TVMS0201M*)FListForm->Items[ii];
  122. pForm->Hide();
  123. SAFE_DELETE(pForm);
  124. }
  125. FListForm->Clear();
  126. int nForms = PgFormTab->PageCount;
  127. for (int ii = 1; ii < nForms; ii++)
  128. {
  129. TcxTabSheet *pTmpSheet = PgFormTab->Pages[1];
  130. if (pTmpSheet) delete pTmpSheet;
  131. }
  132. PgFormTab->ActivePageIndex = 0;
  133. }
  134. catch(Exception &e)
  135. {
  136. TcxTabSheet *pTmpSheet = PgFormTab->Pages[1];
  137. if (pTmpSheet) delete pTmpSheet;
  138. }
  139. }
  140. __finally
  141. {
  142. LockWindowUpdate(0);
  143. }
  144. }
  145. //---------------------------------------------------------------------------
  146. void __fastcall TVMS0200M::FormCreate(TObject *Sender)
  147. {
  148. InitMonitoringForm();
  149. CreateVmsMsgForm(VmsManager->FMaxWidth);
  150. }
  151. //---------------------------------------------------------------------------
  152. void __fastcall TVMS0200M::CreateVmsMsgForm(int AWidth)
  153. {
  154. FReady = false;
  155. ClearFormList();
  156. String sQry;
  157. TADOQuery *pADO = NULL;
  158. sQry = "SELECT MONITORING_NM, MONITORING_SEQ, VMS_CTLR_NMBR \r\n"
  159. " FROM TB_VMS_MONITORING \r\n"
  160. " WHERE MONITORING_TYPE = :p01 \r\n"
  161. " ORDER BY MONITORING_NM DESC, MONITORING_SEQ \r\n";
  162. TcxTabSheet *pSheet = NULL;
  163. TVMS0201M *pScrForm = NULL;
  164. String sOldName = "";
  165. int nIndex = 0;
  166. try
  167. {
  168. LockWindowUpdate(Handle);
  169. try
  170. {
  171. pADO = new TADOQuery(NULL);
  172. pADO->Close();
  173. pADO->Connection = ITSDb_GetConnection();
  174. ITSDb_SQLText(pADO, sQry);
  175. ITSDb_SQLBind(pADO, "p01", String(FMonitoringType));
  176. ITSDb_SQLOpen(pADO);
  177. for( ; !pADO->Eof; pADO->Next())
  178. {
  179. String sScrName = pADO->FieldByName("MONITORING_NM")->AsString;
  180. String sScrSeq = pADO->FieldByName("MONITORING_SEQ")->AsString;
  181. String sVmsNmbr = pADO->FieldByName("VMS_CTLR_NMBR")->AsString;
  182. if (sOldName != sScrName)
  183. {
  184. //신규 화면목록 추가
  185. pSheet = CMM_AddTabSheet(PgFormTab, " " + sScrName + " ");
  186. if (!pSheet) continue;
  187. TVMS0201M *pNewForm = new TVMS0201M(this, Handle, sScrName, nIndex++);
  188. pNewForm->Parent = pSheet;
  189. pNewForm->Show();
  190. pScrForm = pNewForm;
  191. sOldName = sScrName;
  192. FListForm->Add(pNewForm);
  193. }
  194. pScrForm->AddVmsForm(sVmsNmbr);
  195. }
  196. }
  197. catch(EDatabaseError &E)
  198. {
  199. DBERRORMSG("VMS Monitoring screen query", String(E.ClassName()), E.Message, sQry);
  200. throw Exception(String(E.ClassName()) + E.Message);
  201. }
  202. catch(Exception &e)
  203. {
  204. DBERRORMSG("VMS Monitoring screen query", String(e.ClassName()), e.Message, sQry);
  205. throw Exception(String(e.ClassName()) + e.Message);
  206. }
  207. }
  208. __finally
  209. {
  210. if (pADO)
  211. {
  212. pADO->Close();
  213. delete pADO;
  214. }
  215. if (PgFormTab->PageCount == 1)
  216. PgFormTab->ActivePageIndex = 0;
  217. else
  218. PgFormTab->ActivePageIndex = 1;
  219. LockWindowUpdate(0);
  220. }
  221. RefreshScenario();
  222. FReady = true;
  223. }
  224. //---------------------------------------------------------------------------
  225. void __fastcall TVMS0200M::RefreshScenario()
  226. {
  227. try
  228. {
  229. LockWindowUpdate(Handle);
  230. for(int ii = 0; ii < FListForm->Count; ii++)
  231. {
  232. TVMS0201M *pForm = (TVMS0201M*)FListForm->Items[ii];
  233. pForm->RefreshScrnario();
  234. }
  235. }
  236. __finally
  237. {
  238. LockWindowUpdate(0);
  239. }
  240. }
  241. //---------------------------------------------------------------------------
  242. void __fastcall TVMS0200M::FormShow(TObject *Sender)
  243. {
  244. Refresh();
  245. if (PgFormTab->PageCount == 1)
  246. PgFormTab->ActivePageIndex = 0;
  247. else
  248. PgFormTab->ActivePageIndex = 1;
  249. Application->ProcessMessages();
  250. TmrShow->Enabled = true;
  251. }
  252. //---------------------------------------------------------------------------
  253. void __fastcall TVMS0200M::FormActivate(TObject *Sender)
  254. {
  255. ActivateForm(true);
  256. }
  257. //---------------------------------------------------------------------------
  258. void __fastcall TVMS0200M::FormDeactivate(TObject *Sender)
  259. {
  260. ActivateForm(false);
  261. }
  262. //---------------------------------------------------------------------------
  263. void __fastcall TVMS0200M::LoadLocalSkin()
  264. {
  265. }
  266. //---------------------------------------------------------------------------
  267. void __fastcall TVMS0200M::TmrShowTimer(TObject *Sender)
  268. {
  269. TmrShow->Enabled = false;
  270. }
  271. //---------------------------------------------------------------------------
  272. void __fastcall TVMS0200M::FormClose(TObject *Sender, TCloseAction &Action)
  273. {
  274. try {
  275. CommClose();
  276. VMS0200M = NULL;
  277. Action = caFree;
  278. } catch(...) {}
  279. }
  280. //---------------------------------------------------------------------------
  281. void __fastcall TVMS0200M::OnMainFormMessage(TMessage &Msg)
  282. {
  283. }
  284. //---------------------------------------------------------------------------
  285. void __fastcall TVMS0200M::OnVmsStateRefreshMessage(TMessage &Msg)
  286. {
  287. for(int ii = 0; ii < FListForm->Count; ii++)
  288. {
  289. TVMS0201M *pForm = (TVMS0201M*)FListForm->Items[ii];
  290. //pForm->RefreshScrnario();
  291. }
  292. }
  293. //---------------------------------------------------------------------------
  294. void __fastcall TVMS0200M::OnVmsFormRefreshMessage(TMessage &Msg)
  295. {
  296. for(int ii = 0; ii < FListForm->Count; ii++)
  297. {
  298. TVMS0201M *pForm = (TVMS0201M*)FListForm->Items[ii];
  299. pForm->RefreshScrnario();
  300. }
  301. }
  302. //---------------------------------------------------------------------------
  303. void __fastcall TVMS0200M::OnVmsSelectMessage(TMessage &Msg)
  304. {
  305. try {
  306. FSelVmsObj = (TVmsCtlr*)Msg.WParam;
  307. if (!FSelVmsObj) return;
  308. TVMSFORM0 *pSelForm = (TVMSFORM0*)Msg.LParam;
  309. if (pSelForm == FSelForm) return;
  310. if (FSelForm) FSelForm->SelectForm(false);
  311. FSelForm = pSelForm;
  312. if (FSelForm) FSelForm->SelectForm(true);
  313. } catch(...) {};
  314. }
  315. //---------------------------------------------------------------------------
  316. void __fastcall TVMS0200M::BtnMonitoringMngrClick(TObject *Sender)
  317. {
  318. TVMSVIEWM *pForm = new TVMSVIEWM(this);
  319. pForm->FMonitoringType = FMonitoringType;
  320. pForm->ShowModal();
  321. bool bUpdate = pForm->FUpdate;
  322. SAFE_DELETE(pForm);
  323. if (bUpdate)
  324. {
  325. if (FSelForm) FSelForm->SelectForm(false);
  326. FSelVmsObj = NULL;
  327. FSelForm = NULL;
  328. CreateVmsMsgForm(VmsManager->FMaxWidth);
  329. }
  330. }
  331. //---------------------------------------------------------------------------
  332. void __fastcall TVMS0200M::InitMonitoringForm()
  333. {
  334. String sQry;
  335. TADOQuery *pADO = NULL;
  336. sQry = "SELECT COUNT(1) AS CNT \r\n"
  337. " FROM TB_VMS_MONITORING \r\n"
  338. " WHERE MONITORING_TYPE = :p01 \r\n";
  339. try
  340. {
  341. int nString(0), nFigure(0), nFormSeq(0);
  342. VmsManager->FLists.Lock();
  343. try
  344. {
  345. pADO = new TADOQuery(NULL);
  346. pADO->Close();
  347. pADO->Connection = ITSDb_GetConnection();
  348. ITSDb_SQLText(pADO, sQry);
  349. ITSDb_SQLBind(pADO, "p01", String(FMonitoringType));
  350. ITSDb_SQLOpen(pADO);
  351. int nFormCnt = pADO->FieldByName("CNT")->AsInteger;
  352. if (nFormCnt > 0) return;
  353. sQry = "INSERT INTO TB_VMS_MONITORING ( \r\n"
  354. " MONITORING_TYPE, \r\n"
  355. " MONITORING_NM, \r\n"
  356. " MONITORING_SEQ, \r\n"
  357. " VMS_CTLR_NMBR \r\n"
  358. " ) \r\n"
  359. " VALUES ( \r\n"
  360. " :p01, \r\n"
  361. " :p02, \r\n"
  362. " :p03, \r\n"
  363. " :p04 \r\n"
  364. " ) \r\n";
  365. ITSDb_SQLText(pADO, sQry);
  366. FOR_STL(TVmsCtlr*, pObj, VmsManager->FLists)
  367. {
  368. if (pObj->DEL_YN == "Y") continue;
  369. String sFormName = FrmLang->lblVUTN->Caption;//"VMS 문자식";
  370. if (pObj->VMS_USAG_TYPE_CD == "VUTN") //문자식
  371. {
  372. nFormSeq = ++nString;
  373. }
  374. else
  375. if (pObj->VMS_USAG_TYPE_CD == "VUTP") //도형식
  376. {
  377. sFormName = FrmLang->lblVUTF->Caption;//"VMS 도형식";
  378. nFormSeq = ++nFigure;
  379. }
  380. else continue;
  381. ITSDb_SQLBind(pADO, "p01", String(FMonitoringType));
  382. ITSDb_SQLBind(pADO, "p02", sFormName);
  383. ITSDb_SQLBind(pADO, "p03", String(nFormSeq));
  384. ITSDb_SQLBind(pADO, "p04", String(pObj->VMS_CTLR_NMBR));
  385. ITSDb_SQLExec(pADO);
  386. }
  387. }
  388. catch(EDatabaseError &E)
  389. {
  390. DBERRORMSG("VMS Monitoring screen query", String(E.ClassName()), E.Message, sQry);
  391. throw Exception(String(E.ClassName()) + E.Message);
  392. }
  393. catch(Exception &e)
  394. {
  395. DBERRORMSG("VMS Monitoring screen query", String(e.ClassName()), e.Message, sQry);
  396. throw Exception(String(e.ClassName()) + e.Message);
  397. }
  398. }
  399. __finally
  400. {
  401. if (pADO)
  402. {
  403. pADO->Close();
  404. delete pADO;
  405. }
  406. VmsManager->FLists.UnLock();
  407. }
  408. }
  409. //---------------------------------------------------------------------------
  410. void __fastcall TVMS0200M::ActivateForm(bool AActivate)
  411. {
  412. try
  413. {
  414. int nTabIndex = PgFormTab->ActivePageIndex;
  415. nTabIndex--; //ActivePageIndex 으로 구간값은 숨어있는 탭을 포함한 인덱스
  416. for(int ii = 0; ii < FListForm->Count; ii++)
  417. {
  418. TVMS0201M *pForm = (TVMS0201M*)FListForm->Items[ii];
  419. if (AActivate)
  420. {
  421. if (ii == nTabIndex) pForm->Play = true;
  422. else pForm->Play = false;
  423. }
  424. else
  425. {
  426. //비활성이면 모든 화면 비활성으로
  427. pForm->Play = false;
  428. }
  429. }
  430. }
  431. catch(Exception &e)
  432. {
  433. }
  434. }
  435. //---------------------------------------------------------------------------
  436. void __fastcall TVMS0200M::PgFormTabPageChanging(TObject *Sender, TcxTabSheet *NewPage, bool &AllowChange)
  437. {
  438. if (!FReady) return;
  439. try
  440. {
  441. int nTabIndex = NewPage->TabIndex; //숨어있는 탭을 제외한 인덱스
  442. for(int ii = 0; ii < FListForm->Count; ii++)
  443. {
  444. TVMS0201M *pForm = (TVMS0201M*)FListForm->Items[ii];
  445. if (nTabIndex == ii) pForm->Play = true;
  446. else pForm->Play = false;
  447. }
  448. }
  449. catch(Exception &e)
  450. {
  451. }
  452. }
  453. //---------------------------------------------------------------------------
  454. void __fastcall TVMS0200M::BtnSearchClick(TObject *Sender)
  455. {
  456. try
  457. {
  458. LockWindowUpdate(Handle);
  459. for(int ii = 0; ii < FListForm->Count; ii++)
  460. {
  461. TVMS0201M *pForm = (TVMS0201M*)FListForm->Items[ii];
  462. pForm->RefreshScrnario();
  463. }
  464. }
  465. __finally
  466. {
  467. LockWindowUpdate(0);
  468. }
  469. }
  470. //---------------------------------------------------------------------------
  471. void __fastcall TVMS0200M::ChkAutoWidthPropertiesChange(TObject *Sender)
  472. {
  473. try
  474. {
  475. LockWindowUpdate(Handle);
  476. for(int ii = 0; ii < FListForm->Count; ii++)
  477. {
  478. TVMS0201M *pForm = (TVMS0201M*)FListForm->Items[ii];
  479. pForm->TvVmsMsg->BeginUpdate();
  480. pForm->TvVmsMsg->OptionsView->ColumnAutoWidth = ChkAutoWidth->Checked;
  481. pForm->TvVmsMsg->EndUpdate();
  482. }
  483. }
  484. __finally
  485. {
  486. LockWindowUpdate(0);
  487. //BtnBestFit->Visible = !ChkAutoWidth->Checked;
  488. }
  489. }
  490. //---------------------------------------------------------------------------
  491. void __fastcall TVMS0200M::BtnBestFitClick(TObject *Sender)
  492. {
  493. try
  494. {
  495. LockWindowUpdate(Handle);
  496. for(int ii = 0; ii < FListForm->Count; ii++)
  497. {
  498. TVMS0201M *pForm = (TVMS0201M*)FListForm->Items[ii];
  499. pForm->TvVmsMsg->BeginUpdate();
  500. pForm->TvVmsMsg->ApplyBestFit(NULL, false, false);
  501. pForm->TvVmsMsg->EndUpdate();
  502. }
  503. }
  504. __finally
  505. {
  506. LockWindowUpdate(0);
  507. }
  508. }
  509. //---------------------------------------------------------------------------