FRAME_CCamStateListF.cpp 7.0 KB

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