FrmCctvLogCtrlSubF.cpp 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "AppGlobalF.h"
  4. #include "ITSSkinF.h"
  5. #include "ITSUtilF.h"
  6. #include "ITSDbF.h"
  7. #include "ITSLogF.h"
  8. #include "ITSLangTransF.h"
  9. #pragma hdrstop
  10. #include "FrmCctvLogCtrlSubF.h"
  11. //---------------------------------------------------------------------------
  12. #pragma package(smart_init)
  13. #pragma link "cxButtons"
  14. #pragma link "cxCalc"
  15. #pragma link "cxCheckBox"
  16. #pragma link "cxClasses"
  17. #pragma link "cxContainer"
  18. #pragma link "cxControls"
  19. #pragma link "cxCustomData"
  20. #pragma link "cxData"
  21. #pragma link "cxDataStorage"
  22. #pragma link "cxEdit"
  23. #pragma link "cxFilter"
  24. #pragma link "cxGraphics"
  25. #pragma link "cxGrid"
  26. #pragma link "cxGridCustomTableView"
  27. #pragma link "cxGridCustomView"
  28. #pragma link "cxGridLevel"
  29. #pragma link "cxGridTableView"
  30. #pragma link "cxLookAndFeelPainters"
  31. #pragma link "cxLookAndFeels"
  32. #pragma link "cxSplitter"
  33. #pragma link "cxStyles"
  34. #pragma link "cxTextEdit"
  35. #pragma link "dxSkinBlack"
  36. #pragma link "dxSkinBlue"
  37. #pragma link "dxSkinCaramel"
  38. #pragma link "dxSkinCoffee"
  39. #pragma link "dxSkinDarkRoom"
  40. #pragma link "dxSkinDarkSide"
  41. #pragma link "dxSkinFoggy"
  42. #pragma link "dxSkinGlassOceans"
  43. #pragma link "dxSkiniMaginary"
  44. #pragma link "dxSkinLilian"
  45. #pragma link "dxSkinLiquidSky"
  46. #pragma link "dxSkinLondonLiquidSky"
  47. #pragma link "dxSkinMcSkin"
  48. #pragma link "dxSkinMoneyTwins"
  49. #pragma link "dxSkinOffice2007Black"
  50. #pragma link "dxSkinOffice2007Blue"
  51. #pragma link "dxSkinOffice2007Green"
  52. #pragma link "dxSkinOffice2007Pink"
  53. #pragma link "dxSkinOffice2007Silver"
  54. #pragma link "dxSkinOffice2010Black"
  55. #pragma link "dxSkinOffice2010Blue"
  56. #pragma link "dxSkinOffice2010Silver"
  57. #pragma link "dxSkinsCore"
  58. #pragma link "dxSkinscxPCPainter"
  59. #pragma link "dxSkinSeven"
  60. #pragma link "dxSkinSharp"
  61. #pragma link "dxSkinSilver"
  62. #pragma link "dxSkinStardust"
  63. #pragma link "cxLabel"
  64. #pragma resource "*.dfm"
  65. //TFrmCctvLogCtlSub *FrmCctvLogCtlSub = NULL;
  66. //---------------------------------------------------------------------------
  67. __fastcall TFrmCctvLogCtrlSub::TFrmCctvLogCtrlSub(TComponent* Owner, HWND hHandle, String sFrom, String sTo, String sIdList)
  68. : TForm(Owner)
  69. {
  70. LangTrans->Translate(this, ITSDb_GetConnection());
  71. ITSSkin_Load(this);
  72. //CMM_LoadForm(g_sFormsDir, this);
  73. FParent = hHandle;
  74. FStDateTime = sFrom;
  75. FEdDateTime = sTo;
  76. FIdList = sIdList;
  77. }
  78. //---------------------------------------------------------------------------
  79. void __fastcall TFrmCctvLogCtrlSub::FormInit()
  80. {
  81. ADOQry->Connection = ITSDb_GetConnection();
  82. m_pGDC = TvList->DataController;
  83. TvList->OptionsView->NoDataToDisplayInfoText = Caption + ": " + lblText1->Caption;//조회결과가 없습니다.";
  84. LblSearch->Caption = lblText2->Caption + FStDateTime.SubString(1, 10) + " ~ " + FEdDateTime.SubString(1, 10);
  85. }
  86. //---------------------------------------------------------------------------
  87. void __fastcall TFrmCctvLogCtrlSub::FormShow(TObject *Sender)
  88. {
  89. FormInit();
  90. Refresh();
  91. TmrShow->Enabled = true;
  92. }
  93. //---------------------------------------------------------------------------
  94. void __fastcall TFrmCctvLogCtrlSub::CommClose()
  95. {
  96. //CMM_SaveForm(g_sFormsDir, this);
  97. //FrmVmsLogSub = NULL;
  98. }
  99. //---------------------------------------------------------------------------
  100. void __fastcall TFrmCctvLogCtrlSub::TmrShowTimer(TObject *Sender)
  101. {
  102. TmrShow->Enabled = false;
  103. SelHistory();
  104. }
  105. //---------------------------------------------------------------------------
  106. void __fastcall TFrmCctvLogCtrlSub::ChkExpandClick(TObject *Sender)
  107. {
  108. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  109. }
  110. //---------------------------------------------------------------------------
  111. void __fastcall TFrmCctvLogCtrlSub::SelHistory()
  112. {
  113. TSqlCursor sqlCrs;
  114. String sQry;
  115. TADOQuery *pADO = ADOQry;
  116. sQry = "SELECT A.*, B.CCTV_CTLR_ID, B.ISTL_LCTN_NM \r\n"
  117. " FROM TB_CCTV_CTRL_HS A, \r\n"
  118. " TB_CCTV_CTLR B \r\n"
  119. " WHERE B.CCTV_CTLR_NMBR IN(" + FIdList + ") \r\n"
  120. " AND A.CTRL_DT BETWEEN :p01 AND :p02 \r\n"
  121. " AND A.CCTV_CTLR_NMBR = B.CCTV_CTLR_NMBR \r\n";
  122. try
  123. {
  124. ITSDb_SQLText(pADO, sQry);
  125. ITSDb_SQLBind(pADO, "p01", FStDateTime);
  126. ITSDb_SQLBind(pADO, "p02", FEdDateTime);
  127. ITSDb_SQLOpen(pADO);
  128. }
  129. catch(EDatabaseError &E)
  130. {
  131. DBERRORMSG("History Qeury", String(E.ClassName()), E.Message, sQry);
  132. throw Exception(String(E.ClassName()) + E.Message);
  133. }
  134. catch(Exception &e)
  135. {
  136. DBERRORMSG("History Qeury", String(e.ClassName()), e.Message, sQry);
  137. throw Exception(String(e.ClassName()) + e.Message);
  138. }
  139. DspHistory();
  140. }
  141. //---------------------------------------------------------------------------
  142. void __fastcall TFrmCctvLogCtrlSub::DspHistory()
  143. {
  144. TADOQuery *pADO = ADOQry;
  145. try
  146. {
  147. CMM_ClearGridTableView(TvList);
  148. int nRow = 0;
  149. int nDataCnt = 0;
  150. try
  151. {
  152. TvList->BeginUpdate(lsimImmediate);
  153. nDataCnt = pADO->RecordCount;
  154. m_pGDC->RecordCount = nDataCnt;
  155. for( ; !pADO->Eof; pADO->Next(), nRow++)
  156. {
  157. m_pGDC->Values[nRow][Col00->Index] = pADO->FieldByName("CCTV_CTLR_NMBR")->AsString;
  158. m_pGDC->Values[nRow][Col01->Index] = pADO->FieldByName("CCTV_CTLR_ID")->AsString;
  159. m_pGDC->Values[nRow][Col02->Index] = pADO->FieldByName("ISTL_LCTN_NM")->AsString;
  160. String sCtlType = pADO->FieldByName("CTL_TYPE")->AsString;
  161. //제어유형(V01:전광판ON,V02:전광판OFF,V03:제어기리셋,V04:함체환경설정,V05:전광판ON/OFF시각설정)
  162. if (sCtlType == "V01") sCtlType = lblV01->Caption;//"전광판ON";
  163. else if (sCtlType == "V02") sCtlType = lblV02->Caption;//"전광판OFF";
  164. else if (sCtlType == "V03") sCtlType = lblV03->Caption;//"제어기리셋";
  165. else if (sCtlType == "V04") sCtlType = lblV04->Caption;//"함체환경설정";
  166. else if (sCtlType == "V05") sCtlType = lblV05->Caption;//"전광판ON/OFF시각설정";
  167. else if (sCtlType == "V06") sCtlType = lblV06->Caption;//"운영모드변경";
  168. else if (sCtlType == "V07") sCtlType = lblV07->Caption;//"휘도제어";
  169. else if (sCtlType == "V08") sCtlType = lblV08->Caption;//"기본메시지다운로드";
  170. else if (sCtlType == "V09") sCtlType = lblV09->Caption;//"폼 표출주기";
  171. else if (sCtlType == "V10") sCtlType = lblV10->Caption;//"폼 즉시 다운로드";
  172. #if 0
  173. if (sCtlType == "V01") sCtlType = "Board On";
  174. else if (sCtlType == "V02") sCtlType = "Board Off";
  175. else if (sCtlType == "V03") sCtlType = "Reset";
  176. else if (sCtlType == "V04") sCtlType = "Parameter Set";
  177. else if (sCtlType == "V05") sCtlType = "Board ON/OFF Time Set";
  178. else if (sCtlType == "V06") sCtlType = "Operating Mode Change";
  179. else if (sCtlType == "V07") sCtlType = "Luminance contorol";
  180. else if (sCtlType == "V08") sCtlType = "Default Message Download";
  181. else if (sCtlType == "V09") sCtlType = "Form Display Cycle Time";
  182. else if (sCtlType == "V10") sCtlType = "Form Immediately Download";
  183. #endif
  184. m_pGDC->Values[nRow][Col03->Index] = sCtlType;
  185. m_pGDC->Values[nRow][Col04->Index] = ITSUtil_StrToDateTime(pADO->FieldByName("CTRL_DT")->AsString).FormatString(STR_DATETIME);
  186. m_pGDC->Values[nRow][Col05->Index] = pADO->FieldByName("CTRL_VAL")->AsString;
  187. m_pGDC->Values[nRow][Col06->Index] = pADO->FieldByName("CTRL_RESULT")->AsInteger == 1 ? lblSucc->Caption : lblFai->Caption;//"성공" : "실패";
  188. m_pGDC->Values[nRow][Col07->Index] = pADO->FieldByName("USER_ID")->AsString;
  189. }
  190. }
  191. __finally
  192. {
  193. if (pADO)
  194. {
  195. pADO->Close();
  196. }
  197. TvList->EndUpdate();
  198. //CxList->SetFocus();
  199. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + lblCnt->Caption;//" 건";
  200. }
  201. }
  202. catch(EDatabaseError &E)
  203. {
  204. DBERRORMSG("History Results", String(E.ClassName()), E.Message, pADO->SQL->Text);
  205. throw Exception(String(E.ClassName()) + E.Message);
  206. }
  207. catch(Exception &e)
  208. {
  209. DBERRORMSG("History Results", String(e.ClassName()), e.Message, pADO->SQL->Text);
  210. throw Exception(String(e.ClassName()) + e.Message);
  211. }
  212. }
  213. //---------------------------------------------------------------------------
  214. void __fastcall TFrmCctvLogCtrlSub::BtnExlSaveClick(TObject *Sender)
  215. {
  216. TcxGrid *pGrid = CxList;
  217. TcxGridTableView *pView = TvList;
  218. String sTitle= Caption;
  219. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  220. }
  221. //---------------------------------------------------------------------------
  222. void __fastcall TFrmCctvLogCtrlSub::FormClose(TObject *Sender, TCloseAction &Action)
  223. {
  224. POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
  225. CommClose();
  226. }
  227. //---------------------------------------------------------------------------
  228. void __fastcall TFrmCctvLogCtrlSub::FormDestroy(TObject *Sender)
  229. {
  230. //
  231. }
  232. //---------------------------------------------------------------------------
  233. void __fastcall TFrmCctvLogCtrlSub::Col06CustomDrawCell(TcxCustomGridTableView *Sender,
  234. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  235. bool &ADone)
  236. {
  237. try
  238. {
  239. TColor tColor;
  240. String sResult = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
  241. tColor = ACanvas->Brush->Color;
  242. if (sResult == lblFai->Caption)//"실패")
  243. tColor = clRed;
  244. //else tColor = clLime;
  245. ACanvas->SetBrushColor(tColor);
  246. }
  247. catch(Exception &e)
  248. {
  249. }
  250. }
  251. //---------------------------------------------------------------------------