FRAME_AviSectListF.cpp 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "ITSUtilF.h"
  5. #include "FrmResourceF.h"
  6. #include "ITSLangTransF.h"
  7. #pragma hdrstop
  8. #include "FRAME_AviSectListF.h"
  9. //---------------------------------------------------------------------------
  10. #pragma package(smart_init)
  11. #pragma link "cxButtons"
  12. #pragma link "cxCalc"
  13. #pragma link "cxCheckBox"
  14. #pragma link "cxClasses"
  15. #pragma link "cxControls"
  16. #pragma link "cxCustomData"
  17. #pragma link "cxData"
  18. #pragma link "cxDataStorage"
  19. #pragma link "cxEdit"
  20. #pragma link "cxFilter"
  21. #pragma link "cxGraphics"
  22. #pragma link "cxGrid"
  23. #pragma link "cxGridCustomTableView"
  24. #pragma link "cxGridCustomView"
  25. #pragma link "cxGridLevel"
  26. #pragma link "cxGridTableView"
  27. #pragma link "cxLookAndFeelPainters"
  28. #pragma link "cxLookAndFeels"
  29. #pragma link "cxStyles"
  30. #pragma link "cxTextEdit"
  31. #pragma link "dxSkinBlack"
  32. #pragma link "dxSkinBlue"
  33. #pragma link "dxSkinsCore"
  34. #pragma link "dxSkinscxPCPainter"
  35. #pragma resource "*.dfm"
  36. //TFRAMEAviSectList *FRAMEAviSectList;
  37. //---------------------------------------------------------------------------
  38. __fastcall TFRAMEAviSectList::TFRAMEAviSectList(TComponent* Owner)
  39. : TFrame(Owner)
  40. {
  41. ColumnSel->Options->Filtering = false;
  42. m_pGDC = TvList->DataController;
  43. TvList->OptionsView->GroupByBox = false;
  44. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<AVI 구간 정보가 없습니다>";
  45. MyItsAviManager = new TItsAviManager();
  46. MyItsAviManager->LoadFromDb();
  47. MyItsAviManager->LoadFromSectDb();
  48. FCodeIFD = ItsCodeManager->FLists.Find("IFD"); //제어기유형
  49. }
  50. //---------------------------------------------------------------------------
  51. void __fastcall TFRAMEAviSectList::UpdateList()
  52. {
  53. CMM_ClearGridTableView(TvList);
  54. int nRow = 0;
  55. try
  56. {
  57. TvList->BeginUpdate();
  58. try
  59. {
  60. MyItsAviManager->FSectLists.Lock();
  61. FOR_STL(TItsAviSect*, pObj, MyItsAviManager->FSectLists)
  62. {
  63. if (pObj->DEL_YN == "Y") continue;
  64. nRow = m_pGDC->AppendRecord();
  65. m_pGDC->Values[nRow][ColumnSel->Index] = false; //선택
  66. m_pGDC->Values[nRow][Column00->Index] = "-"; //편집
  67. //m_pGDC->Values[nRow][Column01->Index] = pObj->AVI_LCTN_NM; //제어기위치
  68. m_pGDC->Values[nRow][Column02->Index] = pObj->AVI_SECT_NMBR; //AVI ID
  69. m_pGDC->Values[nRow][Column03->Index] = pObj->AVI_SECT_NM; //구간명
  70. m_pGDC->Values[nRow][Column04->Index] = pObj->STRT_SPOT_NM; //시점명
  71. m_pGDC->Values[nRow][Column05->Index] = pObj->END_SPOT_NM; //종점명
  72. m_pGDC->Values[nRow][Column99->Index] = (int)pObj;
  73. }
  74. }
  75. __finally
  76. {
  77. MyItsAviManager->FSectLists.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. //CxList->SetFocus();
  87. CMM_ExpandCollapseChk(TvList, true);
  88. }
  89. }
  90. //---------------------------------------------------------------------------
  91. void __fastcall TFRAMEAviSectList::BtnAllSelectClick(TObject *Sender)
  92. {
  93. TcxButton *pBtn = (TcxButton*)Sender;
  94. CMM_CheckAllListItem(TvList, ColumnSel->Index, pBtn->Tag);
  95. }
  96. //---------------------------------------------------------------------------
  97. int __fastcall TFRAMEAviSectList::GetSelIds(String &ALinkIds)
  98. {
  99. ALinkIds = "";
  100. if (TvList->ViewData->RecordCount <= 0) return 0;
  101. int nIndex = m_pGDC->FocusedRecordIndex;
  102. if( nIndex < 0 )
  103. return 0;
  104. String sLinkId = VarToStr(m_pGDC->Values[nIndex][Column02->Index]);
  105. ALinkIds = sLinkId;
  106. return 1;
  107. }
  108. //---------------------------------------------------------------------------
  109. int __fastcall TFRAMEAviSectList::GetSelIds(TStringList *AStringList)
  110. {
  111. int nSelCnt = 0;
  112. try
  113. {
  114. TvList->BeginUpdate();
  115. int nRowCnt = TvList->ViewData->RecordCount;
  116. for (int ii = 0; ii < nRowCnt; ii++)
  117. {
  118. TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii];
  119. if (((bool)ARow->Values[ColumnSel->Index]))
  120. {
  121. AStringList->Add(ARow->Values[Column02->Index]);
  122. nSelCnt++;
  123. }
  124. }
  125. }
  126. __finally
  127. {
  128. TvList->EndUpdate();
  129. }
  130. return nSelCnt;
  131. }
  132. //---------------------------------------------------------------------------
  133. void __fastcall TFRAMEAviSectList::TvListDataControllerFilterChanged(TObject *Sender)
  134. {
  135. CMM_SetFilterLike(TvList);
  136. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  137. }
  138. //---------------------------------------------------------------------------
  139. void __fastcall TFRAMEAviSectList::BtnExlSaveClick(TObject *Sender)
  140. {
  141. TcxGrid *pGrid = CxList;
  142. TcxGridTableView *pView = TvList;
  143. String sTitle= "AVI구간정보";
  144. CMM_ExportToExcelFile(sTitle, pGrid, pView, (TForm*)this);
  145. }
  146. //---------------------------------------------------------------------------
  147. void __fastcall TFRAMEAviSectList::OnCloseQuery(bool &CanClose)
  148. {
  149. try {
  150. if (MyItsAviManager)
  151. {
  152. delete MyItsAviManager;
  153. MyItsAviManager = NULL;
  154. }
  155. } catch(...) {}
  156. }
  157. //---------------------------------------------------------------------------