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

📄 borrowcommand.cpp

📁 本系统是一简单的物资管理系统
💻 CPP
字号:
// BorrowCommand.cpp: implementation of the CBorrowCommand class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "WhMgr.h"
#include "BorrowCommand.h"

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

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

CBorrowCommand::CBorrowCommand()
{

}

CBorrowCommand::~CBorrowCommand()
{

}

int CBorrowCommand::GetMaxBorrowID()
{
	_RecordsetPtr pRs("ADODB.RecordSet");
	pRs->Open(_variant_t("Select Max(ID) as MAXID From tblBorrow"), _variant_t(m_cnn->m_pConn, true), adOpenStatic, adLockOptimistic, adCmdText);	
	
	int nResult;

	_variant_t vValue = pRs->Fields->Item[_variant_t("MAXID")]->Value;
	
	//如果不为空,返回最大值;否则返回0
	if (V_VT(&vValue) != VT_NULL)
	{
		nResult = atoi(_bstr_t(vValue));	
	}
	else
	{
		nResult = 0;
	}
	
	pRs->Close();
	
	return nResult;
}

CString CBorrowCommand::DoBorrow()
{
	//得到当前时间
	CString strData;
	CTime time = CTime::GetCurrentTime();
	strData.Format("%d-%d-%d %d:%d:%d", 
		time.GetYear(), 
		time.GetMonth(), 
		time.GetDay(),
		time.GetHour(),
		time.GetMinute(),
		time.GetSecond());

	CString strSQL;

	//得到新的借用ID
	int nMaxID = GetMaxBorrowID();
	nMaxID++;
	CString strNewID;
	strNewID.Format("%d", nMaxID);

	strSQL = "Insert into tblBorrow([ID], [MaterialNum], [Count], [Department], [Data], [Use], [State], [Jsr], [Lqr]) Values("
		+ strNewID + ", " 
		+ m_MaterialNum + ", " 
		+ m_Count + ", \"" 
		+ m_Department + "\", #" 
		+ strData + "#, \""
		+ m_Use + "\", \""
		+ m_State + "\", \""
		+ m_Jsr + "\", \""
		+ m_Lqr + "\")";

	if(ExecuteSQL(strSQL))
	{
		return strNewID;
	}
	else
	{
		return "";
	}
}

⌨️ 快捷键说明

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