FRAME_AtrdListF.cpp 5.8 KB

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