IST0040MF.cpp 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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 resource "*.dfm"
  32. TIST0040M *IST0040M = NULL;
  33. //---------------------------------------------------------------------------
  34. __fastcall TIST0040M::TIST0040M(TComponent* Owner)
  35. : TForm(Owner)
  36. {
  37. LangTrans->Translate(this, ITSDb_GetConnection());
  38. ITSSkin_Load(this);
  39. CMM_LoadForm(g_sFormsDir, this);
  40. FTitle = Caption;//"돌발상황 통계";
  41. m_pFormList = new TList();
  42. TsList01->TabVisible = false;
  43. #if 0
  44. FCodeIDTU = ItsCodeManager->FLists.Find("IDTU");
  45. CbInciType->Properties->Items->Clear();
  46. if (FCodeIDTU)
  47. {
  48. FOR_STL(TItsSubCode *, pSubCode, FCodeIDTU->FSubLists)
  49. {
  50. CbInciType->Properties->Items->Add("[" + pSubCode->CMMN_CD + "] " + pSubCode->CMMN_CD_KOR_NM);
  51. }
  52. }
  53. CbInciType->ItemIndex = 0;
  54. #endif
  55. }
  56. //---------------------------------------------------------------------------
  57. /*
  58. * 닫기버튼 이나 x버튼 클릭시 공통으로 처리하는 로직이들어간다..
  59. * Form과 DataModule class를 delete시킨다.
  60. * arguments
  61. *
  62. * return
  63. * void
  64. */
  65. void __fastcall TIST0040M::CommClose()
  66. {
  67. try
  68. {
  69. for (int idx = m_pFormList->Count-1; idx >= 0; idx--)
  70. {
  71. m_pFormList->Delete(idx);
  72. }
  73. delete m_pFormList;
  74. CMM_SaveForm(g_sFormsDir, this);
  75. }
  76. catch(...)
  77. {
  78. }
  79. }
  80. //---------------------------------------------------------------------------
  81. /*
  82. * Form을 보여줄때 호출되는 event 메서드이다.
  83. * arguments
  84. * Sender : event handler 객체
  85. * return
  86. * void
  87. */
  88. void __fastcall TIST0040M::FormShow(TObject *Sender)
  89. {
  90. Refresh();
  91. FormInit();
  92. TmrShow->Enabled = true;
  93. }
  94. //---------------------------------------------------------------------------
  95. /*
  96. * form 초기화
  97. *
  98. * arguments
  99. *
  100. * return
  101. * void
  102. */
  103. void __fastcall TIST0040M::FormInit()
  104. {
  105. CbStatType->ItemIndex = 0;
  106. TDateTime dtStart = Now()-1;
  107. TDateTime dtEnd = Now();
  108. DtStDate->Date = dtStart;
  109. DtEdDate->Date = dtEnd;
  110. }
  111. //---------------------------------------------------------------------------
  112. /*
  113. * Form이 Show되고 난 후 최초 1회 수행되는 타이머 이벤트
  114. * arguments
  115. * Sender : event handler 객체
  116. * return
  117. * void
  118. */
  119. void __fastcall TIST0040M::TmrShowTimer(TObject *Sender)
  120. {
  121. TmrShow->Enabled = false;
  122. }
  123. //---------------------------------------------------------------------------
  124. /*
  125. * Refresh Data Event Function
  126. * arguments
  127. *
  128. * return
  129. * void
  130. */
  131. void __fastcall TIST0040M::RefreshData()
  132. {
  133. // 검색조건에 의한 링크 데이터 조회
  134. try
  135. {
  136. //SelListData();
  137. }
  138. __finally
  139. {
  140. }
  141. }
  142. //---------------------------------------------------------------------------
  143. /*
  144. * Search 버튼 클릭 이벤트 핸들러
  145. * arguments
  146. * Sender : event handler 객체
  147. * return
  148. * void
  149. */
  150. void __fastcall TIST0040M::BtnSearchClick(TObject *Sender)
  151. {
  152. Application->ProcessMessages();
  153. TSqlCursor sqlCrs((TControl*)BtnSearch);
  154. TcxGrid *pCxList;
  155. TcxGridTableView *pTvList = NULL;
  156. String sStTime, sEdTime, sTemp;
  157. switch(CbStatTerm->ItemIndex)
  158. {
  159. case 0: //일간통계
  160. sStTime = DtStDate->Date.FormatString("yyyyMMdd");
  161. sEdTime = DtEdDate->Date.FormatString("yyyyMMdd");
  162. FStTime = sStTime + "000000";
  163. FEdTime = sEdTime + "235959";
  164. break;
  165. case 1: //월통계
  166. sStTime = DtStDate->Date.FormatString("yyyyMM");
  167. sEdTime = DtEdDate->Date.FormatString("yyyyMM");
  168. sTemp.printf(L"%02d", ITSUtil_GetMonthLastDay(AnsiString(sEdTime).c_str()));
  169. FStTime = sStTime + "01000000";
  170. FEdTime = sEdTime + sTemp + "235959";
  171. break;
  172. case 2: //년통계
  173. sStTime = DtStDate->Date.FormatString("yyyy");
  174. sEdTime = DtEdDate->Date.FormatString("yyyy");
  175. FStTime = sStTime + "0101000000";
  176. FEdTime = sEdTime + "1231235959";
  177. break;
  178. }
  179. if (sStTime > sEdTime)
  180. {
  181. Application->MessageBox(FrmLang->lblQryDtErr->Caption.c_str(),//L"검색 시작시각이 검색 종료시각 보다 큽니다.",
  182. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  183. ActiveControl = DtStDate;
  184. return;
  185. }
  186. FStatType = CbStatType->ItemIndex;
  187. FTermType = CbStatTerm->ItemIndex;
  188. FIncidentType = "";//ITSUtil_GetCode(CbInciType->Text);
  189. String sTitle;
  190. sTitle.printf(L"%s - %s(%s~%s) ", CbStatType->Text.c_str(),
  191. CbStatTerm->Text.c_str(),
  192. sStTime.c_str(),
  193. sEdTime.c_str());
  194. try
  195. {
  196. Application->ProcessMessages();
  197. LockWindowUpdate(Handle);
  198. TcxTabSheet *pSheet = CMM_AddTabSheet(PgTab, sTitle);
  199. if (!pSheet) return;
  200. IST00401 = new TIST00401(this, Handle, FStatType, FTermType, FStTime, FEdTime, true, FIncidentType, sTitle);
  201. IST00401->Parent = pSheet;
  202. IST00401->Show();
  203. PgTab->ActivePage = pSheet;
  204. pSheet = PgTab->ActivePage;
  205. m_pFormList->Add(IST00401);
  206. }
  207. __finally
  208. {
  209. LockWindowUpdate(0);
  210. }
  211. }
  212. //---------------------------------------------------------------------------
  213. /*
  214. * Close 버튼 클릭 이벤트 핸들러
  215. * arguments
  216. * Sender : event handler 객체
  217. * return
  218. * void
  219. */
  220. void __fastcall TIST0040M::BtnCloseClick(TObject *Sender)
  221. {
  222. Close();
  223. }
  224. //---------------------------------------------------------------------------
  225. /*
  226. * 조회결과 폼이 닫힐때 메시지를 받아 처리한다.
  227. * arguments
  228. * Sender : event handler 객체
  229. * return
  230. * void
  231. */
  232. void __fastcall TIST0040M::OnSubFormClose(TMessage Msg)
  233. {
  234. int nActiveIdx = PgTab->ActivePageIndex;
  235. if (nActiveIdx <= 0) return;
  236. LockWindowUpdate(Handle);
  237. TcxTabSheet *pSheet = PgTab->ActivePage;
  238. if (pSheet)
  239. {
  240. delete pSheet;
  241. }
  242. nActiveIdx--; // 첫번째 탭은 화면에 숨겨져 있다.
  243. m_pFormList->Delete(nActiveIdx);
  244. LockWindowUpdate(0);
  245. }
  246. //---------------------------------------------------------------------------
  247. /*
  248. * Tab Control의 Tab을 더블클릭하여 닫는다.
  249. * arguments
  250. * Sender : event handler 객체
  251. * return
  252. * void
  253. */
  254. void __fastcall TIST0040M::PgTabDblClick(TObject *Sender)
  255. {
  256. TPoint APoint;
  257. APoint = PgTab->MouseDownPos;
  258. if (PgTab->IndexOfTabAt(APoint.x, APoint.y) != -1)
  259. POST_MSG(Handle, WM_SUBFORM_CLOSE, 0, 0);
  260. }
  261. //---------------------------------------------------------------------------
  262. void __fastcall TIST0040M::FormClose(TObject *Sender, TCloseAction &Action)
  263. {
  264. CommClose();
  265. IST0040M = NULL;
  266. Action = caFree;
  267. }
  268. //---------------------------------------------------------------------------
  269. void __fastcall TIST0040M::CbStatTermPropertiesChange(TObject *Sender)
  270. {
  271. switch(CbStatTerm->ItemIndex)
  272. {
  273. case 0: //일간통계
  274. DtStDate->Format = " yyyy년 MM월 dd일";
  275. DtEdDate->Format = " yyyy년 MM월 dd일";
  276. break;
  277. case 1: //월통계
  278. DtStDate->Format = " yyyy년 MM월";
  279. DtEdDate->Format = " yyyy년 MM월";
  280. break;
  281. case 2: //년통계
  282. DtStDate->Format = " yyyy년";
  283. DtEdDate->Format = " yyyy년";
  284. break;
  285. }
  286. }
  287. //---------------------------------------------------------------------------
  288. void __fastcall TIST0040M::PgTabCanCloseEx(TObject *Sender, int ATabIndex, bool &ACanClose)
  289. {
  290. int nActiveIdx = ATabIndex;
  291. if (nActiveIdx <= 0) return;
  292. nActiveIdx--; // 첫번째 탭은 화면에 숨겨져 있다.
  293. m_pFormList->Delete(nActiveIdx);
  294. }
  295. //---------------------------------------------------------------------------