FRAME_WCamStateListF.cpp 7.0 KB

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