【VC开源代码栏目提醒】:网学会员在VC开源代码频道为大家收集整理了BorrowCommand.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 "";
}
}
上一篇:
BookSet.cpp
下一篇:
科研管理杂志简介