TAS0020MF.cpp 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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 "TAS0020MF.h"
  9. #include "TAS00201F.h"
  10. #include "CDSCodeF.h"
  11. //---------------------------------------------------------------------------
  12. #pragma package(smart_init)
  13. #pragma link "cxButtons"
  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 "cxLookAndFeelPainters"
  21. #pragma link "cxLookAndFeels"
  22. #pragma link "cxMaskEdit"
  23. #pragma link "cxPC"
  24. #pragma link "cxPCdxBarPopupMenu"
  25. #pragma link "cxTextEdit"
  26. #pragma link "dxSkinBlack"
  27. #pragma link "dxSkinBlue"
  28. #pragma link "dxSkinsCore"
  29. #pragma link "dxSkinscxPCPainter"
  30. #pragma resource "*.dfm"
  31. TTAS0020M *TAS0020M = NULL;
  32. //---------------------------------------------------------------------------
  33. __fastcall TTAS0020M::TTAS0020M(TComponent* Owner)
  34. : TForm(Owner)
  35. {
  36. LangTrans->Translate(this, ITSDb_GetConnection());
  37. ITSSkin_Load(this);
  38. CMM_LoadForm(g_sFormsDir, this);
  39. FTitle = Caption;//"교통패턴분석";
  40. m_pFormList = new TList();
  41. TsList01->TabVisible = false;
  42. MyItsAtrdManager = new TItsAtrdManager();
  43. MyItsAtrdManager->LoadFromDb();
  44. }
  45. //---------------------------------------------------------------------------
  46. void __fastcall TTAS0020M::CommClose()
  47. {
  48. try
  49. {
  50. if (MyItsAtrdManager)
  51. {
  52. delete MyItsAtrdManager;
  53. MyItsAtrdManager = NULL;
  54. }
  55. for (int idx = m_pFormList->Count-1; idx >= 0; idx--)
  56. {
  57. m_pFormList->Delete(idx);
  58. }
  59. delete m_pFormList;
  60. CMM_SaveForm(g_sFormsDir, this);
  61. }
  62. catch(...)
  63. {
  64. }
  65. }
  66. //---------------------------------------------------------------------------
  67. void __fastcall TTAS0020M::FormShow(TObject *Sender)
  68. {
  69. Refresh();
  70. FormInit();
  71. TmrShow->Enabled = true;
  72. }
  73. //---------------------------------------------------------------------------
  74. void __fastcall TTAS0020M::FormInit()
  75. {
  76. CbAtrd->Properties->Items->Clear();
  77. try
  78. {
  79. MyItsAtrdManager->FNameLists.Lock();
  80. FOR_STL(TItsAtrdName*, pObj, MyItsAtrdManager->FNameLists)
  81. {
  82. CbAtrd->Properties->Items->AddObject(pObj->Name, (TObject*)pObj);
  83. }
  84. }
  85. __finally
  86. {
  87. MyItsAtrdManager->FNameLists.UnLock();
  88. CbAtrd->ItemIndex = 0;
  89. }
  90. #if 0
  91. try
  92. {
  93. MyItsAtrdManager->FLists.Lock();
  94. FOR_STL(TItsAtrd*, pObj, MyItsAtrdManager->FLists)
  95. {
  96. if (pObj->DEL_YN == "Y") continue;
  97. String sDir = (pObj->DRCT_CD.Trim() == "0") ? FrmLang->lblUp->Caption : FrmLang->lblDown->Caption;String("상행") : String("하행");
  98. String sAtr = pObj->ATRD_NM;
  99. CbAtrd->Properties->Items->AddObject(sAtr + " [" + sDir + "]", (TObject*)pObj);
  100. }
  101. }
  102. __finally
  103. {
  104. MyItsAtrdManager->FLists.UnLock();
  105. CbAtrd->ItemIndex = 0;
  106. }
  107. #endif
  108. TItsCode *pCode = ItsCodeManager->FLists.Find("DTW");
  109. if (pCode)
  110. {
  111. CbPatternWeek->Properties->Items->Clear();
  112. FOR_STL(TItsSubCode *, pSubCode, pCode->FSubLists)
  113. {
  114. CbPatternWeek->Properties->Items->Add("[" + pSubCode->CMMN_CD + "] " + pSubCode->CMMN_CD_KOR_NM);
  115. }
  116. }
  117. CbPatternWeek->ItemIndex = 0;
  118. DtBaseMon->Date = Now();// - 30;
  119. }
  120. //---------------------------------------------------------------------------
  121. void __fastcall TTAS0020M::TmrShowTimer(TObject *Sender)
  122. {
  123. TmrShow->Enabled = false;
  124. }
  125. //---------------------------------------------------------------------------
  126. void __fastcall TTAS0020M::RefreshData()
  127. {
  128. // 검색조건에 의한 링크 데이터 조회
  129. try
  130. {
  131. //SelListData();
  132. }
  133. __finally
  134. {
  135. }
  136. }
  137. //---------------------------------------------------------------------------
  138. void __fastcall TTAS0020M::BtnSearchClick(TObject *Sender)
  139. {
  140. Application->ProcessMessages();
  141. TSqlCursor sqlCrs((TControl*)BtnSearch);
  142. String sTitle;
  143. FQryDay = DtBaseMon->Date.FormatString("yyyymm");
  144. FPtrnWeek = ITSUtil_GetCode(CbPatternWeek->Text);
  145. FPtrnWeekName = CbPatternWeek->Text;
  146. FAtrdId = CbAtrd->Text.Trim();
  147. FAtrdNm = CbAtrd->Text.Trim();
  148. #if 0
  149. if (CbAtrd->ItemIndex == 0)
  150. {
  151. FAtrdId = "";
  152. FAtrdNm = FrmLang->lblChartTotal->Caption;//"전체";
  153. }
  154. #endif
  155. sTitle.printf(L"%s(%s) %s ", FQryDay.c_str(), CbPatternWeek->Text.t_str(), FAtrdNm.c_str());
  156. try
  157. {
  158. Application->ProcessMessages();
  159. LockWindowUpdate(Handle);
  160. TcxTabSheet *pSheet = CMM_AddTabSheet(PgTab, sTitle);
  161. if (!pSheet) return;
  162. TAS00201 = new TTAS00201(this, Handle, FAtrdId, FAtrdNm, FQryDay, FPtrnWeek, FPtrnWeekName);
  163. TAS00201->Parent = pSheet;
  164. TAS00201->Show();
  165. PgTab->ActivePage = pSheet;
  166. pSheet = PgTab->ActivePage;
  167. m_pFormList->Add(TAS00201);
  168. }
  169. __finally
  170. {
  171. LockWindowUpdate(0);
  172. }
  173. }
  174. //---------------------------------------------------------------------------
  175. void __fastcall TTAS0020M::BtnCloseClick(TObject *Sender)
  176. {
  177. Close();
  178. }
  179. //---------------------------------------------------------------------------
  180. void __fastcall TTAS0020M::OnSubFormClose(TMessage Msg)
  181. {
  182. int nActiveIdx = PgTab->ActivePageIndex;
  183. if (nActiveIdx <= 0) return;
  184. LockWindowUpdate(Handle);
  185. TcxTabSheet *pSheet = PgTab->ActivePage;
  186. if (pSheet)
  187. {
  188. delete pSheet;
  189. }
  190. nActiveIdx--; // 첫번째 탭은 화면에 숨겨져 있다.
  191. m_pFormList->Delete(nActiveIdx);
  192. LockWindowUpdate(0);
  193. }
  194. //---------------------------------------------------------------------------
  195. void __fastcall TTAS0020M::PgTabDblClick(TObject *Sender)
  196. {
  197. TPoint APoint;
  198. APoint = PgTab->MouseDownPos;
  199. if (PgTab->IndexOfTabAt(APoint.x, APoint.y) != -1)
  200. POST_MSG(Handle, WM_SUBFORM_CLOSE, 0, 0);
  201. }
  202. //---------------------------------------------------------------------------
  203. void __fastcall TTAS0020M::FormClose(TObject *Sender, TCloseAction &Action)
  204. {
  205. CommClose();
  206. TAS0020M = NULL;
  207. Action = caFree;
  208. }
  209. //---------------------------------------------------------------------------
  210. void __fastcall TTAS0020M::PgTabCanCloseEx(TObject *Sender, int ATabIndex, bool &ACanClose)
  211. {
  212. int nActiveIdx = ATabIndex;
  213. if (nActiveIdx <= 0) return;
  214. nActiveIdx--; // 첫번째 탭은 화면에 숨겨져 있다.
  215. m_pFormList->Delete(nActiveIdx);
  216. }
  217. //---------------------------------------------------------------------------