CCAM010MF.cpp 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "AppGlobalF.h"
  4. #include "ITSSkinF.h"
  5. #include "ITSUtilF.h"
  6. #include "ITSLangTransF.h"
  7. #pragma hdrstop
  8. #include "CCAM010MF.h"
  9. //---------------------------------------------------------------------------
  10. #pragma package(smart_init)
  11. #pragma link "cxButtons"
  12. #pragma link "cxClasses"
  13. #pragma link "cxContainer"
  14. #pragma link "cxControls"
  15. #pragma link "cxCustomData"
  16. #pragma link "cxData"
  17. #pragma link "cxDataStorage"
  18. #pragma link "cxEdit"
  19. #pragma link "cxFilter"
  20. #pragma link "cxGraphics"
  21. #pragma link "cxGrid"
  22. #pragma link "cxGridBandedTableView"
  23. #pragma link "cxGridCustomTableView"
  24. #pragma link "cxGridCustomView"
  25. #pragma link "cxGridLevel"
  26. #pragma link "cxGridTableView"
  27. #pragma link "cxGroupBox"
  28. #pragma link "cxLabel"
  29. #pragma link "cxLookAndFeelPainters"
  30. #pragma link "cxLookAndFeels"
  31. #pragma link "cxStyles"
  32. #pragma link "cxTextEdit"
  33. #pragma link "dxSkinBlue"
  34. #pragma link "dxSkinsCore"
  35. #pragma link "dxSkinscxPCPainter"
  36. #pragma resource "*.dfm"
  37. TCCAM010M *CCAM010M = NULL;
  38. //---------------------------------------------------------------------------
  39. __fastcall TCCAM010M::TCCAM010M(TComponent* Owner)
  40. : TForm(Owner)
  41. {
  42. LangTrans->Translate(this, ITSDb_GetConnection());
  43. ITSSkin_Load(this);
  44. LoadLocalSkin();
  45. FTitle = Caption;
  46. CMM_LoadForm(g_sFormsDir, this);
  47. }
  48. //---------------------------------------------------------------------------
  49. void __fastcall TCCAM010M::CommClose()
  50. {
  51. try
  52. {
  53. CMM_SaveForm(g_sFormsDir, this);
  54. }
  55. catch(...)
  56. {
  57. }
  58. }
  59. //---------------------------------------------------------------------------
  60. void __fastcall TCCAM010M::FormCreate(TObject *Sender)
  61. {
  62. //
  63. }
  64. //---------------------------------------------------------------------------
  65. void __fastcall TCCAM010M::FormShow(TObject *Sender)
  66. {
  67. Refresh();
  68. Application->ProcessMessages();
  69. TmrShow->Enabled = true;
  70. }
  71. //---------------------------------------------------------------------------
  72. void __fastcall TCCAM010M::LoadLocalSkin()
  73. {
  74. }
  75. //---------------------------------------------------------------------------
  76. void __fastcall TCCAM010M::TmrShowTimer(TObject *Sender)
  77. {
  78. TmrShow->Enabled = false;
  79. BtnSearchClick(NULL);
  80. }
  81. //---------------------------------------------------------------------------
  82. void __fastcall TCCAM010M::FormClose(TObject *Sender, TCloseAction &Action)
  83. {
  84. try {
  85. CommClose();
  86. CCAM010M = NULL;
  87. Action = caFree;
  88. } catch(...) {}
  89. }
  90. //---------------------------------------------------------------------------
  91. void __fastcall TCCAM010M::OnMainFormMessage(TMessage &Msg)
  92. {
  93. }
  94. //---------------------------------------------------------------------------
  95. void __fastcall TCCAM010M::Refreshtatus(bool ARealtime/*=false*/)
  96. {
  97. String sQry;
  98. TADOQuery *pADO = NULL;
  99. sQry = "SELECT B.CCAM_CTLR_NMBR, B.CCAM_CTLR_ID, B.CCAM_NM, B.CCAM_CTLR_IP, \r\n"
  100. " A.UPDT_DT, A.CMNC_STTS_CD \r\n"
  101. " FROM (SELECT * \r\n"
  102. " FROM TB_CCAM_CTLR_STTS \r\n"
  103. " WHERE UPDT_DT >= TO_CHAR(SYSDATE-5/1440, 'YYYYMMDDHH24MISS') \r\n"
  104. " ) A, \r\n"
  105. " TB_CCAM_CTLR B \r\n"
  106. " WHERE A.CCAM_CTLR_NMBR(+) = B.CCAM_CTLR_NMBR \r\n";
  107. CMM_ClearGridTableView(TvList);
  108. try
  109. {
  110. int nRow;
  111. TvList->BeginUpdate();
  112. try
  113. {
  114. pADO = new TADOQuery(NULL);
  115. pADO->Close();
  116. pADO->Connection = ITSDb_GetConnection();
  117. pADO->SQL->Clear();
  118. pADO->SQL->Text = sQry;
  119. pADO->Prepared = true;
  120. pADO->Open();
  121. for( ; !pADO->Eof; pADO->Next())
  122. {
  123. nRow = TvList->DataController->AppendRecord();
  124. TvList->DataController->Values[nRow][ColNmbr->Index] = pADO->FieldByName("CCAM_CTLR_NMBR")->AsString;
  125. TvList->DataController->Values[nRow][ColId->Index] = pADO->FieldByName("CCAM_CTLR_ID")->AsString;
  126. TvList->DataController->Values[nRow][ColName->Index] = pADO->FieldByName("CCAM_NM")->AsString;
  127. String UPDT_DT = pADO->FieldByName("UPDT_DT")->AsString;
  128. if (UPDT_DT != "")
  129. {
  130. TvList->DataController->Values[nRow][ColUpdtDt->Index] = ITSUtil_StrToDateTime(UPDT_DT).FormatString(STR_DATETIME);
  131. String CMNC_STTS_CD = pADO->FieldByName("CMNC_STTS_CD")->AsString;
  132. if (CMNC_STTS_CD == "CMS0") TvList->DataController->Values[nRow][ColCommS->Index] = FrmLang->lblComm0->Caption;
  133. else
  134. if (CMNC_STTS_CD == "CMS1") TvList->DataController->Values[nRow][ColCommS->Index] = FrmLang->lblComm1->Caption;
  135. else TvList->DataController->Values[nRow][ColCommS->Index] = FrmLang->lblUnknown->Caption;
  136. }
  137. else
  138. {
  139. TvList->DataController->Values[nRow][ColUpdtDt->Index] = "-";
  140. TvList->DataController->Values[nRow][ColCommS->Index] = FrmLang->lblUnknown->Caption;
  141. }
  142. }
  143. }
  144. catch(EDatabaseError &E)
  145. {
  146. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  147. DBERRORMSG("TCCAM010M::Refreshtatus", String(E.ClassName()), E.Message, sQry);
  148. throw Exception(String(E.ClassName()) + E.Message);
  149. }
  150. catch(Exception &exception)
  151. {
  152. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  153. DBERRORMSG("TCCAM010M::Refreshtatus", String(exception.ClassName()), exception.Message, sQry);
  154. throw Exception(String(exception.ClassName()) + exception.Message);
  155. }
  156. }
  157. __finally
  158. {
  159. if (pADO)
  160. {
  161. pADO->Close();
  162. delete pADO;
  163. }
  164. TvList->EndUpdate();
  165. }
  166. }
  167. //---------------------------------------------------------------------------
  168. void __fastcall TCCAM010M::RefreshData()
  169. {
  170. try
  171. {
  172. LockWindowUpdate(Handle);
  173. Refreshtatus();
  174. }
  175. __finally
  176. {
  177. LockWindowUpdate(0);
  178. }
  179. }
  180. //---------------------------------------------------------------------------
  181. void __fastcall TCCAM010M::BtnSearchClick(TObject *Sender)
  182. {
  183. RefreshData();
  184. }
  185. //---------------------------------------------------------------------------
  186. void __fastcall TCCAM010M::ColCommSCustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  187. bool &ADone)
  188. {
  189. TColor tColor = ACanvas->Brush->Color;
  190. TColor tFont = clBlack;
  191. try
  192. {
  193. if (!VarIsNull(AViewInfo->Value))
  194. {
  195. String sTmp = AViewInfo->Value;
  196. if (sTmp == FrmLang->lblComm0->Caption)
  197. {
  198. tColor = clLime;
  199. }
  200. else
  201. if (sTmp == FrmLang->lblComm1->Caption)
  202. {
  203. tColor = clRed;
  204. }
  205. else
  206. {
  207. tColor = clSilver;
  208. }
  209. }
  210. ACanvas->Font->Color = tFont;
  211. ACanvas->SetBrushColor(tColor);
  212. }
  213. catch(...)
  214. {
  215. }
  216. }
  217. //---------------------------------------------------------------------------
  218. void __fastcall TCCAM010M::BtnCloseClick(TObject *Sender)
  219. {
  220. Close();
  221. }
  222. //---------------------------------------------------------------------------