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

📄 registration.cpp

📁 VC++做的汽车维修管理系统,很有参考价值的,附上源码与说明文档.
💻 CPP
字号:
// Registration.cpp: implementation of the CRegistration class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "CarService.h"
#include "Registration.h"
#include "ADOConn.h"

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

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

CRegistration::CRegistration()
{
	RegId = 0;
	CreateDate = "";
	CustName = "";
	Tel = "";
	CarNo = "";
	CarType = "";
	CarColor = "";
	EngineNo = "";
	DriveMiles = 0;
	RepairMan = "";
	Registor = "";
	FinishDate = "";
	ICost = 0.0;
	MCost = 0.0;
	OCost = 0.0;
	Memo = "";
}

CRegistration::~CRegistration()
{

}

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

	//设置INSERT语句
	CString fiCost,fmCost,foCost,iMile;
	fiCost.Format("%lf", ICost);
	fmCost.Format("%lf", MCost);
	foCost.Format("%lf", OCost);
	iMile.Format("%d", DriveMiles);
	_bstr_t vSQL;
	vSQL = "INSERT INTO Registration VALUES('" + CreateDate + "','" + CustName + "','" 
		+ Tel + "','" + CarNo + "','" + CarType + "','" + CarColor + "','"
		+ EngineNo + "'," + iMile + ",'" + RepairMan + "','" + Registor + "','"
		+ FinishDate + "'," + fiCost + "," + fmCost + "," + foCost + ",'" + Memo + "')";

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

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

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

	//设置UPDATE语句
	CString fiCost,fmCost,foCost,iMile;
	fiCost.Format("%lf", ICost);
	fmCost.Format("%lf", MCost);
	foCost.Format("%lf", OCost);
	iMile.Format("%d", DriveMiles);
	
	_bstr_t vSQL;
	vSQL = "UPDATE Registration SET CreateDate='" + CreateDate + "', CustName='" + CustName
		+ "', Tel='" + Tel + "', CarType='" + CarType + "', CarNo='" + CarNo
		+ "', CarColor='" + CarColor + "',EngineNo='" + EngineNo + "', DriveMiles=" 
		+ iMile + ",RepairMan='" + RepairMan + "',Registor='" + Registor
		+ "',FinishDate='" + FinishDate + "',ICost=" + fiCost
		+ ",MCost=" + fmCost + ",OCost=" + foCost + ",Memo='" + Memo
		+ "' WHERE RegId = " + paraId;

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

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

// 删除操作
void CRegistration::SqlDelete(CString paraId)
{
	//连接数据库
	ADOConn m_AdoConn;
	m_AdoConn.OnInitADOConn();

	//设置DELETE语句
	_bstr_t vSQL;
	vSQL = "DELETE FROM Registration WHERE RegId = " + paraId;

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

	//断开与数据库的连接
	m_AdoConn.ExitConnect();
}
//更新费用,iFlag=0表示更新iCost;iFlag=1表示更新mCost; 
void CRegistration::UpdateCost(CString paraId,CString paraCost,int iFlag,int ibit)
{
	//连接数据库
	ADOConn m_AdoConn;
	m_AdoConn.OnInitADOConn();

	//设置DELETE语句
	_bstr_t vSQL;
	if(iFlag == 0)
	{
		if(ibit == 0)  //增加
			vSQL = "Update Registration Set iCost=iCost+" + paraCost + " WHERE RegId = " + paraId;
		else
			vSQL = "Update Registration Set iCost=iCost-" + paraCost + " WHERE RegId = " + paraId;

	}
	else 
	{
		if(ibit == 0)  //增加
			vSQL = "Update Registration Set mCost=mCost+" + paraCost + " WHERE RegId = " + paraId;
		else
			vSQL = "Update Registration Set mCost=mCost-" + paraCost + " WHERE RegId = " + paraId;

	}

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

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

⌨️ 快捷键说明

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