FRAME_CctvStateListF.cpp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  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 "FrmResourceF.h"
  9. #pragma hdrstop
  10. #include "FRAME_CctvStateListF.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 "cxGridCustomTableView"
  27. #pragma link "cxGridCustomView"
  28. #pragma link "cxGridLevel"
  29. #pragma link "cxGridTableView"
  30. #pragma link "cxLookAndFeelPainters"
  31. #pragma link "cxLookAndFeels"
  32. #pragma link "cxStyles"
  33. #pragma link "cxTextEdit"
  34. #pragma link "dxSkinBlack"
  35. #pragma link "dxSkinBlue"
  36. #pragma link "dxSkinCaramel"
  37. #pragma link "dxSkinCoffee"
  38. #pragma link "dxSkinDarkRoom"
  39. #pragma link "dxSkinDarkSide"
  40. #pragma link "dxSkinFoggy"
  41. #pragma link "dxSkinGlassOceans"
  42. #pragma link "dxSkiniMaginary"
  43. #pragma link "dxSkinLilian"
  44. #pragma link "dxSkinLiquidSky"
  45. #pragma link "dxSkinLondonLiquidSky"
  46. #pragma link "dxSkinMcSkin"
  47. #pragma link "dxSkinMoneyTwins"
  48. #pragma link "dxSkinOffice2007Black"
  49. #pragma link "dxSkinOffice2007Blue"
  50. #pragma link "dxSkinOffice2007Green"
  51. #pragma link "dxSkinOffice2007Pink"
  52. #pragma link "dxSkinOffice2007Silver"
  53. #pragma link "dxSkinOffice2010Black"
  54. #pragma link "dxSkinOffice2010Blue"
  55. #pragma link "dxSkinOffice2010Silver"
  56. #pragma link "dxSkinsCore"
  57. #pragma link "dxSkinscxPCPainter"
  58. #pragma link "dxSkinSeven"
  59. #pragma link "dxSkinSharp"
  60. #pragma link "dxSkinSilver"
  61. #pragma link "dxSkinStardust"
  62. #pragma link "cxGridBandedTableView"
  63. #pragma link "cxSpinEdit"
  64. #pragma link "cxLabel"
  65. #pragma resource "*.dfm"
  66. //TFRAMEVmsStateList *FRAMEVmsStateList;
  67. //---------------------------------------------------------------------------
  68. __fastcall TFRAMECctvStateList::TFRAMECctvStateList(TComponent* Owner)
  69. : TFrame(Owner)
  70. {
  71. LangTrans->Translate(this, ITSDb_GetConnection());
  72. m_pGDC = TvList->DataController;
  73. FTitle = lblTitle->Caption;
  74. }
  75. //---------------------------------------------------------------------------
  76. void __fastcall TFRAMECctvStateList::UpdateList()
  77. {
  78. CMM_ClearGridTableView(TvList);
  79. int ii, jj;
  80. int nCols = 0;
  81. TcxDataController *pGDC = TvList->DataController;
  82. CctvCtlrManager->FLists.Lock();
  83. try
  84. {
  85. int nRow;
  86. TvList->BeginUpdate();
  87. pGDC->BeginUpdate();
  88. FOR_STL(TCctvCtlr*, pObj, CctvCtlrManager->FLists)
  89. {
  90. if (pObj->DEL_YN == "Y") continue;
  91. nRow = pGDC->AppendRecord();
  92. pGDC->Values[nRow][ColumnSel->Index] = false;
  93. pGDC->Values[nRow][Col01->Index] = String(pObj->CCTV_CTLR_NMBR);
  94. pGDC->Values[nRow][Col02->Index] = pObj->CCTV_CTLR_ID;
  95. pGDC->Values[nRow][Col03->Index] = pObj->CCTV_NM;
  96. pGDC->Values[nRow][Col04->Index] = pObj->CCTV_TYPE_CD;
  97. pGDC->Values[nRow][Col10->Index] = pObj->RSTATE.Comm == cctv_normal ? FrmLang->lblState0->Caption : FrmLang->lblState1->Caption; //통신상태
  98. pGDC->Values[nRow][Col11->Index] = pObj->CCTV_CTLR_IP;
  99. pGDC->Values[nRow][Col99->Index] = (int)pObj;
  100. }
  101. }
  102. __finally
  103. {
  104. CctvCtlrManager->FLists.UnLock();
  105. pGDC->EndUpdate();
  106. TvList->EndUpdate();
  107. //RefreshStatus();
  108. }
  109. }
  110. //---------------------------------------------------------------------------
  111. void __fastcall TFRAMECctvStateList::RefreshStatus()
  112. {
  113. TcxDataController *pGDC = TvList->DataController;
  114. try
  115. {
  116. TvList->BeginUpdate();
  117. pGDC->BeginUpdate();
  118. int nRows = pGDC->RecordCount;
  119. for(int nRow = 0; nRow < nRows; nRow++)
  120. {
  121. int nMemPtr = TvList->DataController->Values[nRow][Col99->Index];
  122. TCctvCtlr *pObj = (TCctvCtlr*)nMemPtr;
  123. if (!pObj) continue;
  124. pGDC->Values[nRow][Col10->Index] = pObj->RSTATE.Comm == cctv_normal ? FrmLang->lblState0->Caption : FrmLang->lblState1->Caption; //통신상태
  125. }
  126. }
  127. __finally
  128. {
  129. pGDC->EndUpdate();
  130. TvList->EndUpdate();
  131. //CxList->LayoutChanged();
  132. }
  133. }
  134. //---------------------------------------------------------------------------
  135. void __fastcall TFRAMECctvStateList::BtnAllSelectClick(TObject *Sender)
  136. {
  137. TcxButton *pBtn = (TcxButton*)Sender;
  138. CMM_CheckAllListItem(TvList, ColumnSel->Index, pBtn->Tag);
  139. }
  140. //---------------------------------------------------------------------------
  141. int __fastcall TFRAMECctvStateList::GetSelIds(String &ALinkIds)
  142. {
  143. ALinkIds = "";
  144. if (TvList->ViewData->RecordCount <= 0) return 0;
  145. int nIndex = m_pGDC->FocusedRecordIndex;
  146. if( nIndex < 0 )
  147. return 0;
  148. String sLinkId = VarToStr(m_pGDC->Values[nIndex][Col01->Index]);
  149. ALinkIds = sLinkId;
  150. return 1;
  151. }
  152. //---------------------------------------------------------------------------
  153. int __fastcall TFRAMECctvStateList::GetSelIds(TStringList *AStringList)
  154. {
  155. int nSelCnt = 0;
  156. try
  157. {
  158. TvList->BeginUpdate();
  159. int nRowCnt = TvList->ViewData->RecordCount;
  160. for (int ii = 0; ii < nRowCnt; ii++)
  161. {
  162. TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii];
  163. if (((bool)ARow->Values[ColumnSel->Index]))
  164. {
  165. AStringList->Add(ARow->Values[Col01->Index]);
  166. nSelCnt++;
  167. }
  168. }
  169. }
  170. __finally
  171. {
  172. TvList->EndUpdate();
  173. }
  174. return nSelCnt;
  175. }
  176. //---------------------------------------------------------------------------
  177. void __fastcall TFRAMECctvStateList::TvListDataControllerFilterChanged(TObject *Sender)
  178. {
  179. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  180. }
  181. //---------------------------------------------------------------------------
  182. void __fastcall TFRAMECctvStateList::BtnExlSaveClick(TObject *Sender)
  183. {
  184. TcxGrid *pGrid = CxList;
  185. TcxGridTableView *pView = TvList;
  186. String sTitle= FTitle;//"VMS상태정보";
  187. CMM_ExportToExcelFile(sTitle, pGrid, pView, (TForm*)this);
  188. }
  189. //---------------------------------------------------------------------------
  190. void __fastcall TFRAMECctvStateList::OnCloseQuery(bool &CanClose)
  191. {
  192. }
  193. //---------------------------------------------------------------------------
  194. void __fastcall TFRAMECctvStateList::Col06CustomDrawCell(TcxCustomGridTableView *Sender,
  195. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  196. bool &ADone)
  197. {
  198. try
  199. {
  200. TColor tColor;
  201. String sVmsMode = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
  202. tColor = ACanvas->Brush->Color;
  203. #if 0
  204. if (sVmsMode == "자동") tColor = clLime;
  205. else if (sVmsMode == "고정") tColor = clFuchsia;
  206. else tColor = clYellow;
  207. #else
  208. if (sVmsMode == FrmLang->lblOperA->Caption.Trim()) tColor = clLime;
  209. else if (sVmsMode == FrmLang->lblOperF->Caption.Trim()) tColor = clFuchsia;
  210. else tColor = clYellow;
  211. #endif
  212. ACanvas->SetBrushColor(tColor);
  213. ACanvas->Font->Color = clBlack;
  214. }
  215. catch(Exception &e)
  216. {
  217. }
  218. #if 0
  219. int nRecordIdx = AViewInfo->GridRecord->RecordIndex;
  220. if (nRecordIdx >= 0)
  221. {
  222. int nIdx = AViewInfo->Item->Index;
  223. String sVmsMode = AViewInfo->GridRecord->DisplayTexts[nIdx];
  224. if (sVmsMode == "고정") ACanvas->Canvas->Brush->Color = clLime;
  225. }
  226. #endif
  227. }
  228. //---------------------------------------------------------------------------
  229. void __fastcall TFRAMECctvStateList::Col07CustomDrawCell(TcxCustomGridTableView *Sender,
  230. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  231. bool &ADone)
  232. {
  233. try
  234. {
  235. if (AViewInfo->GridRecord->RecordIndex < 0) return;
  236. String sResult = AViewInfo->GridRecord->DisplayTexts[Col09->Index];
  237. if (sResult == "N")
  238. {
  239. ACanvas->Canvas->Brush->Color = clRed;
  240. }
  241. }
  242. catch(Exception &e)
  243. {
  244. }
  245. }
  246. //---------------------------------------------------------------------------
  247. void __fastcall TFRAMECctvStateList::Col10CustomDrawCell(TcxCustomGridTableView *Sender,
  248. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  249. bool &ADone)
  250. {
  251. try
  252. {
  253. TColor tColor;
  254. String sStatus = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
  255. tColor = ACanvas->Brush->Color;
  256. #if 0
  257. if (sStatus.Pos("-")) tColor = clGray;
  258. else if (sStatus.Pos("장애")) tColor = clRed;
  259. else if (sStatus.Pos("켜짐")) tColor = clYellow;
  260. else if (sStatus.Pos("열림")) tColor = clRed;
  261. else if (sStatus.Pos("동작")) tColor = clYellow;
  262. else if (sStatus.Pos("가동")) tColor = clYellow;
  263. else tColor = clLime;
  264. #else
  265. if (sStatus.Pos("-")) tColor = clGray;
  266. else if (sStatus.Pos(FrmLang->lblState1->Caption.Trim())) tColor = clRed;
  267. else if (sStatus.Pos(FrmLang->lblPOWER0->Caption.Trim())) tColor = clYellow;
  268. else if (sStatus.Pos(FrmLang->lblCDS1->Caption.Trim())) tColor = clRed;
  269. else if (sStatus.Pos(FrmLang->lblFAN0->Caption.Trim())) tColor = clYellow;
  270. //else if (sStatus.Pos(frmLang->lblHEAT0->Caption.Trim())) tColor = clYellow;
  271. else tColor = clLime;
  272. #endif
  273. ACanvas->SetBrushColor(tColor);
  274. ACanvas->Font->Color = clBlack;
  275. /*if (AViewInfo->GridRecord->Selected)
  276. {
  277. ACanvas->Font->Color = clBlack;
  278. }*/
  279. }
  280. catch(Exception &e)
  281. {
  282. }
  283. }
  284. //---------------------------------------------------------------------------
  285. void __fastcall TFRAMECctvStateList::Col12CustomDrawCell(TcxCustomGridTableView *Sender,
  286. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  287. bool &ADone)
  288. {
  289. try
  290. {
  291. TColor tColor;
  292. String sStatus = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
  293. tColor = ACanvas->Brush->Color;
  294. #if 0
  295. if (sStatus.Pos("-")) tColor = clGray;
  296. else if (sStatus.Pos("장애")) tColor = clRed;
  297. else if (sStatus.Pos("켜짐")) tColor = clYellow;
  298. else if (sStatus.Pos("열림")) tColor = clRed;
  299. else if (sStatus.Pos("동작")) tColor = clYellow;
  300. else if (sStatus.Pos("가동")) tColor = clYellow;
  301. else tColor = clLime;
  302. #else
  303. if (sStatus.Pos("-")) tColor = clGray;
  304. else if (sStatus.Pos(FrmLang->lblState1->Caption.Trim())) tColor = clRed;
  305. else if (sStatus.Pos(FrmLang->lblPOWER1->Caption.Trim())) tColor = clRed;
  306. else tColor = clLime;
  307. #if 0
  308. if (sStatus.Pos("-")) tColor = clGray;
  309. else if (sStatus.Pos("Error")) tColor = clRed;
  310. else if (sStatus.Pos("Off")) tColor = clRed;
  311. else tColor = clLime;
  312. #endif
  313. #endif
  314. ACanvas->SetBrushColor(tColor);
  315. ACanvas->Font->Color = clBlack;
  316. /*if (AViewInfo->GridRecord->Selected)
  317. {
  318. ACanvas->Font->Color = clBlack;
  319. }*/
  320. }
  321. catch(Exception &e)
  322. {
  323. }
  324. }
  325. //---------------------------------------------------------------------------