FrmVmsLogCtrlSubF.cpp 10 KB

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