#include "stdafx.h" #include "LaySysSelectDlg.h" #include ".\syslayercfg\WSysLayCfgDlg.h" #include "pipelinetools.h" #include "coretools.h" IMPLEMENT_DYNAMIC(CLaySysSelectDlg, CDialog) CLaySysSelectDlg::CLaySysSelectDlg(CWnd* pParent /*=NULL*/) : CDialog(CLaySysSelectDlg::IDD, pParent) { m_pDb = NULL; } CLaySysSelectDlg::~CLaySysSelectDlg() { } void CLaySysSelectDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_COMBOSYSLAY, m_wndComboSys); } BEGIN_MESSAGE_MAP(CLaySysSelectDlg, CDialog) ON_BN_CLICKED(IDC_BTSYSSET, &CLaySysSelectDlg::OnBnClickedBtsysset) ON_BN_CLICKED(IDOK, &CLaySysSelectDlg::OnBnClickedOk) END_MESSAGE_MAP() BOOL CLaySysSelectDlg::OnInitDialog() { CDialog::OnInitDialog(); //显示当前图层系统 CString sSQL,sStd(CoreTools::getCurrentPipeSysTblName()); //sSQL = _T("select tablename from wpipecfg where currstd=1"); //m_pDb->GetSelData(sSQL,sStd); sSQL.Format(_T("select distinct system from %s"),sStd); CStringArray arSyses; m_pDb->GetSelData(sSQL,arSyses); //映射到系统图层 int nPos = 0; PipelineTools::setCurrentLayerSys(m_sCurrSys); for (int i = 0;i < arSyses.GetSize();i++) { m_wndComboSys.AddString(arSyses.GetAt(i)); if (m_sCurrSys.CompareNoCase(arSyses.GetAt(i)) == 0) { nPos = i; } } if (arSyses.GetSize() > 0) { m_wndComboSys.SetCurSel(nPos); } return TRUE; } void CLaySysSelectDlg::SetADOServer(CUIISQLiteServer* pDb) { m_pDb = pDb; } void CLaySysSelectDlg::OnBnClickedBtsysset() { CWSysLayCfgDlg wsysDlg; int nRes = wsysDlg.DoModal(); if (nRes == IDOK) { //显示当前图层系统 CString sSQL,sStd(CoreTools::getCurrentPipeSysTblName()); //sSQL = _T("select tablename from wpipecfg where currstd=1"); //m_pDb->GetSelData(sSQL,sStd); sSQL.Format(_T("select distinct system from %s"),sStd); CStringArray arSyses; m_pDb->GetSelData(sSQL,arSyses); m_wndComboSys.ResetContent(); for (int i = 0;i < arSyses.GetSize();i++) { m_wndComboSys.AddString(arSyses.GetAt(i)); } if (arSyses.GetSize() > 0) { m_wndComboSys.SetCurSel(0); } } } void CLaySysSelectDlg::OnBnClickedOk() { int nCursel = m_wndComboSys.GetCurSel(); if (nCursel != -1) { m_wndComboSys.GetLBText(nCursel,m_sCurrSys); } else { AfxMessageBox(_T("没有选择分系统!请选择系统!")); return; } OnOK(); }