www.gusucode.com > VC++开发的ACD树形策略编辑器-源码程序 > VC++开发的ACD树形策略编辑器-源码程序/code/DBOperate.cpp
//Download by http://www.NewXing.com // DBOperate.cpp : implementation file // #include "stdafx.h" #include "dsACD_IVR.h" #include "DBOperate.h" #include "dsACD_IVRDoc.h" #include "dsACD_IVRView.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CDBOperate dialog CDBOperate::CDBOperate(CWnd* pParent /*=NULL*/) : CDialog(CDBOperate::IDD, pParent) { //{{AFX_DATA_INIT(CDBOperate) m_csName = _T(""); m_csComment = _T(""); m_csVariable = _T(""); m_csType = _T(""); //}}AFX_DATA_INIT } void CDBOperate::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CDBOperate) DDX_Control(pDX, IDC_STATICPLACE, m_StaticPlace); DDX_CBString(pDX, IDC_DB_CONN, m_csName); DDX_Text(pDX, IDC_DBCONN_COMMENT, m_csComment); DDX_CBString(pDX, IDC_PLACEVAR, m_csVariable); DDX_CBString(pDX, IDC_OPE_TYPE, m_csType); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CDBOperate, CDialog) //{{AFX_MSG_MAP(CDBOperate) ON_CBN_SELENDOK(IDC_OPE_TYPE, OnSelendokOpeType) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CDBOperate message handlers BOOL CDBOperate::OnInitDialog() { CDialog::OnInitDialog(); CComboBox *pName=(CComboBox *)GetDlgItem(IDC_DB_CONN); m_pType=(CComboBox *)GetDlgItem(IDC_OPE_TYPE); CComboBox *pVariable=(CComboBox *)GetDlgItem(IDC_PLACEVAR); CString buf1, buf2, csVarName, csDBConnName; m_pDsACD_IVRView->ReadVariable(buf1); while (!buf1.IsEmpty()) { csVarName = buf1.Left(buf1.Find(";" )); pVariable->AddString(csVarName); buf1.Delete(0, buf1.Find(";" )+1); } m_pDsACD_IVRView->ReadDBConn(buf2); while (!buf2.IsEmpty()) { csDBConnName = buf2.Left(buf2.Find(";" )); pName->AddString(csDBConnName); buf2.Delete(0, buf2.Find(";" )+1); } int nIndex; nIndex = pName->SelectString(-1, m_csName); pName->SetCurSel(nIndex); nIndex = m_pType->SelectString(-1, m_csType); m_pType->SetCurSel(nIndex); nIndex = pVariable->SelectString(-1, m_csVariable); pVariable->SetCurSel(nIndex); if (m_csType == "关闭") { m_StaticPlace.EnableWindow(FALSE); CEdit* pEditPlace=(CEdit*)GetDlgItem(IDC_PLACEVAR); pEditPlace->EnableWindow(FALSE); } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CDBOperate::DisplayDlg(dsACDObjectBase *pObj) { dsDBOpe_INFO * pInfo = (dsDBOpe_INFO*) pObj->Read(); m_csName = pInfo->Name; m_csType = pInfo->Type; m_csVariable = pInfo->Variable; m_csComment = pInfo->Comment; if(DoModal()==IDOK) { if (m_csName == "") m_csName = "无数据库"; if (m_csType == "") m_csType = "无操作"; pInfo->Name = m_csName; pInfo->Type = m_csType; pInfo->Variable = m_csVariable; pInfo->Comment = m_csComment; } else return; } void CDBOperate::OnSelendokOpeType() { if (m_pType->GetCurSel() != 2) { m_StaticPlace.EnableWindow(TRUE); CEdit* pEditPlace=(CEdit*)GetDlgItem(IDC_PLACEVAR); pEditPlace->EnableWindow(TRUE); } else { m_StaticPlace.EnableWindow(FALSE); CEdit* pEditPlace=(CEdit*)GetDlgItem(IDC_PLACEVAR); pEditPlace->EnableWindow(FALSE); } }