WCAM010MF.cpp 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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. sQry = "SELECT B.WCAM_CTLR_NMBR, B.WCAM_CTLR_ID, B.WCAM_NM, B.WCAM_CTLR_IP, \r\n"
  103. " B.WCAM_TYPE_CD, \r\n"
  104. " (SELECT CMMN_CD_KOR_NM \r\n"
  105. " FROM TB_CMMN_CD \r\n"
  106. " WHERE CMMN_CLSF_CD = 'WCAM' \r\n"
  107. " AND CMMN_CD = B.WCAM_TYPE_CD) AS WCAM_TYPE_NM, \r\n"
  108. " A.UPDT_DT, A.CMNC_STTS_CD \r\n"
  109. " FROM (SELECT * \r\n"
  110. " FROM TB_WCAM_CTLR_STTS \r\n"
  111. " WHERE UPDT_DT >= TO_CHAR(SYSDATE-5/1440, 'YYYYMMDDHH24MISS') \r\n"
  112. " ) A, \r\n"
  113. " TB_WCAM_CTLR B \r\n"
  114. " WHERE A.WCAM_CTLR_NMBR(+) = B.WCAM_CTLR_NMBR \r\n"
  115. " ORDER BY WCAM_TYPE_NM, B.WCAM_CTLR_NMBR \r\n";
  116. CMM_ClearGridTableView(TvList);
  117. try
  118. {
  119. int nRow;
  120. TvList->BeginUpdate();
  121. try
  122. {
  123. pADO = new TADOQuery(NULL);
  124. pADO->Close();
  125. pADO->Connection = ITSDb_GetConnection();
  126. pADO->SQL->Clear();
  127. pADO->SQL->Text = sQry;
  128. pADO->Prepared = true;
  129. pADO->Open();
  130. for( ; !pADO->Eof; pADO->Next())
  131. {
  132. nRow = TvList->DataController->AppendRecord();
  133. TvList->DataController->Values[nRow][ColTypeNm->Index] = pADO->FieldByName("WCAM_TYPE_NM")->AsString;
  134. TvList->DataController->Values[nRow][ColNmbr->Index] = pADO->FieldByName("WCAM_CTLR_NMBR")->AsString;
  135. TvList->DataController->Values[nRow][ColId->Index] = pADO->FieldByName("WCAM_CTLR_ID")->AsString;
  136. TvList->DataController->Values[nRow][ColName->Index] = pADO->FieldByName("WCAM_NM")->AsString;
  137. String UPDT_DT = pADO->FieldByName("UPDT_DT")->AsString;
  138. if (UPDT_DT != "")
  139. {
  140. TvList->DataController->Values[nRow][ColUpdtDt->Index] = ITSUtil_StrToDateTime(UPDT_DT).FormatString(STR_DATETIME);
  141. String CMNC_STTS_CD = pADO->FieldByName("CMNC_STTS_CD")->AsString;
  142. if (CMNC_STTS_CD == "CMS0") TvList->DataController->Values[nRow][ColCommS->Index] = FrmLang->lblComm0->Caption;
  143. else
  144. if (CMNC_STTS_CD == "CMS1") TvList->DataController->Values[nRow][ColCommS->Index] = FrmLang->lblComm1->Caption;
  145. else TvList->DataController->Values[nRow][ColCommS->Index] = FrmLang->lblUnknown->Caption;
  146. }
  147. else
  148. {
  149. TvList->DataController->Values[nRow][ColUpdtDt->Index] = "-";
  150. TvList->DataController->Values[nRow][ColCommS->Index] = FrmLang->lblUnknown->Caption;
  151. }
  152. }
  153. }
  154. catch(EDatabaseError &E)
  155. {
  156. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  157. DBERRORMSG("TWCAM010M::Refreshtatus", String(E.ClassName()), E.Message, sQry);
  158. throw Exception(String(E.ClassName()) + E.Message);
  159. }
  160. catch(Exception &exception)
  161. {
  162. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  163. DBERRORMSG("TWCAM010M::Refreshtatus", String(exception.ClassName()), exception.Message, sQry);
  164. throw Exception(String(exception.ClassName()) + exception.Message);
  165. }
  166. }
  167. __finally
  168. {
  169. if (pADO)
  170. {
  171. pADO->Close();
  172. delete pADO;
  173. }
  174. TvList->EndUpdate();
  175. }
  176. }
  177. //---------------------------------------------------------------------------
  178. void __fastcall TWCAM010M::RefreshData()
  179. {
  180. try
  181. {
  182. LockWindowUpdate(Handle);
  183. Refreshtatus();
  184. }
  185. __finally
  186. {
  187. LockWindowUpdate(0);
  188. }
  189. }
  190. //---------------------------------------------------------------------------
  191. void __fastcall TWCAM010M::BtnSearchClick(TObject *Sender)
  192. {
  193. RefreshData();
  194. }
  195. //---------------------------------------------------------------------------
  196. void __fastcall TWCAM010M::ColCommSCustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  197. bool &ADone)
  198. {
  199. TColor tColor = ACanvas->Brush->Color;
  200. TColor tFont = clBlack;
  201. try
  202. {
  203. if (!VarIsNull(AViewInfo->Value))
  204. {
  205. String sTmp = AViewInfo->Value;
  206. if (sTmp == FrmLang->lblComm0->Caption)
  207. {
  208. tColor = clLime;
  209. }
  210. else
  211. if (sTmp == FrmLang->lblComm1->Caption)
  212. {
  213. tColor = clRed;
  214. }
  215. else
  216. {
  217. tColor = clSilver;
  218. }
  219. }
  220. ACanvas->Font->Color = tFont;
  221. ACanvas->SetBrushColor(tColor);
  222. }
  223. catch(...)
  224. {
  225. }
  226. }
  227. //---------------------------------------------------------------------------
  228. void __fastcall TWCAM010M::BtnCloseClick(TObject *Sender)
  229. {
  230. Close();
  231. }
  232. //---------------------------------------------------------------------------