PISH0201F.cpp 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "ITSUtilF.h"
  5. #include "ITSDbF.h"
  6. #include "AppGlobalF.h"
  7. #include "WindowMsgF.h"
  8. #include "ITSLangTransF.h"
  9. #include "ITS_OPLibF.h"
  10. #pragma hdrstop
  11. #include "PISH0201F.h"
  12. //---------------------------------------------------------------------------
  13. #pragma package(smart_init)
  14. #pragma link "cxButtons"
  15. #pragma link "cxCheckBox"
  16. #pragma link "cxClasses"
  17. #pragma link "cxContainer"
  18. #pragma link "cxControls"
  19. #pragma link "cxCustomData"
  20. #pragma link "cxData"
  21. #pragma link "cxDataStorage"
  22. #pragma link "cxEdit"
  23. #pragma link "cxFilter"
  24. #pragma link "cxGraphics"
  25. #pragma link "cxGrid"
  26. #pragma link "cxGridCustomTableView"
  27. #pragma link "cxGridCustomView"
  28. #pragma link "cxGridLevel"
  29. #pragma link "cxGridTableView"
  30. #pragma link "cxLabel"
  31. #pragma link "cxLookAndFeelPainters"
  32. #pragma link "cxLookAndFeels"
  33. #pragma link "cxStyles"
  34. #pragma link "dxSkinBlack"
  35. #pragma link "dxSkinBlue"
  36. #pragma link "dxSkinsCore"
  37. #pragma link "dxSkinscxPCPainter"
  38. #pragma link "cxTextEdit"
  39. #pragma link "dxSkinMcSkin"
  40. #pragma resource "*.dfm"
  41. TPISH0201 *PISH0201 = NULL;
  42. //---------------------------------------------------------------------------
  43. __fastcall TPISH0201::TPISH0201(TComponent* Owner, HWND hHandle, String sFrom, String sTo, String sIdList)
  44. : TForm(Owner)
  45. {
  46. LangTrans->Translate(this, ITSDb_GetConnection());
  47. ITSSkin_Load(this);
  48. CMM_LoadForm(g_sFormsDir, this);
  49. FParent = hHandle;
  50. FStDateTime = sFrom;
  51. FEdDateTime = sTo;
  52. FIdList = sIdList;
  53. Caption = "주차장 실시간정보 이력";
  54. }
  55. //---------------------------------------------------------------------------
  56. __fastcall TPISH0201::~TPISH0201(void)
  57. {
  58. }
  59. //--------------------------------------------------------------------------
  60. void __fastcall TPISH0201::FormInit()
  61. {
  62. ADOQry->Connection = ITSDb_GetConnection();
  63. m_pGDC = TvList->DataController;
  64. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<주차장 실시간정보 이력>";
  65. //TvList->ViewInfo->GroupByBoxViewInfo->Text = "그룹핑할 필드의 헤더를 이곳으로 드래그 하세요";
  66. LblSearch->Caption = "검색조건: " + FStDateTime.SubString(1, 10) + " ~ " + FEdDateTime.SubString(1, 10);
  67. }
  68. //---------------------------------------------------------------------------
  69. void __fastcall TPISH0201::FormShow(TObject *Sender)
  70. {
  71. FormInit();
  72. Refresh();
  73. TmrShow->Enabled = true;
  74. }
  75. //---------------------------------------------------------------------------
  76. void __fastcall TPISH0201::CommClose()
  77. {
  78. CMM_SaveForm(g_sFormsDir, this);
  79. //PISH0201 = NULL;
  80. }
  81. //---------------------------------------------------------------------------
  82. void __fastcall TPISH0201::TmrShowTimer(TObject *Sender)
  83. {
  84. TmrShow->Enabled = false;
  85. Application->ProcessMessages();
  86. SelHistory();
  87. }
  88. //---------------------------------------------------------------------------
  89. void __fastcall TPISH0201::ChkExpandClick(TObject *Sender)
  90. {
  91. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  92. }
  93. //---------------------------------------------------------------------------
  94. void __fastcall TPISH0201::SelHistory()
  95. {
  96. TSqlCursor sqlCrs;
  97. String sQry;
  98. TADOQuery *pADO = ADOQry;
  99. sQry = "SELECT A.*, B.PRLT_CTLR_ID, B.PRLT_NM \r\n"
  100. " FROM TB_PRLT_CTLR_STTS_HS A, TB_PRLT_CTLR B \r\n"
  101. " WHERE A.CRTN_DT BETWEEN :p01 AND :p02 \r\n"
  102. " AND B.PRLT_CTLR_NMBR IN(" + FIdList + ") \r\n"
  103. " AND A.PRLT_CTLR_NMBR = B.PRLT_CTLR_NMBR \r\n"
  104. " ORDER BY A.PRLT_CTLR_NMBR, A.CRTN_DT \r\n";
  105. try
  106. {
  107. ITSDb_SQLText(pADO, sQry);
  108. ITSDb_SQLBind(pADO, "p01", FStDateTime);
  109. ITSDb_SQLBind(pADO, "p02", FEdDateTime);
  110. ITSDb_SQLOpen(pADO);
  111. DspHistory();
  112. }
  113. catch(EDatabaseError &E)
  114. {
  115. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  116. DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQry);
  117. throw Exception(String(E.ClassName()) + E.Message);
  118. }
  119. catch(Exception &exception)
  120. {
  121. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  122. DBERRORMSG(Caption, String(exception.ClassName()), exception.Message, sQry);
  123. throw Exception(String(exception.ClassName()) + exception.Message);
  124. }
  125. }
  126. //---------------------------------------------------------------------------
  127. void __fastcall TPISH0201::DspHistory()
  128. {
  129. TADOQuery *pADO = ADOQry;
  130. try
  131. {
  132. TcxGridChartSeries *pChart = NULL;
  133. CMM_ClearGridTableView(TvList);
  134. int nRow = 0;
  135. int nDataCnt = 0;
  136. try {
  137. TvList->BeginUpdate();
  138. nDataCnt = pADO->RecordCount;
  139. m_pGDC->RecordCount = nDataCnt;
  140. for( ; !pADO->Eof; pADO->Next(), nRow++)
  141. {
  142. m_pGDC->Values[nRow][Column00->Index] = pADO->FieldByName("PRLT_CTLR_NMBR")->AsString;
  143. m_pGDC->Values[nRow][Column11->Index] = pADO->FieldByName("PRLT_CTLR_ID")->AsString;
  144. m_pGDC->Values[nRow][Column09->Index] = pADO->FieldByName("PRLT_NM")->AsString;
  145. String sDbDate = pADO->FieldByName("CRTN_DT")->AsString;
  146. m_pGDC->Values[nRow][Column01->Index] = APP_FormatStr(sDbDate, STR_DATETIME);
  147. String CMNC_STTS_CD = pADO->FieldByName("CMNC_STTS_CD")->AsString;
  148. if (CMNC_STTS_CD == "CMS0") m_pGDC->Values[nRow][Column02->Index] = FrmLang->lblComm0->Caption;
  149. else
  150. if (CMNC_STTS_CD == "CMS1") m_pGDC->Values[nRow][Column02->Index] = FrmLang->lblComm1->Caption;
  151. else m_pGDC->Values[nRow][Column02->Index] = FrmLang->lblUnknown->Caption;
  152. }
  153. }
  154. __finally
  155. {
  156. if (pADO)
  157. {
  158. pADO->Close();
  159. }
  160. TvList->EndUpdate();
  161. //CxList->SetFocus();
  162. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + FrmLang->lblEA->Caption;//" 건";
  163. String sEnd = FrmLang->lblQrySel->Caption + " [" + LblRecords->Caption + "]";//"데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
  164. Application->MessageBox(sEnd.c_str(),
  165. FrmLang->lblQryEnd->Caption.c_str(),//L"데이터 조회 완료",
  166. MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  167. }
  168. }
  169. catch(EDatabaseError &E)
  170. {
  171. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  172. DBERRORMSG(Caption, String(E.ClassName()), E.Message, pADO->SQL->Text);
  173. throw Exception(String(E.ClassName()) + E.Message);
  174. }
  175. catch(Exception &e)
  176. {
  177. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  178. DBERRORMSG(Caption, String(e.ClassName()), e.Message, pADO->SQL->Text);
  179. throw Exception(String(e.ClassName()) + e.Message);
  180. }
  181. }
  182. //---------------------------------------------------------------------------
  183. void __fastcall TPISH0201::OnMessage(TMessage &Msg)
  184. {
  185. switch (Msg.Msg)
  186. {
  187. case WM_PARAM_DATABASE:
  188. if (WP_DB_SELECT_OK == Msg.WParam)
  189. {
  190. //ShowMessage("Select Ok");
  191. }
  192. break;
  193. }
  194. }
  195. //---------------------------------------------------------------------------
  196. void __fastcall TPISH0201::BtnExlSaveClick(TObject *Sender)
  197. {
  198. TcxGrid *pGrid = CxList;
  199. TcxGridTableView *pView = TvList;
  200. String sTitle = "주차장 상태이력";
  201. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  202. }
  203. //---------------------------------------------------------------------------
  204. void __fastcall TPISH0201::FormClose(TObject *Sender, TCloseAction &Action)
  205. {
  206. POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
  207. CommClose();
  208. //PISH0201 = NULL;
  209. }
  210. //---------------------------------------------------------------------------
  211. void __fastcall TPISH0201::Column02CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  212. bool &ADone)
  213. {
  214. TColor tColor = ACanvas->Brush->Color;
  215. TColor tFont = clBlack;
  216. try
  217. {
  218. if (!VarIsNull(AViewInfo->Value))
  219. {
  220. String sTmp = AViewInfo->Value;
  221. if (sTmp == FrmLang->lblComm0->Caption)
  222. {
  223. tColor = clLime;
  224. }
  225. else
  226. if (sTmp == FrmLang->lblComm1->Caption)
  227. {
  228. tColor = clRed;
  229. }
  230. else
  231. {
  232. tColor = clSilver;
  233. }
  234. }
  235. ACanvas->Font->Color = tFont;
  236. ACanvas->SetBrushColor(tColor);
  237. }
  238. catch(...)
  239. {
  240. }
  241. }
  242. //---------------------------------------------------------------------------