?? distribute.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
{
//連接數(shù)據(jù)庫
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);
//斷開與數(shù)據(jù)庫的連接
m_AdoConn.ExitConnect();
}
// 捕捉異常
catch(_com_error e)
{
// 顯示錯誤信息
AfxMessageBox(e.Description());
}
}
// ******更新部門信息*******//
void CDistribute::sql_Update(CString cId)
{
try
{
//連接數(shù)據(jù)庫
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);
//斷開與數(shù)據(jù)庫的連接
m_AdoConn.ExitConnect();
}
// 捕捉異常
catch(_com_error e)
{
// 顯示錯誤信息
AfxMessageBox(e.Description());
}
}
// ******刪除信息*******//
void CDistribute::sql_Delete(CString cId)
{
try
{
//連接數(shù)據(jù)庫
ADOConn m_AdoConn;
_bstr_t bSQL;
bSQL = "Delete From Distribute Where Aid='" + cId + "'";
m_AdoConn.ExecuteSQL(bSQL);
// 更新表Assets中使用狀態(tài)為“未使用”
bSQL = "UPDATE Assets SET Status='未使用' WHERE Aid='" + cId + "'";
m_AdoConn.ExecuteSQL(bSQL);
//斷開與數(shù)據(jù)庫的連接
m_AdoConn.ExitConnect();
}
// 捕捉異常
catch(_com_error e)
{
// 顯示錯誤信息
AfxMessageBox(e.Description());
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -