FRAME_DsrcListF.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "ITSUtilF.h"
  5. #include "FrmResourceF.h"
  6. #include "ITSLangTransF.h"
  7. #include "CDSFacilityF.h"
  8. #pragma hdrstop
  9. #include "FRAME_DsrcListF.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 "cxControls"
  17. #pragma link "cxCustomData"
  18. #pragma link "cxData"
  19. #pragma link "cxDataStorage"
  20. #pragma link "cxEdit"
  21. #pragma link "cxFilter"
  22. #pragma link "cxGraphics"
  23. #pragma link "cxGrid"
  24. #pragma link "cxGridCustomTableView"
  25. #pragma link "cxGridCustomView"
  26. #pragma link "cxGridLevel"
  27. #pragma link "cxGridTableView"
  28. #pragma link "cxLookAndFeelPainters"
  29. #pragma link "cxLookAndFeels"
  30. #pragma link "cxStyles"
  31. #pragma link "cxTextEdit"
  32. #pragma link "dxSkinBlack"
  33. #pragma link "dxSkinBlue"
  34. #pragma link "dxSkinsCore"
  35. #pragma link "dxSkinscxPCPainter"
  36. #pragma link "dxSkinMcSkin"
  37. #pragma resource "*.dfm"
  38. //---------------------------------------------------------------------------
  39. __fastcall TFRAMEDsrcList::TFRAMEDsrcList(TComponent* Owner)
  40. : TFrame(Owner)
  41. {
  42. ColumnSel->Options->Filtering = false;
  43. m_pGDC = TvList->DataController;
  44. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<DSRC 정보가 없습니다>";
  45. MyItsDsrcManager = new TItsDsrcManager();
  46. MyItsDsrcManager->LoadFromDb();
  47. //FCodeIFD = ItsCodeManager->FLists.Find("IFD"); // 방향코드
  48. }
  49. //---------------------------------------------------------------------------
  50. void __fastcall TFRAMEDsrcList::UpdateList()
  51. {
  52. CMM_ClearGridTableView(TvList);
  53. int nRow = 0;
  54. try
  55. {
  56. TvList->BeginUpdate();
  57. try
  58. {
  59. MyItsDsrcManager->FLists.Lock();
  60. FOR_STL(TItsDsrc*, pObj, MyItsDsrcManager->FLists)
  61. {
  62. if (pObj->DEL_YN == "Y") continue;
  63. nRow = m_pGDC->AppendRecord();
  64. m_pGDC->Values[nRow][ColumnSel->Index] = false; //선택
  65. m_pGDC->Values[nRow][Column00->Index] = "-"; //편집
  66. m_pGDC->Values[nRow][Column01->Index] = pObj->CTLR_NMBR; //ID
  67. m_pGDC->Values[nRow][Column02->Index] = pObj->CTLR_ID; //RSE ID
  68. m_pGDC->Values[nRow][Column03->Index] = pObj->ISTL_LCTN_NM; //명칭
  69. m_pGDC->Values[nRow][Column04->Index] = pObj->CTLR_IP; //IP Address
  70. m_pGDC->Values[nRow][Column99->Index] = (int)pObj;
  71. m_pGDC->Values[nRow][Column11->Index] = pObj->CTLR_NMBR.ToIntDef(0); //ID
  72. m_pGDC->Values[nRow][Column12->Index] = pObj->CTLR_ID; //RSE ID
  73. }
  74. }
  75. __finally
  76. {
  77. MyItsDsrcManager->FLists.UnLock();
  78. }
  79. }
  80. __finally
  81. {
  82. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  83. TvList->EndUpdate();
  84. TvList->DataController->GotoFirst();
  85. TvList->DataController->FocusedRecordIndex = 0;
  86. Column11->SortIndex = Column11->Index;
  87. Column11->SortOrder = soAscending;
  88. //CxList->SetFocus();
  89. }
  90. }
  91. //---------------------------------------------------------------------------
  92. void __fastcall TFRAMEDsrcList::UpdateListStatus()
  93. {
  94. CMM_ClearGridTableView(TvList);
  95. int nRow = 0;
  96. try
  97. {
  98. TItsFacility *pFacility = NULL;
  99. TvList->BeginUpdate();
  100. try
  101. {
  102. MyItsDsrcManager->FLists.Lock();
  103. FOR_STL(TItsDsrc*, pObj, MyItsDsrcManager->FLists)
  104. {
  105. if (pObj->DEL_YN == "Y") continue;
  106. nRow = m_pGDC->AppendRecord();
  107. m_pGDC->Values[nRow][ColumnSel->Index] = false; //선택
  108. m_pGDC->Values[nRow][Column00->Index] = "-"; //편집
  109. m_pGDC->Values[nRow][Column01->Index] = pObj->CTLR_NMBR; //ID
  110. m_pGDC->Values[nRow][Column02->Index] = pObj->CTLR_ID; //RSE ID
  111. m_pGDC->Values[nRow][Column03->Index] = pObj->ISTL_LCTN_NM; //명칭
  112. m_pGDC->Values[nRow][Column04->Index] = pObj->CTLR_IP; //IP Address
  113. m_pGDC->Values[nRow][Column99->Index] = (int)pObj;
  114. m_pGDC->Values[nRow][Column11->Index] = pObj->CTLR_NMBR.ToIntDef(0); //ID
  115. m_pGDC->Values[nRow][Column12->Index] = pObj->CTLR_ID; //RSE ID
  116. m_pGDC->Values[nRow][Column06->Index] = str_state_error;
  117. pFacility = ItsFacilityManager->FLists.Find(pObj->CTLR_ID);
  118. if (!pFacility)
  119. {
  120. m_pGDC->Values[nRow][Column05->Index] = FrmLang->lblUnknown->Caption;
  121. }
  122. else
  123. {
  124. String sComm = FrmLang->lblComm0->Caption;//"정상";
  125. if (pFacility->FComm == str_state_normal) sComm = FrmLang->lblComm0->Caption;//"정상";
  126. else
  127. if (pFacility->FComm == str_state_error ) sComm = FrmLang->lblComm1->Caption;//"통신이상";
  128. else
  129. if (pFacility->FComm == str_state_module) sComm = FrmLang->lblComm2->Caption;//"함체문열림";
  130. else
  131. if (pFacility->FComm == str_state_collect) sComm = FrmLang->lblClctErr->Caption;//"수집이상";
  132. else
  133. if (pFacility->FComm == str_state_collect) sComm = "-";
  134. else sComm = FrmLang->lblUnknown->Caption;//"알수없음";
  135. m_pGDC->Values[nRow][Column05->Index] = sComm;
  136. m_pGDC->Values[nRow][Column06->Index] = pFacility->FComm;
  137. #if 0
  138. if (pFacility->FComm == str_state_normal)
  139. {
  140. m_pGDC->Values[nRow][Column05->Index] = FrmLang->lblComm0->Caption;
  141. }
  142. else
  143. {
  144. m_pGDC->Values[nRow][Column05->Index] = FrmLang->lblComm1->Caption;
  145. }
  146. #endif
  147. }
  148. }
  149. }
  150. __finally
  151. {
  152. MyItsDsrcManager->FLists.UnLock();
  153. }
  154. }
  155. __finally
  156. {
  157. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  158. TvList->EndUpdate();
  159. TvList->DataController->GotoFirst();
  160. TvList->DataController->FocusedRecordIndex = 0;
  161. Column11->SortIndex = Column11->Index;
  162. Column11->SortOrder = soAscending;
  163. //CxList->SetFocus();
  164. }
  165. }
  166. //---------------------------------------------------------------------------
  167. void __fastcall TFRAMEDsrcList::BtnAllSelectClick(TObject *Sender)
  168. {
  169. TcxButton *pBtn = (TcxButton*)Sender;
  170. CMM_CheckAllListItem(TvList, ColumnSel->Index, pBtn->Tag);
  171. }
  172. //---------------------------------------------------------------------------
  173. int __fastcall TFRAMEDsrcList::GetSelIds(String &ALinkIds)
  174. {
  175. ALinkIds = "";
  176. if (TvList->ViewData->RecordCount <= 0) return 0;
  177. int nIndex = m_pGDC->FocusedRecordIndex;
  178. if( nIndex < 0 )
  179. return 0;
  180. String sLinkId = VarToStr(m_pGDC->Values[nIndex][Column01->Index]);
  181. ALinkIds = sLinkId;
  182. return 1;
  183. }
  184. //---------------------------------------------------------------------------
  185. int __fastcall TFRAMEDsrcList::GetSelIds(TStringList *AStringList)
  186. {
  187. int nSelCnt = 0;
  188. try
  189. {
  190. TvList->BeginUpdate();
  191. #if 0
  192. int nRowCnt = m_pGDC->RecordCount;
  193. for (int ii = 0; ii < nRowCnt; ii++)
  194. {
  195. if (((bool)m_pGDC->Values[ii][ColumnSel->Index]))
  196. {
  197. AStringList->Add(m_pGDC->Values[ii][Column00->Index]);
  198. nSelIdx++;
  199. }
  200. }
  201. #else
  202. int nRowCnt = TvList->ViewData->RecordCount;
  203. for (int ii = 0; ii < nRowCnt; ii++)
  204. {
  205. TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii];
  206. if (((bool)ARow->Values[ColumnSel->Index]))
  207. {
  208. AStringList->Add(ARow->Values[Column01->Index]);
  209. nSelCnt++;
  210. }
  211. }
  212. #endif
  213. }
  214. __finally
  215. {
  216. TvList->EndUpdate();
  217. }
  218. return nSelCnt;
  219. }
  220. //---------------------------------------------------------------------------
  221. void __fastcall TFRAMEDsrcList::TvListDataControllerFilterChanged(TObject *Sender)
  222. {
  223. CMM_SetFilterLike(TvList);
  224. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  225. }
  226. //---------------------------------------------------------------------------
  227. void __fastcall TFRAMEDsrcList::BtnExlSaveClick(TObject *Sender)
  228. {
  229. TcxGrid *pGrid = CxList;
  230. TcxGridTableView *pView = TvList;
  231. String sTitle= "DSRC정보";
  232. CMM_ExportToExcelFile(sTitle, pGrid, pView, (TForm*)this);
  233. }
  234. //---------------------------------------------------------------------------
  235. void __fastcall TFRAMEDsrcList::OnCloseQuery(bool &CanClose)
  236. {
  237. try {
  238. if (MyItsDsrcManager)
  239. {
  240. delete MyItsDsrcManager;
  241. MyItsDsrcManager = NULL;
  242. }
  243. } catch(...) {}
  244. }
  245. //---------------------------------------------------------------------------
  246. void __fastcall TFRAMEDsrcList::Column05CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  247. bool &ADone)
  248. {
  249. try
  250. {
  251. TColor tColor = ACanvas->Brush->Color;
  252. if (!VarIsNull(AViewInfo->GridRecord->DisplayTexts[Column05->Index]))
  253. {
  254. String sCode = AViewInfo->GridRecord->DisplayTexts[Column05->Index];
  255. if (sCode == FrmLang->lblComm0->Caption) tColor = clLime;
  256. else if (sCode == FrmLang->lblComm1->Caption) tColor = clRed;
  257. else tColor = clGray;
  258. }
  259. ACanvas->SetBrushColor(tColor);
  260. ACanvas->Font->Color = clBlack;
  261. }
  262. catch(Exception &e)
  263. {
  264. }
  265. }
  266. //---------------------------------------------------------------------------