ITSSEL5MF.cpp 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "ITSUtilF.h"
  5. #include "AppGlobalF.h"
  6. #include "ITSLangTransF.h"
  7. #pragma hdrstop
  8. #include "ITSSEL5MF.h"
  9. //---------------------------------------------------------------------------
  10. #pragma package(smart_init)
  11. #pragma link "cxButtons"
  12. #pragma link "cxContainer"
  13. #pragma link "cxControls"
  14. #pragma link "cxEdit"
  15. #pragma link "cxGraphics"
  16. #pragma link "cxGroupBox"
  17. #pragma link "cxLookAndFeelPainters"
  18. #pragma link "cxLookAndFeels"
  19. #pragma link "dxSkinBlack"
  20. #pragma link "dxSkinBlue"
  21. #pragma link "dxSkinsCore"
  22. #pragma link "cxCalc"
  23. #pragma link "cxCheckBox"
  24. #pragma link "cxClasses"
  25. #pragma link "cxCustomData"
  26. #pragma link "cxData"
  27. #pragma link "cxDataStorage"
  28. #pragma link "cxFilter"
  29. #pragma link "cxGrid"
  30. #pragma link "cxGridCustomTableView"
  31. #pragma link "cxGridCustomView"
  32. #pragma link "cxGridLevel"
  33. #pragma link "cxGridTableView"
  34. #pragma link "cxLabel"
  35. #pragma link "cxStyles"
  36. #pragma link "cxTextEdit"
  37. #pragma link "dxSkinscxPCPainter"
  38. #pragma resource "*.dfm"
  39. TITSSEL5M *ITSSEL5M = NULL;
  40. //---------------------------------------------------------------------------
  41. __fastcall TITSSEL5M::TITSSEL5M(TComponent* Owner, TVdsCtlrManager* AVdsCtlrManager)
  42. : TForm(Owner)
  43. {
  44. LangTrans->Translate(this, ITSDb_GetConnection());
  45. ITSSkin_Load(this);
  46. CMM_LoadForm(g_sFormsDir, this);
  47. m_bSelected = false;
  48. m_pGDC = TvList->DataController;
  49. MyVdsCtlrManager = AVdsCtlrManager;
  50. }
  51. //---------------------------------------------------------------------------
  52. void __fastcall TITSSEL5M::CommClose()
  53. {
  54. try
  55. {
  56. CMM_SaveForm(g_sFormsDir, this);
  57. }
  58. catch(...)
  59. {
  60. }
  61. }
  62. //---------------------------------------------------------------------------
  63. void __fastcall TITSSEL5M::FormShow(TObject *Sender)
  64. {
  65. Refresh();
  66. TmrShow->Enabled = true;
  67. }
  68. //---------------------------------------------------------------------------
  69. void __fastcall TITSSEL5M::TmrShowTimer(TObject *Sender)
  70. {
  71. TmrShow->Enabled = false;
  72. BtnSearchClick((TObject*)BtnSearch);
  73. }
  74. //---------------------------------------------------------------------------
  75. void __fastcall TITSSEL5M::BtnSearchClick(TObject *Sender)
  76. {
  77. Application->ProcessMessages();
  78. TSqlCursor sqlCrs((TControl*)BtnSearch);
  79. RefreshData();
  80. }
  81. //---------------------------------------------------------------------------
  82. void __fastcall TITSSEL5M::RefreshData()
  83. {
  84. // 검색조건에 의한 링크 데이터 조회
  85. try
  86. {
  87. SelListData();
  88. }
  89. __finally
  90. {
  91. //TvList->ApplyBestFit(NULL, false, false);
  92. }
  93. }
  94. //---------------------------------------------------------------------------
  95. void __fastcall TITSSEL5M::SelListData()
  96. {
  97. String sQry;
  98. TADOQuery *pADO = NULL;
  99. sQry = "SELECT A.LINK_ID, C.NODE_NAME AS STR_NAME, D.NODE_NAME AS END_NAME, \r\n"
  100. " F.VDS_CTLR_NMBR, F.VDS_NM \r\n"
  101. " FROM TB_VDS_DTCT_RLTN_LINK A, \r\n"
  102. " TB_LINK B, \r\n"
  103. " TB_NODE C, \r\n"
  104. " TB_NODE D, \r\n"
  105. " TB_VDS_DTCT E, \r\n"
  106. " TB_VDS_CTLR F \r\n"
  107. " WHERE A.LINK_ID = B.LINK_ID \r\n"
  108. " AND B.F_NODE_ID = C.NODE_ID \r\n"
  109. " AND B.T_NODE_ID = D.NODE_ID \r\n"
  110. " AND A.VDS_DTCT_NMBR = E.VDS_DTCT_NMBR \r\n"
  111. " AND E.VDS_CTLR_NMBR = F.VDS_CTLR_NMBR \r\n"
  112. " AND F.VDS_TYPE_CD = 'I' \r\n"
  113. " GROUP BY A.LINK_ID, C.NODE_NAME, D.NODE_NAME, F.VDS_CTLR_NMBR, F.VDS_NM \r\n"
  114. " ORDER BY F.VDS_CTLR_NMBR, A.LINK_ID \r\n";
  115. CMM_ClearGridTableView(TvList);
  116. int nRow = 0;
  117. TvList->BeginUpdate();
  118. try
  119. {
  120. try
  121. {
  122. #if 0
  123. pADO = new TADOQuery(NULL);
  124. pADO->Close();
  125. pADO->Connection = ITSDb_GetConnection();
  126. pADO->SQL->Clear();
  127. pADO->SQL->Text = sQry;
  128. pADO->Prepared = true;
  129. pADO->Open();
  130. for( ; !pADO->Eof; pADO->Next())
  131. {
  132. nRow = m_pGDC->AppendRecord();
  133. m_pGDC->Values[nRow][ColumnSel->Index] = false;
  134. m_pGDC->Values[nRow][Column01->Index] = pADO->FieldByName("VDS_CTLR_NMBR")->AsString;
  135. m_pGDC->Values[nRow][Column02->Index] = pADO->FieldByName("VDS_NM")->AsString;
  136. m_pGDC->Values[nRow][Column03->Index] = pADO->FieldByName("LINK_ID")->AsString;
  137. m_pGDC->Values[nRow][Column04->Index] = pADO->FieldByName("STR_NAME")->AsString;
  138. m_pGDC->Values[nRow][Column05->Index] = pADO->FieldByName("END_NAME")->AsString;
  139. }
  140. #else
  141. FOR_STL(TVdsLink*, pObj, MyVdsCtlrManager->FLinkLists)
  142. {
  143. nRow = m_pGDC->AppendRecord();
  144. m_pGDC->Values[nRow][ColumnSel->Index] = pObj->IsSelected;
  145. m_pGDC->Values[nRow][Column01->Index] = pObj->VDS_CTLR_NMBR;
  146. m_pGDC->Values[nRow][Column02->Index] = pObj->VDS_NM;
  147. m_pGDC->Values[nRow][Column03->Index] = pObj->LINK_ID;
  148. m_pGDC->Values[nRow][Column04->Index] = pObj->STR_NAME;
  149. m_pGDC->Values[nRow][Column05->Index] = pObj->END_NAME;
  150. }
  151. #endif
  152. }
  153. catch(EDatabaseError &E)
  154. {
  155. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  156. DBERRORMSG("TITSSEL5M::SelListData", String(E.ClassName()), E.Message, sQry);
  157. throw Exception(String(E.ClassName()) + E.Message);
  158. }
  159. catch(Exception &exception)
  160. {
  161. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  162. DBERRORMSG("TITSSEL5M::SelListData", String(exception.ClassName()), exception.Message, sQry);
  163. throw Exception(String(exception.ClassName()) + exception.Message);
  164. }
  165. }
  166. __finally
  167. {
  168. if (pADO)
  169. {
  170. pADO->Close();
  171. delete pADO;
  172. }
  173. TvList->EndUpdate();
  174. }
  175. }
  176. //---------------------------------------------------------------------------
  177. void __fastcall TITSSEL5M::BtnCloseClick(TObject *Sender)
  178. {
  179. FIdList = "";
  180. Close();
  181. }
  182. //---------------------------------------------------------------------------
  183. void __fastcall TITSSEL5M::BtnSelectClick(TObject *Sender)
  184. {
  185. FIdList = "";
  186. int nSelects = CMM_GetSelectCount(TvList, ColumnSel->Index, Column02->Index, FIdList);
  187. if (0 == nSelects)
  188. {
  189. Application->MessageBox(FrmLang->lblSelErr->Caption.c_str(),//L"목록에서 도로를 먼저 선택 하세요.",
  190. cxGroupBox1->Caption.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  191. return;
  192. }
  193. MyVdsCtlrManager->FLinkSelCnt = 0;
  194. FOR_STL(TVdsLink*, pObj, MyVdsCtlrManager->FLinkLists)
  195. {
  196. pObj->IsSelected = false;
  197. }
  198. TvList->BeginUpdate();
  199. try
  200. {
  201. int nRowCnt = TvList->ViewData->RecordCount;
  202. for (int ii = 0; ii < nRowCnt; ii++)
  203. {
  204. TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii];
  205. if (!ARow->IsData) continue;
  206. if (((bool)ARow->Values[ColumnSel->Index]))
  207. {
  208. String LINK_ID = ARow->Values[Column03->Index];
  209. TVdsLink *pObj = MyVdsCtlrManager->FLinkLists.Find(LINK_ID);
  210. if (pObj)
  211. {
  212. pObj->IsSelected = true;
  213. MyVdsCtlrManager->FLinkSelCnt++;
  214. }
  215. }
  216. }
  217. }
  218. __finally
  219. {
  220. TvList->EndUpdate();
  221. }
  222. m_bSelected = true;
  223. Close();
  224. }
  225. //---------------------------------------------------------------------------
  226. void __fastcall TITSSEL5M::FormClose(TObject *Sender, TCloseAction &Action)
  227. {
  228. CommClose();
  229. ITSSEL5M = NULL;
  230. //Action = caFree;
  231. }
  232. //---------------------------------------------------------------------------
  233. void __fastcall TITSSEL5M::SetMultiSelect(bool AMultiSelect)
  234. {
  235. TvList->OptionsSelection->MultiSelect = AMultiSelect;
  236. }
  237. //---------------------------------------------------------------------------
  238. bool __fastcall TITSSEL5M::GetMultiSelect()
  239. {
  240. return TvList->OptionsSelection->MultiSelect;
  241. }
  242. //---------------------------------------------------------------------------
  243. void __fastcall TITSSEL5M::BtnAllSelectClick(TObject *Sender)
  244. {
  245. TcxButton *pBtn = (TcxButton*)Sender;
  246. CMM_CheckAllListItem(TvList, ColumnSel->Index, pBtn->Tag);
  247. }
  248. //---------------------------------------------------------------------------