IHS00201F.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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 "IHS00201F.h"
  12. //---------------------------------------------------------------------------
  13. #pragma package(smart_init)
  14. #pragma link "cxButtons"
  15. #pragma link "cxClasses"
  16. #pragma link "cxControls"
  17. #pragma link "cxCustomData"
  18. #pragma link "cxData"
  19. #pragma link "cxDataStorage"
  20. #pragma link "cxEdit"
  21. #pragma link "cxFilter"
  22. #pragma link "cxGraphics"
  23. #pragma link "cxGrid"
  24. #pragma link "cxGridCustomTableView"
  25. #pragma link "cxGridCustomView"
  26. #pragma link "cxGridLevel"
  27. #pragma link "cxGridTableView"
  28. #pragma link "cxLabel"
  29. #pragma link "cxLookAndFeelPainters"
  30. #pragma link "cxLookAndFeels"
  31. #pragma link "cxStyles"
  32. #pragma link "cxTextEdit"
  33. #pragma link "dxSkinBlack"
  34. #pragma link "dxSkinBlue"
  35. #pragma link "dxSkinsCore"
  36. #pragma link "dxSkinscxPCPainter"
  37. #pragma link "cxContainer"
  38. #pragma link "dxSkinMcSkin"
  39. #pragma resource "*.dfm"
  40. TIHS00201 *IHS00201 = NULL;
  41. //---------------------------------------------------------------------------
  42. __fastcall TIHS00201::TIHS00201(TComponent* Owner, HWND hHandle, int ARptType, String ASystId, String sFrom, String sTo, String ATitle)
  43. : TForm(Owner)
  44. {
  45. LangTrans->Translate(this, ITSDb_GetConnection());
  46. ITSSkin_Load(this);
  47. CMM_LoadForm(g_sFormsDir, this);
  48. FParent = hHandle;
  49. FStDateTime = sFrom;
  50. FEdDateTime = sTo;
  51. FRptType = ARptType;
  52. FSystId = ASystId;
  53. FTitle = ATitle;
  54. Caption = Caption;//"프로세스 상태이력";
  55. }
  56. //---------------------------------------------------------------------------
  57. __fastcall TIHS00201::~TIHS00201(void)
  58. {
  59. }
  60. //--------------------------------------------------------------------------
  61. void __fastcall TIHS00201::FormInit()
  62. {
  63. ADOQry->Connection = ITSDb_GetConnection();
  64. m_pGDC = TvList->DataController;
  65. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<프로세스 상태이력 정보>";
  66. LblSearch->Caption = FTitle;
  67. }
  68. //---------------------------------------------------------------------------
  69. void __fastcall TIHS00201::FormShow(TObject *Sender)
  70. {
  71. FormInit();
  72. Refresh();
  73. TmrShow->Enabled = true;
  74. }
  75. //---------------------------------------------------------------------------
  76. void __fastcall TIHS00201::CommClose()
  77. {
  78. CMM_SaveForm(g_sFormsDir, this);
  79. //IHS00201 = NULL;
  80. }
  81. //---------------------------------------------------------------------------
  82. void __fastcall TIHS00201::TmrShowTimer(TObject *Sender)
  83. {
  84. TmrShow->Enabled = false;
  85. Application->ProcessMessages();
  86. SelHistory();
  87. }
  88. //---------------------------------------------------------------------------
  89. void __fastcall TIHS00201::SelHistory()
  90. {
  91. TSqlCursor sqlCrs;
  92. String sQry;
  93. TADOQuery *pADO = ADOQry;
  94. sQry = "SELECT X.CRTN_IDX, X.HHMM, Y.SYST_ID, Y.SYST_NM, Y.CRTN_DT, Y.SYST_STTS_CD, Y.RMRK \r\n"
  95. " FROM (SELECT ROWNUM AS CRTN_IDX, \r\n"
  96. " TO_CHAR(TRUNC(SYSDATE)+((LEVEL-1)*5)/1440, 'HH24:MI') AS HHMM \r\n"
  97. " FROM DUAL \r\n"
  98. " CONNECT BY LEVEL <= 288 )X, \r\n"
  99. " (SELECT A.SYST_ID, A.SYST_NM, B.CRTN_DT, TRUNC((B.CHOUR * 60 + B.CMIN) / 5, 0)+1 AS CRTN_IDX, B.SYST_STTS_CD, B.RMRK \r\n"
  100. " FROM TB_UNIT_SYST A, \r\n"
  101. " (SELECT SYST_ID, CRTN_DT, \r\n"
  102. " TO_NUMBER(SUBSTR(CRTN_DT, 9, 2)) AS CHOUR, TO_NUMBER(SUBSTR(CRTN_DT, 11, 2)) AS CMIN, \r\n"
  103. " SYST_STTS_CD, RMRK \r\n"
  104. " FROM TB_UNIT_SYST_STTS_HS \r\n"
  105. " WHERE SYST_ID = :p02 \r\n"
  106. " AND CRTN_DT BETWEEN :p03 AND :p04 \r\n"
  107. " ) B \r\n"
  108. " WHERE A.SYST_ID = :p01 \r\n"
  109. " AND A.SYST_ID = B.SYST_ID) Y \r\n"
  110. " WHERE X.CRTN_IDX = Y.CRTN_IDX(+) \r\n"
  111. " ORDER BY X.CRTN_IDX \r\n";
  112. try
  113. {
  114. ITSDb_SQLText(pADO, sQry);
  115. ITSDb_SQLBind(pADO, "p01", FSystId);
  116. ITSDb_SQLBind(pADO, "p02", FSystId);
  117. ITSDb_SQLBind(pADO, "p03", FStDateTime);
  118. ITSDb_SQLBind(pADO, "p04", FEdDateTime);
  119. ITSDb_SQLOpen(pADO);
  120. DspHistory();
  121. }
  122. catch(EDatabaseError &E)
  123. {
  124. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  125. DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQry);
  126. throw Exception(String(E.ClassName()) + E.Message);
  127. }
  128. catch(Exception &exception)
  129. {
  130. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  131. DBERRORMSG(Caption, String(exception.ClassName()), exception.Message, sQry);
  132. throw Exception(String(exception.ClassName()) + exception.Message);
  133. }
  134. }
  135. //---------------------------------------------------------------------------
  136. void __fastcall TIHS00201::DspHistory()
  137. {
  138. TADOQuery *pADO = ADOQry;
  139. try
  140. {
  141. CMM_ClearGridTableView(TvList);
  142. int nRow = 0;
  143. try {
  144. TvList->BeginUpdate();
  145. for( ; !pADO->Eof; pADO->Next(), nRow++)
  146. {
  147. nRow = m_pGDC->AppendRecord();
  148. m_pGDC->Values[nRow][Column01->Index] = pADO->FieldByName("CRTN_IDX")->AsString;
  149. m_pGDC->Values[nRow][Column02->Index] = pADO->FieldByName("HHMM")->AsString;
  150. String sCrtDt = VarToStr(pADO->FieldByName("CRTN_DT")->AsString);
  151. if (sCrtDt.IsEmpty())
  152. m_pGDC->Values[nRow][Column03->Index] = "---";
  153. else
  154. m_pGDC->Values[nRow][Column03->Index] = ITSUtil_StrToTime(sCrtDt);
  155. String sStatus = VarToStr(pADO->FieldByName("SYST_STTS_CD")->AsString);
  156. m_pGDC->Values[nRow][Column05->Index] = sStatus;
  157. if (sStatus == "SPS0") sStatus = cxLabel1->Caption;//"알 수 없음";
  158. else if (sStatus == "SPS1") sStatus = cxLabel2->Caption;//"실행중";
  159. else if (sStatus == "SPS2") sStatus = cxLabel3->Caption;//"시작";
  160. else if (sStatus == "SPS3") sStatus = cxLabel4->Caption;//"종료";
  161. else if (sStatus == "SPS4") sStatus = cxLabel5->Caption;//"오류 발생";
  162. m_pGDC->Values[nRow][Column04->Index] = sStatus;
  163. }
  164. }
  165. __finally
  166. {
  167. if (pADO)
  168. {
  169. pADO->Close();
  170. delete pADO;
  171. }
  172. TvList->EndUpdate();
  173. //CxList->SetFocus();
  174. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + FrmLang->lblEA->Caption;//" 건";
  175. String sEnd = FrmLang->lblQrySel->Caption + " [" + LblRecords->Caption + "]";//"데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
  176. Application->MessageBox(sEnd.c_str(),
  177. FrmLang->lblQryEnd->Caption.c_str(),//L"데이터 조회 완료",
  178. MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  179. }
  180. }
  181. catch(EDatabaseError &E)
  182. {
  183. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  184. DBERRORMSG(Caption, String(E.ClassName()), E.Message, pADO->SQL->Text);
  185. throw Exception(String(E.ClassName()) + E.Message);
  186. }
  187. catch(Exception &e)
  188. {
  189. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  190. DBERRORMSG(Caption, String(e.ClassName()), e.Message, pADO->SQL->Text);
  191. throw Exception(String(e.ClassName()) + e.Message);
  192. }
  193. }
  194. //---------------------------------------------------------------------------
  195. void __fastcall TIHS00201::OnMessage(TMessage &Msg)
  196. {
  197. switch (Msg.Msg)
  198. {
  199. case WM_PARAM_DATABASE:
  200. if (WP_DB_SELECT_OK == Msg.WParam)
  201. {
  202. //ShowMessage("Select Ok");
  203. }
  204. break;
  205. }
  206. }
  207. //---------------------------------------------------------------------------
  208. void __fastcall TIHS00201::BtnExlSaveClick(TObject *Sender)
  209. {
  210. TcxGrid *pGrid = CxList;
  211. TcxGridTableView *pView = TvList;
  212. String sTitle= Caption;//"프로세스상태이력";
  213. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  214. }
  215. //---------------------------------------------------------------------------
  216. void __fastcall TIHS00201::FormClose(TObject *Sender, TCloseAction &Action)
  217. {
  218. POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
  219. CommClose();
  220. //IHS00201 = NULL;
  221. }
  222. //---------------------------------------------------------------------------
  223. void __fastcall TIHS00201::TvListCustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  224. bool &ADone)
  225. {
  226. if (AViewInfo)
  227. {
  228. String sStatus = AViewInfo->GridRecord->DisplayTexts[Column05->Index];
  229. if (sStatus == "SPS0") ACanvas->Brush->Color = clOlive;
  230. else if (sStatus == "SPS1") ACanvas->Brush->Color = clLime;
  231. else if (sStatus == "SPS2") ACanvas->Brush->Color = clLime;
  232. else if (sStatus == "SPS3") ACanvas->Brush->Color = clRed;
  233. else if (sStatus == "SPS4") ACanvas->Brush->Color = clRed;
  234. }
  235. }
  236. //---------------------------------------------------------------------------
  237. void __fastcall TIHS00201::FormDestroy(TObject *Sender)
  238. {
  239. CommClose();
  240. }
  241. //---------------------------------------------------------------------------