DataLinkDlg.cpp
资源名称:vc开发gis代码.rar [点击查看]
上传用户:jndfzt02
上传日期:2007-04-25
资源大小:391k
文件大小:3k
源码类别:
GIS编程
开发平台:
Visual C++
- // DataLinkDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "draw.h"
- #include "linkdataset.h"
- #include "drawdoc.h"
- #include "data1ret.h"
- #include "data1dlg.h"
- #include "DataLinkDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CDataLinkDlg dialog
- CDataLinkDlg::CDataLinkDlg(CDrawDoc* pDoc,CLinkDataSet* pLinkSet,CWnd* pParent /*=NULL*/)
- : CDialog(CDataLinkDlg::IDD, pParent)
- {
- m_pDoc=pDoc;
- m_pLinkSet=pLinkSet;
- //{{AFX_DATA_INIT(CDataLinkDlg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- }
- void CDataLinkDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CDataLinkDlg)
- // NOTE: the ClassWizard will add DDX and DDV calls here
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CDataLinkDlg, CDialog)
- //{{AFX_MSG_MAP(CDataLinkDlg)
- ON_BN_CLICKED(IDC_DATA_MODIFY, OnDataModify)
- ON_BN_CLICKED(IDC_LINK_DELETE, OnLinkDelete)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CDataLinkDlg message handlers
- BOOL CDataLinkDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- CString m_str;
- char p1[9];
- int nRecord;
- if(!m_pLinkSet->IsOpen())
- m_pLinkSet->Open();
- m_NumbLink=0;
- if(!m_pLinkSet->IsBOF())
- {
- m_pLinkSet->MoveFirst();
- do
- {
- database_id[m_NumbLink]=m_pLinkSet->m_database_id;
- link_mode[m_NumbLink]=m_pLinkSet->m_link_mode;
- record_id[m_NumbLink]=m_pLinkSet->m_record_id;
- m_NumbLink++;
- m_pLinkSet->MoveNext();
- }while(!m_pLinkSet->IsEOF());
- }
- CListBox *plist1=(CListBox *)GetDlgItem(IDC_LIST1);
- plist1->ResetContent();
- for(int i=0;i<m_NumbLink;i++)
- {
- nRecord=m_pDoc->GetDataIndex(database_id[i]);
- if(nRecord<0)
- {
- AfxMessageBox("不能找到数据对象");
- }
- m_str=m_pDoc->DataInfo[nRecord].Name;
- sprintf(p1,"%d",record_id[i]);
- m_str+=" ";
- m_str+=p1;
- plist1->AddString(m_str);
- }
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CDataLinkDlg::OnDataModify()
- {
- // TODO: Add your control notification handler code here
- char p1[9];
- CListBox *plist1=(CListBox *)GetDlgItem(IDC_LIST1);
- int nn=plist1->GetCurSel();
- if(link_mode[nn]==1)
- {
- if(database_id[nn]==1)
- {
- m_pSet1=&m_pDoc->m_data1;
- if(m_pSet1->IsOpen())
- m_pSet1->Close();
- m_pSet1->m_strFilter="only_id=";
- sprintf(p1,"%d",record_id[nn]);
- m_pSet1->m_strFilter+=p1;
- m_pSet1->Open();
- CData1Dlg pDg1(m_pSet1,0,0);
- pDg1.DoModal();
- }
- }
- }
- void CDataLinkDlg::OnLinkDelete()
- {
- // TODO: Add your control notification handler code here
- CListBox *plist1=(CListBox *)GetDlgItem(IDC_LIST1);
- int nn=plist1->GetCurSel();
- m_pLinkSet->MoveFirst();
- m_pLinkSet->Move(nn);
- m_pLinkSet->Delete();
- m_pLinkSet->Close();
- SendMessage(WM_INITDIALOG);
- if(nn>=m_NumbLink)
- plist1->SetCurSel(m_NumbLink-1);
- else
- plist1->SetCurSel(nn-1);
- }