DataLinkDlg.cpp
上传用户:jndfzt02
上传日期:2007-04-25
资源大小:391k
文件大小:3k
源码类别:

GIS编程

开发平台:

Visual C++

  1. // DataLinkDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "draw.h"
  5. #include "linkdataset.h"
  6. #include "drawdoc.h"
  7. #include "data1ret.h"
  8. #include "data1dlg.h"
  9. #include "DataLinkDlg.h"
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CDataLinkDlg dialog
  17. CDataLinkDlg::CDataLinkDlg(CDrawDoc* pDoc,CLinkDataSet* pLinkSet,CWnd* pParent /*=NULL*/)
  18. : CDialog(CDataLinkDlg::IDD, pParent)
  19. {
  20. m_pDoc=pDoc;
  21. m_pLinkSet=pLinkSet;
  22. //{{AFX_DATA_INIT(CDataLinkDlg)
  23. // NOTE: the ClassWizard will add member initialization here
  24. //}}AFX_DATA_INIT
  25. }
  26. void CDataLinkDlg::DoDataExchange(CDataExchange* pDX)
  27. {
  28. CDialog::DoDataExchange(pDX);
  29. //{{AFX_DATA_MAP(CDataLinkDlg)
  30. // NOTE: the ClassWizard will add DDX and DDV calls here
  31. //}}AFX_DATA_MAP
  32. }
  33. BEGIN_MESSAGE_MAP(CDataLinkDlg, CDialog)
  34. //{{AFX_MSG_MAP(CDataLinkDlg)
  35. ON_BN_CLICKED(IDC_DATA_MODIFY, OnDataModify)
  36. ON_BN_CLICKED(IDC_LINK_DELETE, OnLinkDelete)
  37. //}}AFX_MSG_MAP
  38. END_MESSAGE_MAP()
  39. /////////////////////////////////////////////////////////////////////////////
  40. // CDataLinkDlg message handlers
  41. BOOL CDataLinkDlg::OnInitDialog() 
  42. {
  43. CDialog::OnInitDialog();
  44. CString m_str;
  45. char p1[9];
  46. int nRecord;
  47. if(!m_pLinkSet->IsOpen())
  48. m_pLinkSet->Open();
  49. m_NumbLink=0;
  50. if(!m_pLinkSet->IsBOF())
  51. {
  52. m_pLinkSet->MoveFirst();
  53. do
  54. {
  55. database_id[m_NumbLink]=m_pLinkSet->m_database_id;
  56. link_mode[m_NumbLink]=m_pLinkSet->m_link_mode;
  57. record_id[m_NumbLink]=m_pLinkSet->m_record_id;
  58. m_NumbLink++;
  59. m_pLinkSet->MoveNext();
  60. }while(!m_pLinkSet->IsEOF());
  61. }
  62. CListBox *plist1=(CListBox *)GetDlgItem(IDC_LIST1);
  63. plist1->ResetContent();
  64. for(int i=0;i<m_NumbLink;i++)
  65. {
  66. nRecord=m_pDoc->GetDataIndex(database_id[i]);
  67. if(nRecord<0)
  68. {
  69. AfxMessageBox("不能找到数据对象");
  70. }
  71. m_str=m_pDoc->DataInfo[nRecord].Name;
  72. sprintf(p1,"%d",record_id[i]);
  73. m_str+="   ";
  74. m_str+=p1;
  75. plist1->AddString(m_str);
  76. }
  77. return TRUE;  // return TRUE unless you set the focus to a control
  78.               // EXCEPTION: OCX Property Pages should return FALSE
  79. }
  80. void CDataLinkDlg::OnDataModify() 
  81. {
  82. // TODO: Add your control notification handler code here
  83. char p1[9];
  84. CListBox *plist1=(CListBox *)GetDlgItem(IDC_LIST1);
  85. int nn=plist1->GetCurSel();
  86. if(link_mode[nn]==1)
  87. {
  88. if(database_id[nn]==1)
  89. {
  90. m_pSet1=&m_pDoc->m_data1;
  91. if(m_pSet1->IsOpen())
  92. m_pSet1->Close();
  93. m_pSet1->m_strFilter="only_id=";
  94. sprintf(p1,"%d",record_id[nn]);
  95. m_pSet1->m_strFilter+=p1;
  96. m_pSet1->Open();
  97. CData1Dlg pDg1(m_pSet1,0,0);
  98. pDg1.DoModal();
  99. }
  100. }
  101. }
  102. void CDataLinkDlg::OnLinkDelete() 
  103. {
  104. // TODO: Add your control notification handler code here
  105. CListBox *plist1=(CListBox *)GetDlgItem(IDC_LIST1);
  106. int nn=plist1->GetCurSel();
  107. m_pLinkSet->MoveFirst();
  108. m_pLinkSet->Move(nn);
  109. m_pLinkSet->Delete();
  110. m_pLinkSet->Close();
  111. SendMessage(WM_INITDIALOG);
  112. if(nn>=m_NumbLink)
  113. plist1->SetCurSel(m_NumbLink-1);
  114. else
  115. plist1->SetCurSel(nn-1);
  116. }