VMSEDT0MF.cpp 40 KB

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