TAS0050MF.cpp 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  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 "TAS0050MF.h"
  11. #include "TAS00501F.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. TTAS0050M *TAS0050M = NULL;
  34. //---------------------------------------------------------------------------
  35. __fastcall TTAS0050M::TTAS0050M(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 TTAS0050M::CommClose()
  49. {
  50. try
  51. {
  52. if (MyItsAtrdManager)
  53. {
  54. delete MyItsAtrdManager;
  55. MyItsAtrdManager = NULL;
  56. }
  57. for (int idx = m_pFormList->Count-1; idx >= 0; idx--)
  58. {
  59. m_pFormList->Delete(idx);
  60. }
  61. delete m_pFormList;
  62. CMM_SaveForm(g_sFormsDir, this);
  63. }
  64. catch(...)
  65. {
  66. }
  67. }
  68. //---------------------------------------------------------------------------
  69. void __fastcall TTAS0050M::FormShow(TObject *Sender)
  70. {
  71. Refresh();
  72. FormInit();
  73. TmrShow->Enabled = true;
  74. }
  75. //---------------------------------------------------------------------------
  76. void __fastcall TTAS0050M::FormInit()
  77. {
  78. FAtrdId = "";
  79. FAtrdId1 = "";
  80. CbIfsc->Properties->Items->Clear();
  81. CbIfsc1->Properties->Items->Clear();
  82. CbAtrd->Properties->Items->Clear();
  83. CbAtrd1->Properties->Items->Clear();
  84. try
  85. {
  86. MyItsAtrdManager->FLists.Lock();
  87. FOR_STL(TItsAtrd*, pObj, MyItsAtrdManager->FLists)
  88. {
  89. if (pObj->DEL_YN == "Y") continue;
  90. String sDir = (pObj->DRCT_CD.Trim() == "0") ? FrmLang->lblUp->Caption : FrmLang->lblDown->Caption;//String("상행") : String("하행");
  91. String sAtr = pObj->ATRD_NM;
  92. CbAtrd->Properties->Items->AddObject(sAtr + " [" + sDir + "]", (TObject*)pObj);
  93. CbAtrd1->Properties->Items->AddObject(sAtr + " [" + sDir + "]", (TObject*)pObj);
  94. }
  95. }
  96. __finally
  97. {
  98. MyItsAtrdManager->FLists.UnLock();
  99. CbAtrd->ItemIndex = 0;
  100. CbAtrd1->ItemIndex = CbAtrd1->Properties->Items->Count-1;
  101. }
  102. DtDay->Date = IncHour(Now(), -24);
  103. }
  104. //---------------------------------------------------------------------------
  105. void __fastcall TTAS0050M::TmrShowTimer(TObject *Sender)
  106. {
  107. TmrShow->Enabled = false;
  108. }
  109. //---------------------------------------------------------------------------
  110. void __fastcall TTAS0050M::RefreshData()
  111. {
  112. // 검색조건에 의한 링크 데이터 조회
  113. try
  114. {
  115. //SelListData();
  116. }
  117. __finally
  118. {
  119. }
  120. }
  121. //---------------------------------------------------------------------------
  122. void __fastcall TTAS0050M::BtnSearchClick(TObject *Sender)
  123. {
  124. Application->ProcessMessages();
  125. TSqlCursor sqlCrs((TControl*)BtnSearch);
  126. String sTitle;
  127. TItsAtrd *pAtrd = (TItsAtrd*)CbAtrd->Properties->Items->Objects[CbAtrd->ItemIndex];
  128. if (!pAtrd)
  129. {
  130. Application->MessageBox(FrmLang->lblSelErr->Caption.c_str(),//L"간선도로를 먼저 선택 하세요.",
  131. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  132. ActiveControl = CbAtrd;
  133. return;
  134. }
  135. FAtrdId = pAtrd->ATRD_ID;
  136. FAtrdNm = CbAtrd->Text.Trim();
  137. TItsIfsc *pIfsc = (TItsIfsc*)CbIfsc->Properties->Items->Objects[CbIfsc->ItemIndex];
  138. if (!pIfsc)
  139. {
  140. Application->MessageBox(FrmLang->lblSelErr->Caption.c_str(),//L"간선도로 구간을 먼저 선택 하세요.",
  141. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  142. ActiveControl = CbIfsc;
  143. return;
  144. }
  145. FLinkId = pIfsc->IFSC_ID;
  146. FLinkNm = pIfsc->STRT_NM + " → " + pIfsc->END_NM;
  147. pAtrd = (TItsAtrd*)CbAtrd1->Properties->Items->Objects[CbAtrd1->ItemIndex];
  148. if (!pAtrd)
  149. {
  150. Application->MessageBox(FrmLang->lblSelErr->Caption.c_str(),//L"간선도로를 먼저 선택 하세요.",
  151. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  152. ActiveControl = CbAtrd1;
  153. return;
  154. }
  155. FAtrdId1 = pAtrd->ATRD_ID;
  156. FAtrdNm1 = CbAtrd1->Text.Trim();
  157. pIfsc = (TItsIfsc*)CbIfsc1->Properties->Items->Objects[CbIfsc1->ItemIndex];
  158. if (!pIfsc)
  159. {
  160. Application->MessageBox(FrmLang->lblSelErr->Caption.c_str(),//L"간선도로 구간을 먼저 선택 하세요.",
  161. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  162. ActiveControl = CbIfsc1;
  163. return;
  164. }
  165. FLinkId1 = pIfsc->IFSC_ID;
  166. FLinkNm1 = pIfsc->STRT_NM + " → " + pIfsc->END_NM;
  167. if (FLinkId == FLinkId1)
  168. {
  169. Application->MessageBox(L"간선도로 구간과 우회도로 구간이 일치합니다. 다른 구간을 선택 하세요.", FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  170. ActiveControl = CbAtrd;
  171. return;
  172. }
  173. FQryDay = DtDay->Date.FormatString("yyyymmdd");
  174. sTitle.printf(L"%s/%s [%s] ", FLinkId.c_str(), FLinkId1.c_str(), FQryDay.c_str());
  175. try
  176. {
  177. Application->ProcessMessages();
  178. LockWindowUpdate(Handle);
  179. TcxTabSheet *pSheet = CMM_AddTabSheet(PgTab, sTitle);
  180. if (!pSheet) return;
  181. TAS00501 = new TTAS00501(this, Handle, FLinkId, FLinkNm, FLinkId1, FLinkNm1, FQryDay);
  182. TAS00501->Parent = pSheet;
  183. TAS00501->Show();
  184. PgTab->ActivePage = pSheet;
  185. pSheet = PgTab->ActivePage;
  186. m_pFormList->Add(TAS00501);
  187. }
  188. __finally
  189. {
  190. LockWindowUpdate(0);
  191. }
  192. }
  193. //---------------------------------------------------------------------------
  194. void __fastcall TTAS0050M::BtnCloseClick(TObject *Sender)
  195. {
  196. Close();
  197. }
  198. //---------------------------------------------------------------------------
  199. void __fastcall TTAS0050M::OnSubFormClose(TMessage Msg)
  200. {
  201. int nActiveIdx = PgTab->ActivePageIndex;
  202. if (nActiveIdx <= 0) return;
  203. LockWindowUpdate(Handle);
  204. TcxTabSheet *pSheet = PgTab->ActivePage;
  205. if (pSheet)
  206. {
  207. delete pSheet;
  208. }
  209. nActiveIdx--; // 첫번째 탭은 화면에 숨겨져 있다.
  210. m_pFormList->Delete(nActiveIdx);
  211. LockWindowUpdate(0);
  212. }
  213. //---------------------------------------------------------------------------
  214. void __fastcall TTAS0050M::PgTabDblClick(TObject *Sender)
  215. {
  216. TPoint APoint;
  217. APoint = PgTab->MouseDownPos;
  218. if (PgTab->IndexOfTabAt(APoint.x, APoint.y) != -1)
  219. POST_MSG(Handle, WM_SUBFORM_CLOSE, 0, 0);
  220. }
  221. //---------------------------------------------------------------------------
  222. void __fastcall TTAS0050M::FormClose(TObject *Sender, TCloseAction &Action)
  223. {
  224. CommClose();
  225. TAS0050M = NULL;
  226. Action = caFree;
  227. }
  228. //---------------------------------------------------------------------------
  229. void __fastcall TTAS0050M::PgTabCanCloseEx(TObject *Sender, int ATabIndex, bool &ACanClose)
  230. {
  231. int nActiveIdx = ATabIndex;
  232. if (nActiveIdx <= 0) return;
  233. nActiveIdx--; // 첫번째 탭은 화면에 숨겨져 있다.
  234. m_pFormList->Delete(nActiveIdx);
  235. }
  236. //---------------------------------------------------------------------------
  237. void __fastcall TTAS0050M::CbAtrdPropertiesChange(TObject *Sender)
  238. {
  239. TItsAtrd *pObj = (TItsAtrd*)CbAtrd->Properties->Items->Objects[CbAtrd->ItemIndex];
  240. if (!pObj) return;
  241. FAtrdId = pObj->ATRD_ID;
  242. FAtrdNm = pObj->ATRD_NM;
  243. CbIfsc->Properties->Items->Clear();
  244. FOR_STL(TItsAtrdRoad*, pAtrdRoad, pObj->FRoads)
  245. {
  246. TItsRoad *pRoad = ItsRoadManager->FLists.Find(pAtrdRoad->ROAD_ID);
  247. if (!pRoad) continue;
  248. std::map<int, String>::iterator itPos;
  249. for(itPos = pRoad->FIfscs.begin(); itPos != pRoad->FIfscs.end(); ++itPos)
  250. {
  251. String sIfscId = itPos->second;
  252. TItsIfsc *pIfsc = ItsIfscManager->FLists.Find(sIfscId);
  253. if (!pIfsc) continue;
  254. CbIfsc->Properties->Items->AddObject(" [" + pIfsc->IFSC_ID + "] " + pIfsc->STRT_NM + " → " + pIfsc->END_NM, (TObject*)pIfsc);
  255. }
  256. }
  257. CbIfsc->ItemIndex = 0;
  258. }
  259. //---------------------------------------------------------------------------
  260. void __fastcall TTAS0050M::CbAtrd1PropertiesChange(TObject *Sender)
  261. {
  262. TItsAtrd *pObj = (TItsAtrd*)CbAtrd1->Properties->Items->Objects[CbAtrd1->ItemIndex];
  263. if (!pObj) return;
  264. FAtrdId1 = pObj->ATRD_ID;
  265. FAtrdNm1 = pObj->ATRD_NM;
  266. CbIfsc1->Properties->Items->Clear();
  267. FOR_STL(TItsAtrdRoad*, pAtrdRoad, pObj->FRoads)
  268. {
  269. TItsRoad *pRoad = ItsRoadManager->FLists.Find(pAtrdRoad->ROAD_ID);
  270. if (!pRoad) continue;
  271. std::map<int, String>::iterator itPos;
  272. for(itPos = pRoad->FIfscs.begin(); itPos != pRoad->FIfscs.end(); ++itPos)
  273. {
  274. String sIfscId = itPos->second;
  275. TItsIfsc *pIfsc = ItsIfscManager->FLists.Find(sIfscId);
  276. if (!pIfsc) continue;
  277. CbIfsc1->Properties->Items->AddObject(" [" + pIfsc->IFSC_ID + "] " + pIfsc->STRT_NM + " → " + pIfsc->END_NM, (TObject*)pIfsc);
  278. }
  279. }
  280. CbIfsc1->ItemIndex = 0;
  281. }
  282. //---------------------------------------------------------------------------