【VC开源代码栏目提醒】:以下是网学会员为您推荐的VC开源代码-Doctor.cpp,希望本篇文章对您学习有所帮助。
// Doctor.cpp: implementation of the CDoctor class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "HosptialMan.h"
#include "Doctor.h"
#include "ADOConn.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CDoctor::CDoctor()
{
Name = "";
Sex = "男";
DeptId = 2;
Title = "";
}
CDoctor::~CDoctor()
{
}
// 插入新的医生信息
void CDoctor::sql_Insert()
{
try
{
//连接数据库
ADOConn m_AdoConn;
//设置INSERT语句, 将数值转换为字符串
CString cSql,cAge,cDId;
_bstr_t bSql;
cDId.Format("%ld",DeptId);
// 插入语句
cSql = "Insert Into Doctor(Name,Sex,DeptId,Title) "
" Values('"+Name+"','"+Sex+"',"+cDId+",'"+Title+"')";
bSql = (LPCTSTR)(_bstr_t)cSql;
m_AdoConn.ExecuteSQL(bSql);
//断开与数据库的连接
m_AdoConn.ExitConnect();
}
// 捕捉异常
catch(_com_error e)
{
// 显示错误信息
AfxMessageBox(e.Description());
}
}
// 更改医生信息
void CDoctor::sql_Update(CString cDocId)
{
try
{
//连接数据库
ADOConn m_AdoConn;
//设置INSERT语句, 将数值转换为字符串
CString cSql,cAge,cDId;
_bstr_t bSql;
cDId.Format("%ld",DeptId);
// 插入语句
cSql = "Update Doctor Set Name='"+Name+"',Sex='"+Sex+"',"
"DeptId="+cDId+",Title='"+Title+"' Where DocId="+cDocId;
bSql = (LPCTSTR)(_bstr_t)cSql;
m_AdoConn.ExecuteSQL(bSql);
//断开与数据库的连接
m_AdoConn.ExitConnect();
}
// 捕捉异常
catch(_com_error e)
{
// 显示错误信息
AfxMessageBox(e.Description());
}
}
// 删除医生信息
void CDoctor::sql_Delete(CString cDocId)
{
try
{
//连接数据库
ADOConn m_AdoConn;
//设置INSERT语句, 将数值转换为字符串
_bstr_t bSql;
bSql = "Delete From Doctor Where DocId="+cDocId;
m_AdoConn.ExecuteSQL(bSql);
//断开与数据库的连接
m_AdoConn.ExitConnect();
}
// 捕捉异常
catch(_com_error e)
{
// 显示错误信息
AfxMessageBox(e.Description());
}
}
上一篇:
ColorQuantizationLibrary.pas
下一篇:
本科生毕业论文参考文献