FRAME_AviListF.cpp 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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_AviListF.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. //TFRAMEAviList *FRAMEAviList;
  37. //---------------------------------------------------------------------------
  38. __fastcall TFRAMEAviList::TFRAMEAviList(TComponent* Owner)
  39. : TFrame(Owner)
  40. {
  41. ColumnSel->Options->Filtering = false;
  42. m_pGDC = TvList->DataController;
  43. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<AVI 제어기 정보가 없습니다>";
  44. MyItsAviManager = new TItsAviManager();
  45. MyItsAviManager->LoadFromDb();
  46. FCodeIFD = ItsCodeManager->FLists.Find("IFD"); //제어기유형
  47. }
  48. //---------------------------------------------------------------------------
  49. void __fastcall TFRAMEAviList::UpdateList()
  50. {
  51. CMM_ClearGridTableView(TvList);
  52. int nRow = 0;
  53. try
  54. {
  55. TvList->BeginUpdate();
  56. try
  57. {
  58. MyItsAviManager->FLists.Lock();
  59. FOR_STL(TItsAvi*, pObj, MyItsAviManager->FLists)
  60. {
  61. if (pObj->DEL_YN == "Y") continue;
  62. nRow = m_pGDC->AppendRecord();
  63. m_pGDC->Values[nRow][ColumnSel->Index] = false; //선택
  64. m_pGDC->Values[nRow][Column00->Index] = "-"; //편집
  65. m_pGDC->Values[nRow][Column01->Index] = pObj->AVI_CTLR_MNGM_NMBR; //관리번호
  66. m_pGDC->Values[nRow][Column02->Index] = pObj->AVI_ID; //AVI ID
  67. m_pGDC->Values[nRow][Column03->Index] = pObj->AVI_LCTN_NM; //위치
  68. m_pGDC->Values[nRow][Column99->Index] = (int)pObj;
  69. }
  70. }
  71. __finally
  72. {
  73. MyItsAviManager->FLists.UnLock();
  74. }
  75. }
  76. __finally
  77. {
  78. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  79. TvList->EndUpdate();
  80. TvList->DataController->GotoFirst();
  81. TvList->DataController->FocusedRecordIndex = 0;
  82. //CxList->SetFocus();
  83. }
  84. }
  85. //---------------------------------------------------------------------------
  86. void __fastcall TFRAMEAviList::BtnAllSelectClick(TObject *Sender)
  87. {
  88. TcxButton *pBtn = (TcxButton*)Sender;
  89. CMM_CheckAllListItem(TvList, ColumnSel->Index, pBtn->Tag);
  90. }
  91. //---------------------------------------------------------------------------
  92. int __fastcall TFRAMEAviList::GetSelIds(String &ALinkIds)
  93. {
  94. ALinkIds = "";
  95. if (TvList->ViewData->RecordCount <= 0) return 0;
  96. int nIndex = m_pGDC->FocusedRecordIndex;
  97. if( nIndex < 0 )
  98. return 0;
  99. String sLinkId = VarToStr(m_pGDC->Values[nIndex][Column01->Index]);
  100. ALinkIds = sLinkId;
  101. return 1;
  102. }
  103. //---------------------------------------------------------------------------
  104. int __fastcall TFRAMEAviList::GetSelIds(TStringList *AStringList)
  105. {
  106. int nSelCnt = 0;
  107. try
  108. {
  109. TvList->BeginUpdate();
  110. #if 0
  111. int nRowCnt = m_pGDC->RecordCount;
  112. for (int ii = 0; ii < nRowCnt; ii++)
  113. {
  114. if (((bool)m_pGDC->Values[ii][ColumnSel->Index]))
  115. {
  116. AStringList->Add(m_pGDC->Values[ii][Column00->Index]);
  117. nSelIdx++;
  118. }
  119. }
  120. #else
  121. int nRowCnt = TvList->ViewData->RecordCount;
  122. for (int ii = 0; ii < nRowCnt; ii++)
  123. {
  124. TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii];
  125. if (((bool)ARow->Values[ColumnSel->Index]))
  126. {
  127. AStringList->Add(ARow->Values[Column01->Index]);
  128. nSelCnt++;
  129. }
  130. }
  131. #endif
  132. }
  133. __finally
  134. {
  135. TvList->EndUpdate();
  136. }
  137. return nSelCnt;
  138. }
  139. //---------------------------------------------------------------------------
  140. void __fastcall TFRAMEAviList::TvListDataControllerFilterChanged(TObject *Sender)
  141. {
  142. CMM_SetFilterLike(TvList);
  143. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  144. }
  145. //---------------------------------------------------------------------------
  146. void __fastcall TFRAMEAviList::BtnExlSaveClick(TObject *Sender)
  147. {
  148. TcxGrid *pGrid = CxList;
  149. TcxGridTableView *pView = TvList;
  150. String sTitle= "AVI제어기정보";
  151. CMM_ExportToExcelFile(sTitle, pGrid, pView, (TForm*)this);
  152. }
  153. //---------------------------------------------------------------------------
  154. void __fastcall TFRAMEAviList::OnCloseQuery(bool &CanClose)
  155. {
  156. try {
  157. if (MyItsAviManager)
  158. {
  159. delete MyItsAviManager;
  160. MyItsAviManager = NULL;
  161. }
  162. } catch(...) {}
  163. }
  164. //---------------------------------------------------------------------------