CCAM010MF.cpp 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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 "CCAM010MF.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. TCCAM010M *CCAM010M = NULL;
  41. //---------------------------------------------------------------------------
  42. __fastcall TCCAM010M::TCCAM010M(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 TCCAM010M::CommClose()
  53. {
  54. try
  55. {
  56. CMM_SaveForm(g_sFormsDir, this);
  57. }
  58. catch(...)
  59. {
  60. }
  61. }
  62. //---------------------------------------------------------------------------
  63. void __fastcall TCCAM010M::FormCreate(TObject *Sender)
  64. {
  65. //
  66. }
  67. //---------------------------------------------------------------------------
  68. void __fastcall TCCAM010M::FormShow(TObject *Sender)
  69. {
  70. Refresh();
  71. Application->ProcessMessages();
  72. TmrShow->Enabled = true;
  73. }
  74. //---------------------------------------------------------------------------
  75. void __fastcall TCCAM010M::LoadLocalSkin()
  76. {
  77. }
  78. //---------------------------------------------------------------------------
  79. void __fastcall TCCAM010M::TmrShowTimer(TObject *Sender)
  80. {
  81. TmrShow->Enabled = false;
  82. BtnSearchClick(NULL);
  83. }
  84. //---------------------------------------------------------------------------
  85. void __fastcall TCCAM010M::FormClose(TObject *Sender, TCloseAction &Action)
  86. {
  87. try {
  88. CommClose();
  89. CCAM010M = NULL;
  90. Action = caFree;
  91. } catch(...) {}
  92. }
  93. //---------------------------------------------------------------------------
  94. void __fastcall TCCAM010M::OnMainFormMessage(TMessage &Msg)
  95. {
  96. }
  97. //---------------------------------------------------------------------------
  98. void __fastcall TCCAM010M::Refreshtatus(bool ARealtime/*=false*/)
  99. {
  100. String sQry;
  101. TADOQuery *pADO = NULL;
  102. sQry = "SELECT B.CCAM_CTLR_NMBR, B.CCAM_CTLR_ID, B.CCAM_NM, B.CCAM_CTLR_IP, \r\n"
  103. " A.UPDT_DT, A.CMNC_STTS_CD \r\n"
  104. " FROM (SELECT * \r\n"
  105. " FROM TB_CCAM_CTLR_STTS \r\n"
  106. " WHERE UPDT_DT >= TO_CHAR(SYSDATE-5/1440, 'YYYYMMDDHH24MISS') \r\n"
  107. " ) A, \r\n"
  108. " TB_CCAM_CTLR B \r\n"
  109. " WHERE A.CCAM_CTLR_NMBR(+) = B.CCAM_CTLR_NMBR \r\n";
  110. CMM_ClearGridTableView(TvList);
  111. try
  112. {
  113. int nRow;
  114. TvList->BeginUpdate();
  115. try
  116. {
  117. pADO = new TADOQuery(NULL);
  118. pADO->Close();
  119. pADO->Connection = ITSDb_GetConnection();
  120. pADO->SQL->Clear();
  121. pADO->SQL->Text = sQry;
  122. pADO->Prepared = true;
  123. pADO->Open();
  124. for( ; !pADO->Eof; pADO->Next())
  125. {
  126. nRow = TvList->DataController->AppendRecord();
  127. TvList->DataController->Values[nRow][ColNmbr->Index] = pADO->FieldByName("CCAM_CTLR_NMBR")->AsString;
  128. TvList->DataController->Values[nRow][ColId->Index] = pADO->FieldByName("CCAM_CTLR_ID")->AsString;
  129. TvList->DataController->Values[nRow][ColName->Index] = pADO->FieldByName("CCAM_NM")->AsString;
  130. String UPDT_DT = pADO->FieldByName("UPDT_DT")->AsString;
  131. if (UPDT_DT != "")
  132. {
  133. TvList->DataController->Values[nRow][ColUpdtDt->Index] = ITSUtil_StrToDateTime(UPDT_DT).FormatString(STR_DATETIME);
  134. String CMNC_STTS_CD = pADO->FieldByName("CMNC_STTS_CD")->AsString;
  135. if (CMNC_STTS_CD == "CMS0") TvList->DataController->Values[nRow][ColCommS->Index] = FrmLang->lblComm0->Caption;
  136. else
  137. if (CMNC_STTS_CD == "CMS1") TvList->DataController->Values[nRow][ColCommS->Index] = FrmLang->lblComm1->Caption;
  138. else TvList->DataController->Values[nRow][ColCommS->Index] = FrmLang->lblUnknown->Caption;
  139. }
  140. else
  141. {
  142. TvList->DataController->Values[nRow][ColUpdtDt->Index] = "-";
  143. TvList->DataController->Values[nRow][ColCommS->Index] = FrmLang->lblUnknown->Caption;
  144. }
  145. }
  146. }
  147. catch(EDatabaseError &E)
  148. {
  149. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  150. DBERRORMSG("TCCAM010M::Refreshtatus", String(E.ClassName()), E.Message, sQry);
  151. throw Exception(String(E.ClassName()) + E.Message);
  152. }
  153. catch(Exception &exception)
  154. {
  155. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  156. DBERRORMSG("TCCAM010M::Refreshtatus", String(exception.ClassName()), exception.Message, sQry);
  157. throw Exception(String(exception.ClassName()) + exception.Message);
  158. }
  159. }
  160. __finally
  161. {
  162. if (pADO)
  163. {
  164. pADO->Close();
  165. delete pADO;
  166. }
  167. TvList->EndUpdate();
  168. }
  169. }
  170. //---------------------------------------------------------------------------
  171. void __fastcall TCCAM010M::RefreshData()
  172. {
  173. try
  174. {
  175. LockWindowUpdate(Handle);
  176. Refreshtatus();
  177. }
  178. __finally
  179. {
  180. LockWindowUpdate(0);
  181. }
  182. }
  183. //---------------------------------------------------------------------------
  184. void __fastcall TCCAM010M::BtnSearchClick(TObject *Sender)
  185. {
  186. RefreshData();
  187. }
  188. //---------------------------------------------------------------------------
  189. void __fastcall TCCAM010M::ColCommSCustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  190. bool &ADone)
  191. {
  192. TColor tColor = ACanvas->Brush->Color;
  193. TColor tFont = clBlack;
  194. try
  195. {
  196. if (!VarIsNull(AViewInfo->Value))
  197. {
  198. String sTmp = AViewInfo->Value;
  199. if (sTmp == FrmLang->lblComm0->Caption)
  200. {
  201. tColor = clLime;
  202. }
  203. else
  204. if (sTmp == FrmLang->lblComm1->Caption)
  205. {
  206. tColor = clRed;
  207. }
  208. else
  209. {
  210. tColor = clSilver;
  211. }
  212. }
  213. ACanvas->Font->Color = tFont;
  214. ACanvas->SetBrushColor(tColor);
  215. }
  216. catch(...)
  217. {
  218. }
  219. }
  220. //---------------------------------------------------------------------------
  221. void __fastcall TCCAM010M::BtnCloseClick(TObject *Sender)
  222. {
  223. Close();
  224. }
  225. //---------------------------------------------------------------------------