AppGlobalF.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "AppGlobalF.h"
  5. #include "ITSDbF.h"
  6. #include "ITSUtilF.h"
  7. #include "ITSLogF.h"
  8. #include "CDSCodeF.h"
  9. #include <inifiles.hpp>
  10. //---------------------------------------------------------------------------
  11. #pragma package(smart_init)
  12. //---------------------------------------------------------------------------
  13. String CenterCd = ""; // 지역센터 코드
  14. String CenterId = ""; // 지역센터 아이디
  15. String CenterName = ""; // 지역센터 명칭
  16. int g_nPid = -1; // Application Process ID
  17. String g_sAppDir = ""; // Application Directory
  18. String g_sAppName= ""; // Program name
  19. String g_sCfgDir = ""; // Config File Directory
  20. String g_sLogDir = ""; // Program Log Directory
  21. String g_sTempDir = ""; // Program Temp Directory
  22. String g_sFormsDir = ""; // Program Forms Directory
  23. String g_sLangDir = "";
  24. APP_CONFIG g_AppCfg;
  25. LOGININFO *g_pLOGIN = NULL;
  26. LOG_INFO g_LogCfg;
  27. TITSLog *ITSLog = NULL;
  28. //---------------------------------------------------------------------------
  29. bool LoadDefaultConfigInfo(String ACfgFile/*=""*/)
  30. {
  31. String sCfgFile;
  32. TIniFile *pIniFile = NULL;
  33. String sIniFile = ChangeFileExt(ExtractFileName(Application->ExeName), ".ini");
  34. if (!ACfgFile.IsEmpty())
  35. sIniFile = ACfgFile + ".ini";
  36. sCfgFile = g_sCfgDir + sIniFile;
  37. g_AppCfg.sConfigFile = sCfgFile;
  38. g_AppCfg.thr.pThread = NULL;
  39. g_AppCfg.thr.dwThreadId = 0;
  40. g_AppCfg.thr.nHandle = 0;
  41. g_AppCfg.thr.bRunning = false;
  42. g_AppCfg.bAppClose = false;
  43. pIniFile = new TIniFile(sCfgFile);
  44. try
  45. {
  46. g_AppCfg.sTitle = pIniFile->ReadString("APPLICATION", "TITLE", "교통정보시스템 통합 운영단말");
  47. g_AppCfg.sProcessId = pIniFile->ReadString("APPLICATION", "PROCESSID", "OPER01");
  48. g_AppCfg.sLogDay = pIniFile->ReadString("APPLICATION", "LOGDAY", "");
  49. g_AppCfg.sAppPath = pIniFile->ReadString("APPLICATION", "APP_PATH", "");
  50. g_AppCfg.sSkinName = pIniFile->ReadString("APPLICATION", "SKINNAME", "Blue");
  51. g_AppCfg.bSaveForm = pIniFile->ReadString("APPLICATION", "SAVEFORM", "1").ToIntDef(1) == 1 ? true : false;
  52. g_AppCfg.bLoginPrompt = pIniFile->ReadString("APPLICATION", "LOGINPROMPT", "1").ToIntDef(1) == 1 ? true : false;
  53. g_AppCfg.bDebug = pIniFile->ReadString("APPLICATION", "DEBUG", "0").ToIntDef(0) == 1 ? true : false;
  54. g_AppCfg.sDefUseId = pIniFile->ReadString("APPLICATION", "LASTUSER", "");
  55. g_AppCfg.sLang = pIniFile->ReadString("APPLICATION", "LANGUAGE", "kr").LowerCase();
  56. if (g_AppCfg.sLang != "en" && g_AppCfg.sLang != "kr") g_AppCfg.sLang = "kr";
  57. g_AppCfg.itsdb.bSqlLog = pIniFile->ReadString("ITSDB", "SQLLOG", "0").ToIntDef(0) == 1 ? true : false;
  58. g_AppCfg.itsdb.sConnectStr = pIniFile->ReadString("ITSDB", "CONNECTSTR", "");
  59. if (g_AppCfg.itsdb.sConnectStr == "")
  60. {
  61. g_AppCfg.itsdb.sProvider = pIniFile->ReadString("ITSDB", "PROVIDER", "OraOLEDB.Oracle.1");
  62. g_AppCfg.itsdb.sServerName = pIniFile->ReadString("ITSDB", "SERVERNAME", "HANTE");
  63. g_AppCfg.itsdb.sUserName = pIniFile->ReadString("ITSDB", "USERNAME", "hnits");
  64. g_AppCfg.itsdb.sPassword = pIniFile->ReadString("ITSDB", "PASSWORD", "hnits");
  65. }
  66. //시설물 온도알람을 사용하지 않는경우 100도가 되기때문에 실제적으로 알람이 발생하지 않는 효과가 있음
  67. //즉, 온도이상알람을 원하는 경우에만 알람값을 설정하여 사용하면 됨
  68. g_AppCfg.Temp.AlarmValue = pIniFile->ReadString("TEMPERATURE", "ALARMVALUE", "100").ToIntDef(100); //45
  69. }
  70. __finally
  71. {
  72. if (pIniFile) delete pIniFile;
  73. pIniFile = NULL;
  74. }
  75. return true;
  76. }
  77. //---------------------------------------------------------------------------
  78. bool CMM_InsertLoginHist(PLOGININFO pLogin, bool ALogin)
  79. {
  80. String sQry;
  81. bool bResult= false;
  82. TADOQuery *adoQry = NULL;
  83. if (!pLogin) return false;
  84. if (ALogin)
  85. {
  86. sQry = "INSERT INTO TB_USERCNNC_HS ( \r\n"
  87. " LOGIN_HMS, \r\n"
  88. " USER_ID, \r\n"
  89. " LOGOUT_HMS \r\n"
  90. " ) \r\n"
  91. "VALUES ( \r\n"
  92. " :p01, \r\n"
  93. " :p02, \r\n"
  94. " NULL \r\n"
  95. " ) \r\n";
  96. }
  97. else
  98. {
  99. sQry = "UPDATE TB_USERCNNC_HS SET \r\n"
  100. " LOGOUT_HMS = TO_CHAR(SYSDATE, 'YYYYMMDDHH24MISS') \r\n"
  101. " WHERE LOGIN_HMS = :p01 \r\n"
  102. " AND USER_ID = :p02 \r\n";
  103. }
  104. try
  105. {
  106. try
  107. {
  108. adoQry = new TADOQuery(NULL);
  109. adoQry->Connection = ITSDb_GetConnection();
  110. ITSDb_GetConnection()->BeginTrans();
  111. adoQry->Close();
  112. adoQry->SQL->Text = sQry;
  113. adoQry->Parameters->ParamByName("p01")->Value = pLogin->sLoginTime;
  114. adoQry->Parameters->ParamByName("p02")->Value = pLogin->sUserId;
  115. int nRowCnt = adoQry->ExecSQL();
  116. ITSDb_GetConnection()->CommitTrans();
  117. bResult = nRowCnt > 1 ? true : false;
  118. }
  119. catch (Exception &exception)
  120. {
  121. ITSDb_GetConnection()->RollbackTrans();
  122. throw Exception(String(exception.ClassName()) + exception.Message);
  123. }
  124. catch (...)
  125. {
  126. ITSDb_GetConnection()->RollbackTrans();
  127. }
  128. }
  129. __finally
  130. {
  131. if (adoQry)
  132. {
  133. adoQry->Close();
  134. delete adoQry;
  135. }
  136. }
  137. return bResult;
  138. }
  139. //---------------------------------------------------------------------------
  140. /*
  141. * 환경설정 정보를 저장하는 함수.
  142. * arguments
  143. * String : RegisterKey 또는 파일이름
  144. * return
  145. * bool : 실패하면 false
  146. */
  147. bool WriteConfigInfo(String sCfgFile, String sTitle, String sItem, String sValue)
  148. {
  149. String ConfigFile;
  150. TIniFile *pIniFile = NULL;
  151. ConfigFile = sCfgFile;
  152. try
  153. {
  154. pIniFile = new TIniFile(ConfigFile);
  155. if (pIniFile == NULL)
  156. {
  157. return false;
  158. }
  159. pIniFile->WriteString(sTitle, sItem, sValue);
  160. }
  161. catch(...)
  162. {
  163. }
  164. if (pIniFile)
  165. {
  166. pIniFile->Free();
  167. pIniFile = NULL;
  168. }
  169. return true;
  170. }
  171. //---------------------------------------------------------------------------
  172. /*
  173. * 환경설정 정보를 읽어오는 함수.
  174. * arguments
  175. * String : RegisterKey 또는 파일이름
  176. * return
  177. * bool : 실패하면 false
  178. */
  179. bool ReadConfigInfo(String sCfgFile, String sTitle, String sItem, String &sValue)
  180. {
  181. bool bRes;
  182. String ConfigFile;
  183. TIniFile *pIniFile = NULL;
  184. bRes = false;
  185. ConfigFile = sCfgFile;
  186. try
  187. {
  188. pIniFile = new TIniFile(ConfigFile);
  189. if (pIniFile == NULL)
  190. {
  191. return bRes;
  192. }
  193. sValue = pIniFile->ReadString(sTitle, sItem, "");
  194. if (sValue != "")
  195. {
  196. bRes = true;
  197. }
  198. }
  199. catch(...)
  200. {
  201. }
  202. if (pIniFile)
  203. {
  204. pIniFile->Free();
  205. pIniFile = NULL;
  206. }
  207. return bRes;
  208. }
  209. //---------------------------------------------------------------------------
  210. void ShowErrorMsg(String ATitle, String AErrMsg)
  211. {
  212. Application->NormalizeTopMosts();
  213. Application->MessageBox(AErrMsg.c_str(), ATitle.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
  214. Application->RestoreTopMosts();
  215. }
  216. //----------------------------------------------------------------------------
  217. String APP_FillCode(TcxComboBox *ACombo, String ACode)
  218. {
  219. String sReturn = "";
  220. ACombo->Properties->Items->Clear();
  221. TItsCode *FCodeRMF = ItsCodeManager->FLists.Find(ACode);
  222. if (FCodeRMF)
  223. {
  224. FOR_STL(TItsSubCode *, pSubCode, FCodeRMF->FSubLists)
  225. {
  226. if (pSubCode->USE_YN == "N") continue;
  227. ACombo->Properties->Items->Add(" [" + pSubCode->CMMN_CD + "] " + pSubCode->CMMN_CD_KOR_NM);
  228. if (sReturn == "")
  229. {
  230. sReturn = " [" + pSubCode->CMMN_CD + "] " + pSubCode->CMMN_CD_KOR_NM;
  231. }
  232. }
  233. }
  234. ACombo->ItemIndex = 0;
  235. return sReturn;
  236. }
  237. //----------------------------------------------------------------------------
  238. String APP_GetCode(TcxComboBox *ACombo)
  239. {
  240. String sReturn = "";
  241. if (ACombo->ItemIndex >= 0)
  242. {
  243. String sDesc = ACombo->Properties->Items->Strings[ACombo->ItemIndex];
  244. String sCode = sDesc.SubString(sDesc.Pos("[") + 1,
  245. sDesc.Pos("]") - (sDesc.Pos("[") + 1));
  246. sReturn = sCode;
  247. }
  248. return sReturn;
  249. }
  250. //----------------------------------------------------------------------------
  251. String APP_GetCodeDesc(TcxComboBox *ACombo, String ACode)
  252. {
  253. String sReturn = "";
  254. for (int ii = 0; ii < ACombo->Properties->Items->Count; ii++)
  255. {
  256. String sDesc = ACombo->Properties->Items->Strings[ii];
  257. String sCode = sDesc.SubString(sDesc.Pos("[") + 1,
  258. sDesc.Pos("]") - (sDesc.Pos("[") + 1));
  259. if (ACode == sCode)
  260. {
  261. sReturn = sDesc;
  262. break;
  263. }
  264. }
  265. return sReturn;
  266. }
  267. //----------------------------------------------------------------------------
  268. String APP_GetCodeName(TcxComboBox *ACombo, String ACode)
  269. {
  270. String sReturn = "";
  271. for (int ii = 0; ii < ACombo->Properties->Items->Count; ii++)
  272. {
  273. String sDesc = ACombo->Properties->Items->Strings[ii];
  274. String sName = sDesc.SubString(sDesc.Pos("]") + 1, sDesc.Length());
  275. String sCode = sDesc.SubString(sDesc.Pos("[") + 1,
  276. sDesc.Pos("]") - (sDesc.Pos("[") + 1));
  277. if (ACode == sCode)
  278. {
  279. sReturn = sName.Trim();
  280. break;
  281. }
  282. }
  283. return sReturn;
  284. }
  285. //----------------------------------------------------------------------------
  286. String APP_GetCodeIdByName(TcxComboBox *ACombo, String AName)
  287. {
  288. String sReturn = "3";
  289. for (int ii = 0; ii < ACombo->Properties->Items->Count; ii++)
  290. {
  291. String sDesc = ACombo->Properties->Items->Strings[ii];
  292. String sName = sDesc.SubString(sDesc.Pos("]") + 1, sDesc.Length());
  293. String sCode = sDesc.SubString(sDesc.Pos("[") + 1,
  294. sDesc.Pos("]") - (sDesc.Pos("[") + 1));
  295. if (sName.Trim() == AName.Trim())
  296. {
  297. sReturn = sCode;
  298. break;
  299. }
  300. }
  301. return sReturn;
  302. }
  303. //----------------------------------------------------------------------------
  304. String APP_GetCodeDefCode(TcxComboBox *ACombo)
  305. {
  306. String sReturn = "";
  307. if (ACombo->Properties->Items->Count > 0)
  308. {
  309. String sDesc = ACombo->Properties->Items->Strings[0];
  310. String sCode = sDesc.SubString(sDesc.Pos("[") + 1,
  311. sDesc.Pos("]") - (sDesc.Pos("[") + 1));
  312. sReturn = sCode;
  313. }
  314. return sReturn;
  315. }
  316. //----------------------------------------------------------------------------
  317. String APP_GetCodeDefDesc(TcxComboBox *ACombo)
  318. {
  319. String sReturn = "";
  320. if (ACombo->Properties->Items->Count > 0)
  321. {
  322. String sDesc = ACombo->Properties->Items->Strings[0];
  323. sReturn = sDesc;
  324. }
  325. return sReturn;
  326. }
  327. //----------------------------------------------------------------------------
  328. int APP_SetCode(TcxComboBox *ACombo, String ACode)
  329. {
  330. int nItemIndex = -1;
  331. for (int ii = 0; ii < ACombo->Properties->Items->Count; ii++)
  332. {
  333. String sDesc = ACombo->Properties->Items->Strings[ii];
  334. String sCode = sDesc.SubString(sDesc.Pos("[") + 1,
  335. sDesc.Pos("]") - (sDesc.Pos("[") + 1));
  336. if (ACode == sCode)
  337. {
  338. nItemIndex = ii;
  339. break;
  340. }
  341. }
  342. ACombo->ItemIndex = nItemIndex;
  343. return nItemIndex;
  344. }
  345. //----------------------------------------------------------------------------
  346. ULONG ProcIDFromWnd(HWND hwnd) // 윈도우 핸들로 프로세스 아이디 얻기
  347. {
  348. ULONG idProc;
  349. GetWindowThreadProcessId( hwnd, &idProc );
  350. return idProc;
  351. }
  352. //----------------------------------------------------------------------------
  353. HWND GetWinHandle(ULONG pid) // 프로세스 아이디로 윈도우 핸들 얻기
  354. {
  355. HWND tempHwnd = FindWindow(NULL,NULL); // 최상위 윈도우 핸들 찾기
  356. while( tempHwnd != NULL )
  357. {
  358. if( GetParent(tempHwnd) == NULL ) // 최상위 핸들인지 체크, 버튼 등도 핸들을 가질 수 있으므로 무시하기 위해
  359. if( pid == ProcIDFromWnd(tempHwnd) )
  360. return tempHwnd;
  361. tempHwnd = GetWindow(tempHwnd, GW_HWNDNEXT); // 다음 윈도우 핸들 찾기
  362. }
  363. return NULL;
  364. }
  365. //----------------------------------------------------------------------------
  366. String ITSUtil_FormatStr(String AStrDateTime, String AFormat)
  367. {
  368. #define SYEAR "-"
  369. #define STIME ":"
  370. #define SPACE " "
  371. String sDateTime = "";
  372. String sInData = AnsiString(AStrDateTime);
  373. //ShowMessage("IN: " + AStrDateTime + " " + sInData + " " + AFormat);
  374. if (sInData.IsEmpty())
  375. return sInData;
  376. //sDateTime = sInData;
  377. try
  378. {
  379. if (AFormat == STR_DATETIME)
  380. {
  381. if (sInData.Length() < 14) return sInData;
  382. sDateTime = sInData.SubString( 1, 4) + SYEAR +
  383. sInData.SubString( 5, 2) + SYEAR +
  384. sInData.SubString( 7, 2) + SPACE +
  385. sInData.SubString( 9, 2) + STIME +
  386. sInData.SubString(11, 2) + STIME +
  387. sInData.SubString(13, 2);
  388. }
  389. else
  390. if (AFormat == STR_HHNN)
  391. {
  392. if (sInData.Length() < 12) return sInData;
  393. sDateTime = sInData.SubString( 1, 4) + SYEAR +
  394. sInData.SubString( 5, 2) + SYEAR +
  395. sInData.SubString( 7, 2) + SPACE +
  396. sInData.SubString( 9, 2) + STIME +
  397. sInData.SubString(11, 2);
  398. }
  399. else
  400. if (AFormat == STR_DATEHOUR)
  401. {
  402. if (sInData.Length() < 10) return sInData;
  403. sDateTime = sInData.SubString( 1, 4) + SYEAR +
  404. sInData.SubString( 5, 2) + SYEAR +
  405. sInData.SubString( 7, 2) + SPACE +
  406. sInData.SubString( 9, 2);
  407. }
  408. else
  409. if (AFormat == STR_DATE)
  410. {
  411. if (sInData.Length() < 8) return sInData;
  412. sDateTime = sInData.SubString( 1, 4) + SYEAR +
  413. sInData.SubString( 5, 2) + SYEAR +
  414. sInData.SubString( 7, 2);
  415. }
  416. else
  417. if (AFormat == STR_MM)
  418. {
  419. if (sInData.Length() < 6) return sInData;
  420. sDateTime = sInData.SubString( 1, 4) + SYEAR +
  421. sInData.SubString( 5, 2);
  422. }
  423. else
  424. {
  425. sDateTime = sInData;
  426. }
  427. }
  428. catch(...)
  429. {
  430. }
  431. //ShowMessage("OUT: " + sDateTime);
  432. return sDateTime;
  433. }
  434. //---------------------------------------------------------------------------
  435. TColor g_DispColor[MAX_DISPCOLOR];
  436. void APP_InitDisplayColor()
  437. {
  438. g_DispColor[ 0] = Graphics::clBlue;
  439. g_DispColor[ 1] = Graphics::clRed;
  440. g_DispColor[ 2] = Graphics::clLime;
  441. g_DispColor[ 3] = Graphics::clMaroon;
  442. g_DispColor[ 4] = Graphics::clGreen;
  443. g_DispColor[ 5] = Graphics::clMenuHighlight;
  444. g_DispColor[ 6] = Graphics::clBackground;
  445. g_DispColor[ 7] = Graphics::clPurple;
  446. g_DispColor[ 8] = Graphics::clTeal;
  447. g_DispColor[ 9] = Graphics::clYellow;
  448. g_DispColor[10] = Graphics::clFuchsia;
  449. g_DispColor[11] = Graphics::clAqua;
  450. g_DispColor[12] = Graphics::clMoneyGreen;
  451. g_DispColor[13] = Graphics::clSkyBlue;
  452. g_DispColor[14] = Graphics::clRed;
  453. g_DispColor[15] = Graphics::clLime;
  454. g_DispColor[16] = Graphics::clYellow;
  455. g_DispColor[17] = Graphics::clBlue;
  456. g_DispColor[18] = Graphics::clFuchsia;
  457. g_DispColor[19] = Graphics::clAqua;
  458. g_DispColor[20] = Graphics::clMoneyGreen;
  459. g_DispColor[21] = Graphics::clActiveCaption;
  460. }
  461. //---------------------------------------------------------------------------
  462. TColor APP_GetDisplayColor(int ASeq)
  463. {
  464. return g_DispColor[ASeq % MAX_DISPCOLOR];
  465. }
  466. //---------------------------------------------------------------------------
  467. void APP_DelVmsSizeCombo(TcxComboBox *cboBox)
  468. {
  469. TStrings *pStrItems;
  470. TVmsSizeType *Ov;
  471. pStrItems = ((TcxComboBox *)cboBox)->Properties->Items;
  472. for (int ii = pStrItems->Count-1; ii >= 0; ii--)
  473. {
  474. Ov = (TVmsSizeType *)pStrItems->Objects[ii];
  475. if (Ov != NULL)
  476. {
  477. delete Ov;
  478. Ov = NULL;
  479. }
  480. }
  481. }
  482. //---------------------------------------------------------------------------
  483. void APP_FillVmsSizeType(TcxComboBox *cboBox, String AType, bool bAddAll/*=false*/)
  484. {
  485. String sQry;
  486. TStrings *pStrItems;
  487. TADOQuery *pADO = NULL;
  488. APP_DelVmsSizeCombo(cboBox);
  489. pStrItems = ((TcxComboBox *)cboBox)->Properties->Items;
  490. ((TcxComboBox *)cboBox)->Properties->Items->Clear();
  491. sQry = "SELECT CMMN_CD, \r\n"
  492. " CMMN_CD_KOR_NM, \r\n"
  493. " NVL(ATRB1, '320') AS FORMW, \r\n"
  494. " NVL(ATRB2, '64') AS FORMH \r\n"
  495. " FROM TB_CMMN_CD \r\n"
  496. " WHERE CMMN_CLSF_CD = 'VMP' \r\n"
  497. " AND USE_YN = 'Y' \r\n"
  498. " AND CMMN_CD IN (SELECT DISTINCT VMS_TYPE_CD \r\n"
  499. " FROM TB_VMS_CTLR) \r\n"
  500. //" WHERE VMS_USAG_TYPE_CD = :p01) \r\n"
  501. " ORDER BY CMMN_CD DESC \r\n";
  502. try
  503. {
  504. try
  505. {
  506. pADO = new TADOQuery(NULL);
  507. pADO->Close();
  508. pADO->Connection = ITSDb_GetConnection();
  509. ITSDb_SQLText(pADO, sQry);
  510. //ITSDb_SQLBind(pADO, "p01", AType);
  511. ITSDb_SQLOpen(pADO);
  512. for( ; !pADO->Eof; pADO->Next())
  513. {
  514. String sTypeCd = pADO->FieldByName("CMMN_CD")->AsString;
  515. String sTypeNm = pADO->FieldByName("CMMN_CD_KOR_NM")->AsString;
  516. String sWidth = pADO->FieldByName("FORMW")->AsString;
  517. String sHeight = pADO->FieldByName("FORMH")->AsString;
  518. int nW = sWidth.ToIntDef(384);
  519. int nH = sHeight.ToIntDef(64);
  520. pStrItems->AddObject(" [" + sTypeCd + "] " + sTypeNm + " (" + String(nW) + "x" + String(nH) + ")", new TVmsSizeType(sTypeCd, sTypeNm, nW, nH) );
  521. }
  522. if (bAddAll)
  523. {
  524. String sAllName = "전체";
  525. pStrItems->AddObject(" [ALL] 전체" , new TVmsSizeType("ALL", sAllName, 384, 64));
  526. }
  527. cboBox->ItemIndex = 0;
  528. }
  529. catch(EDatabaseError &E)
  530. {
  531. DBERRORMSG("APP_FillVmsSizeType", String(E.ClassName()), E.Message, sQry);
  532. throw Exception(String(E.ClassName()) + E.Message);
  533. }
  534. catch(Exception &exception)
  535. {
  536. DBERRORMSG("APP_FillVmsSizeType", String(exception.ClassName()), exception.Message, sQry);
  537. throw Exception(String(exception.ClassName()) + exception.Message);
  538. }
  539. }
  540. __finally
  541. {
  542. if (pADO)
  543. {
  544. pADO->Close();
  545. delete pADO;
  546. }
  547. }
  548. }
  549. //---------------------------------------------------------------------------
  550. TVmsSizeType* APP_GetVmsSizeTypeObject(TcxComboBox *cboBox)
  551. {
  552. TStrings *pStrItems;
  553. TVmsSizeType *Ov = NULL;
  554. int nItemIndex;
  555. pStrItems = ((TcxComboBox *)cboBox)->Properties->Items;
  556. nItemIndex= ((TcxComboBox *)cboBox)->ItemIndex;
  557. if (nItemIndex < 0)
  558. {
  559. return Ov;
  560. }
  561. Ov = (TVmsSizeType *)pStrItems->Objects[nItemIndex];
  562. if (Ov == NULL)
  563. {
  564. Ov = NULL;
  565. }
  566. return Ov;
  567. }
  568. //---------------------------------------------------------------------------
  569. void APP_ImageClear(TCanvas *c, int offX, int offY, int w, int h, TColor color)
  570. {
  571. try
  572. {
  573. c->Pen->Color = clWhite;
  574. c->Pen->Width = 0;
  575. c->Pen->Style = psClear;
  576. c->Brush->Style = bsSolid;
  577. c->Brush->Color = color;
  578. c->Rectangle(offX, offY, w+offX+2, h+offY+2);
  579. }
  580. catch(...)
  581. {
  582. }
  583. }
  584. //---------------------------------------------------------------------------
  585. #include <DateUtils.hpp>
  586. TDateTime APP_StrToDateTime(String AStrDateTime)
  587. {
  588. TDateTime dtReturnValue = NULL;
  589. if (AStrDateTime.IsEmpty()) return dtReturnValue;
  590. if (AStrDateTime.Length() != 14) return dtReturnValue;
  591. AnsiString sDateTime = AnsiString(AStrDateTime);
  592. try
  593. {
  594. #if 0
  595. sDateTime.printf(L"%s-%s-%s %s:%s:%s",
  596. AStrDateTime.SubString( 1, 4).c_str(),
  597. AStrDateTime.SubString( 5, 2).c_str(),
  598. AStrDateTime.SubString( 7, 2).c_str(),
  599. AStrDateTime.SubString( 9, 2).c_str(),
  600. AStrDateTime.SubString(11, 2).c_str(),
  601. AStrDateTime.SubString(13, 2).c_str());
  602. dtReturnValue = StrToDateTime(sDateTime);
  603. #endif
  604. // swscanf(sRgb.c_str(), L"%d,%d,%d", &r, &g, &b);
  605. int year, month, day, hour, minute, second;
  606. sscanf(sDateTime.c_str(), "%4d%2d%2d%2d%2d%2d", &year, &month, &day, &hour, &minute, &second);
  607. dtReturnValue = EncodeDateTime(year, month, day, hour, minute, second, 0);
  608. }
  609. catch(...)
  610. {
  611. }
  612. return dtReturnValue;
  613. }
  614. //---------------------------------------------------------------------------