VMSEDT0MF.cpp 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "ITSUtilF.h"
  5. #include "AppGlobalF.h"
  6. #pragma hdrstop
  7. #include "VMSEDT0MF.h"
  8. #include "VMSSEL0MF.h"
  9. //---------------------------------------------------------------------------
  10. #pragma package(smart_init)
  11. #pragma link "cxButtons"
  12. #pragma link "cxCalendar"
  13. #pragma link "cxContainer"
  14. #pragma link "cxControls"
  15. #pragma link "cxDropDownEdit"
  16. #pragma link "cxEdit"
  17. #pragma link "cxGraphics"
  18. #pragma link "cxGroupBox"
  19. #pragma link "cxLabel"
  20. #pragma link "cxLookAndFeelPainters"
  21. #pragma link "cxLookAndFeels"
  22. #pragma link "cxMaskEdit"
  23. #pragma link "cxPC"
  24. #pragma link "cxPCdxBarPopupMenu"
  25. #pragma link "cxSpinEdit"
  26. #pragma link "cxSplitter"
  27. #pragma link "cxTextEdit"
  28. #pragma link "cxTimeEdit"
  29. #pragma link "dxSkinBlack"
  30. #pragma link "dxSkinBlue"
  31. #pragma link "dxSkinCaramel"
  32. #pragma link "dxSkinCoffee"
  33. #pragma link "dxSkinDarkRoom"
  34. #pragma link "dxSkinDarkSide"
  35. #pragma link "dxSkinFoggy"
  36. #pragma link "dxSkinGlassOceans"
  37. #pragma link "dxSkiniMaginary"
  38. #pragma link "dxSkinLilian"
  39. #pragma link "dxSkinLiquidSky"
  40. #pragma link "dxSkinLondonLiquidSky"
  41. #pragma link "dxSkinMcSkin"
  42. #pragma link "dxSkinMoneyTwins"
  43. #pragma link "dxSkinOffice2007Black"
  44. #pragma link "dxSkinOffice2007Blue"
  45. #pragma link "dxSkinOffice2007Green"
  46. #pragma link "dxSkinOffice2007Pink"
  47. #pragma link "dxSkinOffice2007Silver"
  48. #pragma link "dxSkinOffice2010Black"
  49. #pragma link "dxSkinOffice2010Blue"
  50. #pragma link "dxSkinOffice2010Silver"
  51. #pragma link "dxSkinsCore"
  52. #pragma link "dxSkinscxPCPainter"
  53. #pragma link "dxSkinSeven"
  54. #pragma link "dxSkinSharp"
  55. #pragma link "dxSkinSilver"
  56. #pragma link "dxSkinStardust"
  57. #pragma link "cxRadioGroup"
  58. #pragma link "cxClasses"
  59. #pragma link "cxCustomData"
  60. #pragma link "cxData"
  61. #pragma link "cxDataStorage"
  62. #pragma link "cxDBData"
  63. #pragma link "cxFilter"
  64. #pragma link "cxGrid"
  65. #pragma link "cxGridCustomTableView"
  66. #pragma link "cxGridCustomView"
  67. #pragma link "cxGridDBTableView"
  68. #pragma link "cxGridLevel"
  69. #pragma link "cxGridTableView"
  70. #pragma link "cxStyles"
  71. #pragma link "cxCheckBox"
  72. #pragma link "cxImage"
  73. #pragma link "cxButtonEdit"
  74. #pragma link "cxBlobEdit"
  75. #pragma link "cxColorComboBox"
  76. #pragma link "cxCalc"
  77. #pragma resource "*.dfm"
  78. TVMSEDT0M *VMSEDT0M = NULL;
  79. //---------------------------------------------------------------------------
  80. __fastcall TVMSEDT0M::TVMSEDT0M(TComponent* Owner)
  81. : TForm(Owner)
  82. {
  83. ITSSkin_Load(this);
  84. ////CMM_LoadForm(g_sFormsDir, this);
  85. FUpdate= false;
  86. FTitle = Caption;//"VMS 폼 스케줄 일괄 관리";
  87. TvForm->OptionsView->DataRowHeight = 0;
  88. TvForm->OptionsView->CellAutoHeight = true;
  89. TvForm->OptionsView->Indicator = false;
  90. TvForm->OptionsCustomize->ColumnMoving = false;
  91. TvForm->OptionsCustomize->ColumnSorting = false;
  92. //TvForm->Columns[0]->Width = 40;
  93. //TvForm->Columns[0]->Options->HorzSizing = false;
  94. FStrTime = "";
  95. FEndTime = "";
  96. FSelected = false;
  97. }
  98. //---------------------------------------------------------------------------
  99. /*
  100. * 닫기버튼 이나 x버튼 클릭시 공통으로 처리하는 로직이들어간다..
  101. * Form과 DataModule class를 delete시킨다.
  102. * arguments
  103. *
  104. * return
  105. * void
  106. */
  107. void __fastcall TVMSEDT0M::CommClose()
  108. {
  109. try
  110. {
  111. ////CMM_SaveForm(g_sFormsDir, this);
  112. }
  113. catch(...)
  114. {
  115. }
  116. }
  117. //---------------------------------------------------------------------------
  118. void __fastcall TVMSEDT0M::FormCreate(TObject *Sender)
  119. {
  120. //
  121. }
  122. //---------------------------------------------------------------------------
  123. /*
  124. * Form을 보여줄때 호출되는 event 메서드이다.
  125. * arguments
  126. * Sender : event handler 객체
  127. * return
  128. * void
  129. */
  130. void __fastcall TVMSEDT0M::FormShow(TObject *Sender)
  131. {
  132. #if 1
  133. if (FMode == "A")
  134. {
  135. FTitle = lblText1->Caption;//"VMS 폼 스케줄 일괄 등록";
  136. GrpObj->Caption = lblText2->Caption;//"▶ VMS 목록";
  137. BtnAllDel->Visible = false;
  138. }
  139. else
  140. {
  141. FTitle = lblText3->Caption;//"VMS 폼 스케줄 일괄 편집";
  142. GrpObj->Caption = lblText4->Caption;//"▶ 선택폼을 스케줄에 사용중인 VMS 목록";
  143. }
  144. #else
  145. if (FMode == "A")
  146. {
  147. FTitle = "Batch add of VMS form schedule";
  148. GrpObj->Caption = "▶ VMS List";
  149. BtnAllDel->Visible = false;
  150. }
  151. else
  152. {
  153. FTitle = "Batch edit VMS form schedule";
  154. GrpObj->Caption = "▶ List the VMS using to schedule the selection form";
  155. }
  156. #endif
  157. Caption = FTitle;
  158. Refresh();
  159. FormInit();
  160. ChangeEditMode(1);
  161. TmrShow->Enabled = true;
  162. }
  163. //---------------------------------------------------------------------------
  164. void __fastcall TVMSEDT0M::FormInit()
  165. {
  166. FormObjectInit();
  167. FNewDb = false;
  168. }
  169. //---------------------------------------------------------------------------
  170. void __fastcall TVMSEDT0M::FormObjectInit()
  171. {
  172. //TvList->OptionsView->NoDataToDisplayInfoText = "<관련 VMS 정보가 없습니다>";
  173. }
  174. //---------------------------------------------------------------------------
  175. void __fastcall TVMSEDT0M::TmrShowTimer(TObject *Sender)
  176. {
  177. TmrShow->Enabled = false;
  178. BtnSearchClick(NULL);
  179. }
  180. //---------------------------------------------------------------------------
  181. void __fastcall TVMSEDT0M::BtnCloseClick(TObject *Sender)
  182. {
  183. Close();
  184. }
  185. //---------------------------------------------------------------------------
  186. void __fastcall TVMSEDT0M::FormClose(TObject *Sender, TCloseAction &Action)
  187. {
  188. CommClose();
  189. VMSEDT0M = NULL;
  190. //Action = caFree;
  191. }
  192. //---------------------------------------------------------------------------
  193. void __fastcall TVMSEDT0M::ChangeEditMode(int AEdit)
  194. {
  195. }
  196. //---------------------------------------------------------------------------
  197. void __fastcall TVMSEDT0M::BtnSearchClick(TObject *Sender)
  198. {
  199. RefreshData();
  200. EdFocus->SetFocus();
  201. ChangeEditMode(1);
  202. if (FStrTime == "")
  203. {
  204. DtStrDate->Date = Now();
  205. }
  206. else
  207. {
  208. TDateTime dtStrDate = APP_StrToDateTime(FStrTime);
  209. DtStrDate->Date = dtStrDate;
  210. DtStrTime->Date = dtStrDate;
  211. DtStrTime->Time = dtStrDate;
  212. }
  213. if (FEndTime == "")
  214. {
  215. TDateTime dtEndDate = EncodeDate(2099, 12, 31);
  216. TDateTime dtEndTime = EncodeTime(23, 59, 59, 0);
  217. DtEndDate->Date = dtEndDate;
  218. DtEndTime->Date = dtEndDate;
  219. DtEndTime->Time = dtEndTime;
  220. }
  221. else
  222. {
  223. TDateTime dtEndDate = APP_StrToDateTime(FEndTime);
  224. DtEndDate->Date = dtEndDate;
  225. DtEndTime->Date = dtEndDate;
  226. DtEndTime->Time = dtEndDate;
  227. }
  228. }
  229. //---------------------------------------------------------------------------
  230. void __fastcall TVMSEDT0M::RefreshData()
  231. {
  232. // 검색조건에 의한 링크 데이터 조회
  233. FormClear();
  234. DisplayFormInfo(0);
  235. DisplayVmsInfo(0);
  236. }
  237. //---------------------------------------------------------------------------
  238. void __fastcall TVMSEDT0M::FormClear()
  239. {
  240. EdFormId->Clear();
  241. EdObjId->Clear();
  242. FNewDb = false;
  243. }
  244. //---------------------------------------------------------------------------
  245. void __fastcall TVMSEDT0M::DisplayInfo()
  246. {
  247. FormClear();
  248. ChangeEditMode(3);
  249. }
  250. //---------------------------------------------------------------------------
  251. void __fastcall TVMSEDT0M::DisplayFormInfo(int AIdx)
  252. {
  253. CMM_ClearGridTableView(TvForm);
  254. String sQry;
  255. TADOQuery *pADO = NULL;
  256. sQry = "SELECT A.* \r\n"
  257. " FROM TB_VMS_FORM A \r\n"
  258. " WHERE A.VMS_FORM_ID = :p01 \r\n"
  259. " ORDER BY A.VMS_FORM_ID \r\n";
  260. try
  261. {
  262. TvForm->BeginUpdate();
  263. TcxDataController *pGDC = TvForm->DataController;
  264. int nRow;
  265. try
  266. {
  267. pADO = new TADOQuery(NULL);
  268. pADO->Close();
  269. pADO->Connection = ITSDb_GetConnection();
  270. ITSDb_SQLText(pADO, sQry);
  271. ITSDb_SQLBind(pADO, "p01", FFormId);
  272. ITSDb_SQLOpen(pADO);
  273. for( ; !pADO->Eof; pADO->Next())
  274. {
  275. nRow = pGDC->AppendRecord();
  276. pGDC->Values[nRow][0] = pADO->FieldByName("VMS_FORM_ID")->AsString;
  277. pGDC->Values[nRow][1] = pADO->FieldByName("VMS_FORM_IMAG")->AsVariant;
  278. }
  279. }
  280. catch(EDatabaseError &E)
  281. {
  282. DBERRORMSG("TVMSEDT0M::DisplayFormInfo", String(E.ClassName()), E.Message, sQry);
  283. throw Exception(String(E.ClassName()) + E.Message);
  284. }
  285. catch(Exception &e)
  286. {
  287. DBERRORMSG("TVMSEDT0M::DisplayFormInfo", String(e.ClassName()), e.Message, sQry);
  288. throw Exception(String(e.ClassName()) + e.Message);
  289. }
  290. }
  291. __finally
  292. {
  293. if (pADO)
  294. {
  295. pADO->Close();
  296. delete pADO;
  297. }
  298. TvForm->ApplyBestFit(NULL, false, false);
  299. TvForm->EndUpdate();
  300. }
  301. }
  302. //---------------------------------------------------------------------------
  303. void __fastcall TVMSEDT0M::DisplayVmsInfo(int AIdx)
  304. {
  305. CMM_ClearGridTableView(TvList);
  306. String sQry;
  307. TADOQuery *pADO = NULL;
  308. String sWhere;
  309. if (FMode == "A")
  310. {
  311. sWhere = " AND A.VMS_CTLR_ID = B.VMS_CTLR_ID(+) \r\n";
  312. }
  313. else
  314. {
  315. sWhere = " AND A.VMS_CTLR_ID = B.VMS_CTLR_ID \r\n";
  316. }
  317. sQry = "SELECT A.VMS_CTLR_ID, A.VMS_CTLR_ID, A.VMS_NM, \r\n"
  318. " B.PHASE, B.DSPL_HH, B.DSPL_STRT_HH, B.DSPL_END_HH, \r\n"
  319. " B.USE_YN, B.VMS_FORM_ID, \r\n"
  320. " DECODE(B.VMS_CTLR_ID, NULL, 0, 1) AS FG \r\n"
  321. " FROM TB_VMS_CTLR A, \r\n"
  322. " (SELECT X.VMS_CTLR_ID, \r\n"
  323. " X.VMS_SCH_TYPE, \r\n"
  324. " X.VMS_SCH_FORM_TYPE, \r\n"
  325. " X.PHASE, \r\n"
  326. " X.VMS_FORM_ID, \r\n"
  327. " X.DSPL_STRT_HH, \r\n"
  328. " X.DSPL_END_HH, \r\n"
  329. " X.DSPL_HH, \r\n"
  330. " X.FRST_VMS_IFSC_ID, \r\n"
  331. " X.SECD_VMS_IFSC_ID, \r\n"
  332. " X.THIR_VMS_IFSC_ID, \r\n"
  333. " X.FOUR_VMS_IFSC_ID, \r\n"
  334. " X.FRST_IMG_IFSC_ID, \r\n"
  335. " X.SECD_IMG_IFSC_ID, \r\n"
  336. " X.THIR_IMG_IFSC_ID, \r\n"
  337. " X.FOUR_IMG_IFSC_ID, \r\n"
  338. " X.SYMB_LIB_NMBR, \r\n"
  339. " X.STRM_ADDR, \r\n"
  340. " X.USE_YN, \r\n"
  341. " Y.VMS_MODL_KIND, \r\n"
  342. " Y.VMS_FORM_TYPE_CD, \r\n"
  343. " Y.VMS_FORM_NM \r\n"
  344. " FROM TB_VMS_DSPL_SCH X, \r\n"
  345. " TB_VMS_FORM Y \r\n"
  346. " WHERE X.VMS_FORM_ID = Y.VMS_FORM_ID \r\n"
  347. " AND X.VMS_SCH_TYPE = :p02 \r\n"
  348. " AND X.VMS_SCH_FORM_TYPE = :p03 \r\n"
  349. " AND X.VMS_FORM_ID = :p04) B \r\n"
  350. " WHERE A.VMS_MODL_KIND = :p01 \r\n";
  351. sQry+= sWhere;
  352. try
  353. {
  354. TvList->BeginUpdate();
  355. TcxDataController *pGDC = TvList->DataController;
  356. int nRow;
  357. try
  358. {
  359. pADO = new TADOQuery(NULL);
  360. pADO->Close();
  361. pADO->Connection = ITSDb_GetConnection();
  362. ITSDb_SQLText(pADO, sQry);
  363. ITSDb_SQLBind(pADO, "p01", FVmsTypeCd);
  364. ITSDb_SQLBind(pADO, "p02", FScheType);
  365. ITSDb_SQLBind(pADO, "p03", FScheFormType);
  366. ITSDb_SQLBind(pADO, "p04", FFormId);
  367. ITSDb_SQLOpen(pADO);
  368. for( ; !pADO->Eof; pADO->Next())
  369. {
  370. String sFormId = pADO->FieldByName("VMS_FORM_ID")->AsString;
  371. if (FMode == "A")
  372. {
  373. if (sFormId == FFormId)
  374. {
  375. //전체추가인데 기존에 등록되어 있으면 추가하지 않는다.
  376. //continue;
  377. }
  378. }
  379. nRow = pGDC->AppendRecord();
  380. pGDC->Values[nRow][Col00->Index] = pADO->FieldByName("VMS_CTLR_ID")->AsString;
  381. pGDC->Values[nRow][Col01->Index] = pADO->FieldByName("VMS_CTLR_ID")->AsString;
  382. pGDC->Values[nRow][Col02->Index] = pADO->FieldByName("VMS_NM")->AsString;
  383. String sFlag = pADO->FieldByName("FG")->AsString;
  384. if (sFlag == "0")
  385. {
  386. pGDC->Values[nRow][ColumnSel->Index] = true;
  387. pGDC->Values[nRow][Col03->Index] = "4";
  388. pGDC->Values[nRow][Col04->Index] = Now().FormatString(STR_HHNN);
  389. pGDC->Values[nRow][Col05->Index] = "2099-12-31 23:59";
  390. pGDC->Values[nRow][Col06->Index] = "Y";
  391. pGDC->Values[nRow][Col07->Index] = "1";
  392. pGDC->Values[nRow][Col08->Index] = Now().FormatString("YYYYMMDDHHNN") + "00";
  393. pGDC->Values[nRow][Col09->Index] = "20991231235959";
  394. continue;
  395. }
  396. if (FMode == "A")
  397. {
  398. pGDC->Values[nRow][ColumnSel->Index] = false;
  399. }
  400. else
  401. {
  402. pGDC->Values[nRow][ColumnSel->Index] = true;
  403. }
  404. String sStrDate = pADO->FieldByName("DSPL_STRT_HH")->AsString;
  405. String sEndDate = pADO->FieldByName("DSPL_END_HH")->AsString;
  406. pGDC->Values[nRow][Col03->Index] = pADO->FieldByName("DSPL_HH")->AsString;
  407. pGDC->Values[nRow][Col04->Index] = ITSUtil_FormatStr(sStrDate, STR_HHNN);
  408. pGDC->Values[nRow][Col05->Index] = ITSUtil_FormatStr(sEndDate, STR_HHNN);
  409. pGDC->Values[nRow][Col06->Index] = pADO->FieldByName("USE_YN")->AsString;
  410. pGDC->Values[nRow][Col07->Index] = pADO->FieldByName("PHASE")->AsString;
  411. pGDC->Values[nRow][Col08->Index] = sStrDate;
  412. pGDC->Values[nRow][Col09->Index] = sEndDate;
  413. FStrTime = sStrDate;
  414. FEndTime = sEndDate;
  415. }
  416. }
  417. catch(EDatabaseError &E)
  418. {
  419. DBERRORMSG("TVMSEDT0M::DisplayVmsInfo", String(E.ClassName()), E.Message, sQry);
  420. throw Exception(String(E.ClassName()) + E.Message);
  421. }
  422. catch(Exception &e)
  423. {
  424. DBERRORMSG("TVMSEDT0M::DisplayVmsInfo", String(e.ClassName()), e.Message, sQry);
  425. throw Exception(String(e.ClassName()) + e.Message);
  426. }
  427. }
  428. __finally
  429. {
  430. if (pADO)
  431. {
  432. pADO->Close();
  433. delete pADO;
  434. }
  435. TvList->EndUpdate();
  436. }
  437. }
  438. //---------------------------------------------------------------------------
  439. void __fastcall TVMSEDT0M::BtnAllSelectClick(TObject *Sender)
  440. {
  441. TcxButton *pBtn = (TcxButton*)Sender;
  442. CMM_CheckAllListItem(TvList, ColumnSel->Index, pBtn->Tag);
  443. }
  444. //---------------------------------------------------------------------------
  445. void __fastcall TVMSEDT0M::TvListCellDblClick(TcxCustomGridTableView *Sender, TcxGridTableDataCellViewInfo *ACellViewInfo,
  446. TMouseButton AButton, TShiftState AShift,
  447. bool &AHandled)
  448. {
  449. if (!ACellViewInfo) return;
  450. int nRow = Sender->DataController->FocusedRecordIndex;
  451. if( nRow <= -1 )
  452. return;
  453. TcxGridDataController *pDc = (TcxGridDataController*)Sender->DataController;
  454. int nColIdx = ACellViewInfo->Item->Index;
  455. String sStrDate = VarToStr(pDc->Values[nRow][Col08->Index]);
  456. String sEndDate = VarToStr(pDc->Values[nRow][Col09->Index]);
  457. {
  458. //표출기간설정
  459. TVMSSEL0M *pSelDate = new TVMSSEL0M(this);
  460. pSelDate->FStrTime = sStrDate;
  461. pSelDate->FEndTime = sEndDate;
  462. pSelDate->ShowModal();
  463. bool bSelected = pSelDate->FSelected;
  464. sStrDate = pSelDate->FStrTime;
  465. sEndDate = pSelDate->FEndTime;
  466. delete pSelDate;
  467. pSelDate = NULL;
  468. if (bSelected)
  469. {
  470. pDc->Values[nRow][Col04->Index] = ITSUtil_FormatStr(sStrDate, STR_HHNN);;
  471. pDc->Values[nRow][Col05->Index] = ITSUtil_FormatStr(sEndDate, STR_HHNN);;
  472. pDc->Values[nRow][Col08->Index] = sStrDate;
  473. pDc->Values[nRow][Col09->Index] = sEndDate;
  474. }
  475. return;
  476. }
  477. }
  478. //---------------------------------------------------------------------------
  479. bool __fastcall TVMSEDT0M::CheckData(bool ACheckData)
  480. {
  481. int nSelCnt = CMM_GetCheckCount(TvList, ColumnSel->Index);
  482. if (nSelCnt <= 0)
  483. {
  484. //Application->MessageBox(L"VMS Schedule Batch Management\r\nSelect the VMS you want to work on from the VMS list.", FTitle.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
  485. Application->MessageBox(lblText5->Caption.c_str(),//L"VMS 스케줄 일괄 관리\r\nVMS 목록에서 작업대상 VMS를 먼저 선택하세요.",
  486. FTitle.c_str(),
  487. MB_OK|MB_ICONERROR|MB_APPLMODAL);
  488. return false;
  489. }
  490. if (!ACheckData) return true;
  491. String sStrDate = DtStrDate->Date.FormatString("yyyymmdd");
  492. String sStrTime = DtStrTime->DateTime.FormatString("HHnn");
  493. String sEndDate = DtEndDate->Date.FormatString("yyyymmdd");
  494. String sEndTime = DtEndTime->DateTime.FormatString("HHnn");
  495. FStrTime = sStrDate + sStrTime;
  496. FEndTime = sEndDate + sEndTime;
  497. if (FStrTime > FEndTime)
  498. {
  499. //Application->MessageBox(L"The display start time is larger than the display end time.", L"Set VMS form expiration period", MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  500. Application->MessageBox(lblText6->Caption.c_str(),//L"표출 시작시각이 표출 종료시각 보다 큽니다.",
  501. lblText7->Caption.c_str(),//L"VMS 폼 표출기간 설정",
  502. MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  503. ActiveControl = DtStrDate;
  504. return false;
  505. }
  506. FStrTime = FStrTime + "00";
  507. FEndTime = FEndTime + "59";
  508. return true;
  509. }
  510. //---------------------------------------------------------------------------
  511. void __fastcall TVMSEDT0M::UpdateEditData()
  512. {
  513. try
  514. {
  515. TvList->BeginUpdate();
  516. int nRowCnt = TvList->ViewData->RecordCount;
  517. for (int ii = 0; ii < nRowCnt; ii++)
  518. {
  519. TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii];
  520. if (!ARow->IsData) continue;
  521. if (!((bool)ARow->Values[ColumnSel->Index]))
  522. {
  523. continue;
  524. }
  525. ARow->Values[Col03->Index] = CbCycle->Text.Trim();
  526. ARow->Values[Col04->Index] = ITSUtil_FormatStr(FStrTime, STR_HHNN);
  527. ARow->Values[Col05->Index] = ITSUtil_FormatStr(FEndTime, STR_HHNN);
  528. ARow->Values[Col06->Index] = CbUse->Text.Trim();
  529. //ARow->Values[Col07->Index] = ""; //phase
  530. ARow->Values[Col08->Index] = FStrTime;
  531. ARow->Values[Col09->Index] = FEndTime;
  532. }
  533. }
  534. __finally
  535. {
  536. TvList->EndUpdate();
  537. }
  538. }
  539. //---------------------------------------------------------------------------
  540. void __fastcall TVMSEDT0M::BtnAllAddClick(TObject *Sender)
  541. {
  542. //등록 - 등록 또는 수정 INSERT or UPDATE
  543. if (!CheckData(true)) return;
  544. #if 1
  545. if (Application->MessageBox(lblText8->Caption.c_str(),//L"VMS 스케줄 일괄 관리\r\n선택한 VMS에 대하여 스케줄 정보를 [[[동일내용으로]]] 저장 하시겠습니까?",
  546. FTitle.c_str(),
  547. MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES) return;
  548. #else
  549. if (Application->MessageBox(L"VMS schedule management\r\nDo you want to save schedule information for selected VMS [[[Same as above]]]?",
  550. FTitle.c_str(),
  551. MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES) return;
  552. #endif
  553. UpdateEditData(); //동일 편집내용을 VMS목록에 적용
  554. bool bResult;
  555. if (FMode == "A")
  556. {
  557. //INSERT
  558. bResult = InsertVmsSchedule();
  559. }
  560. else
  561. {
  562. //UPDATE
  563. bResult = UpdateVmsSchedule();
  564. }
  565. }
  566. //---------------------------------------------------------------------------
  567. void __fastcall TVMSEDT0M::BtnAllEdtClick(TObject *Sender)
  568. {
  569. //수정 - 등록 또는 수정 INSERT or UPDATE
  570. if (!CheckData(true)) return;
  571. #if 1
  572. if (Application->MessageBox(lblText9->Caption.c_str(),//L"VMS 스케줄 일괄 관리\r\n선택한 VMS에 대하여 스케줄 정보를 저장 하시겠습니까?",
  573. FTitle.c_str(),
  574. MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES) return;
  575. #else
  576. if (Application->MessageBox(L"VMS schedule management\r\nDo you want to save schedule information for selected VMS?",
  577. FTitle.c_str(),
  578. MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES) return;
  579. #endif
  580. bool bResult;
  581. if (FMode == "A")
  582. {
  583. //INSERT
  584. bResult = InsertVmsSchedule();
  585. }
  586. else
  587. {
  588. //UPDATE
  589. bResult = UpdateVmsSchedule();
  590. }
  591. }
  592. //---------------------------------------------------------------------------
  593. void __fastcall TVMSEDT0M::BtnAllDelClick(TObject *Sender)
  594. {
  595. //삭제 - 무조건 DELETE
  596. if (!CheckData(false)) return;
  597. #if 1
  598. if (Application->MessageBox(lblText10->Caption.c_str(),//L"VMS 스케줄 일괄 관리\r\n선택한 VMS에 대하여 스케줄 정보를 삭제하시겠습니까?",
  599. FTitle.c_str(),
  600. MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES) return;
  601. #else
  602. if (Application->MessageBox(L"VMS schedule management\r\nDo you want to delete the schedule information for the selected VMS?",
  603. FTitle.c_str(),
  604. MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES) return;
  605. #endif
  606. bool bResult = true;
  607. if (bResult)
  608. {
  609. bResult = DeleteVmsSchedule();
  610. }
  611. }
  612. //---------------------------------------------------------------------------
  613. bool __fastcall TVMSEDT0M::DeleteVmsSchedule()
  614. {
  615. bool bResult = false;
  616. String sQry;
  617. TADOQuery *pADO = NULL;
  618. sQry = "DELETE TB_VMS_DSPL_SCH \r\n"
  619. " WHERE VMS_CTLR_ID = :p01 \r\n"
  620. " AND VMS_SCH_TYPE = :p02 \r\n"
  621. " AND VMS_SCH_FORM_TYPE = :p03 \r\n"
  622. " AND PHASE = :p04 \r\n"
  623. " AND VMS_FORM_ID = :p05 \r\n";
  624. try
  625. {
  626. try
  627. {
  628. pADO = new TADOQuery(NULL);
  629. pADO->Close();
  630. pADO->Connection = ITSDb_GetConnection();
  631. ITSDb_SQLText(pADO, sQry);
  632. //ITSDb_GetConnection()->BeginTrans();
  633. int nRowCnt = TvList->ViewData->RecordCount;
  634. for (int ii = 0; ii < nRowCnt; ii++)
  635. {
  636. TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii];
  637. if (!ARow->IsData) continue;
  638. if (!((bool)ARow->Values[ColumnSel->Index]))
  639. {
  640. continue;
  641. }
  642. String sVmsNmbr = VarToStr(ARow->Values[Col00->Index]);
  643. String sScheType = FScheType;
  644. String sScheFormType = FScheFormType;
  645. String sPhase = VarToStr(ARow->Values[Col07->Index]);
  646. String sFormId = FFormId;
  647. ITSDb_SQLBind(pADO, "p01", sVmsNmbr);
  648. ITSDb_SQLBind(pADO, "p02", sScheType);
  649. ITSDb_SQLBind(pADO, "p03", sScheFormType);
  650. ITSDb_SQLBind(pADO, "p04", sPhase);
  651. ITSDb_SQLBind(pADO, "p05", sFormId);
  652. ITSDb_SQLExec(pADO);
  653. }
  654. //ITSDb_GetConnection()->CommitTrans();
  655. bResult = true;
  656. }
  657. catch(EDatabaseError &E)
  658. {
  659. ITSDb_GetConnection()->RollbackTrans();
  660. DBERRORMSG("TVMSEDT0M::DeleteVmsSchedule", String(E.ClassName()), E.Message, sQry);
  661. throw Exception(String(E.ClassName()) + E.Message);
  662. }
  663. catch(Exception &e)
  664. {
  665. ITSDb_GetConnection()->RollbackTrans();
  666. DBERRORMSG("TVMSEDT0M::DeleteVmsSchedule", String(e.ClassName()), e.Message, sQry);
  667. throw Exception(String(e.ClassName()) + e.Message);
  668. }
  669. }
  670. __finally
  671. {
  672. if (pADO)
  673. {
  674. pADO->Close();
  675. delete pADO;
  676. }
  677. }
  678. if (bResult)
  679. {
  680. #if 1
  681. Application->MessageBox(lblText11->Caption.c_str(),//L"VMS 스케줄 일괄 관리\r\nVMS 스케줄 정보를 삭제 하였습니다.",
  682. FTitle.c_str(),
  683. MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  684. #else
  685. Application->MessageBox(L"VMS schedule management\r\nDeleted the VMS schedule information.",
  686. FTitle.c_str(),
  687. MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  688. #endif
  689. FSelected = true;
  690. Close();
  691. }
  692. return bResult;
  693. }
  694. //---------------------------------------------------------------------------
  695. bool __fastcall TVMSEDT0M::UpdateVmsSchedule()
  696. {
  697. bool bResult = false;
  698. String sQry;
  699. TADOQuery *pADO = NULL;
  700. sQry = "UPDATE TB_VMS_DSPL_SCH \r\n"
  701. " SET DSPL_HH = :p05, \r\n"
  702. " DSPL_STRT_HH = :p06, \r\n"
  703. " DSPL_END_HH = :p07, \r\n"
  704. " USE_YN = :p08 \r\n"
  705. " WHERE VMS_CTLR_ID = :p01 \r\n"
  706. " AND VMS_SCH_TYPE = :p09 \r\n"
  707. " AND VMS_SCH_FORM_TYPE = :p02 \r\n"
  708. " AND PHASE = :p03 \r\n"
  709. " AND VMS_FORM_ID = :p04 \r\n";
  710. try
  711. {
  712. try
  713. {
  714. pADO = new TADOQuery(NULL);
  715. pADO->Close();
  716. pADO->Connection = ITSDb_GetConnection();
  717. ITSDb_SQLText(pADO, sQry);
  718. //ITSDb_GetConnection()->BeginTrans();
  719. int nRowCnt = TvList->ViewData->RecordCount;
  720. for (int ii = 0; ii < nRowCnt; ii++)
  721. {
  722. TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii];
  723. if (!ARow->IsData) continue;
  724. if (!((bool)ARow->Values[ColumnSel->Index]))
  725. {
  726. continue;
  727. }
  728. String sVmsNmbr = VarToStr(ARow->Values[Col00->Index]);
  729. String sScheType = FScheType;
  730. String sScheFormType = FScheFormType;
  731. String sPhase = VarToStr(ARow->Values[Col07->Index]);
  732. String sFormId = FFormId;
  733. String sDispHH = VarToStr(ARow->Values[Col03->Index]);
  734. String sStrTime = VarToStr(ARow->Values[Col08->Index]);
  735. String sEndTime = VarToStr(ARow->Values[Col09->Index]);
  736. String sUseYn = VarToStr(ARow->Values[Col06->Index]);
  737. ITSDb_SQLBind(pADO, "p01", sVmsNmbr);
  738. ITSDb_SQLBind(pADO, "p02", sScheFormType);
  739. ITSDb_SQLBind(pADO, "p03", sPhase);
  740. ITSDb_SQLBind(pADO, "p04", sFormId);
  741. ITSDb_SQLBind(pADO, "p05", sDispHH);
  742. ITSDb_SQLBind(pADO, "p06", sStrTime);
  743. ITSDb_SQLBind(pADO, "p07", sEndTime);
  744. ITSDb_SQLBind(pADO, "p08", sUseYn);
  745. ITSDb_SQLBind(pADO, "p09", sScheType);
  746. ITSDb_SQLExec(pADO);
  747. }
  748. //ITSDb_GetConnection()->CommitTrans();
  749. bResult = true;
  750. }
  751. catch(EDatabaseError &E)
  752. {
  753. ITSDb_GetConnection()->RollbackTrans();
  754. DBERRORMSG("TVMSEDT0M::UpdateVmsSchedule", String(E.ClassName()), E.Message, sQry);
  755. throw Exception(String(E.ClassName()) + E.Message);
  756. }
  757. catch(Exception &e)
  758. {
  759. ITSDb_GetConnection()->RollbackTrans();
  760. DBERRORMSG("TVMSEDT0M::UpdateVmsSchedule", String(e.ClassName()), e.Message, sQry);
  761. throw Exception(String(e.ClassName()) + e.Message);
  762. }
  763. }
  764. __finally
  765. {
  766. if (pADO)
  767. {
  768. pADO->Close();
  769. delete pADO;
  770. }
  771. }
  772. if (bResult)
  773. {
  774. #if 1
  775. Application->MessageBox(lblText12->Caption.c_str(),//L"VMS 스케줄 일괄 관리\r\nVMS 스케줄 정보를 수정 하였습니다.",
  776. FTitle.c_str(),
  777. MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  778. #else
  779. Application->MessageBox(L"VMS schedule management\r\Edited the VMS schedule information.",
  780. FTitle.c_str(),
  781. MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  782. #endif
  783. FSelected = true;
  784. Close();
  785. }
  786. return bResult;
  787. }
  788. //---------------------------------------------------------------------------
  789. bool __fastcall TVMSEDT0M::InsertVmsSchedule()
  790. {
  791. bool bResult = false;
  792. String sQry;
  793. TADOQuery *pADO = NULL;
  794. #if 0
  795. sQry = "INSERT INTO TB_VMS_DSPL_SCH ( \r\n"
  796. " VMS_CTLR_ID, \r\n"
  797. " VMS_SCH_TYPE, \r\n"
  798. " VMS_SCH_FORM_TYPE, \r\n"
  799. " PHASE, \r\n"
  800. " VMS_FORM_ID, \r\n"
  801. " DSPL_HH, \r\n"
  802. " DSPL_STRT_HH, \r\n"
  803. " DSPL_END_HH, \r\n"
  804. " SYMB_LIB_NMBR, \r\n"
  805. " STRM_ADDR, \r\n"
  806. " USE_YN \r\n"
  807. " ) \r\n"
  808. " VALUES ( \r\n"
  809. " :p01, \r\n"
  810. " :p02, \r\n"
  811. " :p11, \r\n"
  812. " (SELECT NVL(MAX(PHASE), 0) + 1 \r\n"
  813. " FROM TB_VMS_DSPL_SCH \r\n"
  814. " WHERE VMS_CTLR_ID = :p08 \r\n"
  815. " AND VMS_SCH_TYPE = :p09 \r\n"
  816. " AND VMS_SCH_FORM_TYPE = :p10), \r\n"
  817. " :p03, \r\n"
  818. " :p04, \r\n"
  819. " :p05, \r\n"
  820. " :p06, \r\n"
  821. " :p12, \r\n"
  822. " :p13, \r\n"
  823. " :p07 \r\n"
  824. " ) \r\n";
  825. #else
  826. sQry = "INSERT INTO TB_VMS_DSPL_SCH ( \r\n"
  827. " VMS_CTLR_ID, \r\n"
  828. " VMS_SCH_TYPE, \r\n"
  829. " VMS_SCH_FORM_TYPE, \r\n"
  830. " PHASE, \r\n"
  831. " VMS_FORM_ID, \r\n"
  832. " DSPL_HH, \r\n"
  833. " DSPL_STRT_HH, \r\n"
  834. " DSPL_END_HH, \r\n"
  835. " SYMB_LIB_NMBR, \r\n"
  836. " STRM_ADDR, \r\n"
  837. " USE_YN \r\n"
  838. " ) \r\n"
  839. " VALUES ( \r\n"
  840. " :p01, \r\n"
  841. " :p02, \r\n"
  842. " :p11, \r\n"
  843. " (SELECT NVL(MAX(PHASE), 0) + 1 \r\n"
  844. " FROM TB_VMS_DSPL_SCH \r\n"
  845. " WHERE VMS_CTLR_ID = :p08 \r\n"
  846. " AND VMS_SCH_TYPE = :p09), \r\n"
  847. " :p03, \r\n"
  848. " :p04, \r\n"
  849. " :p05, \r\n"
  850. " :p06, \r\n"
  851. " :p12, \r\n"
  852. " :p13, \r\n"
  853. " :p07 \r\n"
  854. " ) \r\n";
  855. #endif
  856. try
  857. {
  858. try
  859. {
  860. pADO = new TADOQuery(NULL);
  861. pADO->Close();
  862. pADO->Connection = ITSDb_GetConnection();
  863. ITSDb_SQLText(pADO, sQry);
  864. //ITSDb_GetConnection()->BeginTrans();
  865. int nRowCnt = TvList->ViewData->RecordCount;
  866. for (int ii = 0; ii < nRowCnt; ii++)
  867. {
  868. TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii];
  869. if (!ARow->IsData) continue;
  870. if (!((bool)ARow->Values[ColumnSel->Index]))
  871. {
  872. continue;
  873. }
  874. String sVmsNmbr = VarToStr(ARow->Values[Col00->Index]);
  875. String sScheType = FScheType;
  876. String sScheFormType = FScheFormType;
  877. String sFormId = FFormId;
  878. String sDispHH = VarToStr(ARow->Values[Col03->Index]);
  879. String sStrTime = VarToStr(ARow->Values[Col08->Index]);
  880. String sEndTime = VarToStr(ARow->Values[Col09->Index]);
  881. String sUseYn = VarToStr(ARow->Values[Col06->Index]);
  882. ITSDb_SQLBind(pADO, "p01", sVmsNmbr);
  883. ITSDb_SQLBind(pADO, "p02", sScheType);
  884. ITSDb_SQLBind(pADO, "p03", sFormId);
  885. ITSDb_SQLBind(pADO, "p04", sDispHH);
  886. ITSDb_SQLBind(pADO, "p05", sStrTime);
  887. ITSDb_SQLBind(pADO, "p06", sEndTime);
  888. ITSDb_SQLBind(pADO, "p07", sUseYn);
  889. ITSDb_SQLBind(pADO, "p08", sVmsNmbr);
  890. ITSDb_SQLBind(pADO, "p09", sScheType);
  891. //ITSDb_SQLBind(pADO, "p10", sScheFormType);
  892. ITSDb_SQLBind(pADO, "p11", sScheFormType);
  893. ITSDb_SQLBind(pADO, "p12", FSymbLibNmbr);
  894. ITSDb_SQLBind(pADO, "p13", FStreamAddr);
  895. ITSDb_SQLExec(pADO);
  896. }
  897. //ITSDb_GetConnection()->CommitTrans();
  898. bResult = true;
  899. }
  900. catch(EDatabaseError &E)
  901. {
  902. ITSDb_GetConnection()->RollbackTrans();
  903. DBERRORMSG("TVMSEDT0M::InsertVmsSchedule", String(E.ClassName()), E.Message, sQry);
  904. throw Exception(String(E.ClassName()) + E.Message);
  905. }
  906. catch(Exception &e)
  907. {
  908. ITSDb_GetConnection()->RollbackTrans();
  909. DBERRORMSG("TVMSEDT0M::InsertVmsSchedule", String(e.ClassName()), e.Message, sQry);
  910. throw Exception(String(e.ClassName()) + e.Message);
  911. }
  912. }
  913. __finally
  914. {
  915. if (pADO)
  916. {
  917. pADO->Close();
  918. delete pADO;
  919. }
  920. }
  921. if (bResult)
  922. {
  923. #if 1
  924. Application->MessageBox(lblText13->Caption.c_str(),//L"VMS 스케줄 일괄 관리\r\nVMS 스케줄 정보를 저장 하였습니다.",
  925. FTitle.c_str(),
  926. MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  927. #else
  928. Application->MessageBox(L"VMS schedule management\r\nVMS schedule information saved.",
  929. FTitle.c_str(),
  930. MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  931. #endif
  932. FSelected = true;
  933. Close();
  934. }
  935. return bResult;
  936. }
  937. //---------------------------------------------------------------------------
  938. bool __fastcall TVMSEDT0M::InsertVmsScheduleWeek()
  939. {
  940. bool bResult = false;
  941. #if 0
  942. String sQry;
  943. TADOQuery *pADO = NULL;
  944. sQry = "INSERT INTO TB_VMS_DSPL_SCH_WEEK ( \r\n"
  945. " VMS_CTLR_ID, \r\n"
  946. " VMS_SCH_TYPE, \r\n"
  947. " PHASE, \r\n"
  948. " WEEK_CD, \r\n"
  949. " SCH_HH \r\n"
  950. " ) \r\n"
  951. " VALUES( \r\n"
  952. " :p01, :p02, \r\n"
  953. " (SELECT NVL(MAX(PHASE), 0) \r\n"
  954. " FROM TB_VMS_DSPL_SCH \r\n"
  955. " WHERE VMS_CTLR_ID = :p05 \r\n"
  956. " AND VMS_SCH_TYPE = :p06 \r\n"
  957. " AND VMS_SCH_FORM_TYPE = :p07), \r\n"
  958. " :p03, :p04 \r\n"
  959. " ) \r\n";
  960. try
  961. {
  962. try
  963. {
  964. pADO = new TADOQuery(NULL);
  965. pADO->Close();
  966. pADO->Connection = ITSDb_GetConnection();
  967. ITSDb_SQLText(pADO, sQry);
  968. int nRowCnt = TvList->ViewData->RecordCount;
  969. for (int ii = 0; ii < nRowCnt; ii++)
  970. {
  971. TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii];
  972. if (!ARow->IsData) continue;
  973. if (!((bool)ARow->Values[ColumnSel->Index]))
  974. {
  975. continue;
  976. }
  977. String sVmsNmbr = VarToStr(ARow->Values[Col00->Index]);
  978. String sScheType = FScheType;
  979. String sScheFormType = FScheFormType;
  980. for (int jj = 1; jj <= 7; jj++)
  981. {
  982. ITSDb_SQLBind(pADO, "p01", sVmsNmbr);
  983. ITSDb_SQLBind(pADO, "p02", sScheType);
  984. ITSDb_SQLBind(pADO, "p03", String(jj));
  985. ITSDb_SQLBind(pADO, "p04", "111111111111111111111111");
  986. ITSDb_SQLBind(pADO, "p05", sVmsNmbr);
  987. ITSDb_SQLBind(pADO, "p06", sScheType);
  988. ITSDb_SQLBind(pADO, "p07", sScheFormType);
  989. pADO->ExecSQL();
  990. }
  991. }
  992. bResult = true;
  993. }
  994. catch(EDatabaseError &E)
  995. {
  996. ITSDb_GetConnection()->RollbackTrans();
  997. DBERRORMSG("TVMSEDT0M::InsertVmsScheduleWeek", String(E.ClassName()), E.Message, sQry);
  998. throw Exception(String(E.ClassName()) + E.Message);
  999. }
  1000. catch(Exception &e)
  1001. {
  1002. ITSDb_GetConnection()->RollbackTrans();
  1003. DBERRORMSG("TVMSEDT0M::InsertVmsScheduleWeek", String(e.ClassName()), e.Message, sQry);
  1004. throw Exception(String(e.ClassName()) + e.Message);
  1005. }
  1006. }
  1007. __finally
  1008. {
  1009. if (pADO)
  1010. {
  1011. pADO->Close();
  1012. delete pADO;
  1013. }
  1014. }
  1015. #endif
  1016. return bResult;
  1017. }
  1018. //---------------------------------------------------------------------------