FRAME_AtrdListF.cpp 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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_AtrdListF.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 link "cxContainer"
  36. #pragma link "cxLabel"
  37. #pragma link "dxSkinMcSkin"
  38. #pragma resource "*.dfm"
  39. //TFRAMEAtrdList *FRAMEAtrdList;
  40. //---------------------------------------------------------------------------
  41. __fastcall TFRAMEAtrdList::TFRAMEAtrdList(TComponent* Owner)
  42. : TFrame(Owner)
  43. {
  44. LangTrans->Translate(this, ITSDb_GetConnection());
  45. ColumnSel->Options->Filtering = false;
  46. m_pGDC = TvList->DataController;
  47. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<간선도로 정보가 없습니다>";
  48. MyItsAtrdManager = new TItsAtrdManager();
  49. MyItsAtrdManager->LoadFromDb();
  50. FCodeIFD = ItsCodeManager->FLists.Find("IFD"); //정보제공구간 방향코드
  51. }
  52. //---------------------------------------------------------------------------
  53. void __fastcall TFRAMEAtrdList::UpdateList()
  54. {
  55. CMM_ClearGridTableView(TvList);
  56. int nRow = 0;
  57. try
  58. {
  59. TvList->BeginUpdate();
  60. try
  61. {
  62. MyItsAtrdManager->FLists.Lock();
  63. FOR_STL(TItsAtrd*, pObj, MyItsAtrdManager->FLists)
  64. {
  65. if (pObj->DEL_YN == "Y") continue;
  66. nRow = m_pGDC->AppendRecord();
  67. m_pGDC->Values[nRow][ColumnSel->Index] = false; //선택
  68. m_pGDC->Values[nRow][Column00->Index] = "-"; //편집
  69. m_pGDC->Values[nRow][Column01->Index] = pObj->ATRD_ID; //간선도로 ID
  70. m_pGDC->Values[nRow][Column02->Index] = pObj->ATRD_NM; //간선도로 명
  71. m_pGDC->Values[nRow][Column03->Index] = (pObj->DRCT_CD.Trim() == "0") ? FrmLang->lblUp->Caption : FrmLang->lblDown->Caption;//String("상행") : String("하행"); //위치
  72. m_pGDC->Values[nRow][Column04->Index] = pObj->DRCT_NM.Trim();
  73. m_pGDC->Values[nRow][Column99->Index] = (int)pObj;
  74. }
  75. }
  76. __finally
  77. {
  78. MyItsAtrdManager->FLists.UnLock();
  79. }
  80. }
  81. __finally
  82. {
  83. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  84. TvList->EndUpdate();
  85. TvList->DataController->GotoFirst();
  86. TvList->DataController->FocusedRecordIndex = 0;
  87. //CxList->SetFocus();
  88. }
  89. }
  90. //---------------------------------------------------------------------------
  91. void __fastcall TFRAMEAtrdList::BtnAllSelectClick(TObject *Sender)
  92. {
  93. TcxButton *pBtn = (TcxButton*)Sender;
  94. CMM_CheckAllListItem(TvList, ColumnSel->Index, pBtn->Tag);
  95. }
  96. //---------------------------------------------------------------------------
  97. int __fastcall TFRAMEAtrdList::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][Column01->Index]);
  105. ALinkIds = sLinkId;
  106. return 1;
  107. }
  108. //---------------------------------------------------------------------------
  109. int __fastcall TFRAMEAtrdList::GetSelIds(TStringList *AStringList)
  110. {
  111. int nSelCnt = 0;
  112. try
  113. {
  114. TvList->BeginUpdate();
  115. #if 0
  116. int nRowCnt = m_pGDC->RecordCount;
  117. for (int ii = 0; ii < nRowCnt; ii++)
  118. {
  119. if (((bool)m_pGDC->Values[ii][ColumnSel->Index]))
  120. {
  121. AStringList->Add(m_pGDC->Values[ii][Column00->Index]);
  122. nSelIdx++;
  123. }
  124. }
  125. #else
  126. int nRowCnt = TvList->ViewData->RecordCount;
  127. for (int ii = 0; ii < nRowCnt; ii++)
  128. {
  129. TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii];
  130. if (((bool)ARow->Values[ColumnSel->Index]))
  131. {
  132. AStringList->Add(ARow->Values[Column01->Index]);
  133. nSelCnt++;
  134. }
  135. }
  136. #endif
  137. }
  138. __finally
  139. {
  140. TvList->EndUpdate();
  141. }
  142. return nSelCnt;
  143. }
  144. //---------------------------------------------------------------------------
  145. void __fastcall TFRAMEAtrdList::TvListDataControllerFilterChanged(TObject *Sender)
  146. {
  147. CMM_SetFilterLike(TvList);
  148. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  149. }
  150. //---------------------------------------------------------------------------
  151. void __fastcall TFRAMEAtrdList::BtnExlSaveClick(TObject *Sender)
  152. {
  153. TcxGrid *pGrid = CxList;
  154. TcxGridTableView *pView = TvList;
  155. String sTitle= lblFileName->Caption;//"간선도로정보";
  156. CMM_ExportToExcelFile(sTitle, pGrid, pView, (TForm*)this);
  157. }
  158. //---------------------------------------------------------------------------
  159. void __fastcall TFRAMEAtrdList::OnCloseQuery(bool &CanClose)
  160. {
  161. try {
  162. if (MyItsAtrdManager)
  163. {
  164. delete MyItsAtrdManager;
  165. MyItsAtrdManager = NULL;
  166. }
  167. } catch(...) {}
  168. }
  169. //---------------------------------------------------------------------------