FRAME_DsrcOfferSectListF.cpp 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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_DsrcOfferSectListF.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 TFRAMEDsrcOfferSectList::TFRAMEDsrcOfferSectList(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. //FCodeIFD = ItsCodeManager->FLists.Find("IFD"); // 방향코드
  46. }
  47. //---------------------------------------------------------------------------
  48. void __fastcall TFRAMEDsrcOfferSectList::UpdateList()
  49. {
  50. CMM_ClearGridTableView(TvList);
  51. int nRow = 0;
  52. String sQry;
  53. TADOQuery *pADO = NULL;
  54. sQry = "SELECT A.OFFR_SECT_ID, A.OFFR_DRCT_NM, A.ID, B.PRE_ID \r\n"
  55. " FROM TB_RSE_OFFR_SECT_MNGM A, \r\n"
  56. " TB_RSE_OFFR_DRCT_INFR B \r\n"
  57. " WHERE A.ID = B.ID \r\n"
  58. " AND A.OBU_ENTR_DRCT_NMBR = B.OBU_ENTR_DRCT_NMBR \r\n"
  59. " ORDER BY OFFR_SECT_ID \r\n";
  60. //" ORDER BY TO_NUMBER(OFFR_SECT_ID) \r\n";
  61. try
  62. {
  63. try
  64. {
  65. pADO = new TADOQuery(NULL);
  66. pADO->Close();
  67. pADO->Connection = ITSDb_GetConnection();
  68. pADO->SQL->Clear();
  69. pADO->SQL->Text = sQry;
  70. pADO->Open();
  71. for( ; !pADO->Eof; pADO->Next())
  72. {
  73. nRow = m_pGDC->AppendRecord();
  74. m_pGDC->Values[nRow][ColumnSel->Index] = false; //선택
  75. m_pGDC->Values[nRow][Column01->Index] = pADO->FieldByName("OFFR_SECT_ID")->AsString;
  76. m_pGDC->Values[nRow][Column02->Index] = pADO->FieldByName("OFFR_DRCT_NM")->AsString;
  77. m_pGDC->Values[nRow][Column03->Index] = pADO->FieldByName("ID")->AsString;
  78. m_pGDC->Values[nRow][Column04->Index] = pADO->FieldByName("PRE_ID")->AsString;
  79. String sId = pADO->FieldByName("OFFR_SECT_ID")->AsString;
  80. m_pGDC->Values[nRow][Column11->Index] = sId.ToIntDef(0); //ID
  81. }
  82. }
  83. catch(EDatabaseError &E)
  84. {
  85. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  86. throw Exception(String(E.ClassName()) + E.Message);
  87. }
  88. catch(Exception &exception)
  89. {
  90. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  91. throw Exception(String(exception.ClassName()) + exception.Message);
  92. }
  93. catch(...)
  94. {
  95. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  96. throw Exception(FrmLang->lblDbErr->Caption);//"알수없는 DB 오류가 발생하였습니다.");
  97. }
  98. }
  99. __finally
  100. {
  101. if (pADO)
  102. {
  103. pADO->Close();
  104. delete pADO;
  105. }
  106. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  107. TvList->EndUpdate();
  108. TvList->DataController->GotoFirst();
  109. TvList->DataController->FocusedRecordIndex = 0;
  110. Column11->SortIndex = Column11->Index;
  111. Column11->SortOrder = soAscending;
  112. //CxList->SetFocus();
  113. }
  114. }
  115. //---------------------------------------------------------------------------
  116. void __fastcall TFRAMEDsrcOfferSectList::BtnAllSelectClick(TObject *Sender)
  117. {
  118. TcxButton *pBtn = (TcxButton*)Sender;
  119. CMM_CheckAllListItem(TvList, ColumnSel->Index, pBtn->Tag);
  120. }
  121. //---------------------------------------------------------------------------
  122. int __fastcall TFRAMEDsrcOfferSectList::GetSelIds(String &ALinkIds)
  123. {
  124. ALinkIds = "";
  125. if (TvList->ViewData->RecordCount <= 0) return 0;
  126. int nIndex = m_pGDC->FocusedRecordIndex;
  127. if( nIndex < 0 )
  128. return 0;
  129. String sLinkId = VarToStr(m_pGDC->Values[nIndex][Column01->Index]);
  130. ALinkIds = sLinkId;
  131. return 1;
  132. }
  133. //---------------------------------------------------------------------------
  134. int __fastcall TFRAMEDsrcOfferSectList::GetSelIds(TStringList *AStringList)
  135. {
  136. int nSelCnt = 0;
  137. try
  138. {
  139. TvList->BeginUpdate();
  140. #if 0
  141. int nRowCnt = m_pGDC->RecordCount;
  142. for (int ii = 0; ii < nRowCnt; ii++)
  143. {
  144. if (((bool)m_pGDC->Values[ii][ColumnSel->Index]))
  145. {
  146. AStringList->Add(m_pGDC->Values[ii][Column00->Index]);
  147. nSelIdx++;
  148. }
  149. }
  150. #else
  151. int nRowCnt = TvList->ViewData->RecordCount;
  152. for (int ii = 0; ii < nRowCnt; ii++)
  153. {
  154. TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii];
  155. if (((bool)ARow->Values[ColumnSel->Index]))
  156. {
  157. AStringList->Add(ARow->Values[Column01->Index]);
  158. nSelCnt++;
  159. }
  160. }
  161. #endif
  162. }
  163. __finally
  164. {
  165. TvList->EndUpdate();
  166. }
  167. return nSelCnt;
  168. }
  169. //---------------------------------------------------------------------------
  170. void __fastcall TFRAMEDsrcOfferSectList::TvListDataControllerFilterChanged(TObject *Sender)
  171. {
  172. CMM_SetFilterLike(TvList);
  173. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  174. }
  175. //---------------------------------------------------------------------------
  176. void __fastcall TFRAMEDsrcOfferSectList::BtnExlSaveClick(TObject *Sender)
  177. {
  178. TcxGrid *pGrid = CxList;
  179. TcxGridTableView *pView = TvList;
  180. String sTitle= "DSRC정보제공구간정보";
  181. CMM_ExportToExcelFile(sTitle, pGrid, pView, (TForm*)this);
  182. }
  183. //---------------------------------------------------------------------------
  184. void __fastcall TFRAMEDsrcOfferSectList::OnCloseQuery(bool &CanClose)
  185. {
  186. try {
  187. } catch(...) {}
  188. }
  189. //---------------------------------------------------------------------------