FRAME_CctvStateListF.cpp 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "AppGlobalF.h"
  4. #include "ITSSkinF.h"
  5. #include "ITSUtilF.h"
  6. #include "ITSLangTransF.h"
  7. #include "DMDbF.h"
  8. #include "FrmResourceF.h"
  9. //#include "CDSFacilityF.h"
  10. #pragma hdrstop
  11. #include "FRAME_CctvStateListF.h"
  12. //---------------------------------------------------------------------------
  13. #pragma package(smart_init)
  14. #pragma link "cxButtons"
  15. #pragma link "cxCalc"
  16. #pragma link "cxCheckBox"
  17. #pragma link "cxClasses"
  18. #pragma link "cxContainer"
  19. #pragma link "cxControls"
  20. #pragma link "cxCustomData"
  21. #pragma link "cxData"
  22. #pragma link "cxDataStorage"
  23. #pragma link "cxEdit"
  24. #pragma link "cxFilter"
  25. #pragma link "cxGraphics"
  26. #pragma link "cxGrid"
  27. #pragma link "cxGridBandedTableView"
  28. #pragma link "cxGridCustomTableView"
  29. #pragma link "cxGridCustomView"
  30. #pragma link "cxGridLevel"
  31. #pragma link "cxGridTableView"
  32. #pragma link "cxLabel"
  33. #pragma link "cxLookAndFeelPainters"
  34. #pragma link "cxLookAndFeels"
  35. #pragma link "cxSpinEdit"
  36. #pragma link "cxStyles"
  37. #pragma link "cxTextEdit"
  38. #pragma link "dxSkinBlue"
  39. #pragma link "dxSkinsCore"
  40. #pragma link "dxSkinscxPCPainter"
  41. #pragma link "dxSkinBlack"
  42. #pragma link "dxSkinMcSkin"
  43. #pragma link "cxDropDownEdit"
  44. #pragma link "cxMaskEdit"
  45. #pragma link "cxPC"
  46. #pragma link "cxPCdxBarPopupMenu"
  47. #pragma resource "*.dfm"
  48. //TFRAMEWCamStateList *FRAMEWCamStateList;
  49. //---------------------------------------------------------------------------
  50. __fastcall TFRAMECctvStateList::TFRAMECctvStateList(TComponent* Owner)
  51. : TFrame(Owner)
  52. {
  53. LangTrans->Translate(this, ITSDb_GetConnection());
  54. m_pGDC = TvList->DataController;
  55. m_pGDC2 = TvList2->DataController;
  56. FTitle = lblTitle->Caption;
  57. }
  58. //---------------------------------------------------------------------------
  59. void __fastcall TFRAMECctvStateList::UpdateList()
  60. {
  61. CMM_ClearGridTableView(TvList);
  62. CMM_ClearGridTableView(TvList2);
  63. int nRow = 0;
  64. TvList->BeginUpdate();
  65. TvList2->BeginUpdate();
  66. try
  67. {
  68. CctvCtlrManager->FLists.Lock();
  69. try
  70. {
  71. FOR_STL(TCctvCtlr*, pObj, CctvCtlrManager->FLists)
  72. {
  73. if (pObj->DEL_YN == "Y") continue;
  74. if (pObj->CCTV_AREA_DVSN == 1)
  75. {
  76. // 북구
  77. nRow = m_pGDC->AppendRecord();
  78. m_pGDC->Values[nRow][ColumnSel->Index] = false;
  79. m_pGDC->Values[nRow][Col01->Index] = pObj->CCTV_CTLR_NMBR.ToIntDef(0);
  80. m_pGDC->Values[nRow][Col02->Index] = pObj->CCTV_CTLR_ID;
  81. m_pGDC->Values[nRow][Col03->Index] = pObj->CCTV_NM;
  82. m_pGDC->Values[nRow][Col11->Index] = pObj->CCTV_CTLR_IP;
  83. m_pGDC->Values[nRow][Col04->Index] = pObj->CCTV_TYPE_NM;
  84. m_pGDC->Values[nRow][Col99->Index] = (int)pObj;
  85. }
  86. else
  87. if (pObj->CCTV_AREA_DVSN == 2)
  88. {
  89. // 남구
  90. nRow = m_pGDC2->AppendRecord();
  91. m_pGDC2->Values[nRow][ColumnSel2->Index] = false;
  92. m_pGDC2->Values[nRow][ColNmbr->Index] = pObj->CCTV_CTLR_NMBR.ToIntDef(0);
  93. m_pGDC2->Values[nRow][ColId->Index] = pObj->CCTV_CTLR_ID;
  94. m_pGDC2->Values[nRow][ColNm->Index] = pObj->CCTV_NM;
  95. m_pGDC2->Values[nRow][ColIp->Index] = pObj->CCTV_CTLR_IP;
  96. m_pGDC2->Values[nRow][ColType->Index] = pObj->CCTV_TYPE_NM;
  97. m_pGDC2->Values[nRow][Column99->Index] = (int)pObj;
  98. }
  99. }
  100. }
  101. __finally
  102. {
  103. CctvCtlrManager->FLists.UnLock();
  104. }
  105. }
  106. __finally
  107. {
  108. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  109. TvList->EndUpdate();
  110. Col01->SortIndex = Col01->Index;
  111. Col01->SortOrder = soAscending;
  112. TvList->DataController->GotoFirst();
  113. TvList->DataController->FocusedRecordIndex = 0;
  114. TvList2->EndUpdate();
  115. ColNmbr->SortIndex = ColNmbr->Index;
  116. ColNmbr->SortOrder = soAscending;
  117. TvList2->DataController->GotoFirst();
  118. TvList2->DataController->FocusedRecordIndex = 0;
  119. }
  120. }
  121. //---------------------------------------------------------------------------
  122. void __fastcall TFRAMECctvStateList::RefreshStatus()
  123. {
  124. TcxDataController *pGDC = TvList->DataController;
  125. try
  126. {
  127. TvList->BeginUpdate();
  128. pGDC->BeginUpdate();
  129. int nRows = pGDC->RecordCount;
  130. for(int nRow = 0; nRow < nRows; nRow++)
  131. {
  132. int nMemPtr = TvList->DataController->Values[nRow][Col99->Index];
  133. TCctvCtlr *pObj = (TCctvCtlr*)nMemPtr;
  134. if (!pObj) continue;
  135. if (pObj->STATE.Comm == cctv_normal) pGDC->Values[nRow][Col10->Index] = FrmLang->lblComm0->Caption;//"정상";
  136. else if (pObj->STATE.Comm == cctv_error ) pGDC->Values[nRow][Col10->Index] = FrmLang->lblComm1->Caption;//"통신이상";
  137. else pGDC->Values[nRow][Col10->Index] = FrmLang->lblUnknown->Caption;
  138. }
  139. }
  140. __finally
  141. {
  142. pGDC->EndUpdate();
  143. TvList->EndUpdate();
  144. //CxList->LayoutChanged();
  145. }
  146. pGDC = TvList2->DataController;
  147. try
  148. {
  149. TvList2->BeginUpdate();
  150. pGDC->BeginUpdate();
  151. int nRows = pGDC->RecordCount;
  152. for(int nRow = 0; nRow < nRows; nRow++)
  153. {
  154. int nMemPtr = TvList2->DataController->Values[nRow][Column99->Index];
  155. TCctvCtlr *pObj = (TCctvCtlr*)nMemPtr;
  156. if (!pObj) continue;
  157. if (pObj->STATE.Comm == cctv_normal) pGDC->Values[nRow][ColStat->Index] = FrmLang->lblComm0->Caption;//"정상";
  158. else if (pObj->STATE.Comm == cctv_error ) pGDC->Values[nRow][ColStat->Index] = FrmLang->lblComm1->Caption;//"통신이상";
  159. else pGDC->Values[nRow][ColStat->Index] = FrmLang->lblUnknown->Caption;
  160. }
  161. }
  162. __finally
  163. {
  164. pGDC->EndUpdate();
  165. TvList2->EndUpdate();
  166. //CxList->LayoutChanged();
  167. }
  168. }
  169. //---------------------------------------------------------------------------
  170. void __fastcall TFRAMECctvStateList::BtnAllSelectClick(TObject *Sender)
  171. {
  172. TcxButton *pBtn = (TcxButton*)Sender;
  173. CMM_CheckAllListItem(TvList, ColumnSel->Index, pBtn->Tag);
  174. }
  175. //---------------------------------------------------------------------------
  176. int __fastcall TFRAMECctvStateList::GetSelIds(String &ALinkIds)
  177. {
  178. ALinkIds = "";
  179. if (TvList->ViewData->RecordCount <= 0) return 0;
  180. int nIndex = m_pGDC->FocusedRecordIndex;
  181. if( nIndex < 0 )
  182. return 0;
  183. String sLinkId = VarToStr(m_pGDC->Values[nIndex][Col01->Index]);
  184. ALinkIds = sLinkId;
  185. return 1;
  186. }
  187. //---------------------------------------------------------------------------
  188. int __fastcall TFRAMECctvStateList::GetSelIds(TStringList *AStringList)
  189. {
  190. int nSelCnt = 0;
  191. try
  192. {
  193. TvList->BeginUpdate();
  194. int nRowCnt = TvList->ViewData->RecordCount;
  195. for (int ii = 0; ii < nRowCnt; ii++)
  196. {
  197. TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii];
  198. if (((bool)ARow->Values[ColumnSel->Index]))
  199. {
  200. AStringList->Add(ARow->Values[Col01->Index]);
  201. nSelCnt++;
  202. }
  203. }
  204. }
  205. __finally
  206. {
  207. TvList->EndUpdate();
  208. }
  209. return nSelCnt;
  210. }
  211. //---------------------------------------------------------------------------
  212. void __fastcall TFRAMECctvStateList::TvListDataControllerFilterChanged(TObject *Sender)
  213. {
  214. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  215. }
  216. //---------------------------------------------------------------------------
  217. void __fastcall TFRAMECctvStateList::BtnExlSaveClick(TObject *Sender)
  218. {
  219. TcxGrid *pGrid = CxList;
  220. TcxGridTableView *pView = TvList;
  221. String sTitle= FTitle;
  222. CMM_ExportToExcelFile(sTitle, pGrid, pView, (TForm*)this);
  223. }
  224. //---------------------------------------------------------------------------
  225. void __fastcall TFRAMECctvStateList::OnCloseQuery(bool &CanClose)
  226. {
  227. }
  228. //---------------------------------------------------------------------------
  229. void __fastcall TFRAMECctvStateList::Col10CustomDrawCell(TcxCustomGridTableView *Sender,
  230. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  231. bool &ADone)
  232. {
  233. try
  234. {
  235. TColor tColor = ACanvas->Brush->Color;
  236. if (!VarIsNull(AViewInfo->GridRecord->DisplayTexts[Col10->Index]))
  237. {
  238. String sCode = AViewInfo->GridRecord->DisplayTexts[Col10->Index];
  239. if (sCode == FrmLang->lblComm0->Caption) tColor = clLime;
  240. else if (sCode == FrmLang->lblComm1->Caption) tColor = clRed;
  241. else tColor = clGray;
  242. }
  243. ACanvas->SetBrushColor(tColor);
  244. ACanvas->Font->Color = clBlack;
  245. }
  246. catch(Exception &e)
  247. {
  248. }
  249. }
  250. //---------------------------------------------------------------------------
  251. void __fastcall TFRAMECctvStateList::ColStatCustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  252. bool &ADone)
  253. {
  254. try
  255. {
  256. TColor tColor = ACanvas->Brush->Color;
  257. if (!VarIsNull(AViewInfo->GridRecord->DisplayTexts[ColStat->Index]))
  258. {
  259. String sCode = AViewInfo->GridRecord->DisplayTexts[ColStat->Index];
  260. if (sCode == FrmLang->lblComm0->Caption) tColor = clLime;
  261. else if (sCode == FrmLang->lblComm1->Caption) tColor = clRed;
  262. else tColor = clGray;
  263. }
  264. ACanvas->SetBrushColor(tColor);
  265. ACanvas->Font->Color = clBlack;
  266. }
  267. catch(Exception &e)
  268. {
  269. }
  270. }
  271. //---------------------------------------------------------------------------