⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 daoxianview.cpp

📁 这是一个能简单处理测量里面导线网平差的程序
💻 CPP
字号:
// DaoxianView.cpp : implementation file
//

#include "stdafx.h"
#include "demo_devstudio.h"
#include "DaoxianView.h"
#include "Afxdao.h"
#include "Demo_devStudioDoc.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDaoxianView

IMPLEMENT_DYNCREATE(CDaoxianView, CFormView)

CDaoxianView::CDaoxianView()
	: CFormView(CDaoxianView::IDD)
{
	//{{AFX_DATA_INIT(CDaoxianView)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}

CDaoxianView::~CDaoxianView()
{
}

void CDaoxianView::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDaoxianView)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDaoxianView, CFormView)
	//{{AFX_MSG_MAP(CDaoxianView)
	ON_BN_CLICKED(IDC_BAOCHUN, OnBaochun)
	ON_BN_CLICKED(IDC_INCREASEROW, OnIncreaserow)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDaoxianView diagnostics

#ifdef _DEBUG
void CDaoxianView::AssertValid() const
{
	CFormView::AssertValid();
}

void CDaoxianView::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CDaoxianView message handlers

void CDaoxianView::OnBaochun() 
{
	
	// TODO: Add your control notification handler code here
	
 CDemo_DevStudioDoc *mypdoc;
 mypdoc=( CDemo_DevStudioDoc*)GetDocument();
 CString zuoyestr=mypdoc->m_workname;
 CString dataname,csname;
 if(zuoyestr.IsEmpty())
	 return;
 int viewname=mypdoc->m_viewname;
 if(viewname<=0)
	 	 return;
 if(viewname==1)
 {dataname=_T("水平观测角");
    csname=_T("(测站点,照准点,角度)");
 }
 if(viewname==2)
 { 
     dataname=_T("距离");
	 csname=_T("(首点,末点,距离)");
 }
 if(viewname==3)
 {
	 dataname=_T("高差");
	 csname=_T("(起点,末点,高差)");
 }
 if(viewname==5)
 {	 dataname=_T("起始方位角");
     csname=_T("(首点,末点,方位角)");
 }
	CDaoDatabase *m_database;
	CDaoRecordset *m_recordset;
	
	m_database=new CDaoDatabase;
  
	try
	{ 
		m_database->Open(zuoyestr);
		m_recordset=new CDaoRecordset(m_database);


	}
	 catch(CDaoException* e)
	 {
        e->ReportError();
		delete m_database;
		m_database=NULL;
		e->Delete();
		return;
	 
	 }
	 if(m_recordset->IsOpen())
		 m_recordset->Close();
     
	 if(viewname!=4)
	 {
		 try
		 {CString strselect(_T("Select * From["));
		 strselect+=dataname;
		 strselect+=_T("]");
		 m_recordset->Open(dbOpenDynaset,strselect);
         if(!m_recordset->CanUpdate())
			 return;
		 while(!m_recordset->IsEOF())
		 {   
			 m_recordset->Delete();
			 m_recordset->MoveNext();
		 }
		 }
		 catch(CDaoException* e)
		 {
			 e->ReportError();
			 e->Delete();
			 return;
		 }
		 CString str1,str2,str3;
         
		 for(int row=1;;row++)
		 { 
		  str1=m_pbianjiview->m_pGridCtrl->GetItemText(row,0);
		  str2=m_pbianjiview->m_pGridCtrl->GetItemText(row,1);
          str3=m_pbianjiview->m_pGridCtrl->GetItemText(row,2);
	      CString strsql;
		  strsql.Format("values('%s','%s','%s')",str1,str2,str3);
          strsql=_T("insert into ")+dataname+csname+strsql;

		  if(str1.IsEmpty()&&str2.IsEmpty()&&str3.IsEmpty())
			  break;

		  try
		  {if(m_database->CanUpdate())
		     m_database->Execute(strsql,dbDenyWrite|dbConsistent);

		      
		  }
		  catch(CDaoException* e)
   
		  {e->ReportError();
		  e->Delete();
		  return;

		  }
		 
		 }
	 }
	 if(viewname==4)
	 {  
		 if(m_recordset->IsOpen())
		    m_recordset->Close();
	    	 try
		 {
		 CString strselect(_T("Select * From["));
		 strselect+=_T("已知点坐标高程");
		 strselect+=_T("]");
		 m_recordset->Open(dbOpenDynaset,strselect);
         if(!m_recordset->CanUpdate())
			 return;
		 while(!m_recordset->IsEOF())
		 {   
			 m_recordset->Delete();
			 m_recordset->MoveNext();
		 }
		 }
		 catch(CDaoException* e)
		 {   
			 e->ReportError();
			 e->Delete();
			 return;
		 }
		 CString str1,str2,str3,str4;
         
		 for(int row=1;;row++)
		 {
		  str1=m_pbianjiview->m_pGridCtrl->GetItemText(row,0);
		  str2=m_pbianjiview->m_pGridCtrl->GetItemText(row,1);
          str3=m_pbianjiview->m_pGridCtrl->GetItemText(row,2);
	      str4=m_pbianjiview->m_pGridCtrl->GetItemText(row,3);
		  CString strsql;
		  strsql.Format("insert into 已知点坐标高程(点号,x,y,高程)values('%s','%s','%s','%s')",str1,str2,str3,str4);

		  if(str1.IsEmpty()&&str2.IsEmpty()&&str3.IsEmpty()&&str4.IsEmpty())
			  break;

		  try
		  {if(m_database->CanUpdate())
		     m_database->Execute(strsql,dbDenyWrite|dbConsistent);

		      
		  }
		  catch(CDaoException* e)
   
		  {e->ReportError();
		  e->Delete();
		  return;

		  }
		 
		 }
	 
	 }
     m_recordset->Close();
	 delete m_recordset;
     m_database->Close();
	 delete m_database;
     MessageBox("保存成功");
}

void CDaoxianView::OnIncreaserow() 
{
	// TODO: Add your control notification handler code here
	if(m_pbianjiview)
	{   int rows=m_pbianjiview->m_pGridCtrl->GetRowCount();
        m_pbianjiview->m_pGridCtrl->InsertRow("ok");
		m_pbianjiview->m_pGridCtrl->SetItemText(rows,0,"");
		m_pbianjiview->m_pGridCtrl->Invalidate();
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -