IST0040MF.cpp 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "ITSUtilF.h"
  5. #include "AppGlobalF.h"
  6. #include "CDSCodeF.h"
  7. #include "ITSLangTransF.h"
  8. #pragma hdrstop
  9. #include "IST0040MF.h"
  10. #include "IST00401F.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 "cxSplitter"
  26. #pragma link "cxTextEdit"
  27. #pragma link "dxSkinBlack"
  28. #pragma link "dxSkinBlue"
  29. #pragma link "dxSkinsCore"
  30. #pragma link "dxSkinscxPCPainter"
  31. #pragma link "cxCalendar"
  32. #pragma resource "*.dfm"
  33. TIST0040M *IST0040M = NULL;
  34. //---------------------------------------------------------------------------
  35. __fastcall TIST0040M::TIST0040M(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. #if 0
  45. FCodeIDTU = ItsCodeManager->FLists.Find("IDTU");
  46. CbInciType->Properties->Items->Clear();
  47. if (FCodeIDTU)
  48. {
  49. FOR_STL(TItsSubCode *, pSubCode, FCodeIDTU->FSubLists)
  50. {
  51. CbInciType->Properties->Items->Add("[" + pSubCode->CMMN_CD + "] " + pSubCode->CMMN_CD_KOR_NM);
  52. }
  53. }
  54. CbInciType->ItemIndex = 0;
  55. #endif
  56. }
  57. //---------------------------------------------------------------------------
  58. void __fastcall TIST0040M::CommClose()
  59. {
  60. try
  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 TIST0040M::FormShow(TObject *Sender)
  75. {
  76. Refresh();
  77. FormInit();
  78. TmrShow->Enabled = true;
  79. }
  80. //---------------------------------------------------------------------------
  81. void __fastcall TIST0040M::FormInit()
  82. {
  83. CbStatType->ItemIndex = 0;
  84. TDateTime dtStart = Now()-1;
  85. TDateTime dtEnd = Now();
  86. DtStDate->Date = dtStart;
  87. DtEdDate->Date = dtEnd;
  88. }
  89. //---------------------------------------------------------------------------
  90. void __fastcall TIST0040M::TmrShowTimer(TObject *Sender)
  91. {
  92. TmrShow->Enabled = false;
  93. }
  94. //---------------------------------------------------------------------------
  95. void __fastcall TIST0040M::RefreshData()
  96. {
  97. // 검색조건에 의한 링크 데이터 조회
  98. try
  99. {
  100. //SelListData();
  101. }
  102. __finally
  103. {
  104. }
  105. }
  106. //---------------------------------------------------------------------------
  107. void __fastcall TIST0040M::BtnSearchClick(TObject *Sender)
  108. {
  109. Application->ProcessMessages();
  110. TSqlCursor sqlCrs((TControl*)BtnSearch);
  111. TcxGrid *pCxList;
  112. TcxGridTableView *pTvList = NULL;
  113. String sStTime, sEdTime, sTemp;
  114. switch(CbStatTerm->ItemIndex)
  115. {
  116. case 0: //일간통계
  117. sStTime = DtStDate->Date.FormatString("yyyyMMdd");
  118. sEdTime = DtEdDate->Date.FormatString("yyyyMMdd");
  119. FStTime = sStTime + "000000";
  120. FEdTime = sEdTime + "235959";
  121. break;
  122. case 1: //월통계
  123. sStTime = DtStDate->Date.FormatString("yyyyMM");
  124. sEdTime = DtEdDate->Date.FormatString("yyyyMM");
  125. sTemp.printf(L"%02d", ITSUtil_GetMonthLastDay(AnsiString(sEdTime).c_str()));
  126. FStTime = sStTime + "01000000";
  127. FEdTime = sEdTime + sTemp + "235959";
  128. break;
  129. case 2: //년통계
  130. sStTime = DtStDate->Date.FormatString("yyyy");
  131. sEdTime = DtEdDate->Date.FormatString("yyyy");
  132. FStTime = sStTime + "0101000000";
  133. FEdTime = sEdTime + "1231235959";
  134. break;
  135. }
  136. if (sStTime > sEdTime)
  137. {
  138. Application->MessageBox(FrmLang->lblQryDtErr->Caption.c_str(),//L"검색 시작시각이 검색 종료시각 보다 큽니다.",
  139. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  140. ActiveControl = DtStDate;
  141. return;
  142. }
  143. FStatType = CbStatType->ItemIndex;
  144. FTermType = CbStatTerm->ItemIndex;
  145. FIncidentType = "";//ITSUtil_GetCode(CbInciType->Text);
  146. String sTitle;
  147. sTitle.printf(L"%s - %s(%s~%s) ", CbStatType->Text.c_str(),
  148. CbStatTerm->Text.c_str(),
  149. sStTime.c_str(),
  150. sEdTime.c_str());
  151. try
  152. {
  153. Application->ProcessMessages();
  154. LockWindowUpdate(Handle);
  155. TcxTabSheet *pSheet = CMM_AddTabSheet(PgTab, sTitle);
  156. if (!pSheet) return;
  157. IST00401 = new TIST00401(this, Handle, FStatType, FTermType, FStTime, FEdTime, true, FIncidentType, sTitle);
  158. IST00401->Parent = pSheet;
  159. IST00401->Show();
  160. PgTab->ActivePage = pSheet;
  161. pSheet = PgTab->ActivePage;
  162. m_pFormList->Add(IST00401);
  163. }
  164. __finally
  165. {
  166. LockWindowUpdate(0);
  167. }
  168. }
  169. //---------------------------------------------------------------------------
  170. void __fastcall TIST0040M::BtnCloseClick(TObject *Sender)
  171. {
  172. Close();
  173. }
  174. //---------------------------------------------------------------------------
  175. void __fastcall TIST0040M::OnSubFormClose(TMessage Msg)
  176. {
  177. int nActiveIdx = PgTab->ActivePageIndex;
  178. if (nActiveIdx <= 0) return;
  179. LockWindowUpdate(Handle);
  180. TcxTabSheet *pSheet = PgTab->ActivePage;
  181. if (pSheet)
  182. {
  183. delete pSheet;
  184. }
  185. nActiveIdx--; // 첫번째 탭은 화면에 숨겨져 있다.
  186. m_pFormList->Delete(nActiveIdx);
  187. LockWindowUpdate(0);
  188. }
  189. //---------------------------------------------------------------------------
  190. void __fastcall TIST0040M::PgTabDblClick(TObject *Sender)
  191. {
  192. TPoint APoint;
  193. APoint = PgTab->MouseDownPos;
  194. if (PgTab->IndexOfTabAt(APoint.x, APoint.y) != -1)
  195. POST_MSG(Handle, WM_SUBFORM_CLOSE, 0, 0);
  196. }
  197. //---------------------------------------------------------------------------
  198. void __fastcall TIST0040M::FormClose(TObject *Sender, TCloseAction &Action)
  199. {
  200. CommClose();
  201. IST0040M = NULL;
  202. Action = caFree;
  203. }
  204. //---------------------------------------------------------------------------
  205. void __fastcall TIST0040M::CbStatTermPropertiesChange(TObject *Sender)
  206. {
  207. switch(CbStatTerm->ItemIndex)
  208. {
  209. case 0: //일간통계
  210. DtStDate->Format = " yyyy년 MM월 dd일";
  211. DtEdDate->Format = " yyyy년 MM월 dd일";
  212. break;
  213. case 1: //월통계
  214. DtStDate->Format = " yyyy년 MM월";
  215. DtEdDate->Format = " yyyy년 MM월";
  216. break;
  217. case 2: //년통계
  218. DtStDate->Format = " yyyy년";
  219. DtEdDate->Format = " yyyy년";
  220. break;
  221. }
  222. }
  223. //---------------------------------------------------------------------------
  224. void __fastcall TIST0040M::PgTabCanCloseEx(TObject *Sender, int ATabIndex, bool &ACanClose)
  225. {
  226. int nActiveIdx = ATabIndex;
  227. if (nActiveIdx <= 0) return;
  228. nActiveIdx--; // 첫번째 탭은 화면에 숨겨져 있다.
  229. m_pFormList->Delete(nActiveIdx);
  230. }
  231. //---------------------------------------------------------------------------