DSRH0101F.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  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. #pragma hdrstop
  9. #include "DSRH0101F.h"
  10. //---------------------------------------------------------------------------
  11. #pragma package(smart_init)
  12. #pragma link "cxButtons"
  13. #pragma link "cxCalc"
  14. #pragma link "cxCheckBox"
  15. #pragma link "cxClasses"
  16. #pragma link "cxContainer"
  17. #pragma link "cxControls"
  18. #pragma link "cxCustomData"
  19. #pragma link "cxData"
  20. #pragma link "cxDataStorage"
  21. #pragma link "cxEdit"
  22. #pragma link "cxFilter"
  23. #pragma link "cxGraphics"
  24. #pragma link "cxGrid"
  25. #pragma link "cxGridCustomTableView"
  26. #pragma link "cxGridCustomView"
  27. #pragma link "cxGridLevel"
  28. #pragma link "cxGridTableView"
  29. #pragma link "cxLabel"
  30. #pragma link "cxLookAndFeelPainters"
  31. #pragma link "cxLookAndFeels"
  32. #pragma link "cxStyles"
  33. #pragma link "cxTextEdit"
  34. #pragma link "dxSkinBlack"
  35. #pragma link "dxSkinBlue"
  36. #pragma link "dxSkinsCore"
  37. #pragma link "dxSkinscxPCPainter"
  38. #pragma resource "*.dfm"
  39. TDSRH0101 *DSRH0101 = NULL;
  40. //---------------------------------------------------------------------------
  41. __fastcall TDSRH0101::TDSRH0101(TComponent* Owner, HWND hHandle, String sFrom, String sTo, String sIdList)
  42. : TForm(Owner)
  43. {
  44. ITSSkin_Load(this);
  45. CMM_LoadForm(g_sFormsDir, this);
  46. FParent = hHandle;
  47. FStDateTime = sFrom;
  48. FEdDateTime = sTo;
  49. FIdList = sIdList;
  50. Caption = "DSRC-RSE 상태 이력";
  51. }
  52. //---------------------------------------------------------------------------
  53. __fastcall TDSRH0101::~TDSRH0101(void)
  54. {
  55. }
  56. //--------------------------------------------------------------------------
  57. /*
  58. * form 초기화
  59. *
  60. * arguments
  61. *
  62. * return
  63. * void
  64. */
  65. void __fastcall TDSRH0101::FormInit()
  66. {
  67. ADOQry->Connection = ITSDb_GetConnection();
  68. m_pGDC = TvList->DataController;
  69. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<DSRC-RSE 상태 이력 정보>";
  70. //TvList->ViewInfo->GroupByBoxViewInfo->Text = "그룹핑할 필드의 헤더를 이곳으로 드래그 하세요";
  71. LblSearch->Caption = "검색조건: " + FStDateTime.SubString(1, 12) + " ~ " + FEdDateTime.SubString(1, 12);
  72. }
  73. //---------------------------------------------------------------------------
  74. /*
  75. * form을 보여줄때 호출되는 event 메서드이다.
  76. * arguments
  77. * Sender : event handler 객체
  78. * return
  79. * void
  80. */
  81. void __fastcall TDSRH0101::FormShow(TObject *Sender)
  82. {
  83. FormInit();
  84. Refresh();
  85. TmrShow->Enabled = true;
  86. }
  87. //---------------------------------------------------------------------------
  88. /*
  89. * 닫기버튼 이나 x버튼 클릭시 공통으로 처리하는 로직이들어간다..
  90. * Form과 DataModule class를 delete시킨다.
  91. * arguments
  92. *
  93. * return
  94. * void
  95. */
  96. void __fastcall TDSRH0101::CommClose()
  97. {
  98. CMM_SaveForm(g_sFormsDir, this);
  99. //DSRH0101 = NULL;
  100. }
  101. //---------------------------------------------------------------------------
  102. /*
  103. * 최초 1회 수행되는 타이머 이벤트
  104. * arguments
  105. * Sender : event handler 객체
  106. * return
  107. * void
  108. */
  109. void __fastcall TDSRH0101::TmrShowTimer(TObject *Sender)
  110. {
  111. TmrShow->Enabled = false;
  112. Application->ProcessMessages();
  113. SelHistory();
  114. }
  115. //---------------------------------------------------------------------------
  116. void __fastcall TDSRH0101::ChkExpandClick(TObject *Sender)
  117. {
  118. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  119. }
  120. //---------------------------------------------------------------------------
  121. /*
  122. * Refresh Data Event Function
  123. * arguments
  124. *
  125. * return
  126. * void
  127. */
  128. void __fastcall TDSRH0101::SelHistory()
  129. {
  130. TSqlCursor sqlCrs;
  131. String sQry;
  132. TADOQuery *pADO = ADOQry;
  133. #if 1
  134. sQry = "SELECT A.ID, B.RSE_ID, B.ISTL_LCTN_NM, \r\n"
  135. " A.CLCT_DT, A.CNTL_DEVC_STTS, A.CMNC_STTS, A.ATN_1_STTS, \r\n"
  136. " A.ATN_2_STTS, A.ATN_3_STTS, A.ATN_4_STTS, A.ATN_1_MTNS \r\n"
  137. " FROM TB_RSE_STTS_HS A, TB_RSE_MSTR B \r\n"
  138. " WHERE A.CLCT_DT BETWEEN :p01 AND :p02 \r\n"
  139. " AND A.ID = B.ID \r\n"
  140. " AND B.ID IN(" + FIdList + ") \r\n"
  141. " ORDER BY A.ID, A.CLCT_DT \r\n";
  142. //" ORDER BY TO_NUMBER(ID), CLCT_DT \r\n";
  143. #else
  144. sQry = "SELECT ID, CLCT_DT, CNTL_DEVC_STTS, CMNC_STTS, ATN_1_STTS, \r\n"
  145. " ATN_2_STTS, ATN_3_STTS, ATN_4_STTS, ATN_1_MTNS \r\n"
  146. " FROM TB_RSE_STTS_HS \r\n"
  147. " WHERE CLCT_DT BETWEEN :p01 AND :p02 \r\n"
  148. " AND ID IN(" + FIdList + ") \r\n"
  149. " ORDER BY ID, CLCT_DT \r\n";
  150. //" ORDER BY TO_NUMBER(ID), CLCT_DT \r\n";
  151. #endif
  152. try
  153. {
  154. ITSDb_SQLText(pADO, sQry);
  155. ITSDb_SQLBind(pADO, "p01", FStDateTime);
  156. ITSDb_SQLBind(pADO, "p02", FEdDateTime);
  157. ITSDb_SQLOpen(pADO);
  158. DspHistory();
  159. }
  160. catch(EDatabaseError &E)
  161. {
  162. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  163. DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQry);
  164. throw Exception(String(E.ClassName()) + E.Message);
  165. }
  166. catch(Exception &exception)
  167. {
  168. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  169. DBERRORMSG(Caption, String(exception.ClassName()), exception.Message, sQry);
  170. throw Exception(String(exception.ClassName()) + exception.Message);
  171. }
  172. }
  173. //---------------------------------------------------------------------------
  174. void __fastcall TDSRH0101::DspHistory()
  175. {
  176. TADOQuery *pADO = ADOQry;
  177. try
  178. {
  179. TcxGridChartSeries *pChart = NULL;
  180. CMM_ClearGridTableView(TvList);
  181. int nRow = 0;
  182. int nDataCnt = 0;
  183. try {
  184. TvList->BeginUpdate();
  185. nDataCnt = pADO->RecordCount;
  186. m_pGDC->RecordCount = nDataCnt;
  187. for( ; !pADO->Eof; pADO->Next(), nRow++)
  188. {
  189. m_pGDC->Values[nRow][Column00->Index] = pADO->FieldByName("ID")->AsString;
  190. m_pGDC->Values[nRow][Column11->Index] = pADO->FieldByName("RSE_ID")->AsString;
  191. m_pGDC->Values[nRow][Column12->Index] = pADO->FieldByName("ISTL_LCTN_NM")->AsString;
  192. String sDbDate = pADO->FieldByName("CLCT_DT")->AsString;
  193. m_pGDC->Values[nRow][Column01->Index] = ITSUtil_FormatStr(sDbDate, STR_DATETIME);
  194. String sDevcStts = pADO->FieldByName("CNTL_DEVC_STTS")->AsString;
  195. String sCmncStts = pADO->FieldByName("CMNC_STTS")->AsString;
  196. String sAtn1Stts = pADO->FieldByName("ATN_1_STTS")->AsString;
  197. #if 0
  198. String sAtn2Stts = pADO->FieldByName("ATN_2_STTS")->AsString;
  199. String sAtn3Stts = pADO->FieldByName("ATN_3_STTS")->AsString;
  200. String sAtn4Stts = pADO->FieldByName("ATN_4_STTS")->AsString;
  201. #endif
  202. String sAtn1Mtns = pADO->FieldByName("ATN_1_MTNS")->AsString;
  203. if (sDevcStts == "0") sDevcStts = "정상";
  204. else if (sDevcStts == "1") sDevcStts = "문열림";
  205. else if (sDevcStts == "2") sDevcStts = "팬동작";
  206. else if (sDevcStts == "3") sDevcStts = "내부온도 이상";
  207. else if (sDevcStts == "4") sDevcStts = "정보 없음";
  208. m_pGDC->Values[nRow][Column02->Index] = sDevcStts;
  209. if (sCmncStts == "0") sCmncStts = "정상";
  210. else if (sCmncStts == "1") sCmncStts = "장애";
  211. else if (sCmncStts == "2") sCmncStts = "정보 없음";
  212. m_pGDC->Values[nRow][Column03->Index] = sCmncStts;
  213. if (sAtn1Stts == "0") sAtn1Stts = "정상";
  214. else if (sAtn1Stts == "1") sAtn1Stts = "장애";
  215. else if (sAtn1Stts == "2") sAtn1Stts = "정보 없음";
  216. m_pGDC->Values[nRow][Column04->Index] = sAtn1Stts;
  217. if (sAtn1Mtns == "0") sAtn1Mtns = "송출종료";
  218. else if (sAtn1Mtns == "1") sAtn1Mtns = "송출개시";
  219. else if (sAtn1Mtns == "2") sAtn1Mtns = "유지보수 근무개시";
  220. else if (sAtn1Mtns == "3") sAtn1Mtns = "정보 없음";
  221. m_pGDC->Values[nRow][Column05->Index] = sAtn1Mtns;
  222. #if 0
  223. if (sAtn2Stts == "0") sAtn2Stts = "정상";
  224. else if (sAtn2Stts == "1") sAtn2Stts = "장애";
  225. else if (sAtn2Stts == "2") sAtn2Stts = "정보 없음";
  226. if (sAtn3Stts == "0") sAtn3Stts = "정상";
  227. else if (sAtn3Stts == "1") sAtn3Stts = "장애";
  228. else if (sAtn3Stts == "2") sAtn3Stts = "정보 없음";
  229. if (sAtn4Stts == "0") sAtn4Stts = "정상";
  230. else if (sAtn4Stts == "1") sAtn4Stts = "장애";
  231. else if (sAtn4Stts == "2") sAtn4Stts = "정보 없음";
  232. m_pGDC->Values[nRow][Column06->Index] = sAtn2Stts;
  233. m_pGDC->Values[nRow][Column07->Index] = sAtn3Stts;
  234. m_pGDC->Values[nRow][Column08->Index] = sAtn4Stts;
  235. #endif
  236. }
  237. }
  238. __finally
  239. {
  240. if (pADO)
  241. {
  242. pADO->Close();
  243. }
  244. TvList->EndUpdate();
  245. //CxList->SetFocus();
  246. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + " 건";
  247. String sEnd = "데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
  248. Application->MessageBox(sEnd.c_str(), L"데이터 조회 완료", MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  249. }
  250. }
  251. catch(EDatabaseError &E)
  252. {
  253. throw Exception(String(E.ClassName()) + E.Message);
  254. }
  255. catch(...)
  256. {
  257. throw Exception(FrmLang->lblDbErr->Caption);//"알수없는 오류가 발생하였습니다.");
  258. }
  259. }
  260. //---------------------------------------------------------------------------
  261. void __fastcall TDSRH0101::OnMessage(TMessage &Msg)
  262. {
  263. switch (Msg.Msg)
  264. {
  265. case WM_PARAM_DATABASE:
  266. if (WP_DB_SELECT_OK == Msg.WParam)
  267. {
  268. //ShowMessage("Select Ok");
  269. }
  270. break;
  271. }
  272. }
  273. //---------------------------------------------------------------------------
  274. void __fastcall TDSRH0101::BtnExlSaveClick(TObject *Sender)
  275. {
  276. TcxGrid *pGrid = CxList;
  277. TcxGridTableView *pView = TvList;
  278. String sTitle = "DSRC-RSE 상태이력";
  279. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  280. }
  281. //---------------------------------------------------------------------------
  282. void __fastcall TDSRH0101::FormClose(TObject *Sender, TCloseAction &Action)
  283. {
  284. POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
  285. CommClose();
  286. //DSRH0101 = NULL;
  287. }
  288. //---------------------------------------------------------------------------
  289. void __fastcall TDSRH0101::Column02CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  290. bool &ADone)
  291. {
  292. if( AViewInfo )
  293. {
  294. if(AViewInfo->Text == "정상")
  295. {
  296. ACanvas->Canvas->Font->Color = clTeal;
  297. }
  298. else if(AViewInfo->Text == "장애")
  299. {
  300. ACanvas->Canvas->Font->Color = clFuchsia;
  301. }
  302. else
  303. {
  304. ACanvas->Canvas->Font->Color = clGray;
  305. }
  306. }
  307. }
  308. //---------------------------------------------------------------------------