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

📄 chargeitem.cpp

📁 本学期的一个小项目学校收费管理系统
💻 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;
	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 = "UPDATE ChargeItem SET Tuition = " + fTuition + ", Incidental = " + fIncidental
		+ ", MacTimeFee = " + fMacTimeFee + ", Insurance = " + fInsurance
		+ ", DormFee=" + fDormFee + ",BicycleFee = " + fBicycleFee
		+ ", BookFee=" + fBookFee + ",FileFee=" + fFileFee + ",iYear=" + cYear
		+ ",SpeId=" + strSpeId + " WHERE ItemId = " + paraId;

	//执行UPDATE语句
	m_AdoConn.ExecuteSQL(vSQL);

	//断开与数据库的连接
	m_AdoConn.ExitConnect();
}

// 删除指定收费信息
void CChargeItem::SqlDelete(CString paraId)
{
	//连接数据库
	ADOConn m_AdoConn;
	m_AdoConn.OnInitADOConn();

	//设置DELETE语句
	_bstr_t vSQL;
	vSQL = "DELETE FROM ChargeItem WHERE ItemId = " + paraId;

	//执行DELETE语句
	m_AdoConn.ExecuteSQL(vSQL);	

	//断开与数据库的连接
	m_AdoConn.ExitConnect();
}
// 返回指定编号的收费总额
float CChargeItem::GetSum(CString paraId,CString cYear)
{
	//连接数据库
	ADOConn m_AdoConn;
	m_AdoConn.OnInitADOConn();
	
	//设置SELECT语句
	_bstr_t vSQL;
	vSQL = "SELECT (Tuition+Incidental+MacTimeFee+Insurance+DormFee+"
		"BicycleFee+BookFee+FileFee) AS cSum FROM ChargeItem "
		" WHERE SpeId = " + paraId + " And iYear = " + cYear;
	
	//执行SELECT语句
	_RecordsetPtr m_pRecordset;
	m_pRecordset = m_AdoConn.GetRecordSet(vSQL);
	
	if (m_pRecordset->adoEOF)
		return 0;
	else
		return atof((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("cSum"));
	
	//断开与数据库的连接
	m_AdoConn.ExitConnect();
}
// 返回项目编号
CString CChargeItem::GetItemId(CString paraId,CString cYear)
{
	//连接数据库
	ADOConn m_AdoConn;
	m_AdoConn.OnInitADOConn();
	
	//设置SELECT语句
	_bstr_t vSQL;
	vSQL = "SELECT ItemId FROM ChargeItem "
		" WHERE SpeId = " + paraId + " And iYear = " + cYear;
	
	//执行SELECT语句
	_RecordsetPtr m_pRecordset;
	m_pRecordset = m_AdoConn.GetRecordSet(vSQL);
	
	if (m_pRecordset->adoEOF)
		return "";
	else
		return (LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("ItemId");
	
	//断开与数据库的连接
	m_AdoConn.ExitConnect();
}

⌨️ 快捷键说明

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