WCAMH101F.cpp 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "ITSUtilF.h"
  5. #include "ITSDbF.h"
  6. #include "AppGlobalF.h"
  7. #include "WindowMsgF.h"
  8. #include "ITSLangTransF.h"
  9. #include "ITS_OPLibF.h"
  10. #pragma hdrstop
  11. #include "WCAMH101F.h"
  12. //---------------------------------------------------------------------------
  13. #pragma package(smart_init)
  14. #pragma link "cxButtons"
  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 "cxLabel"
  31. #pragma link "cxLookAndFeelPainters"
  32. #pragma link "cxLookAndFeels"
  33. #pragma link "cxStyles"
  34. #pragma link "cxTextEdit"
  35. #pragma link "dxSkinBlack"
  36. #pragma link "dxSkinBlue"
  37. #pragma link "dxSkinsCore"
  38. #pragma link "dxSkinscxPCPainter"
  39. #pragma link "dxSkinMcSkin"
  40. #pragma link "cxDropDownEdit"
  41. #pragma link "cxMaskEdit"
  42. #pragma resource "*.dfm"
  43. TWCAMH101 *WCAMH101 = NULL;
  44. //---------------------------------------------------------------------------
  45. __fastcall TWCAMH101::TWCAMH101(TComponent* Owner, HWND hHandle, String sFrom, String sTo, String sIdList)
  46. : TForm(Owner)
  47. {
  48. LangTrans->Translate(this, ITSDb_GetConnection());
  49. ITSSkin_Load(this);
  50. CMM_LoadForm(g_sFormsDir, this);
  51. FParent = hHandle;
  52. FStDateTime = sFrom;
  53. FEdDateTime = sTo;
  54. FIdList = sIdList;
  55. APP_FillCode(CbType, "WCAM");
  56. }
  57. //---------------------------------------------------------------------------
  58. __fastcall TWCAMH101::~TWCAMH101(void)
  59. {
  60. }
  61. //--------------------------------------------------------------------------
  62. void __fastcall TWCAMH101::FormInit()
  63. {
  64. ADOQry->Connection = ITSDb_GetConnection();
  65. m_pGDC = TvList->DataController;
  66. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<VDS-제어기 상태 이력 정보>";
  67. //TvList->ViewInfo->GroupByBoxViewInfo->Text = "그룹핑할 필드의 헤더를 이곳으로 드래그 하세요";
  68. LblSearch->Caption = FrmLang->lblQryCond->Caption + FStDateTime.SubString(1, 12) + " ~ " + FEdDateTime.SubString(1, 12);
  69. }
  70. //---------------------------------------------------------------------------
  71. void __fastcall TWCAMH101::FormShow(TObject *Sender)
  72. {
  73. FormInit();
  74. Refresh();
  75. TmrShow->Enabled = true;
  76. }
  77. //---------------------------------------------------------------------------
  78. void __fastcall TWCAMH101::CommClose()
  79. {
  80. CMM_SaveForm(g_sFormsDir, this);
  81. //WCAMH101 = NULL;
  82. }
  83. //---------------------------------------------------------------------------
  84. void __fastcall TWCAMH101::TmrShowTimer(TObject *Sender)
  85. {
  86. TmrShow->Enabled = false;
  87. Application->ProcessMessages();
  88. SelHistory();
  89. }
  90. //---------------------------------------------------------------------------
  91. void __fastcall TWCAMH101::ChkExpandClick(TObject *Sender)
  92. {
  93. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  94. }
  95. //---------------------------------------------------------------------------
  96. void __fastcall TWCAMH101::SelHistory()
  97. {
  98. TSqlCursor sqlCrs;
  99. String sQry;
  100. TADOQuery *pADO = ADOQry;
  101. sQry = "SELECT A.*, B.WCAM_CTLR_ID, B.WCAM_NM, \r\n"
  102. " B.WCAM_TYPE_CD \r\n"
  103. " FROM TB_WCAM_CTLR_STTS_HS A, TB_WCAM_CTLR B \r\n"
  104. " WHERE A.CRTN_DT BETWEEN :p01 AND :p02 \r\n"
  105. " AND B.WCAM_CTLR_NMBR IN(" + FIdList + ") \r\n"
  106. " AND A.WCAM_CTLR_NMBR = B.WCAM_CTLR_NMBR \r\n"
  107. " ORDER BY A.WCAM_CTLR_NMBR, A.CRTN_DT \r\n";
  108. try
  109. {
  110. ITSDb_SQLText(pADO, sQry);
  111. ITSDb_SQLBind(pADO, "p01", FStDateTime);
  112. ITSDb_SQLBind(pADO, "p02", FEdDateTime);
  113. ITSDb_SQLOpen(pADO);
  114. DspHistory();
  115. }
  116. catch(EDatabaseError &E)
  117. {
  118. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  119. DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQry);
  120. throw Exception(String(E.ClassName()) + E.Message);
  121. }
  122. catch(Exception &e)
  123. {
  124. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  125. DBERRORMSG(Caption, String(e.ClassName()), e.Message, sQry);
  126. throw Exception(String(e.ClassName()) + e.Message);
  127. }
  128. }
  129. //---------------------------------------------------------------------------
  130. void __fastcall TWCAMH101::DspHistory()
  131. {
  132. TADOQuery *pADO = ADOQry;
  133. try
  134. {
  135. TcxGridChartSeries *pChart = NULL;
  136. CMM_ClearGridTableView(TvList);
  137. int nRow = 0;
  138. int nDataCnt = 0;
  139. try {
  140. TvList->BeginUpdate();
  141. nDataCnt = pADO->RecordCount;
  142. m_pGDC->RecordCount = nDataCnt;
  143. for( ; !pADO->Eof; pADO->Next(), nRow++)
  144. {
  145. m_pGDC->Values[nRow][Column12->Index] = APP_GetCodeName(CbType, pADO->FieldByName("WCAM_TYPE_CD")->AsString);
  146. m_pGDC->Values[nRow][Column00->Index] = pADO->FieldByName("WCAM_CTLR_NMBR")->AsString;
  147. m_pGDC->Values[nRow][Column11->Index] = pADO->FieldByName("WCAM_CTLR_ID")->AsString;
  148. m_pGDC->Values[nRow][Column09->Index] = pADO->FieldByName("WCAM_NM")->AsString;
  149. String sDbDate = pADO->FieldByName("CRTN_DT")->AsString;
  150. m_pGDC->Values[nRow][Column01->Index] = APP_FormatStr(sDbDate, STR_DATETIME);
  151. String CMNC_STTS_CD = pADO->FieldByName("CMNC_STTS_CD")->AsString;
  152. if (CMNC_STTS_CD == "CMS0") m_pGDC->Values[nRow][Column02->Index] = FrmLang->lblComm0->Caption;
  153. else
  154. if (CMNC_STTS_CD == "CMS1") m_pGDC->Values[nRow][Column02->Index] = FrmLang->lblComm1->Caption;
  155. else m_pGDC->Values[nRow][Column02->Index] = FrmLang->lblUnknown->Caption;
  156. }
  157. }
  158. __finally
  159. {
  160. if (pADO)
  161. {
  162. pADO->Close();
  163. }
  164. TvList->EndUpdate();
  165. //CxList->SetFocus();
  166. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + FrmLang->lblEA->Caption;//" 건";
  167. String sEnd = FrmLang->lblQrySel->Caption + " [" + LblRecords->Caption + "]";//"데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
  168. Application->MessageBox(sEnd.c_str(),
  169. FrmLang->lblQryEnd->Caption.c_str(),//L"데이터 조회 완료",
  170. MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  171. }
  172. }
  173. catch(EDatabaseError &E)
  174. {
  175. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  176. DBERRORMSG(Caption, String(E.ClassName()), E.Message, pADO->SQL->Text);
  177. throw Exception(String(E.ClassName()) + E.Message);
  178. }
  179. catch(Exception &e)
  180. {
  181. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  182. DBERRORMSG(Caption, String(e.ClassName()), e.Message, pADO->SQL->Text);
  183. throw Exception(String(e.ClassName()) + e.Message);
  184. }
  185. }
  186. //---------------------------------------------------------------------------
  187. void __fastcall TWCAMH101::OnMessage(TMessage &Msg)
  188. {
  189. switch (Msg.Msg)
  190. {
  191. case WM_PARAM_DATABASE:
  192. if (WP_DB_SELECT_OK == Msg.WParam)
  193. {
  194. //ShowMessage("Select Ok");
  195. }
  196. break;
  197. }
  198. }
  199. //---------------------------------------------------------------------------
  200. void __fastcall TWCAMH101::BtnExlSaveClick(TObject *Sender)
  201. {
  202. TcxGrid *pGrid = CxList;
  203. TcxGridTableView *pView = TvList;
  204. String sTitle= Caption;//"VDS-제어기 상태이력";
  205. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  206. }
  207. //---------------------------------------------------------------------------
  208. void __fastcall TWCAMH101::FormClose(TObject *Sender, TCloseAction &Action)
  209. {
  210. POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
  211. CommClose();
  212. //WCAMH101 = NULL;
  213. }
  214. //---------------------------------------------------------------------------
  215. void __fastcall TWCAMH101::Column02CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  216. bool &ADone)
  217. {
  218. TColor tColor = ACanvas->Brush->Color;
  219. TColor tFont = clBlack;
  220. try
  221. {
  222. if (!VarIsNull(AViewInfo->Value))
  223. {
  224. String sTmp = AViewInfo->Value;
  225. if (sTmp == FrmLang->lblComm0->Caption)
  226. {
  227. tColor = clLime;
  228. }
  229. else
  230. if (sTmp == FrmLang->lblComm1->Caption)
  231. {
  232. tColor = clRed;
  233. }
  234. else
  235. {
  236. tColor = clSilver;
  237. }
  238. }
  239. ACanvas->Font->Color = tFont;
  240. ACanvas->SetBrushColor(tColor);
  241. }
  242. catch(...)
  243. {
  244. }
  245. }
  246. //---------------------------------------------------------------------------