FRAME_CCamStateListF.cpp 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "AppGlobalF.h"
  4. #include "ITSSkinF.h"
  5. #include "ITSUtilF.h"
  6. #include "ITSLangTransF.h"
  7. #include "FrmResourceF.h"
  8. #include "CDSFacilityF.h"
  9. #pragma hdrstop
  10. #include "FRAME_CCamStateListF.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 "cxGridBandedTableView"
  27. #pragma link "cxGridCustomTableView"
  28. #pragma link "cxGridCustomView"
  29. #pragma link "cxGridLevel"
  30. #pragma link "cxGridTableView"
  31. #pragma link "cxLabel"
  32. #pragma link "cxLookAndFeelPainters"
  33. #pragma link "cxLookAndFeels"
  34. #pragma link "cxSpinEdit"
  35. #pragma link "cxStyles"
  36. #pragma link "cxTextEdit"
  37. #pragma link "dxSkinBlue"
  38. #pragma link "dxSkinsCore"
  39. #pragma link "dxSkinscxPCPainter"
  40. #pragma resource "*.dfm"
  41. //TFRAMECCamStateList *FRAMECCamStateList;
  42. //---------------------------------------------------------------------------
  43. __fastcall TFRAMECCamStateList::TFRAMECCamStateList(TComponent* Owner)
  44. : TFrame(Owner)
  45. {
  46. LangTrans->Translate(this, ITSDb_GetConnection());
  47. m_pGDC = TvList->DataController;
  48. FTitle = lblTitle->Caption;
  49. }
  50. //---------------------------------------------------------------------------
  51. void __fastcall TFRAMECCamStateList::UpdateList()
  52. {
  53. CMM_ClearGridTableView(TvList);
  54. int ii, jj;
  55. int nCols = 0;
  56. TcxDataController *pGDC = TvList->DataController;
  57. CCamCtlrManager->FLists.Lock();
  58. try
  59. {
  60. int nRow;
  61. TvList->BeginUpdate();
  62. pGDC->BeginUpdate();
  63. FOR_STL(TCCamCtlr*, pObj, CCamCtlrManager->FLists)
  64. {
  65. if (pObj->DEL_YN == "Y") continue;
  66. nRow = pGDC->AppendRecord();
  67. pGDC->Values[nRow][ColumnSel->Index] = false;
  68. pGDC->Values[nRow][Col01->Index] = pObj->CCAM_CTLR_NMBR;
  69. pGDC->Values[nRow][Col02->Index] = pObj->CCAM_CTLR_ID;
  70. pGDC->Values[nRow][Col03->Index] = pObj->CCAM_NM;
  71. pGDC->Values[nRow][Col04->Index] = pObj->CCAM_TYPE_CD;
  72. if (pObj->STATE.Comm == wcam_normal) pGDC->Values[nRow][Col10->Index] = FrmLang->lblComm0->Caption;//"정상";
  73. else if (pObj->STATE.Comm == wcam_error ) pGDC->Values[nRow][Col10->Index] = FrmLang->lblComm1->Caption;//"통신이상";
  74. else pGDC->Values[nRow][Col10->Index] = FrmLang->lblUnknown->Caption;
  75. pGDC->Values[nRow][Col11->Index] = pObj->CCAM_CTLR_IP;
  76. pGDC->Values[nRow][Col99->Index] = (int)pObj;
  77. }
  78. }
  79. __finally
  80. {
  81. CCamCtlrManager->FLists.UnLock();
  82. pGDC->EndUpdate();
  83. TvList->EndUpdate();
  84. //RefreshStatus();
  85. }
  86. }
  87. //---------------------------------------------------------------------------
  88. void __fastcall TFRAMECCamStateList::RefreshStatus()
  89. {
  90. TcxDataController *pGDC = TvList->DataController;
  91. try
  92. {
  93. TvList->BeginUpdate();
  94. pGDC->BeginUpdate();
  95. int nRows = pGDC->RecordCount;
  96. for(int nRow = 0; nRow < nRows; nRow++)
  97. {
  98. int nMemPtr = TvList->DataController->Values[nRow][Col99->Index];
  99. TCCamCtlr *pObj = (TCCamCtlr*)nMemPtr;
  100. if (!pObj) continue;
  101. if (pObj->STATE.Comm == wcam_normal) pGDC->Values[nRow][Col10->Index] = FrmLang->lblComm0->Caption;//"정상";
  102. else if (pObj->STATE.Comm == wcam_error ) pGDC->Values[nRow][Col10->Index] = FrmLang->lblComm1->Caption;//"통신이상";
  103. else pGDC->Values[nRow][Col10->Index] = FrmLang->lblUnknown->Caption;
  104. }
  105. }
  106. __finally
  107. {
  108. pGDC->EndUpdate();
  109. TvList->EndUpdate();
  110. //CxList->LayoutChanged();
  111. }
  112. }
  113. //---------------------------------------------------------------------------
  114. void __fastcall TFRAMECCamStateList::BtnAllSelectClick(TObject *Sender)
  115. {
  116. TcxButton *pBtn = (TcxButton*)Sender;
  117. CMM_CheckAllListItem(TvList, ColumnSel->Index, pBtn->Tag);
  118. }
  119. //---------------------------------------------------------------------------
  120. int __fastcall TFRAMECCamStateList::GetSelIds(String &ALinkIds)
  121. {
  122. ALinkIds = "";
  123. if (TvList->ViewData->RecordCount <= 0) return 0;
  124. int nIndex = m_pGDC->FocusedRecordIndex;
  125. if( nIndex < 0 )
  126. return 0;
  127. String sLinkId = VarToStr(m_pGDC->Values[nIndex][Col01->Index]);
  128. ALinkIds = sLinkId;
  129. return 1;
  130. }
  131. //---------------------------------------------------------------------------
  132. int __fastcall TFRAMECCamStateList::GetSelIds(TStringList *AStringList)
  133. {
  134. int nSelCnt = 0;
  135. try
  136. {
  137. TvList->BeginUpdate();
  138. int nRowCnt = TvList->ViewData->RecordCount;
  139. for (int ii = 0; ii < nRowCnt; ii++)
  140. {
  141. TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii];
  142. if (((bool)ARow->Values[ColumnSel->Index]))
  143. {
  144. AStringList->Add(ARow->Values[Col01->Index]);
  145. nSelCnt++;
  146. }
  147. }
  148. }
  149. __finally
  150. {
  151. TvList->EndUpdate();
  152. }
  153. return nSelCnt;
  154. }
  155. //---------------------------------------------------------------------------
  156. void __fastcall TFRAMECCamStateList::TvListDataControllerFilterChanged(TObject *Sender)
  157. {
  158. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  159. }
  160. //---------------------------------------------------------------------------
  161. void __fastcall TFRAMECCamStateList::BtnExlSaveClick(TObject *Sender)
  162. {
  163. TcxGrid *pGrid = CxList;
  164. TcxGridTableView *pView = TvList;
  165. String sTitle= FTitle;
  166. CMM_ExportToExcelFile(sTitle, pGrid, pView, (TForm*)this);
  167. }
  168. //---------------------------------------------------------------------------
  169. void __fastcall TFRAMECCamStateList::OnCloseQuery(bool &CanClose)
  170. {
  171. }
  172. //---------------------------------------------------------------------------
  173. void __fastcall TFRAMECCamStateList::Col10CustomDrawCell(TcxCustomGridTableView *Sender,
  174. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  175. bool &ADone)
  176. {
  177. try
  178. {
  179. TColor tColor = ACanvas->Brush->Color;
  180. if (!VarIsNull(AViewInfo->GridRecord->DisplayTexts[Col10->Index]))
  181. {
  182. String sCode = AViewInfo->GridRecord->DisplayTexts[Col10->Index];
  183. if (sCode == FrmLang->lblComm0->Caption) tColor = clLime;
  184. else if (sCode == FrmLang->lblComm1->Caption) tColor = clRed;
  185. else tColor = clGray;
  186. }
  187. ACanvas->SetBrushColor(tColor);
  188. ACanvas->Font->Color = clBlack;
  189. }
  190. catch(Exception &e)
  191. {
  192. }
  193. }
  194. //---------------------------------------------------------------------------