FRAME_CrsCamListF.cpp 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "ITSUtilF.h"
  5. #include "FrmResourceF.h"
  6. #include "ITSLangTransF.h"
  7. #include "ITS_OPLibF.h"
  8. #pragma hdrstop
  9. #include "FRAME_CrsCamListF.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 "cxContainer"
  17. #pragma link "cxControls"
  18. #pragma link "cxCustomData"
  19. #pragma link "cxData"
  20. #pragma link "cxDataStorage"
  21. #pragma link "cxEdit"
  22. #pragma link "cxFilter"
  23. #pragma link "cxGraphics"
  24. #pragma link "cxGrid"
  25. #pragma link "cxGridCustomTableView"
  26. #pragma link "cxGridCustomView"
  27. #pragma link "cxGridLevel"
  28. #pragma link "cxGridTableView"
  29. #pragma link "cxLookAndFeelPainters"
  30. #pragma link "cxLookAndFeels"
  31. #pragma link "cxStyles"
  32. #pragma link "cxTextEdit"
  33. #pragma link "dxSkinBlack"
  34. #pragma link "dxSkinBlue"
  35. #pragma link "dxSkinsCore"
  36. #pragma link "dxSkinscxPCPainter"
  37. #pragma link "cxLabel"
  38. #pragma link "cxDropDownEdit"
  39. #pragma link "cxMaskEdit"
  40. #pragma link "dxSkinMcSkin"
  41. #pragma resource "*.dfm"
  42. //TFRAMECrsCamList *FRAMECrsCamList;
  43. //---------------------------------------------------------------------------
  44. __fastcall TFRAMECrsCamList::TFRAMECrsCamList(TComponent* Owner)
  45. : TFrame(Owner)
  46. {
  47. LangTrans->Translate(this, ITSDb_GetConnection());
  48. ColumnSel->Options->Filtering = false;
  49. m_pGDC = TvList->DataController;
  50. TvList->OptionsView->GroupByBox = false;
  51. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;
  52. //APP_FillCode(CbType, "DTT");
  53. //APP_FillCode(Cb_DTCT_DIR, "VCD");
  54. }
  55. //---------------------------------------------------------------------------
  56. void __fastcall TFRAMECrsCamList::UpdateList(int AType/*=0*/)
  57. {
  58. CMM_ClearGridTableView(TvList);
  59. int nRow = 0;
  60. try
  61. {
  62. TvList->BeginUpdate();
  63. try
  64. {
  65. CrossManager->FLists.Lock();
  66. FOR_STL(TCross*, pCross, CrossManager->FLists)
  67. {
  68. if (pCross->DEL_YN == "Y") continue;
  69. FOR_STL(TCrossCam*, pObj, pCross->FLists)
  70. {
  71. if (pObj->DEL_YN == "Y") continue;
  72. nRow = m_pGDC->AppendRecord();
  73. m_pGDC->Values[nRow][ColumnSel->Index] = false; //¼±ÅÃ
  74. m_pGDC->Values[nRow][Column00->Index] = "-"; //ÆíÁý
  75. m_pGDC->Values[nRow][Column01->Index] = pCross->CTLR_NMBR+"."+pCross->NAME;
  76. m_pGDC->Values[nRow][Column02->Index] = pObj->CTLR_NMBR;
  77. m_pGDC->Values[nRow][Column04->Index] = pObj->DIRECTION;
  78. m_pGDC->Values[nRow][Column05->Index] = pObj->NAME;
  79. m_pGDC->Values[nRow][Column99->Index] = (int)pObj;
  80. }
  81. }
  82. }
  83. __finally
  84. {
  85. CrossManager->FLists.UnLock();
  86. }
  87. }
  88. __finally
  89. {
  90. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  91. TvList->EndUpdate();
  92. TvList->DataController->GotoFirst();
  93. TvList->DataController->FocusedRecordIndex = 0;
  94. //CxList->SetFocus();
  95. CMM_ExpandCollapseChk(TvList, true);
  96. }
  97. }
  98. //---------------------------------------------------------------------------
  99. void __fastcall TFRAMECrsCamList::BtnAllSelectClick(TObject *Sender)
  100. {
  101. TcxButton *pBtn = (TcxButton*)Sender;
  102. CMM_CheckAllListItem(TvList, ColumnSel->Index, pBtn->Tag);
  103. }
  104. //---------------------------------------------------------------------------
  105. int __fastcall TFRAMECrsCamList::GetSelIds(String &ALinkIds)
  106. {
  107. ALinkIds = "";
  108. if (TvList->ViewData->RecordCount <= 0) return 0;
  109. int nIndex = m_pGDC->FocusedRecordIndex;
  110. if( nIndex < 0 )
  111. return 0;
  112. String sLinkId = VarToStr(m_pGDC->Values[nIndex][Column02->Index]);
  113. ALinkIds = sLinkId;
  114. return 1;
  115. }
  116. //---------------------------------------------------------------------------
  117. int __fastcall TFRAMECrsCamList::GetSelIds(TStringList *AStringList)
  118. {
  119. int nSelCnt = 0;
  120. try
  121. {
  122. TvList->BeginUpdate();
  123. int nRowCnt = TvList->ViewData->RecordCount;
  124. for (int ii = 0; ii < nRowCnt; ii++)
  125. {
  126. TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii];
  127. if (((bool)ARow->Values[ColumnSel->Index]))
  128. {
  129. AStringList->Add(ARow->Values[Column02->Index]);
  130. nSelCnt++;
  131. }
  132. }
  133. }
  134. __finally
  135. {
  136. TvList->EndUpdate();
  137. }
  138. return nSelCnt;
  139. }
  140. //---------------------------------------------------------------------------
  141. void __fastcall TFRAMECrsCamList::TvListDataControllerFilterChanged(TObject *Sender)
  142. {
  143. CMM_SetFilterLike(TvList);
  144. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  145. }
  146. //---------------------------------------------------------------------------
  147. void __fastcall TFRAMECrsCamList::BtnExlSaveClick(TObject *Sender)
  148. {
  149. TcxGrid *pGrid = CxList;
  150. TcxGridTableView *pView = TvList;
  151. String sTitle= lblFileName->Caption;
  152. CMM_ExportToExcelFile(sTitle, pGrid, pView, (TForm*)this);
  153. }
  154. //---------------------------------------------------------------------------
  155. void __fastcall TFRAMECrsCamList::OnCloseQuery(bool &CanClose)
  156. {
  157. }
  158. //---------------------------------------------------------------------------
  159. void __fastcall TFRAMECrsCamList::ChkExpandClick(TObject *Sender)
  160. {
  161. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  162. }
  163. //---------------------------------------------------------------------------