IHS00201F.cpp 11 KB

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