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

📄 datadlg.cpp

📁 医院管理系统 医院管理系统
💻 CPP
字号:
// datadlg.cpp : implementation file
//

#include "stdafx.h"
#include "数据库.h"
#include "datadlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// Cdatadlg dialog


Cdatadlg::Cdatadlg(CWnd* pParent /*=NULL*/)
	: CDialog(Cdatadlg::IDD, pParent)
{
first=true;
	//{{AFX_DATA_INIT(Cdatadlg)
	m_xinixdata = _T("");
	m_xinxitable = _T("");
	m_xinxiword = _T("");
	//}}AFX_DATA_INIT
}


void Cdatadlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(Cdatadlg)
	DDX_Control(pDX, IDC_word, m_word);
	DDX_Control(pDX, IDC_table, m_table);
	DDX_Control(pDX, IDC_database, m_data);
	DDX_Text(pDX, IDC_xinxidata, m_xinixdata);
	DDX_Text(pDX, IDC_xinxitable, m_xinxitable);
	DDX_Text(pDX, IDC_xinxiword, m_xinxiword);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(Cdatadlg, CDialog)
	//{{AFX_MSG_MAP(Cdatadlg)
	ON_BN_CLICKED(IDC_finish, Onfinish)
	ON_BN_CLICKED(IDC_finishdata, Onfinishdata)
	ON_BN_CLICKED(IDC_nextword, Onnextword)
	ON_BN_CLICKED(IDC_newword, Onnewword)
	ON_BN_CLICKED(IDC_newtable, Onnewtable)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Cdatadlg message handlers

void Cdatadlg::Onfinish() 
{
	UpdateData();
CDaoDatabase m_db;
//CString str;
m_data.GetWindowText(base);
	// TODO: Add your control notification handler code here
	try{
		m_db.Create(base);
		MessageBox("创建成功");
		m_data.SetReadOnly();
		m_table.SetReadOnly(false);
		m_xinixdata=base;
		UpdateData(false);
	}
	catch(CDaoException *e)
	{
		MessageBox("创建不成功");

		//DisplayDaoException(e);
		//MessageBox(e);
		e->Delete();
		return;
}
m_db.Close();
	
}

void Cdatadlg::Onnewtable() 
{
UpdateData();
first=true;
m_table.GetWindowText(table);
	// TODO: Add your control notification handler code here
m_word.SetReadOnly(false);
m_xinxitable=m_xinxitable+table+"-";
UpdateData(false);

}

void Cdatadlg::Onnewword() 
{

CDaoDatabase m_db;
try{
		m_db.Open(base);
	}
	catch(CDaoException *e)
	{
		MessageBox("创建不成功");
		e->Delete();
		return;
}
CDaoTableDef mtable(&m_db);
if(first==true)
{
try
	{
	mtable.Create(table);
	}
		catch(CDaoException *e)
	{
		e->Delete();
		return;
		}

}
else
{
	mtable.Open(table);
}
UpdateData();

CString str;
m_word.GetWindowText(str);
try
{
	mtable.CreateField(str,dbText,255,dbVariableField);
		MessageBox("创建成功");
	m_word.SetReadOnly();
	m_xinxiword=m_xinxiword+str+"-";
	UpdateData(false);
}
	catch(CDaoException *e)
	{

		e->Delete();
		return;
	}
	if(first==true)
	{
try
{
	mtable.Append();
}
	catch(CDaoException *e)
	{
		e->Delete();
		return;
}
	first=false;
	}
	m_table.SetReadOnly(false);
	m_table.SetFocus();
mtable.Close();
m_db.Close();	
}


void Cdatadlg::Onfinishdata() 
{
	// TODO: Add your control notification handler code here
m_table.SetReadOnly();
	m_data.SetFocus();
	m_data.SetReadOnly(false);
	CString str;
	str="你创建的数据库为:  "+base+"\n\n"+"请继续或者按“退出键”退出\n";
	MessageBox(str,"恭喜");
}

void Cdatadlg::Onnextword() 
{
	m_table.SetReadOnly();
m_word.GetFocus();
m_word.SetReadOnly(false);
//Cdatadlg::Onnewword();

	// TODO: Add your control notification handler code here
	
}

⌨️ 快捷键说明

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