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

📄 distribute.cpp

📁 固定资产管理系统,VC++做的,很有参考价值,源码也说明文档都有.
💻 CPP
字号:
// Distribute.cpp: implementation of the CDistribute class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "AssetsMan.h"
#include "Distribute.h"
#include "ADOConn.h"

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

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

CDistribute::CDistribute()
{
	DepId = 0;
	EmpName = "";
	Aid = "";
	CreateDate = "";
}

CDistribute::~CDistribute()
{

}

void CDistribute::sql_Insert()
{
	try
	{
		//连接数据库
		ADOConn m_AdoConn;
		_bstr_t bSQL;

		CString cDepId;
		cDepId.Format("%d", DepId);

		bSQL = "Insert Into Distribute Values('" + Aid + "'," + cDepId 
			 + ",'" + EmpName + "','" + CreateDate + "')";
		m_AdoConn.ExecuteSQL(bSQL);
		//断开与数据库的连接
		m_AdoConn.ExitConnect();
	}
	// 捕捉异常
	catch(_com_error e)
	{
		// 显示错误信息
		AfxMessageBox(e.Description());
	}
}
// ******更新部门信息*******//
void CDistribute::sql_Update(CString cId)
{
	try
	{
		//连接数据库
		ADOConn m_AdoConn;
		_bstr_t bSQL;

		CString cDepId;
		cDepId.Format("%d", DepId);
		bSQL = "Update Distribute Set DepId=" + cDepId + ", EmpName='" 
			 + EmpName + "', CreateDate='" + CreateDate
			 + "' Where Aid='" + cId + "'";
		m_AdoConn.ExecuteSQL(bSQL);
		//断开与数据库的连接
		m_AdoConn.ExitConnect();
	}
	// 捕捉异常
	catch(_com_error e)
	{
		// 显示错误信息
		AfxMessageBox(e.Description());
	}
}
// ******删除信息*******//
void CDistribute::sql_Delete(CString cId)
{
	try
	{
		//连接数据库
		ADOConn m_AdoConn;
		_bstr_t bSQL;
		bSQL = "Delete From Distribute Where Aid='" + cId + "'";
		m_AdoConn.ExecuteSQL(bSQL);

		// 更新表Assets中使用状态为“未使用”
		bSQL = "UPDATE Assets SET Status='未使用' WHERE Aid='" + cId + "'";
		m_AdoConn.ExecuteSQL(bSQL);
		//断开与数据库的连接
		m_AdoConn.ExitConnect();
	}
	// 捕捉异常
	catch(_com_error e)
	{
		// 显示错误信息
		AfxMessageBox(e.Description());
	}
}

⌨️ 快捷键说明

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