TAS0040MF.cpp 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "ITSUtilF.h"
  5. #include "AppGlobalF.h"
  6. #include "CDSRoadF.h"
  7. #include "CDSIfscF.h"
  8. #include "ITSLangTransF.h"
  9. #pragma hdrstop
  10. #include "TAS0040MF.h"
  11. #include "TAS00401F.h"
  12. #include "CDSCodeF.h"
  13. //---------------------------------------------------------------------------
  14. #pragma package(smart_init)
  15. #pragma link "cxButtons"
  16. #pragma link "cxContainer"
  17. #pragma link "cxControls"
  18. #pragma link "cxDropDownEdit"
  19. #pragma link "cxEdit"
  20. #pragma link "cxGraphics"
  21. #pragma link "cxGroupBox"
  22. #pragma link "cxLookAndFeelPainters"
  23. #pragma link "cxLookAndFeels"
  24. #pragma link "cxMaskEdit"
  25. #pragma link "cxPC"
  26. #pragma link "cxPCdxBarPopupMenu"
  27. #pragma link "cxTextEdit"
  28. #pragma link "dxSkinBlack"
  29. #pragma link "dxSkinBlue"
  30. #pragma link "dxSkinsCore"
  31. #pragma link "dxSkinscxPCPainter"
  32. #pragma resource "*.dfm"
  33. TTAS0040M *TAS0040M = NULL;
  34. //---------------------------------------------------------------------------
  35. __fastcall TTAS0040M::TTAS0040M(TComponent* Owner)
  36. : TForm(Owner)
  37. {
  38. LangTrans->Translate(this, ITSDb_GetConnection());
  39. ITSSkin_Load(this);
  40. CMM_LoadForm(g_sFormsDir, this);
  41. FTitle = Caption;//"특수일분석";
  42. m_pFormList = new TList();
  43. TsList01->TabVisible = false;
  44. MyItsAtrdManager = new TItsAtrdManager();
  45. MyItsAtrdManager->LoadFromDb();
  46. }
  47. //---------------------------------------------------------------------------
  48. void __fastcall TTAS0040M::CommClose()
  49. {
  50. try
  51. {
  52. if (MyHolidayManager)
  53. {
  54. delete MyHolidayManager;
  55. MyHolidayManager = NULL;
  56. }
  57. if (MyItsAtrdManager)
  58. {
  59. delete MyItsAtrdManager;
  60. MyItsAtrdManager = NULL;
  61. }
  62. for (int idx = m_pFormList->Count-1; idx >= 0; idx--)
  63. {
  64. m_pFormList->Delete(idx);
  65. }
  66. delete m_pFormList;
  67. CMM_SaveForm(g_sFormsDir, this);
  68. }
  69. catch(...)
  70. {
  71. }
  72. }
  73. //---------------------------------------------------------------------------
  74. void __fastcall TTAS0040M::FormShow(TObject *Sender)
  75. {
  76. Refresh();
  77. FormInit();
  78. TmrShow->Enabled = true;
  79. }
  80. //---------------------------------------------------------------------------
  81. void __fastcall TTAS0040M::FormInit()
  82. {
  83. FAtrdId = "";
  84. if (!MyHolidayManager)
  85. {
  86. MyHolidayManager = new TItsHolidayManager();
  87. }
  88. MyHolidayManager->LoadFromDb();
  89. CbIfsc->Properties->Items->Clear();
  90. CbYear->Properties->Items->Clear();
  91. CbType->Properties->Items->Clear();
  92. CbAtrd->Properties->Items->Clear();
  93. try
  94. {
  95. MyItsAtrdManager->FLists.Lock();
  96. FOR_STL(TItsAtrd*, pObj, MyItsAtrdManager->FLists)
  97. {
  98. if (pObj->DEL_YN == "Y") continue;
  99. String sDir = (pObj->DRCT_CD.Trim() == "0") ? FrmLang->lblUp->Caption : FrmLang->lblDown->Caption;//String("상행") : String("하행");
  100. String sAtr = pObj->ATRD_NM;
  101. CbAtrd->Properties->Items->AddObject(sAtr + " [" + sDir + "]", (TObject*)pObj);
  102. }
  103. }
  104. __finally
  105. {
  106. MyItsAtrdManager->FLists.UnLock();
  107. CbAtrd->ItemIndex = 0;
  108. }
  109. int nMinYear = 2018;
  110. int nMaxYear = Now().FormatString("YYYY").ToIntDef(2018);
  111. for (int ii = nMinYear; ii <= nMaxYear; ii++)
  112. {
  113. String sYear;
  114. sYear.printf(L"%04d", ii);
  115. CbYear->Properties->Items->AddObject(sYear, (TObject*)NULL);
  116. }
  117. CbYear->ItemIndex = 0;
  118. }
  119. //---------------------------------------------------------------------------
  120. void __fastcall TTAS0040M::TmrShowTimer(TObject *Sender)
  121. {
  122. TmrShow->Enabled = false;
  123. }
  124. //---------------------------------------------------------------------------
  125. void __fastcall TTAS0040M::RefreshData()
  126. {
  127. // 검색조건에 의한 링크 데이터 조회
  128. try
  129. {
  130. //SelListData();
  131. }
  132. __finally
  133. {
  134. }
  135. }
  136. //---------------------------------------------------------------------------
  137. void __fastcall TTAS0040M::BtnSearchClick(TObject *Sender)
  138. {
  139. Application->ProcessMessages();
  140. TSqlCursor sqlCrs((TControl*)BtnSearch);
  141. String sTitle;
  142. TItsAtrd *pAtrd = (TItsAtrd*)CbAtrd->Properties->Items->Objects[CbAtrd->ItemIndex];
  143. if (!pAtrd)
  144. {
  145. Application->MessageBox(FrmLang->lblSelErr->Caption.c_str(),//L"간선도로를 먼저 선택 하세요.",
  146. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  147. ActiveControl = CbAtrd;
  148. return;
  149. }
  150. FAtrdId = pAtrd->ATRD_ID;
  151. FAtrdNm = CbAtrd->Text.Trim();
  152. TItsIfsc *pIfsc = (TItsIfsc*)CbIfsc->Properties->Items->Objects[CbIfsc->ItemIndex];
  153. if (!pIfsc)
  154. {
  155. Application->MessageBox(FrmLang->lblSelErr->Caption.c_str(),//L"간선도로 구간을 먼저 선택 하세요.",
  156. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  157. ActiveControl = CbIfsc;
  158. return;
  159. }
  160. FLinkId = pIfsc->IFSC_ID;
  161. FLinkNm = pIfsc->STRT_NM + " → " + pIfsc->END_NM;
  162. TItsHoliday *pHoliday = (TItsHoliday*)CbType->Properties->Items->Objects[CbType->ItemIndex];
  163. if (!pHoliday)
  164. {
  165. Application->MessageBox(FrmLang->lblSelErr->Caption.c_str(),//L"특수일을 먼저 선택 하세요.",
  166. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  167. ActiveControl = CbType;
  168. return;
  169. }
  170. FQryDay = pHoliday->YMD;
  171. FQryDayNm = pHoliday->LEGL_HLDY_NM;
  172. sTitle.printf(L"%s [%s] ", FLinkNm.c_str(), FQryDayNm.c_str());
  173. try
  174. {
  175. Application->ProcessMessages();
  176. LockWindowUpdate(Handle);
  177. TcxTabSheet *pSheet = CMM_AddTabSheet(PgTab, sTitle);
  178. if (!pSheet) return;
  179. TAS00401 = new TTAS00401(this, Handle, FLinkId, FLinkNm, FQryDay, FPtrnWeek, FQryDayNm);
  180. TAS00401->Parent = pSheet;
  181. TAS00401->Show();
  182. PgTab->ActivePage = pSheet;
  183. pSheet = PgTab->ActivePage;
  184. m_pFormList->Add(TAS00401);
  185. }
  186. __finally
  187. {
  188. LockWindowUpdate(0);
  189. }
  190. }
  191. //---------------------------------------------------------------------------
  192. void __fastcall TTAS0040M::BtnCloseClick(TObject *Sender)
  193. {
  194. Close();
  195. }
  196. //---------------------------------------------------------------------------
  197. void __fastcall TTAS0040M::OnSubFormClose(TMessage Msg)
  198. {
  199. int nActiveIdx = PgTab->ActivePageIndex;
  200. if (nActiveIdx <= 0) return;
  201. LockWindowUpdate(Handle);
  202. TcxTabSheet *pSheet = PgTab->ActivePage;
  203. if (pSheet)
  204. {
  205. delete pSheet;
  206. }
  207. nActiveIdx--; // 첫번째 탭은 화면에 숨겨져 있다.
  208. m_pFormList->Delete(nActiveIdx);
  209. LockWindowUpdate(0);
  210. }
  211. //---------------------------------------------------------------------------
  212. void __fastcall TTAS0040M::PgTabDblClick(TObject *Sender)
  213. {
  214. TPoint APoint;
  215. APoint = PgTab->MouseDownPos;
  216. if (PgTab->IndexOfTabAt(APoint.x, APoint.y) != -1)
  217. POST_MSG(Handle, WM_SUBFORM_CLOSE, 0, 0);
  218. }
  219. //---------------------------------------------------------------------------
  220. void __fastcall TTAS0040M::FormClose(TObject *Sender, TCloseAction &Action)
  221. {
  222. CommClose();
  223. TAS0040M = NULL;
  224. Action = caFree;
  225. }
  226. //---------------------------------------------------------------------------
  227. void __fastcall TTAS0040M::CbAtrdPropertiesChange(TObject *Sender)
  228. {
  229. TItsAtrd *pObj = (TItsAtrd*)CbAtrd->Properties->Items->Objects[CbAtrd->ItemIndex];
  230. if (!pObj) return;
  231. FAtrdId = pObj->ATRD_ID;
  232. FAtrdNm = pObj->ATRD_NM;
  233. CbIfsc->Properties->Items->Clear();
  234. FOR_STL(TItsAtrdRoad*, pAtrdRoad, pObj->FRoads)
  235. {
  236. TItsRoad *pRoad = ItsRoadManager->FLists.Find(pAtrdRoad->ROAD_ID);
  237. if (!pRoad) continue;
  238. std::map<int, String>::iterator itPos;
  239. for(itPos = pRoad->FIfscs.begin(); itPos != pRoad->FIfscs.end(); ++itPos)
  240. {
  241. String sIfscId = itPos->second;
  242. TItsIfsc *pIfsc = ItsIfscManager->FLists.Find(sIfscId);
  243. if (!pIfsc) continue;
  244. CbIfsc->Properties->Items->AddObject(" [" + pIfsc->IFSC_ID + "] " + pIfsc->STRT_NM + " → " + pIfsc->END_NM, (TObject*)pIfsc);
  245. }
  246. }
  247. CbIfsc->ItemIndex = 0;
  248. }
  249. //---------------------------------------------------------------------------
  250. void __fastcall TTAS0040M::CbYearPropertiesChange(TObject *Sender)
  251. {
  252. String sYear = CbYear->Text.Trim();
  253. String sFromDay = sYear + "0101";
  254. String sToDay;
  255. int nSelYear = sYear.ToIntDef(2018);
  256. int nCurYear = Now().FormatString("YYYY").ToIntDef(2018);
  257. if (nSelYear == nCurYear)
  258. {
  259. sToDay = sYear + Now().FormatString("MMDD");
  260. }
  261. else
  262. {
  263. sToDay = sYear + "1231";
  264. }
  265. double nStartYear = sFromDay.ToDouble();
  266. double nEndYear = sToDay.ToDouble();
  267. double nTempYear;
  268. CbType->Properties->Items->Clear();
  269. FOR_STL(TItsHoliday*, pObj, MyHolidayManager->FLists)
  270. {
  271. if (pObj->DEL_YN != "N") continue;
  272. nTempYear = pObj->YMD.ToDouble();
  273. if (nTempYear < nStartYear || nTempYear > nEndYear) continue;
  274. CbType->Properties->Items->AddObject(" [" + pObj->YMD + "] " + pObj->LEGL_HLDY_NM, (TObject*)pObj);
  275. }
  276. CbType->ItemIndex = 0;
  277. }
  278. //---------------------------------------------------------------------------
  279. void __fastcall TTAS0040M::PgTabCanCloseEx(TObject *Sender, int ATabIndex, bool &ACanClose)
  280. {
  281. int nActiveIdx = ATabIndex;
  282. if (nActiveIdx <= 0) return;
  283. nActiveIdx--; // 첫번째 탭은 화면에 숨겨져 있다.
  284. m_pFormList->Delete(nActiveIdx);
  285. }
  286. //---------------------------------------------------------------------------