VMS0200MF.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "AppGlobalF.h"
  4. #include "ITSSkinF.h"
  5. #include "ITSUtilF.h"
  6. #include "FrmVmsOprMainF.h"
  7. #include "ITSLangTransF.h"
  8. #pragma hdrstop
  9. #include "VMS0200MF.h"
  10. #include "VMSVIEWMF.h"
  11. //---------------------------------------------------------------------------
  12. #pragma package(smart_init)
  13. #pragma link "cxContainer"
  14. #pragma link "cxControls"
  15. #pragma link "cxEdit"
  16. #pragma link "cxGraphics"
  17. #pragma link "cxGroupBox"
  18. #pragma link "cxLabel"
  19. #pragma link "cxLookAndFeelPainters"
  20. #pragma link "cxLookAndFeels"
  21. #pragma link "cxPC"
  22. #pragma link "cxPCdxBarPopupMenu"
  23. #pragma link "cxSplitter"
  24. #pragma link "dxSkinBlack"
  25. #pragma link "dxSkinBlue"
  26. #pragma link "dxSkinCaramel"
  27. #pragma link "dxSkinCoffee"
  28. #pragma link "dxSkinDarkRoom"
  29. #pragma link "dxSkinDarkSide"
  30. #pragma link "dxSkinFoggy"
  31. #pragma link "dxSkinGlassOceans"
  32. #pragma link "dxSkiniMaginary"
  33. #pragma link "dxSkinLilian"
  34. #pragma link "dxSkinLiquidSky"
  35. #pragma link "dxSkinLondonLiquidSky"
  36. #pragma link "dxSkinMcSkin"
  37. #pragma link "dxSkinMoneyTwins"
  38. #pragma link "dxSkinOffice2007Black"
  39. #pragma link "dxSkinOffice2007Blue"
  40. #pragma link "dxSkinOffice2007Green"
  41. #pragma link "dxSkinOffice2007Pink"
  42. #pragma link "dxSkinOffice2007Silver"
  43. #pragma link "dxSkinOffice2010Black"
  44. #pragma link "dxSkinOffice2010Blue"
  45. #pragma link "dxSkinOffice2010Silver"
  46. #pragma link "dxSkinsCore"
  47. #pragma link "dxSkinscxPCPainter"
  48. #pragma link "dxSkinSeven"
  49. #pragma link "dxSkinSharp"
  50. #pragma link "dxSkinSilver"
  51. #pragma link "dxSkinStardust"
  52. #pragma link "cxClasses"
  53. #pragma link "cxCustomData"
  54. #pragma link "cxData"
  55. #pragma link "cxDataStorage"
  56. #pragma link "cxFilter"
  57. #pragma link "cxGrid"
  58. #pragma link "cxGridCustomTableView"
  59. #pragma link "cxGridCustomView"
  60. #pragma link "cxGridLevel"
  61. #pragma link "cxGridTableView"
  62. #pragma link "cxStyles"
  63. #pragma link "cxTextEdit"
  64. #pragma link "cxGridCardView"
  65. #pragma link "cxGridCustomLayoutView"
  66. #pragma link "cxCheckBox"
  67. #pragma link "cxDropDownEdit"
  68. #pragma link "cxImage"
  69. #pragma link "cxButtons"
  70. #pragma resource "*.dfm"
  71. TVMS0200M *VMS0200M = NULL;
  72. //---------------------------------------------------------------------------
  73. __fastcall TVMS0200M::TVMS0200M(TComponent* Owner)
  74. : TForm(Owner)
  75. {
  76. LangTrans->Translate(this, ITSDb_GetConnection());
  77. ITSSkin_Load(this);
  78. LoadLocalSkin();
  79. FMonitoringType = enMonitoringScenario;
  80. TsList01->TabVisible = false;
  81. if (FormStyle != fsMDIChild) CMM_LoadForm(g_sFormsDir, this);
  82. FListForm = new TList;
  83. FSelVmsObj= NULL;
  84. FSelForm = NULL;
  85. //PgVmsState->Properties->HideTabs = true;
  86. //PgVmsIfscTraf->Properties->HideTabs = true;
  87. FReady = false;
  88. }
  89. //---------------------------------------------------------------------------
  90. void __fastcall TVMS0200M::CommClose()
  91. {
  92. try
  93. {
  94. ClearFormList();
  95. SAFE_DELETE(FListForm);
  96. if (FormStyle != fsMDIChild) CMM_SaveForm(g_sFormsDir, this);
  97. }
  98. catch(...)
  99. {
  100. }
  101. }
  102. //---------------------------------------------------------------------------
  103. void __fastcall TVMS0200M::ClearFormList()
  104. {
  105. try
  106. {
  107. LockWindowUpdate(Handle);
  108. PgFormTab->HideTabs = true;
  109. try
  110. {
  111. for(int ii = 0; ii < FListForm->Count; ii++)
  112. {
  113. TVMS0201M *pForm = (TVMS0201M*)FListForm->Items[ii];
  114. pForm->Hide();
  115. SAFE_DELETE(pForm);
  116. }
  117. FListForm->Clear();
  118. int nForms = PgFormTab->PageCount;
  119. for (int ii = 1; ii < nForms; ii++)
  120. {
  121. TcxTabSheet *pTmpSheet = PgFormTab->Pages[1];
  122. if (pTmpSheet) delete pTmpSheet;
  123. }
  124. PgFormTab->ActivePageIndex = 0;
  125. }
  126. catch(Exception &e)
  127. {
  128. TcxTabSheet *pTmpSheet = PgFormTab->Pages[1];
  129. if (pTmpSheet) delete pTmpSheet;
  130. }
  131. }
  132. __finally
  133. {
  134. LockWindowUpdate(0);
  135. }
  136. }
  137. //---------------------------------------------------------------------------
  138. void __fastcall TVMS0200M::FormCreate(TObject *Sender)
  139. {
  140. InitMonitoringForm();
  141. CreateVmsMsgForm(VmsCtlrManager->FMaxWidth);
  142. }
  143. //---------------------------------------------------------------------------
  144. void __fastcall TVMS0200M::CreateVmsMsgForm(int AWidth)
  145. {
  146. FReady = false;
  147. ClearFormList();
  148. String sQry;
  149. TADOQuery *pADO = NULL;
  150. sQry = "SELECT MONITORING_NM, MONITORING_SEQ, VMS_CTLR_NMBR \r\n"
  151. " FROM TB_VMS_MONITORING \r\n"
  152. " WHERE MONITORING_TYPE = :p01 \r\n"
  153. " ORDER BY MONITORING_NM DESC, MONITORING_SEQ \r\n";
  154. TcxTabSheet *pSheet = NULL;
  155. TVMS0201M *pScrForm = NULL;
  156. String sOldName = "";
  157. int nIndex = 0;
  158. try
  159. {
  160. LockWindowUpdate(Handle);
  161. try
  162. {
  163. pADO = new TADOQuery(NULL);
  164. pADO->Close();
  165. pADO->Connection = ITSDb_GetConnection();
  166. ITSDb_SQLText(pADO, sQry);
  167. ITSDb_SQLBind(pADO, "p01", String(FMonitoringType));
  168. ITSDb_SQLOpen(pADO);
  169. for( ; !pADO->Eof; pADO->Next())
  170. {
  171. String sScrName = pADO->FieldByName("MONITORING_NM")->AsString;
  172. String sScrSeq = pADO->FieldByName("MONITORING_SEQ")->AsString;
  173. String sVmsNmbr = pADO->FieldByName("VMS_CTLR_NMBR")->AsString;
  174. if (sOldName != sScrName)
  175. {
  176. //신규 화면목록 추가
  177. pSheet = CMM_AddTabSheet(PgFormTab, " " + sScrName + " ");
  178. if (!pSheet) continue;
  179. TVMS0201M *pNewForm = new TVMS0201M(this, Handle, sScrName, nIndex++);
  180. pNewForm->Parent = pSheet;
  181. pNewForm->Show();
  182. pScrForm = pNewForm;
  183. sOldName = sScrName;
  184. FListForm->Add(pNewForm);
  185. }
  186. pScrForm->AddVmsForm(sVmsNmbr);
  187. }
  188. }
  189. catch(EDatabaseError &E)
  190. {
  191. DBERRORMSG("VMS Monitoring screen query", String(E.ClassName()), E.Message, sQry);
  192. throw Exception(String(E.ClassName()) + E.Message);
  193. }
  194. catch(Exception &e)
  195. {
  196. DBERRORMSG("VMS Monitoring screen query", String(e.ClassName()), e.Message, sQry);
  197. throw Exception(String(e.ClassName()) + e.Message);
  198. }
  199. }
  200. __finally
  201. {
  202. if (pADO)
  203. {
  204. pADO->Close();
  205. delete pADO;
  206. }
  207. if (PgFormTab->PageCount == 1)
  208. PgFormTab->ActivePageIndex = 0;
  209. else
  210. PgFormTab->ActivePageIndex = 1;
  211. LockWindowUpdate(0);
  212. }
  213. RefreshScenario();
  214. if (FListForm->Count <= 1)
  215. {
  216. PgFormTab->HideTabs = true;
  217. }
  218. else
  219. {
  220. PgFormTab->HideTabs = false;
  221. }
  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->RefreshScenario();
  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->RefreshScenario();
  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->RefreshScenario();
  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(VmsCtlrManager->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. VmsCtlrManager->FLists.Lock();
  340. try
  341. {
  342. int nFormSeq;
  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. " VIEW_MODE \r\n"
  359. " ) \r\n"
  360. " VALUES ( \r\n"
  361. " :p01, \r\n"
  362. " :p02, \r\n"
  363. " :p03, \r\n"
  364. " :p04, \r\n"
  365. " 0 \r\n"
  366. " ) \r\n";
  367. ITSDb_SQLText(pADO, sQry);
  368. nFormSeq = 0;
  369. FOR_STL(TVmsCtlr*, pObj, VmsCtlrManager->FLists)
  370. {
  371. if (pObj->DEL_YN == "Y") continue;
  372. String sFormName = "Default";
  373. ITSDb_SQLBind(pADO, "p01", String(FMonitoringType));
  374. ITSDb_SQLBind(pADO, "p02", sFormName);
  375. ITSDb_SQLBind(pADO, "p03", String(++nFormSeq));
  376. ITSDb_SQLBind(pADO, "p04", String(pObj->VMS_CTLR_NMBR));
  377. ITSDb_SQLExec(pADO);
  378. }
  379. }
  380. catch(EDatabaseError &E)
  381. {
  382. DBERRORMSG("TVMS0200M::InitMonitoringForm", String(E.ClassName()), E.Message, sQry);
  383. throw Exception(String(E.ClassName()) + E.Message);
  384. }
  385. catch(Exception &e)
  386. {
  387. DBERRORMSG("TVMS0200M::InitMonitoringForm", String(e.ClassName()), e.Message, sQry);
  388. throw Exception(String(e.ClassName()) + e.Message);
  389. }
  390. }
  391. __finally
  392. {
  393. if (pADO)
  394. {
  395. pADO->Close();
  396. delete pADO;
  397. }
  398. VmsCtlrManager->FLists.UnLock();
  399. }
  400. }
  401. //---------------------------------------------------------------------------
  402. void __fastcall TVMS0200M::ActivateForm(bool AActivate)
  403. {
  404. try
  405. {
  406. int nTabIndex = PgFormTab->ActivePageIndex;
  407. nTabIndex--; //ActivePageIndex 으로 구간값은 숨어있는 탭을 포함한 인덱스
  408. for(int ii = 0; ii < FListForm->Count; ii++)
  409. {
  410. TVMS0201M *pForm = (TVMS0201M*)FListForm->Items[ii];
  411. if (AActivate)
  412. {
  413. if (ii == nTabIndex) pForm->Play = true;
  414. else pForm->Play = false;
  415. }
  416. else
  417. {
  418. //비활성이면 모든 화면 비활성으로
  419. pForm->Play = false;
  420. }
  421. }
  422. }
  423. catch(Exception &e)
  424. {
  425. }
  426. }
  427. //---------------------------------------------------------------------------
  428. void __fastcall TVMS0200M::PgFormTabPageChanging(TObject *Sender, TcxTabSheet *NewPage, bool &AllowChange)
  429. {
  430. if (!FReady) return;
  431. try
  432. {
  433. int nTabIndex = NewPage->TabIndex; //숨어있는 탭을 제외한 인덱스
  434. for(int ii = 0; ii < FListForm->Count; ii++)
  435. {
  436. TVMS0201M *pForm = (TVMS0201M*)FListForm->Items[ii];
  437. if (nTabIndex == ii) pForm->Play = true;
  438. else pForm->Play = false;
  439. }
  440. }
  441. catch(Exception &e)
  442. {
  443. }
  444. }
  445. //---------------------------------------------------------------------------
  446. void __fastcall TVMS0200M::BtnSearchClick(TObject *Sender)
  447. {
  448. VmsCtlrManager->LoadVmsMsg();
  449. try
  450. {
  451. LockWindowUpdate(Handle);
  452. for(int ii = 0; ii < FListForm->Count; ii++)
  453. {
  454. TVMS0201M *pForm = (TVMS0201M*)FListForm->Items[ii];
  455. pForm->RefreshScenario();
  456. }
  457. }
  458. __finally
  459. {
  460. LockWindowUpdate(0);
  461. }
  462. }
  463. //---------------------------------------------------------------------------
  464. void __fastcall TVMS0200M::ChkAutoWidthPropertiesChange(TObject *Sender)
  465. {
  466. try
  467. {
  468. LockWindowUpdate(Handle);
  469. for(int ii = 0; ii < FListForm->Count; ii++)
  470. {
  471. TVMS0201M *pForm = (TVMS0201M*)FListForm->Items[ii];
  472. pForm->TvVmsMsg->BeginUpdate();
  473. pForm->TvVmsMsg->OptionsView->ColumnAutoWidth = ChkAutoWidth->Checked;
  474. pForm->TvVmsMsg->EndUpdate();
  475. }
  476. }
  477. __finally
  478. {
  479. LockWindowUpdate(0);
  480. //BtnBestFit->Visible = !ChkAutoWidth->Checked;
  481. }
  482. }
  483. //---------------------------------------------------------------------------
  484. void __fastcall TVMS0200M::BtnBestFitClick(TObject *Sender)
  485. {
  486. try
  487. {
  488. LockWindowUpdate(Handle);
  489. for(int ii = 0; ii < FListForm->Count; ii++)
  490. {
  491. TVMS0201M *pForm = (TVMS0201M*)FListForm->Items[ii];
  492. pForm->TvVmsMsg->BeginUpdate();
  493. pForm->TvVmsMsg->ApplyBestFit(NULL, false, false);
  494. pForm->TvVmsMsg->EndUpdate();
  495. }
  496. }
  497. __finally
  498. {
  499. LockWindowUpdate(0);
  500. }
  501. }
  502. //---------------------------------------------------------------------------