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

📄 stucharge.cpp

📁 VC++做的学校收费管理系统,很有参考价值,附上源码与说明文档.
💻 CPP
字号:
// StuCharge.cpp: implementation of the CStuCharge class.
//
// 1 CheId int 编号 Identity = Yes Allow Null = False 主键
// 2 StuId int 学生编号 
// 3 iYear int 缴费年度 
// 4 ChargeDate datetime 交费日期 

// 5 Should_Tuition float 应交学费 Allow Null = Yes
// 6 Fact_Tuition float 实交学费 Allow Null = Yes
// 7 Should_Incidental float 应交杂费 Allow Null = Yes
// 8 Fact_Incidental float 实交杂费 Allow Null = Yes

// 9 Should_MacTimeFee float 应交机时费 Allow Null = Yes 
// 10 Fact_MacTimeFee float 实交机时费 Allow Null = Yes
// 11 Should_Insurance float 应交保险费 Allow Null = Yes
// 12 Fact_Insurance float 实交保险费 Allow Null = Yes 

// 13 Should_DormFee float 应交住宿费 Allow Null = Yes
// 14 Fact_DormFee float 实交住宿费 Allow Null = Yes 
// 15 Should_BicycleFee float 应交存车费 Allow Null = Yes
// 16 Fact_BicycleFee float 实交存车费 Allow Null = Yes 

// 17 Should_BookFee float 应交书费 Allow Null = Yes
// 18 Fact_BookFee float 实交书费 Allow Null = Yes 
// 19 Should_FileFee float 应交资料费 Allow Null = Yes
// 20 Fact_FileFee float 实交资料费 Allow Null = Yes 

// 21 Should_Total float 应交总计 Allow Null = Yes
// 22 Fact_Total float 实交总计 Allow Null = Yes 
// 23 Memo varchar(200) 备注 Allow Null = True
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "ChargeManage.h"
#include "StuCharge.h"
#include "ADOConn.h"

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

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CStuCharge::CStuCharge()
{
	StuId = 0;
	iYear = 0;
	CTime CurrentTime;
	CurrentTime = CTime::GetCurrentTime();
	ChargeDate = CurrentTime.Format("%Y-%m-%d");

	Should_Tuition = 0.0;
	Fact_Tuition = 0.0;
	Should_Incidental = 0.0;
	Fact_Incidental = 0.0;

	Should_MacTimeFee = 0.0;
	Fact_MacTimeFee = 0.0;
	Should_Insurance = 0.0;
	Fact_Insurance = 0.0;

	Should_DormFee = 0.0;
	Fact_DormFee = 0.0;
	Should_BicycleFee = 0.0;
	Fact_BicycleFee = 0.0;

	Should_BookFee = 0.0;
	Fact_BookFee = 0.0;
	Should_FileFee = 0.0;
	Fact_FileFee = 0.0;

	Should_Total = 0.0;
	Fact_Total = 0.0;
	Memo = "";
}

CStuCharge::~CStuCharge()
{

}

// 判断是否存在相同的学生交费信息
int CStuCharge::HaveChargeInfo(CString paraId,CString cYear)
{
	//连接数据库
	ADOConn m_AdoConn;
	m_AdoConn.OnInitADOConn();

	//设置SELECT语句
	_bstr_t vSQL;
	vSQL = "SELECT * FROM StuCharge WHERE StuId = " + paraId + " And iYear=" + cYear;

	//执行SELECT语句
	_RecordsetPtr m_pRecordset;
	m_pRecordset = m_AdoConn.GetRecordSet(vSQL);

	if (m_pRecordset->adoEOF)
		return -1;
	else
		return 1;

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


// 根据学生编号得到其他信息
void CStuCharge::GetInfo(CString paraId)
{
	//连接数据库
	ADOConn m_AdoConn;
	m_AdoConn.OnInitADOConn();

	//设置SELECT语句
	_bstr_t vSQL;
	vSQL = "SELECT * FROM StuCharge WHERE StuId = " + paraId;

	//执行SELETE语句
	_RecordsetPtr m_pRecordset;
	m_pRecordset = m_AdoConn.GetRecordSet(vSQL);

	//返回各列的值
	if (m_pRecordset->adoEOF)
		CStuCharge();
	else
	{
		ChgId = atol(paraId);
		StuId = atol((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("StuId"));
		iYear = atoi((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("iYear"));
		ChargeDate = (LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("ChargeDate");

		Should_Tuition = atof((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Should_Tuition"));
		Fact_Tuition = atof((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Fact_Tuition"));
		Should_Incidental = atof((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Should_Incidental"));
		Fact_Incidental = atof((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Fact_Incidental"));

		Should_MacTimeFee = atof((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Should_MacTimeFee"));
		Fact_MacTimeFee = atof((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Fact_MacTimeFee"));
		Should_Insurance = atof((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Should_Insurance"));
		Fact_Insurance = atof((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Fact_Insurance"));

		Should_DormFee = atof((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Should_DormFee"));
		Fact_DormFee = atof((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Fact_DormFee"));
		Should_BicycleFee = atof((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Should_BicycleFee"));
		Fact_BicycleFee = atof((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Fact_BicycleFee"));

		Should_BookFee = atof((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Should_BookFee"));
		Fact_BookFee = atof((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Fact_BookFee"));
		Should_FileFee = atof((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Should_FileFee"));
		Fact_FileFee = atof((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Fact_FileFee"));

		Should_Total = atof((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Should_Total"));
		Fact_Total = atof((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Fact_Total"));
		Memo = (LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Memo");
	}

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

// 插入操作
void CStuCharge::SqlInsert()
{
	//连接数据库
	ADOConn m_AdoConn;
	m_AdoConn.OnInitADOConn();

	//设置INSERT语句
	CString strStuId;
	strStuId.Format("%ld", StuId);
	CString strYear;
	strYear.Format("%d", iYear);

	CString fShould_Tuition;
	fShould_Tuition.Format("%lf", Should_Tuition);
	CString fFact_Tuition;
	fFact_Tuition.Format("%lf", Fact_Tuition);

	CString fShould_Incidental;
	fShould_Incidental.Format("%lf", Should_Incidental);
	CString fFact_Incidental;
	fFact_Incidental.Format("%lf", Fact_Incidental);

	CString fShould_MacTimeFee;
	fShould_MacTimeFee.Format("%lf", Should_MacTimeFee);
	CString fFact_MacTimeFee;
	fFact_MacTimeFee.Format("%lf", Fact_MacTimeFee);

	CString fShould_Insurance;
	fShould_Insurance.Format("%lf", Should_Insurance);
	CString fFact_Insurance;
	fFact_Insurance.Format("%lf", Fact_Insurance);

	CString fShould_DormFee;
	fShould_DormFee.Format("%lf", Should_DormFee);
	CString fFact_DormFee;
	fFact_DormFee.Format("%lf", Fact_DormFee);

	CString fShould_BicycleFee;
	fShould_BicycleFee.Format("%lf", Should_BicycleFee);
	CString fFact_BicycleFee;
	fFact_BicycleFee.Format("%lf", Fact_BicycleFee);

	CString fShould_BookFee;
	fShould_BookFee.Format("%lf", Should_BookFee);
	CString fFact_BookFee;
	fFact_BookFee.Format("%lf", Fact_BookFee);

	CString fShould_FileFee;
	fShould_FileFee.Format("%lf", Should_FileFee);
	CString fFact_FileFee;
	fFact_FileFee.Format("%lf", Fact_FileFee);

	CString fShould_Total;
	fShould_Total.Format("%lf", Should_Total);
	CString fFact_Total;
	fFact_Total.Format("%lf", Fact_Total);

	_bstr_t vSQL;
	vSQL = "INSERT INTO StuCharge (StuId, iYear, ChargeDate, Should_Tuition, Fact_Tuition,"
		" Should_Incidental, Fact_Incidental, Should_MacTimeFee, Fact_MacTimeFee, "
		" Should_Insurance, Fact_Insurance, Should_DormFee, Fact_DormFee, "
		" Should_BicycleFee, Fact_BicycleFee, Should_BookFee,Fact_BookFee, "
		" Should_FileFee, Fact_FileFee, Should_Total,Fact_Total, Memo) "
		" VALUES (" + strStuId + ", " + strYear + ", '" + ChargeDate + "', "
		+ fShould_Tuition + ", " + fFact_Tuition + ", "  
		+ fShould_Incidental + ", " + fFact_Incidental + ", "
		+ fShould_MacTimeFee + ", " + fFact_MacTimeFee + ", " 
		+ fShould_Insurance + ", " + fFact_Insurance + ", "
		+ fShould_DormFee + ", " + fFact_DormFee + ", " 
		+ fShould_BicycleFee + ", " + fFact_BicycleFee + ", " 
		+ fShould_BookFee + ", " + fFact_BookFee + ", "
		+ fShould_FileFee + ", " + fFact_FileFee + ", " 
		+ fShould_Total + ", " + fFact_Total + ", '" + Memo + "')";

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

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

// 修改操作
void CStuCharge::SqlUpdate(CString paraId)
{
	//连接数据库
	ADOConn m_AdoConn;
	m_AdoConn.OnInitADOConn();

	//设置UPDATE语句
	CString fShould_Tuition;
	fShould_Tuition.Format("%lf", Should_Tuition);
	CString fFact_Tuition;
	fFact_Tuition.Format("%lf", Fact_Tuition);

	CString fShould_Incidental;
	fShould_Incidental.Format("%lf", Should_Incidental);
	CString fFact_Incidental;
	fFact_Incidental.Format("%lf", Fact_Incidental);

	CString fShould_MacTimeFee;
	fShould_MacTimeFee.Format("%lf", Should_MacTimeFee);
	CString fFact_MacTimeFee;
	fFact_MacTimeFee.Format("%lf", Fact_MacTimeFee);

	CString fShould_Insurance;
	fShould_Insurance.Format("%lf", Should_Insurance);
	CString fFact_Insurance;
	fFact_Insurance.Format("%lf", Fact_Insurance);

	CString fShould_DormFee;
	fShould_DormFee.Format("%lf", Should_DormFee);
	CString fFact_DormFee;
	fFact_DormFee.Format("%lf", Fact_DormFee);

	CString fShould_BicycleFee;
	fShould_BicycleFee.Format("%lf", Should_BicycleFee);
	CString fFact_BicycleFee;
	fFact_BicycleFee.Format("%lf", Fact_BicycleFee);

	CString fShould_BookFee;
	fShould_BookFee.Format("%lf", Should_BookFee);
	CString fFact_BookFee;
	fFact_BookFee.Format("%lf", Fact_BookFee);

	CString fShould_FileFee;
	fShould_FileFee.Format("%lf", Should_FileFee);
	CString fFact_FileFee;
	fFact_FileFee.Format("%lf", Fact_FileFee);

	CString fShould_Total;
	fShould_Total.Format("%lf", Should_Total);
	CString fFact_Total;
	fFact_Total.Format("%lf", Fact_Total);

	_bstr_t vSQL;
	vSQL = "UPDATE StuCharge SET Should_Tuition = " + fShould_Tuition + ", Fact_Tuition = " 
		+ fFact_Tuition + ", Should_Incidental = " + fShould_Incidental 
		+ ", Fact_Incidental = " + fFact_Incidental + ", Should_MacTimeFee = " 
		+ fShould_MacTimeFee + ", Fact_MacTimeFee = " + fFact_MacTimeFee 
		+ ", Should_Insurance = " + fShould_Insurance + ", Fact_Insurance = " + fFact_Insurance 
		+ ", Should_DormFee = " + fShould_DormFee + ", Fact_DormFee = " + fFact_DormFee 
		+ ", Should_BicycleFee = " + fShould_BicycleFee + ", Fact_BicycleFee = " + fFact_BicycleFee 
		+ ", Should_BookFee = " + fShould_BookFee + ", Fact_BookFee = " + fFact_BookFee 
		+ ", Should_FileFee = " + fShould_FileFee + ", Fact_FileFee = " + fFact_FileFee 
		+ ", Should_Total = " + fShould_Total + ", Fact_Total = " + fFact_Total
		+ ", Memo = '" + Memo + "' WHERE ChgId = " + paraId;
//	AfxMessageBox(vSQL);
	//执行UPDATE语句
	m_AdoConn.ExecuteSQL(vSQL);

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

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

	//设置DELETE语句
	_bstr_t vSQL;
	vSQL = "DELETE FROM StuCharge WHERE ChgId = " + paraId;

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

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

⌨️ 快捷键说明

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