WCAM010MF.cpp 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "AppGlobalF.h"
  4. #include "ITSSkinF.h"
  5. #include "ITSUtilF.h"
  6. #include "ITSLangTransF.h"
  7. #include "ITS_OPLibF.h"
  8. #pragma hdrstop
  9. #include "WCAM010MF.h"
  10. //---------------------------------------------------------------------------
  11. #pragma package(smart_init)
  12. #pragma link "cxButtons"
  13. #pragma link "cxClasses"
  14. #pragma link "cxContainer"
  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 "cxGridBandedTableView"
  24. #pragma link "cxGridCustomTableView"
  25. #pragma link "cxGridCustomView"
  26. #pragma link "cxGridLevel"
  27. #pragma link "cxGridTableView"
  28. #pragma link "cxGroupBox"
  29. #pragma link "cxLabel"
  30. #pragma link "cxLookAndFeelPainters"
  31. #pragma link "cxLookAndFeels"
  32. #pragma link "cxStyles"
  33. #pragma link "cxTextEdit"
  34. #pragma link "dxSkinBlue"
  35. #pragma link "dxSkinsCore"
  36. #pragma link "dxSkinscxPCPainter"
  37. #pragma link "dxSkinBlack"
  38. #pragma link "dxSkinMcSkin"
  39. #pragma resource "*.dfm"
  40. TWCAM010M *WCAM010M = NULL;
  41. //---------------------------------------------------------------------------
  42. __fastcall TWCAM010M::TWCAM010M(TComponent* Owner)
  43. : TForm(Owner)
  44. {
  45. LangTrans->Translate(this, ITSDb_GetConnection());
  46. ITSSkin_Load(this);
  47. LoadLocalSkin();
  48. FTitle = Caption;
  49. CMM_LoadForm(g_sFormsDir, this);
  50. }
  51. //---------------------------------------------------------------------------
  52. void __fastcall TWCAM010M::CommClose()
  53. {
  54. try
  55. {
  56. CMM_SaveForm(g_sFormsDir, this);
  57. }
  58. catch(...)
  59. {
  60. }
  61. }
  62. //---------------------------------------------------------------------------
  63. void __fastcall TWCAM010M::FormCreate(TObject *Sender)
  64. {
  65. //
  66. }
  67. //---------------------------------------------------------------------------
  68. void __fastcall TWCAM010M::FormShow(TObject *Sender)
  69. {
  70. Refresh();
  71. Application->ProcessMessages();
  72. TmrShow->Enabled = true;
  73. }
  74. //---------------------------------------------------------------------------
  75. void __fastcall TWCAM010M::LoadLocalSkin()
  76. {
  77. }
  78. //---------------------------------------------------------------------------
  79. void __fastcall TWCAM010M::TmrShowTimer(TObject *Sender)
  80. {
  81. TmrShow->Enabled = false;
  82. BtnSearchClick(NULL);
  83. }
  84. //---------------------------------------------------------------------------
  85. void __fastcall TWCAM010M::FormClose(TObject *Sender, TCloseAction &Action)
  86. {
  87. try {
  88. CommClose();
  89. WCAM010M = NULL;
  90. Action = caFree;
  91. } catch(...) {}
  92. }
  93. //---------------------------------------------------------------------------
  94. void __fastcall TWCAM010M::OnMainFormMessage(TMessage &Msg)
  95. {
  96. }
  97. //---------------------------------------------------------------------------
  98. void __fastcall TWCAM010M::Refreshtatus(bool ARealtime/*=false*/)
  99. {
  100. String sQry;
  101. TADOQuery *pADO = NULL;
  102. #ifdef USE_WEB_CMRA
  103. sQry = "SELECT B.WEB_CMRA_NMBR AS WCAM_CTLR_NMBR, B.WEB_CMRA_ID AS WCAM_CTLR_ID,\r\n"
  104. " B.ISTL_LCTN_NM AS WCAM_NM, B.CMRA_IP AS WCAM_CTLR_IP, \r\n"
  105. " 'WCAM' AS WCAM_TYPE_CD, \r\n"
  106. " 'À¥Ä«¸Þ¶ó' AS WCAM_TYPE_NM, \r\n"
  107. " A.UPDT_DT, A.CMNC_STTS_CD \r\n"
  108. " FROM (SELECT * \r\n"
  109. " FROM TB_WEB_CMRA_STTS \r\n"
  110. " WHERE UPDT_DT >= TO_CHAR(SYSDATE-5/1440, 'YYYYMMDDHH24MISS') \r\n"
  111. " ) A, \r\n"
  112. " TB_WEB_CMRA B \r\n"
  113. " WHERE A.WEB_CMRA_NMBR(+) = B.WEB_CMRA_NMBR \r\n"
  114. " ORDER BY WCAM_TYPE_NM, B.WEB_CMRA_NMBR \r\n";
  115. #else
  116. sQry = "SELECT B.WCAM_CTLR_NMBR, B.WCAM_CTLR_ID, B.WCAM_NM, B.WCAM_CTLR_IP, \r\n"
  117. " B.WCAM_TYPE_CD, \r\n"
  118. " (SELECT CMMN_CD_KOR_NM \r\n"
  119. " FROM TB_CMMN_CD \r\n"
  120. " WHERE CMMN_CLSF_CD = 'WCAM' \r\n"
  121. " AND CMMN_CD = B.WCAM_TYPE_CD) AS WCAM_TYPE_NM, \r\n"
  122. " A.UPDT_DT, A.CMNC_STTS_CD \r\n"
  123. " FROM (SELECT * \r\n"
  124. " FROM TB_WCAM_CTLR_STTS \r\n"
  125. " WHERE UPDT_DT >= TO_CHAR(SYSDATE-5/1440, 'YYYYMMDDHH24MISS') \r\n"
  126. " ) A, \r\n"
  127. " TB_WCAM_CTLR B \r\n"
  128. " WHERE A.WCAM_CTLR_NMBR(+) = B.WCAM_CTLR_NMBR \r\n"
  129. " ORDER BY WCAM_TYPE_NM, B.WCAM_CTLR_NMBR \r\n";
  130. #endif
  131. CMM_ClearGridTableView(TvList);
  132. try
  133. {
  134. int nRow;
  135. TvList->BeginUpdate();
  136. try
  137. {
  138. pADO = new TADOQuery(NULL);
  139. pADO->Close();
  140. pADO->Connection = ITSDb_GetConnection();
  141. pADO->SQL->Clear();
  142. pADO->SQL->Text = sQry;
  143. pADO->Prepared = true;
  144. pADO->Open();
  145. for( ; !pADO->Eof; pADO->Next())
  146. {
  147. nRow = TvList->DataController->AppendRecord();
  148. TvList->DataController->Values[nRow][ColTypeNm->Index] = pADO->FieldByName("WCAM_TYPE_NM")->AsString;
  149. TvList->DataController->Values[nRow][ColNmbr->Index] = pADO->FieldByName("WCAM_CTLR_NMBR")->AsString;
  150. TvList->DataController->Values[nRow][ColId->Index] = pADO->FieldByName("WCAM_CTLR_ID")->AsString;
  151. TvList->DataController->Values[nRow][ColName->Index] = pADO->FieldByName("WCAM_NM")->AsString;
  152. String UPDT_DT = pADO->FieldByName("UPDT_DT")->AsString;
  153. if (UPDT_DT != "")
  154. {
  155. TvList->DataController->Values[nRow][ColUpdtDt->Index] = ITSUtil_StrToDateTime(UPDT_DT).FormatString(STR_DATETIME);
  156. String CMNC_STTS_CD = pADO->FieldByName("CMNC_STTS_CD")->AsString;
  157. if (CMNC_STTS_CD == "CMS0") TvList->DataController->Values[nRow][ColCommS->Index] = FrmLang->lblComm0->Caption;
  158. else
  159. if (CMNC_STTS_CD == "CMS1") TvList->DataController->Values[nRow][ColCommS->Index] = FrmLang->lblComm1->Caption;
  160. else TvList->DataController->Values[nRow][ColCommS->Index] = FrmLang->lblUnknown->Caption;
  161. }
  162. else
  163. {
  164. TvList->DataController->Values[nRow][ColUpdtDt->Index] = "-";
  165. TvList->DataController->Values[nRow][ColCommS->Index] = FrmLang->lblUnknown->Caption;
  166. }
  167. }
  168. }
  169. catch(EDatabaseError &E)
  170. {
  171. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  172. DBERRORMSG("TWCAM010M::Refreshtatus", String(E.ClassName()), E.Message, sQry);
  173. throw Exception(String(E.ClassName()) + E.Message);
  174. }
  175. catch(Exception &exception)
  176. {
  177. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  178. DBERRORMSG("TWCAM010M::Refreshtatus", String(exception.ClassName()), exception.Message, sQry);
  179. throw Exception(String(exception.ClassName()) + exception.Message);
  180. }
  181. }
  182. __finally
  183. {
  184. if (pADO)
  185. {
  186. pADO->Close();
  187. delete pADO;
  188. }
  189. TvList->EndUpdate();
  190. }
  191. }
  192. //---------------------------------------------------------------------------
  193. void __fastcall TWCAM010M::RefreshData()
  194. {
  195. try
  196. {
  197. LockWindowUpdate(Handle);
  198. Refreshtatus();
  199. }
  200. __finally
  201. {
  202. LockWindowUpdate(0);
  203. }
  204. }
  205. //---------------------------------------------------------------------------
  206. void __fastcall TWCAM010M::BtnSearchClick(TObject *Sender)
  207. {
  208. RefreshData();
  209. }
  210. //---------------------------------------------------------------------------
  211. void __fastcall TWCAM010M::ColCommSCustomDrawCell(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. //---------------------------------------------------------------------------
  243. void __fastcall TWCAM010M::BtnCloseClick(TObject *Sender)
  244. {
  245. Close();
  246. }
  247. //---------------------------------------------------------------------------