【VC开源代码栏目提醒】:以下是网学会员为您推荐的VC开源代码-ChargeItem.cpp,希望本篇文章对您学习有所帮助。
// ChargeItem.cpp: implementation of the CChargeItem class.
//
// 1 ItemId int identity(1,1) 项目编号
// 2 SpeId int 专业编号 Allow Null = False
// 3 iYear int 年级 Allow Null = False
// 4 Tuition float 学费 Allow Null = Yes
// 5 Incidental float 杂费 Allow Null = Yes
// 6 MacTimeFee float 机时费 Allow Null = Yes
// 7 Insurance float 保险费 Allow Null = Yes
// 8 DormFee float 住宿费 Allow Null = Yes
// 9 BicycleFee float 存车费 Allow Null = Yes
// 10 BookFee float 书费 Allow Null = Yes
// 11 FileFee float 资料费 Allow Null = Yes
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "ChargeManage.h"
#include "ChargeItem.h"
#include "ADOConn.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CChargeItem::CChargeItem()
{
ItemId = 0;
SpeId = 0;
iYear = 2006;
Tuition = 0.0;
Incidental = 0.0;
MacTimeFee = 0.0;
Insurance = 0.0;
DormFee = 0.0;
BicycleFee = 0.0;
BookFee = 0.0;
FileFee = 0.0;
}
CChargeItem::~CChargeItem()
{
}
// 判断此专业\此年度是否有收费标准
bool CChargeItem::HaveSpe(CString paraId,CString cYear)
{
//连接数据库
ADOConn m_AdoConn;
m_AdoConn.OnInitADOConn();
//设置SELECT语句
_bstr_t vSQL;
vSQL = "SELECT * FROM ChargeItem WHERE SpeId=" + paraId + " And iYear=" + cYear;
//执行SELETE语句
_RecordsetPtr m_pRecordset;
m_pRecordset = m_AdoConn.GetRecordSet(vSQL);
//返回值
if (m_pRecordset->adoEOF)
return false;
else
return true;
//断开与数据库的连接
m_AdoConn.ExitConnect();
}
// 根据收费项目编号得到其他信息
void CChargeItem::GetInfo(CString paraId)
{
//连接数据库
ADOConn m_AdoConn;
m_AdoConn.OnInitADOConn();
//设置SELECT语句
_bstr_t vSQL;
vSQL = "SELECT * FROM ChargeItem WHERE ItemId = " + paraId;
//执行SELETE语句
_RecordsetPtr m_pRecordset;
m_pRecordset = m_AdoConn.GetRecordSet(vSQL);
//返回各列的值
if (m_pRecordset->adoEOF)
CChargeItem();
else
{
ItemId = atol(paraId);
SpeId = atol((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("ItemId"));
iYear = atoi((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("iYear"));
Tuition = atof((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Tuition"));
Incidental = atof((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Incidental"));
MacTimeFee = atof((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("MacTimeFee"));
Insurance = atof((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Insurance"));
DormFee = atof((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("DormFee"));
BicycleFee = atof((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("BicycleFee"));
BookFee = atof((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("BookFee"));
FileFee = atof((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("FileFee"));
}
//断开与数据库的连接
m_AdoConn.ExitConnect();
}
// 插入操作
void CChargeItem::SqlInsert()
{
//连接数据库
ADOConn m_AdoConn;
m_AdoConn.OnInitADOConn();
//设置INSERT语句
CString strSpeId;
strSpeId.Format("%ld", SpeId);
CString cYear;
cYear.Format("%d", iYear);
CString fTuition;
fTuition.Format("%lf", Tuition);
CString fIncidental;
fIncidental.Format("%lf", Incidental);
CString fMacTimeFee;
fMacTimeFee.Format("%lf", MacTimeFee);
CString fInsurance;
fInsurance.Format("%lf", Insurance);
CString fDormFee;
fDormFee.Format("%lf", DormFee);
CString fBicycleFee;
fBicycleFee.Format("%lf", BicycleFee);
CString fBookFee;
fBookFee.Format("%lf", BookFee);
CString fFileFee;
fFileFee.Format("%lf", FileFee);
_bstr_t vSQL;
vSQL = "INSERT INTO ChargeItem (SpeId,iYear,Tuition, Incidental,"
" MacTimeFee,Insurance, DormFee, BicycleFee, BookFee, FileFee) VALUES ("
+ strSpeId + ", " + cYear + "," + fTuition + ", "
+ fIncidental + ", " + fMacTimeFee + ", " + fInsurance + ", " + fDormFee + ", "
+ fBicycleFee + ", " + fBookFee + ", " + fFileFee + ")";
//执行INSERT语句
m_AdoConn.ExecuteSQL(vSQL);
//断开与数据库的连接
m_AdoConn.ExitConnect();
}
// 修改操作
void CChargeItem::SqlUpdate(CString paraId)
{
//连接数据库
ADOConn m_AdoConn;
m_AdoConn.OnInitADOConn();
//设置UPDATE语句
CString strSpeId;
strSpeId.Format("%ld", SpeId);
CString cYear;
c