IAN0050MF.cpp 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  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 "IAN0050MF.h"
  9. #include "IAN00501F.h"
  10. #include "CDSCodeF.h"
  11. //---------------------------------------------------------------------------
  12. #pragma package(smart_init)
  13. #pragma link "FRAME_LinkListF"
  14. #pragma link "FRAME_RoadListF"
  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 "cxSplitter"
  28. #pragma link "cxTextEdit"
  29. #pragma link "dxSkinBlack"
  30. #pragma link "dxSkinBlue"
  31. #pragma link "dxSkinsCore"
  32. #pragma link "dxSkinscxPCPainter"
  33. #pragma link "cxLabel"
  34. #pragma link "FRAME_IfscListF"
  35. #pragma resource "*.dfm"
  36. TIAN0050M *IAN0050M = NULL;
  37. //---------------------------------------------------------------------------
  38. __fastcall TIAN0050M::TIAN0050M(TComponent* Owner)
  39. : TForm(Owner)
  40. {
  41. LangTrans->Translate(this, ITSDb_GetConnection());
  42. ITSSkin_Load(this);
  43. CMM_LoadForm(g_sFormsDir, this);
  44. FTitle = Caption;//"패턴데이터 분석";
  45. m_pFormList = new TList();
  46. TsList01->TabVisible = false;
  47. FRAMELinkList1->PnlTop->Visible = false;
  48. FRAMELinkList1->PnlBottom->Visible = false;
  49. FRAMEIfscList1->PnlTop->Visible = false;
  50. FRAMEIfscList1->PnlBottom->Visible = false;
  51. FRAMERoadList1->PnlTop->Visible = false;
  52. FRAMERoadList1->PnlBottom->Visible = false;
  53. cxPageControl1->ActivePageIndex = 0;
  54. }
  55. //---------------------------------------------------------------------------
  56. void __fastcall TIAN0050M::CommClose()
  57. {
  58. try
  59. {
  60. for (int idx = m_pFormList->Count-1; idx >= 0; idx--)
  61. {
  62. m_pFormList->Delete(idx);
  63. }
  64. delete m_pFormList;
  65. CMM_SaveForm(g_sFormsDir, this);
  66. }
  67. catch(...)
  68. {
  69. }
  70. }
  71. //---------------------------------------------------------------------------
  72. void __fastcall TIAN0050M::FormShow(TObject *Sender)
  73. {
  74. Refresh();
  75. FormInit();
  76. TmrShow->Enabled = true;
  77. }
  78. //---------------------------------------------------------------------------
  79. void __fastcall TIAN0050M::FormInit()
  80. {
  81. TItsCode *pCode = ItsCodeManager->FLists.Find("DTW");
  82. if (pCode)
  83. {
  84. CbPatternWeek->Properties->Items->Clear();
  85. FOR_STL(TItsSubCode *, pSubCode, pCode->FSubLists)
  86. {
  87. CbPatternWeek->Properties->Items->Add("[" + pSubCode->CMMN_CD + "] " + pSubCode->CMMN_CD_KOR_NM);
  88. }
  89. }
  90. CbPatternWeek->ItemIndex = 0;
  91. DtBaseMon->Date = Now() - 60;
  92. DtDiffMon->Date = Now() - 30;
  93. DtStTime->Time = StrToDateTime("00:00");
  94. DtEdTime->Time = StrToDateTime("23:59");
  95. }
  96. //---------------------------------------------------------------------------
  97. void __fastcall TIAN0050M::TmrShowTimer(TObject *Sender)
  98. {
  99. TmrShow->Enabled = false;
  100. FRAMELinkList1->UpdateList();
  101. FRAMEIfscList1->UpdateList();
  102. FRAMERoadList1->UpdateList();
  103. }
  104. //---------------------------------------------------------------------------
  105. void __fastcall TIAN0050M::RefreshData()
  106. {
  107. // 검색조건에 의한 링크 데이터 조회
  108. try
  109. {
  110. //SelListData();
  111. }
  112. __finally
  113. {
  114. }
  115. }
  116. //---------------------------------------------------------------------------
  117. void __fastcall TIAN0050M::BtnSearchClick(TObject *Sender)
  118. {
  119. Application->ProcessMessages();
  120. TSqlCursor sqlCrs((TControl*)BtnSearch);
  121. TcxGrid *pCxList;
  122. TcxGridTableView *pTvList = NULL;
  123. int nIdCol = -1;
  124. if (cxPageControl1->Properties->ActivePage->PageIndex == 0)
  125. {
  126. pCxList = FRAMELinkList1->CxList;
  127. pTvList = FRAMELinkList1->TvList;
  128. nIdCol = FRAMELinkList1->Column01->Index;
  129. FLinkLevel = 0;
  130. }
  131. else
  132. if (cxPageControl1->Properties->ActivePage->PageIndex == 1)
  133. {
  134. pCxList = FRAMEIfscList1->CxList;
  135. pTvList = FRAMEIfscList1->TvList;
  136. nIdCol = FRAMEIfscList1->Column01->Index;
  137. FLinkLevel = 1;
  138. }
  139. else
  140. {
  141. pCxList = FRAMERoadList1->CxList;
  142. pTvList = FRAMERoadList1->TvList;
  143. nIdCol = FRAMERoadList1->Column01->Index;
  144. FLinkLevel = 2;
  145. }
  146. if (!pTvList) return;
  147. TcxDataController *pGDC = pTvList->DataController;
  148. int nIndex = pGDC->FocusedRecordIndex;
  149. if( nIndex < 0 )
  150. {
  151. Application->MessageBox(FrmLang->lblSelErr->Caption.c_str(),//L"링크를 먼저 선택 하세요.",
  152. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  153. ActiveControl = pCxList;
  154. return;
  155. }
  156. FLinkId = VarToStr(pGDC->Values[nIndex][nIdCol]);
  157. FBaseMon = DtBaseMon->Date.FormatString("yyyymm");
  158. FDiffMon = DtDiffMon->Date.FormatString("yyyymm");
  159. if (FBaseMon == FDiffMon)
  160. {
  161. Application->MessageBox(lblText1->Caption.c_str(),//L"기준월과 비교월이 같습니다. 다르게 선택 하세요.",
  162. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  163. ActiveControl = DtBaseMon;
  164. return;
  165. }
  166. FStTime = DtStTime->Time.FormatString("hhnn");
  167. FEdTime = DtEdTime->Time.FormatString("hhnn");
  168. if (FStTime > FEdTime)
  169. {
  170. Application->MessageBox(FrmLang->lblQryDtErr->Caption.c_str(),//L"검색 시작시각이 검색 종료시각 보다 큽니다.",
  171. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  172. ActiveControl = DtStTime;
  173. return;
  174. }
  175. FPatternType = CbPatternType->ItemIndex;
  176. FPatternWeek = ITSUtil_GetCode(CbPatternWeek->Text);
  177. String sTitle;
  178. sTitle.printf(L"%s - %s(%s)[%s vs %s]%s ", cxPageControl1->Properties->ActivePage->Caption.c_str(),
  179. CbPatternType->Text.t_str(),
  180. CbPatternWeek->Text.t_str(),
  181. FBaseMon.c_str(),
  182. FDiffMon.c_str(),
  183. FLinkId.c_str());
  184. try
  185. {
  186. Application->ProcessMessages();
  187. LockWindowUpdate(Handle);
  188. TcxTabSheet *pSheet = CMM_AddTabSheet(PgTab, sTitle);
  189. if (!pSheet) return;
  190. IAN00501 = new TIAN00501(this, Handle, FLinkId, FBaseMon, FDiffMon, FStTime, FEdTime, FLinkLevel, FPatternType, FPatternWeek, CbPatternWeek->Text);
  191. IAN00501->Parent = pSheet;
  192. IAN00501->Show();
  193. PgTab->ActivePage = pSheet;
  194. pSheet = PgTab->ActivePage;
  195. m_pFormList->Add(IAN00501);
  196. }
  197. __finally
  198. {
  199. LockWindowUpdate(0);
  200. }
  201. }
  202. //---------------------------------------------------------------------------
  203. void __fastcall TIAN0050M::BtnCloseClick(TObject *Sender)
  204. {
  205. Close();
  206. }
  207. //---------------------------------------------------------------------------
  208. void __fastcall TIAN0050M::OnSubFormClose(TMessage Msg)
  209. {
  210. int nActiveIdx = PgTab->ActivePageIndex;
  211. if (nActiveIdx <= 0) return;
  212. LockWindowUpdate(Handle);
  213. TcxTabSheet *pSheet = PgTab->ActivePage;
  214. if (pSheet)
  215. {
  216. delete pSheet;
  217. }
  218. nActiveIdx--; // 첫번째 탭은 화면에 숨겨져 있다.
  219. m_pFormList->Delete(nActiveIdx);
  220. LockWindowUpdate(0);
  221. }
  222. //---------------------------------------------------------------------------
  223. void __fastcall TIAN0050M::PgTabDblClick(TObject *Sender)
  224. {
  225. TPoint APoint;
  226. APoint = PgTab->MouseDownPos;
  227. if (PgTab->IndexOfTabAt(APoint.x, APoint.y) != -1)
  228. POST_MSG(Handle, WM_SUBFORM_CLOSE, 0, 0);
  229. }
  230. //---------------------------------------------------------------------------
  231. void __fastcall TIAN0050M::FormClose(TObject *Sender, TCloseAction &Action)
  232. {
  233. CommClose();
  234. IAN0050M = NULL;
  235. Action = caFree;
  236. }
  237. //---------------------------------------------------------------------------
  238. void __fastcall TIAN0050M::PgTabCanCloseEx(TObject *Sender, int ATabIndex, bool &ACanClose)
  239. {
  240. int nActiveIdx = ATabIndex;
  241. if (nActiveIdx <= 0) return;
  242. nActiveIdx--; // 첫번째 탭은 화면에 숨겨져 있다.
  243. m_pFormList->Delete(nActiveIdx);
  244. }
  245. //---------------------------------------------------------------------------