123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include "ITSSkinF.h"
- #include "ITSUtilF.h"
- #include "AppGlobalF.h"
- #include "CDSRoadF.h"
- #include "CDSIfscF.h"
- #include "ITSLangTransF.h"
- #pragma hdrstop
- #include "TAS0050MF.h"
- #include "TAS00501F.h"
- #include "CDSCodeF.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "cxButtons"
- #pragma link "cxContainer"
- #pragma link "cxControls"
- #pragma link "cxDropDownEdit"
- #pragma link "cxEdit"
- #pragma link "cxGraphics"
- #pragma link "cxGroupBox"
- #pragma link "cxLookAndFeelPainters"
- #pragma link "cxLookAndFeels"
- #pragma link "cxMaskEdit"
- #pragma link "cxPC"
- #pragma link "cxPCdxBarPopupMenu"
- #pragma link "cxTextEdit"
- #pragma link "dxSkinBlack"
- #pragma link "dxSkinBlue"
- #pragma link "dxSkinsCore"
- #pragma link "dxSkinscxPCPainter"
- #pragma resource "*.dfm"
- TTAS0050M *TAS0050M = NULL;
- //---------------------------------------------------------------------------
- __fastcall TTAS0050M::TTAS0050M(TComponent* Owner)
- : TForm(Owner)
- {
- LangTrans->Translate(this, ITSDb_GetConnection());
- ITSSkin_Load(this);
- CMM_LoadForm(g_sFormsDir, this);
- FTitle = Caption;//"우회도로분석";
- m_pFormList = new TList();
- TsList01->TabVisible = false;
- MyItsAtrdManager = new TItsAtrdManager();
- MyItsAtrdManager->LoadFromDb();
- }
- //---------------------------------------------------------------------------
- void __fastcall TTAS0050M::CommClose()
- {
- try
- {
- if (MyItsAtrdManager)
- {
- delete MyItsAtrdManager;
- MyItsAtrdManager = NULL;
- }
- for (int idx = m_pFormList->Count-1; idx >= 0; idx--)
- {
- m_pFormList->Delete(idx);
- }
- delete m_pFormList;
- CMM_SaveForm(g_sFormsDir, this);
- }
- catch(...)
- {
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TTAS0050M::FormShow(TObject *Sender)
- {
- Refresh();
- FormInit();
- TmrShow->Enabled = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TTAS0050M::FormInit()
- {
- FAtrdId = "";
- FAtrdId1 = "";
- CbIfsc->Properties->Items->Clear();
- CbIfsc1->Properties->Items->Clear();
- CbAtrd->Properties->Items->Clear();
- CbAtrd1->Properties->Items->Clear();
- try
- {
- MyItsAtrdManager->FLists.Lock();
- FOR_STL(TItsAtrd*, pObj, MyItsAtrdManager->FLists)
- {
- if (pObj->DEL_YN == "Y") continue;
- String sDir = (pObj->DRCT_CD.Trim() == "0") ? FrmLang->lblUp->Caption : FrmLang->lblDown->Caption;//String("상행") : String("하행");
- String sAtr = pObj->ATRD_NM;
- CbAtrd->Properties->Items->AddObject(sAtr + " [" + sDir + "]", (TObject*)pObj);
- CbAtrd1->Properties->Items->AddObject(sAtr + " [" + sDir + "]", (TObject*)pObj);
- }
- }
- __finally
- {
- MyItsAtrdManager->FLists.UnLock();
- CbAtrd->ItemIndex = 0;
- CbAtrd1->ItemIndex = CbAtrd1->Properties->Items->Count-1;
- }
- DtDay->Date = IncHour(Now(), -24);
- }
- //---------------------------------------------------------------------------
- void __fastcall TTAS0050M::TmrShowTimer(TObject *Sender)
- {
- TmrShow->Enabled = false;
- }
- //---------------------------------------------------------------------------
- void __fastcall TTAS0050M::RefreshData()
- {
- // 검색조건에 의한 링크 데이터 조회
- try
- {
- //SelListData();
- }
- __finally
- {
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TTAS0050M::BtnSearchClick(TObject *Sender)
- {
- Application->ProcessMessages();
- TSqlCursor sqlCrs((TControl*)BtnSearch);
- String sTitle;
- TItsAtrd *pAtrd = (TItsAtrd*)CbAtrd->Properties->Items->Objects[CbAtrd->ItemIndex];
- if (!pAtrd)
- {
- Application->MessageBox(FrmLang->lblSelErr->Caption.c_str(),//L"간선도로를 먼저 선택 하세요.",
- FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
- ActiveControl = CbAtrd;
- return;
- }
- FAtrdId = pAtrd->ATRD_ID;
- FAtrdNm = CbAtrd->Text.Trim();
- TItsIfsc *pIfsc = (TItsIfsc*)CbIfsc->Properties->Items->Objects[CbIfsc->ItemIndex];
- if (!pIfsc)
- {
- Application->MessageBox(FrmLang->lblSelErr->Caption.c_str(),//L"간선도로 구간을 먼저 선택 하세요.",
- FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
- ActiveControl = CbIfsc;
- return;
- }
- FLinkId = pIfsc->IFSC_ID;
- FLinkNm = pIfsc->STRT_NM + " → " + pIfsc->END_NM;
- pAtrd = (TItsAtrd*)CbAtrd1->Properties->Items->Objects[CbAtrd1->ItemIndex];
- if (!pAtrd)
- {
- Application->MessageBox(FrmLang->lblSelErr->Caption.c_str(),//L"간선도로를 먼저 선택 하세요.",
- FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
- ActiveControl = CbAtrd1;
- return;
- }
- FAtrdId1 = pAtrd->ATRD_ID;
- FAtrdNm1 = CbAtrd1->Text.Trim();
- pIfsc = (TItsIfsc*)CbIfsc1->Properties->Items->Objects[CbIfsc1->ItemIndex];
- if (!pIfsc)
- {
- Application->MessageBox(FrmLang->lblSelErr->Caption.c_str(),//L"간선도로 구간을 먼저 선택 하세요.",
- FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
- ActiveControl = CbIfsc1;
- return;
- }
- FLinkId1 = pIfsc->IFSC_ID;
- FLinkNm1 = pIfsc->STRT_NM + " → " + pIfsc->END_NM;
- if (FLinkId == FLinkId1)
- {
- Application->MessageBox(L"간선도로 구간과 우회도로 구간이 일치합니다. 다른 구간을 선택 하세요.", FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
- ActiveControl = CbAtrd;
- return;
- }
- FQryDay = DtDay->Date.FormatString("yyyymmdd");
- sTitle.printf(L"%s/%s [%s] ", FLinkId.c_str(), FLinkId1.c_str(), FQryDay.c_str());
- try
- {
- Application->ProcessMessages();
- LockWindowUpdate(Handle);
- TcxTabSheet *pSheet = CMM_AddTabSheet(PgTab, sTitle);
- if (!pSheet) return;
- TAS00501 = new TTAS00501(this, Handle, FLinkId, FLinkNm, FLinkId1, FLinkNm1, FQryDay);
- TAS00501->Parent = pSheet;
- TAS00501->Show();
- PgTab->ActivePage = pSheet;
- pSheet = PgTab->ActivePage;
- m_pFormList->Add(TAS00501);
- }
- __finally
- {
- LockWindowUpdate(0);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TTAS0050M::BtnCloseClick(TObject *Sender)
- {
- Close();
- }
- //---------------------------------------------------------------------------
- void __fastcall TTAS0050M::OnSubFormClose(TMessage Msg)
- {
- int nActiveIdx = PgTab->ActivePageIndex;
- if (nActiveIdx <= 0) return;
- LockWindowUpdate(Handle);
- TcxTabSheet *pSheet = PgTab->ActivePage;
- if (pSheet)
- {
- delete pSheet;
- }
- nActiveIdx--; // 첫번째 탭은 화면에 숨겨져 있다.
- m_pFormList->Delete(nActiveIdx);
- LockWindowUpdate(0);
- }
- //---------------------------------------------------------------------------
- void __fastcall TTAS0050M::PgTabDblClick(TObject *Sender)
- {
- TPoint APoint;
- APoint = PgTab->MouseDownPos;
- if (PgTab->IndexOfTabAt(APoint.x, APoint.y) != -1)
- POST_MSG(Handle, WM_SUBFORM_CLOSE, 0, 0);
- }
- //---------------------------------------------------------------------------
- void __fastcall TTAS0050M::FormClose(TObject *Sender, TCloseAction &Action)
- {
- CommClose();
- TAS0050M = NULL;
- Action = caFree;
- }
- //---------------------------------------------------------------------------
- void __fastcall TTAS0050M::PgTabCanCloseEx(TObject *Sender, int ATabIndex, bool &ACanClose)
- {
- int nActiveIdx = ATabIndex;
- if (nActiveIdx <= 0) return;
- nActiveIdx--; // 첫번째 탭은 화면에 숨겨져 있다.
- m_pFormList->Delete(nActiveIdx);
- }
- //---------------------------------------------------------------------------
- void __fastcall TTAS0050M::CbAtrdPropertiesChange(TObject *Sender)
- {
- TItsAtrd *pObj = (TItsAtrd*)CbAtrd->Properties->Items->Objects[CbAtrd->ItemIndex];
- if (!pObj) return;
- FAtrdId = pObj->ATRD_ID;
- FAtrdNm = pObj->ATRD_NM;
- CbIfsc->Properties->Items->Clear();
- FOR_STL(TItsAtrdRoad*, pAtrdRoad, pObj->FRoads)
- {
- TItsRoad *pRoad = ItsRoadManager->FLists.Find(pAtrdRoad->ROAD_ID);
- if (!pRoad) continue;
- std::map<int, String>::iterator itPos;
- for(itPos = pRoad->FIfscs.begin(); itPos != pRoad->FIfscs.end(); ++itPos)
- {
- String sIfscId = itPos->second;
- TItsIfsc *pIfsc = ItsIfscManager->FLists.Find(sIfscId);
- if (!pIfsc) continue;
- CbIfsc->Properties->Items->AddObject(" [" + pIfsc->IFSC_ID + "] " + pIfsc->STRT_NM + " → " + pIfsc->END_NM, (TObject*)pIfsc);
- }
- }
- CbIfsc->ItemIndex = 0;
- }
- //---------------------------------------------------------------------------
- void __fastcall TTAS0050M::CbAtrd1PropertiesChange(TObject *Sender)
- {
- TItsAtrd *pObj = (TItsAtrd*)CbAtrd1->Properties->Items->Objects[CbAtrd1->ItemIndex];
- if (!pObj) return;
- FAtrdId1 = pObj->ATRD_ID;
- FAtrdNm1 = pObj->ATRD_NM;
- CbIfsc1->Properties->Items->Clear();
- FOR_STL(TItsAtrdRoad*, pAtrdRoad, pObj->FRoads)
- {
- TItsRoad *pRoad = ItsRoadManager->FLists.Find(pAtrdRoad->ROAD_ID);
- if (!pRoad) continue;
- std::map<int, String>::iterator itPos;
- for(itPos = pRoad->FIfscs.begin(); itPos != pRoad->FIfscs.end(); ++itPos)
- {
- String sIfscId = itPos->second;
- TItsIfsc *pIfsc = ItsIfscManager->FLists.Find(sIfscId);
- if (!pIfsc) continue;
- CbIfsc1->Properties->Items->AddObject(" [" + pIfsc->IFSC_ID + "] " + pIfsc->STRT_NM + " → " + pIfsc->END_NM, (TObject*)pIfsc);
- }
- }
- CbIfsc1->ItemIndex = 0;
- }
- //---------------------------------------------------------------------------
|