📄 dzctdoc.cpp
字号:
// dzctDoc.cpp : implementation of the CDzctDoc class
//
#include "stdafx.h"
#include "dzct.h"
#include "Cz_cl.h"
#include "dzctDoc.h"
#include "reateNewProject.h"
#include "Cqxx.h"
#include "xcsz.h"
#include "Zd_set.h"
#include "CeFileFind.h"
#include "dxfg.h"
#include "yqsz.h"
#include "FileOpenDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDzctDoc
//extern CDzctApp theApp;//程序变量
IMPLEMENT_DYNCREATE(CDzctDoc, CDocument)
BEGIN_MESSAGE_MAP(CDzctDoc, CDocument)
//{{AFX_MSG_MAP(CDzctDoc)
ON_COMMAND(ID_FILE_NEW, OnFileNew)
ON_COMMAND(ID_GC_KZCL, OnGcKzcl)
ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
ON_COMMAND(ID_SZ_KZCL, OnSzKzcl)
ON_COMMAND(ID_XDX_KZCL, OnXdxKzcl)
ON_COMMAND(ID_SZ_YQ, OnSzYq)
ON_COMMAND(ID_EXIT, OnExit)
ON_COMMAND(ID_APP_EXIT, OnExit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDzctDoc construction/destruction
CDzctDoc::CDzctDoc()
{
// TODO: add one-time construction code here
}
CDzctDoc::~CDzctDoc()
{
}
BOOL CDzctDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CDzctDoc serialization
void CDzctDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
}
}
/////////////////////////////////////////////////////////////////////////////
// CDzctDoc diagnostics
#ifdef _DEBUG
void CDzctDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CDzctDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CDzctDoc commands
//建立一个新工程
void CDzctDoc::OnFileNew()
{
theApp.DataBase.CloseTable();
CreateNewProject dlg;
CString struct_str,str,install;
TCHAR file[300],src_file[300];
HINSTANCE h=AfxGetInstanceHandle();
TCHAR filepath[260];
int n=GetModuleFileName(h,filepath,sizeof(filepath));
wsprintf(str.GetBuffer(260),_T("%s"),filepath);
str.ReleaseBuffer();
if(n)
{
install=str.Left(str.ReverseFind('\\'));
}
install+=_T("\\");
if(dlg.DoModal()==IDOK)
{
wsprintf(file,_T("%s%s.cdb"),install,dlg.m_Projectname);
wsprintf(src_file,_T("\\%s.cdb"),dlg.m_Projectname);
theApp.DataBase.DeleteDatabase(dlg.m_Projectname);
if(!theApp.DataBase.CreateDatabase(dlg.m_Projectname))
{
AfxMessageBox(_T("不能建立新的数据库"));
return;
}
theApp.zf=true;
struct_str.Format(_T("等级 varchar(10),2C INTEGER,归零差 INTEGER,方向较差 INTEGER,距离读数较差 INTEGER,距离测回间差 INTEGER,垂直角差 INTEGER,指标差 INTEGER,水平 INTEGER,垂直 INTEGER,测距 INTEGER"));
if(!theApp.DataBase.CreateTable(_T("SZXCB"),struct_str,dlg.m_Projectname))
{
AfxMessageBox(_T("不能建立SZXCB表"));
return;
}
//建立导线索引表 DXSYB
struct_str.Format(_T("测站名 varchar(20),标志 varchar(20),气温气压 varchar(20),仪器名 varchar(10),仪器编号 varchar(6),仪器高 FLOAT,方向数 INTEGER,导线结束 varchar(6),记录号 INTEGER,测量员 varchar(10),测量时间 varchar(10)"));
if(!theApp.DataBase.CreateTable(_T("DXSYB"),struct_str,dlg.m_Projectname))
{
AfxMessageBox(_T("不能建立DXSYB表"));
return;
}
///测量结果存储表
//jczj表
struct_str.Format(_T("测回数 INTEGER,测站名 varchar(20),觇点名 varchar(20),觇标高 FLOAT,垂直盘左 FLOAT,垂直盘右 FLOAT,记录号 INTEGER,站点记录号 INTEGER"));
if(!theApp.DataBase.CreateTable(_T("JDXCZJ"),struct_str,dlg.m_Projectname))
{
AfxMessageBox(_T("不能建立JDXCZJ表"));
return;
}
//jSPJ 表
struct_str.Format(_T("测回数 INTEGER,测站名 varchar(20),觇点名 varchar(20),觇标高 FLOAT,水平盘左 FLOAT,水平盘右 FLOAT,记录号 INTEGER,站点记录号 INTEGER"));
if(!theApp.DataBase.CreateTable(_T("JDXSPJ"),struct_str,dlg.m_Projectname))
{
AfxMessageBox(_T("不能建立JDXSPJ表"));
return;
}
//jJL
struct_str.Format(_T("测回数 INTEGER,测站名 varchar(20),觇点名 varchar(20),觇标高 FLOAT,距离1 FLOAT,距离2 FLOAT,距离3 FLOAT,距离4 FLOAT,记录号 INTEGER,站点记录号 INTEGER"));
if(!theApp.DataBase.CreateTable(_T("JDXJL"),struct_str,dlg.m_Projectname))
{
AfxMessageBox(_T("不能建立JDXJL表"));
return;
}
//临时数据存储表
//czj表
struct_str.Format(_T("测回数 INTEGER,测站名 varchar(20),觇点名 varchar(20),觇标高 FLOAT,垂直盘左 FLOAT,垂直盘右 FLOAT,垂直角 FLOAT,I指标 FLOAT,记录号 INTEGER"));
if(!theApp.DataBase.CreateTable(_T("DXCZJ"),struct_str,dlg.m_Projectname))
{
AfxMessageBox(_T("不能建立DXCZJ表"));
return;
}
//SPJ 表
struct_str.Format(_T("测回数 INTEGER,测站名 varchar(20),觇点名 varchar(20),觇标高 FLOAT,水平盘左 FLOAT,水平盘右 FLOAT,水平角 FLOAT,C2 FLOAT,记录号 INTEGER"));
if(!theApp.DataBase.CreateTable(_T("DXSPJ"),struct_str,dlg.m_Projectname))
{
AfxMessageBox(_T("不能建立DXSPJ表"));
return;
}
//JL
struct_str.Format(_T("测回数 INTEGER,测站名 varchar(20),觇点名 varchar(20),觇标高 FLOAT,距离1 FLOAT,距离2 FLOAT,距离3 FLOAT,距离4 FLOAT,距离 FLOAT,记录号 INTEGER"));
if(!theApp.DataBase.CreateTable(_T("DXJL"),struct_str,dlg.m_Projectname))
{
AfxMessageBox(_T("不能建立DXJL表"));
return;
}
OnSzKzcl();
}
}
void CDzctDoc::OnGcKzcl()
{
// TODO: Add your command handler code here
if(!theApp.DataBase.OpenTable(theApp.DataBase.szFileName,_T("SZXCB")))
{
AfxMessageBox(_T("请确定一个工程"));
return;
}
theApp.DataBase.CloseTable();
if(theApp.yq.yqmc==-1)
{
yqsz dlg;
dlg.DoModal();
}
CZd_set dlg1;
CCz_cl dg;
dlg1.ShowWindow(SW_SHOW);
if(dlg1.DoModal()==IDOK)
{
//执行觇点测量
dg.DoModal();
}
}
int CDzctDoc::wchartofloat(CString point)
{
char buf [250];
buf[0]='\0';
int i,len=wcslen(point);
for(i=0;i<len;i++)
{
switch(point.GetAt(i))
{
case '-':
buf[i]='-';
buf[i+1]='\0';
break;
case '.':
buf[i]='.';
buf[i+1]='\0';
break;
case '0':
buf[i]='0';
buf[i+1]='\0';
break;
case '1':
buf[i]='1';
buf[i+1]='\0';
break;
case '2':
buf[i]='2';
buf[i+1]='\0';
break;
case '3':
buf[i]='3';
buf[i+1]='\0';
break;
case '4':
buf[i]='4';
buf[i+1]='\0';
break;
case '5':
buf[i]='5';
buf[i+1]='\0';
break;
case '6':
buf[i]='6';
buf[i+1]='\0';
break;
case '7':
buf[i]='7';
buf[i+1]='\0';
break;
case '8':
buf[i]='8';
buf[i+1]='\0';
break;
case '9':
buf[i]='9';
buf[i+1]='\0';
break;
}
}
return atoi(buf);
}
void CDzctDoc::OnFileOpen()
{
// TODO: Add your command handler code here
theApp.DataBase.CloseTable();
CFileOpenDlg dlg;
TCHAR filename[255];
CString szFilter;
szFilter.Format(_T("*.cdb"));
dlg.SetFilter(szFilter);
if(dlg.DoModal()==IDOK)
{
theApp.zf=true;
wcscpy(filename,dlg.GetPath());
wcscat(filename,dlg.GetFileName());
szFilter=filename;
int rec;
if(theApp.DataBase.OpenTable(szFilter,_T("SZXCB")))//读限差配置
{
rec=theApp.DataBase.GetRecordNumber();
theApp.DataBase.ReadRecord(rec-1);
theApp.cldj=theApp.DataBase.m_values.GetAt(0);
theApp.p_2c=wchartofloat(theApp.DataBase.m_values.GetAt(1));
theApp.p_c=wchartofloat(theApp.DataBase.m_values.GetAt(2));
theApp.p_fc=wchartofloat(theApp.DataBase.m_values.GetAt(3));
theApp.dc=wchartofloat(theApp.DataBase.m_values.GetAt(4));
theApp.n_dc=wchartofloat(theApp.DataBase.m_values.GetAt(5));
theApp.I_c=wchartofloat(theApp.DataBase.m_values.GetAt(6));
theApp.A_c=wchartofloat(theApp.DataBase.m_values.GetAt(7));
theApp.spj_chs_kz=wchartofloat(theApp.DataBase.m_values.GetAt(8));
theApp.czj_chs_kz=wchartofloat(theApp.DataBase.m_values.GetAt(9));
theApp.dis_chs_kz=wchartofloat(theApp.DataBase.m_values.GetAt(10));
}
}
theApp.DataBase.CloseTable();
}
void CDzctDoc::OnSzKzcl() //重新设置测量参数
{
// TODO: Add your command handler code here
if(!theApp.DataBase.OpenTable(theApp.DataBase.szFileName,_T("SZXCB")))
{
AfxMessageBox(_T("请确定一个工程"));
return;
}
Cxcsz dlg;
dlg.DoModal();
theApp.DataBase.CloseTable();
}
void CDzctDoc::OnXdxKzcl()
{
// TODO: Add your command handler code here
/* if(!theApp.DataBase.OpenTable(theApp.DataBase.szFileName,_T("DXJLB")))
{
AfxMessageBox(_T("请确定一个工程"));
return;
}
dxfg dlg;
if(dlg.DoModal()==IDOK)
{
theApp.DataBase.m_values.Add(dlg.m_dxfgdm);
if(!theApp.DataBase.AddNewRecord())
AfxMessageBox(_T("can not add"));
}
*/ theApp.DataBase.CloseTable();
}
//仪器设置
void CDzctDoc::OnSzYq()
{
// TODO: Add your command handler code here
yqsz dlg;
dlg.DoModal();
}
void CDzctDoc::OnExit()
{
// TODO: Add your command handler code here
DWORD lpExitCode=STILL_ACTIVE;
ExitThread(lpExitCode);
}
void CDzctDoc::SetTitle(LPCTSTR lpszTitle)
{
// TODO: Add your specialized code here and/or call the base class
CString str;
str.Format(_T("电子记簿"));
CDocument::SetTitle(lpszTitle);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -