DSRH070MF.cpp 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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 "DSRH070MF.h"
  9. #include "DSRH0701F.h"
  10. //---------------------------------------------------------------------------
  11. #pragma package(smart_init)
  12. #pragma link "FRAME_DsrcListF"
  13. #pragma link "cxButtons"
  14. #pragma link "cxCalendar"
  15. #pragma link "cxContainer"
  16. #pragma link "cxControls"
  17. #pragma link "cxDropDownEdit"
  18. #pragma link "cxEdit"
  19. #pragma link "cxGraphics"
  20. #pragma link "cxGroupBox"
  21. #pragma link "cxLabel"
  22. #pragma link "cxLookAndFeelPainters"
  23. #pragma link "cxLookAndFeels"
  24. #pragma link "cxMaskEdit"
  25. #pragma link "cxPC"
  26. #pragma link "cxPCdxBarPopupMenu"
  27. #pragma link "cxSpinEdit"
  28. #pragma link "cxSplitter"
  29. #pragma link "cxTextEdit"
  30. #pragma link "cxTimeEdit"
  31. #pragma link "dxSkinBlack"
  32. #pragma link "dxSkinBlue"
  33. #pragma link "dxSkinsCore"
  34. #pragma link "dxSkinscxPCPainter"
  35. #pragma link "dxSkinMcSkin"
  36. #pragma resource "*.dfm"
  37. TDSRH070M *DSRH070M = NULL;
  38. //---------------------------------------------------------------------------
  39. __fastcall TDSRH070M::TDSRH070M(TComponent* Owner)
  40. : TForm(Owner)
  41. {
  42. LangTrans->Translate(this, ITSDb_GetConnection());
  43. ITSSkin_Load(this);
  44. CMM_LoadForm(g_sFormsDir, this);
  45. FTitle = Caption;
  46. m_pFormList = new TList();
  47. TsList01->TabVisible = false;
  48. FRAMEDsrcList1->PnlBottom->Visible = false;
  49. }
  50. //---------------------------------------------------------------------------
  51. void __fastcall TDSRH070M::CommClose()
  52. {
  53. try
  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 TDSRH070M::FormShow(TObject *Sender)
  68. {
  69. Refresh();
  70. FormInit();
  71. TmrShow->Enabled = true;
  72. }
  73. //---------------------------------------------------------------------------
  74. void __fastcall TDSRH070M::FormInit()
  75. {
  76. DtStDate->Date = Now() - 1;// - 1;
  77. DtEdDate->Date = Now() - 1;
  78. //DtEdTime->EditValue = Now().FormatString("hh");
  79. DtStTime->Time = StrToDateTime("00:00");
  80. DtEdTime->Time = StrToDateTime("23:59");
  81. InitCode();
  82. }
  83. //---------------------------------------------------------------------------
  84. void __fastcall TDSRH070M::TmrShowTimer(TObject *Sender)
  85. {
  86. TmrShow->Enabled = false;
  87. FRAMEDsrcList1->UpdateList();
  88. }
  89. //---------------------------------------------------------------------------
  90. void __fastcall TDSRH070M::RefreshData()
  91. {
  92. // 검색조건에 의한 링크 데이터 조회
  93. try
  94. {
  95. //SelListData();
  96. }
  97. __finally
  98. {
  99. }
  100. }
  101. //---------------------------------------------------------------------------
  102. void __fastcall TDSRH070M::BtnSearchClick(TObject *Sender)
  103. {
  104. Application->ProcessMessages();
  105. TSqlCursor sqlCrs((TControl*)BtnSearch);
  106. int STAT = CbStat->ItemIndex;
  107. if (STAT == 0)
  108. {
  109. #if 0
  110. FStDateTime = DtStDate->Date.FormatString("yyyymmdd") + DtStTime->Time.FormatString("hh");
  111. FEdDateTime = DtEdDate->Date.FormatString("yyyymmdd") + DtEdTime->Time.FormatString("hh");
  112. #else
  113. FStDateTime = DtStDate->Date.FormatString("yyyymmdd") + DtStTime->Time.FormatString("hhnn");
  114. FEdDateTime = DtEdDate->Date.FormatString("yyyymmdd") + DtEdTime->Time.FormatString("hhnn");
  115. #endif
  116. }
  117. else
  118. {
  119. FStDateTime = DtStDate->Date.FormatString("yyyymmdd");
  120. FEdDateTime = DtEdDate->Date.FormatString("yyyymmdd");
  121. }
  122. if (FStDateTime > FEdDateTime)
  123. {
  124. Application->MessageBox(FrmLang->lblQryDtErr->Caption.c_str(),//L"검색 시작시각이 검색 종료시각 보다 큽니다.",
  125. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  126. ActiveControl = DtStDate;
  127. return;
  128. }
  129. String sTitle;
  130. if (STAT == 0)
  131. {
  132. sTitle = "시간통계 [" + FStDateTime + " ~ " + FEdDateTime + "]";
  133. #if 0
  134. FStDateTime = FStDateTime + "0000";
  135. FEdDateTime = FEdDateTime + "5959";
  136. #else
  137. FStDateTime = FStDateTime + "00";
  138. FEdDateTime = FEdDateTime + "59";
  139. #endif
  140. }
  141. else
  142. {
  143. sTitle = "일통계 [" + FStDateTime + " ~ " + FEdDateTime + "]";
  144. FStDateTime = FStDateTime + "000000";
  145. FEdDateTime = FEdDateTime + "235959";
  146. }
  147. FIdList = "";
  148. int nSelects = CMM_GetSelectCount(FRAMEDsrcList1->TvList, FRAMEDsrcList1->ColumnSel->Index, FRAMEDsrcList1->Column01->Index, FIdList);
  149. if (0 == nSelects)
  150. {
  151. Application->MessageBox(FrmLang->lblSelLstErr->Caption.c_str(),//L"검색 목록을 선택하지 않았습니다.",
  152. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  153. FRAMEDsrcList1->CxList->SetFocus();
  154. return;
  155. }
  156. try
  157. {
  158. Application->ProcessMessages();
  159. LockWindowUpdate(Handle);
  160. TcxTabSheet *pSheet = CMM_AddTabSheet(PgTab, sTitle);
  161. if (!pSheet) return;
  162. DSRH0701 = new TDSRH0701(this, Handle, FStDateTime, FEdDateTime, FIdList, STAT);
  163. DSRH0701->Parent = pSheet;
  164. DSRH0701->Show();
  165. PgTab->ActivePage = pSheet;
  166. pSheet = PgTab->ActivePage;
  167. m_pFormList->Add(DSRH0701);
  168. }
  169. __finally
  170. {
  171. LockWindowUpdate(0);
  172. }
  173. }
  174. //---------------------------------------------------------------------------
  175. void __fastcall TDSRH070M::BtnCloseClick(TObject *Sender)
  176. {
  177. Close();
  178. }
  179. //---------------------------------------------------------------------------
  180. void __fastcall TDSRH070M::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 TDSRH070M::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 TDSRH070M::FormClose(TObject *Sender, TCloseAction &Action)
  204. {
  205. CommClose();
  206. DSRH070M = NULL;
  207. Action = caFree;
  208. }
  209. //---------------------------------------------------------------------------
  210. void __fastcall TDSRH070M::FormCloseQuery(TObject *Sender, bool &CanClose)
  211. {
  212. FRAMEDsrcList1->OnCloseQuery(CanClose);
  213. }
  214. //---------------------------------------------------------------------------
  215. void __fastcall TDSRH070M::InitCode()
  216. {
  217. #if 0
  218. TItsCode *FCodeRCT;
  219. TItsCode *FCodeOBU;
  220. FCodeRCT = ItsCodeManager->FLists.Find("RCT");
  221. FCodeOBU = ItsCodeManager->FLists.Find("OBU");
  222. // 차종
  223. CbCTyp->Properties->Items->Clear();
  224. CbCTyp->Properties->Items->Add(" [ALL] 전체");
  225. if (FCodeRCT)
  226. {
  227. FOR_STL(TItsSubCode *, pSubCode, FCodeRCT->FSubLists)
  228. {
  229. if (pSubCode->USE_YN == "N") continue;
  230. CbCTyp->Properties->Items->Add(" [" + pSubCode->CMMN_CD + "] " + pSubCode->CMMN_CD_KOR_NM);
  231. }
  232. }
  233. CbCTyp->ItemIndex = 0;
  234. // OBU 종류
  235. CbObuKind->Properties->Items->Clear();
  236. CbObuKind->Properties->Items->Add(" [ALL] 전체");
  237. if (FCodeOBU)
  238. {
  239. FOR_STL(TItsSubCode *, pSubCode, FCodeOBU->FSubLists)
  240. {
  241. if (pSubCode->USE_YN == "N") continue;
  242. CbObuKind->Properties->Items->Add(" [" + pSubCode->CMMN_CD + "] " + pSubCode->CMMN_CD_KOR_NM);
  243. }
  244. }
  245. CbObuKind->ItemIndex = 0;
  246. #endif
  247. }
  248. //---------------------------------------------------------------------------
  249. void __fastcall TDSRH070M::CbStatPropertiesChange(TObject *Sender)
  250. {
  251. switch(CbStat->ItemIndex)
  252. {
  253. case 0: //시간 통계
  254. DtStTime->Visible = true;
  255. DtEdTime->Visible = true;
  256. break;
  257. case 1: //일 통계
  258. DtStTime->Visible = false;
  259. DtEdTime->Visible = false;
  260. break;
  261. }
  262. }
  263. //---------------------------------------------------------------------------
  264. void __fastcall TDSRH070M::PgTabCanCloseEx(TObject *Sender, int ATabIndex, bool &ACanClose)
  265. {
  266. int nActiveIdx = ATabIndex;
  267. if (nActiveIdx <= 0) return;
  268. nActiveIdx--; // 첫번째 탭은 화면에 숨겨져 있다.
  269. m_pFormList->Delete(nActiveIdx);
  270. }
  271. //---------------------------------------------------------------------------