distribute.cpp

来自「固定资产管理系统,VC++做的,很有参考价值,源码也说明文档都有.」· C++ 代码 · 共 106 行

CPP
106
字号
// 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 + =
减小字号Ctrl + -
显示快捷键?