FRAME_DsrcSectListF.cpp 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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_DsrcSectListF.h"
  9. #include "CDSRoadF.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 TFRAMEDsrcSectList::TFRAMEDsrcSectList(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. MyItsDsrcSectManager = new TItsDsrcSectManager();
  46. MyItsDsrcSectManager->LoadFromDb();
  47. //FCodeIFD = ItsCodeManager->FLists.Find("IFD"); // 방향코드
  48. }
  49. //---------------------------------------------------------------------------
  50. void __fastcall TFRAMEDsrcSectList::LoadFromDb()
  51. {
  52. MyItsDsrcSectManager->LoadFromDb();
  53. }
  54. void __fastcall TFRAMEDsrcSectList::UpdateList()
  55. {
  56. CMM_ClearGridTableView(TvList);
  57. int nRow = 0;
  58. try
  59. {
  60. TvList->BeginUpdate();
  61. try
  62. {
  63. MyItsDsrcSectManager->FLists.Lock();
  64. FOR_STL(TItsDsrcSect*, pObj, MyItsDsrcSectManager->FLists)
  65. {
  66. if (pObj->DEL_YN == "Y") continue;
  67. nRow = m_pGDC->AppendRecord();
  68. m_pGDC->Values[nRow][ColumnSel->Index] = false; //선택
  69. m_pGDC->Values[nRow][Column00->Index] = "-"; //편집
  70. m_pGDC->Values[nRow][Column01->Index] = pObj->RSE_SECT_ID; //sect ID
  71. m_pGDC->Values[nRow][Column02->Index] = pObj->RSE_SECT_ID; //sect ID
  72. m_pGDC->Values[nRow][Column03->Index] = pObj->RSE_SECT_NM; //명칭
  73. m_pGDC->Values[nRow][Column04->Index] = pObj->STRT_SPOT_NM; //시작 지점 명
  74. m_pGDC->Values[nRow][Column05->Index] = pObj->END_SPOT_NM; //종료 지점 명
  75. m_pGDC->Values[nRow][Column06->Index] = pObj->DSTC; //거리
  76. m_pGDC->Values[nRow][Column99->Index] = (int)pObj;
  77. m_pGDC->Values[nRow][Column11->Index] = pObj->RSE_SECT_ID.ToIntDef(0); //ID
  78. }
  79. }
  80. __finally
  81. {
  82. MyItsDsrcSectManager->FLists.UnLock();
  83. }
  84. }
  85. __finally
  86. {
  87. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  88. TvList->EndUpdate();
  89. TvList->DataController->GotoFirst();
  90. TvList->DataController->FocusedRecordIndex = 0;
  91. Column11->SortIndex = Column11->Index;
  92. Column11->SortOrder = soAscending;
  93. //CxList->SetFocus();
  94. }
  95. }
  96. //---------------------------------------------------------------------------
  97. void __fastcall TFRAMEDsrcSectList::BtnAllSelectClick(TObject *Sender)
  98. {
  99. TcxButton *pBtn = (TcxButton*)Sender;
  100. CMM_CheckAllListItem(TvList, ColumnSel->Index, pBtn->Tag);
  101. }
  102. //---------------------------------------------------------------------------
  103. int __fastcall TFRAMEDsrcSectList::GetSelIds(String &ALinkIds)
  104. {
  105. ALinkIds = "";
  106. if (TvList->ViewData->RecordCount <= 0) return 0;
  107. int nIndex = m_pGDC->FocusedRecordIndex;
  108. if( nIndex < 0 )
  109. return 0;
  110. String sLinkId = VarToStr(m_pGDC->Values[nIndex][Column01->Index]);
  111. ALinkIds = sLinkId;
  112. return 1;
  113. }
  114. //---------------------------------------------------------------------------
  115. int __fastcall TFRAMEDsrcSectList::GetSelIds(TStringList *AStringList)
  116. {
  117. int nSelCnt = 0;
  118. try
  119. {
  120. TvList->BeginUpdate();
  121. #if 0
  122. int nRowCnt = m_pGDC->RecordCount;
  123. for (int ii = 0; ii < nRowCnt; ii++)
  124. {
  125. if (((bool)m_pGDC->Values[ii][ColumnSel->Index]))
  126. {
  127. AStringList->Add(m_pGDC->Values[ii][Column00->Index]);
  128. nSelIdx++;
  129. }
  130. }
  131. #else
  132. int nRowCnt = TvList->ViewData->RecordCount;
  133. for (int ii = 0; ii < nRowCnt; ii++)
  134. {
  135. TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii];
  136. if (((bool)ARow->Values[ColumnSel->Index]))
  137. {
  138. AStringList->Add(ARow->Values[Column01->Index]);
  139. nSelCnt++;
  140. }
  141. }
  142. #endif
  143. }
  144. __finally
  145. {
  146. TvList->EndUpdate();
  147. }
  148. return nSelCnt;
  149. }
  150. //---------------------------------------------------------------------------
  151. void __fastcall TFRAMEDsrcSectList::TvListDataControllerFilterChanged(TObject *Sender)
  152. {
  153. CMM_SetFilterLike(TvList);
  154. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  155. }
  156. //---------------------------------------------------------------------------
  157. void __fastcall TFRAMEDsrcSectList::BtnExlSaveClick(TObject *Sender)
  158. {
  159. TcxGrid *pGrid = CxList;
  160. TcxGridTableView *pView = TvList;
  161. String sTitle= "DSRC 구간정보";
  162. CMM_ExportToExcelFile(sTitle, pGrid, pView, (TForm*)this);
  163. }
  164. //---------------------------------------------------------------------------
  165. void __fastcall TFRAMEDsrcSectList::OnCloseQuery(bool &CanClose)
  166. {
  167. try {
  168. if (MyItsDsrcSectManager)
  169. {
  170. delete MyItsDsrcSectManager;
  171. MyItsDsrcSectManager = NULL;
  172. }
  173. } catch(...) {}
  174. }
  175. //---------------------------------------------------------------------------