📄 prdstruct.cpp
字号:
// PrdStruct.cpp: implementation of the CPrdStruct class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "PrdStruct.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CPrdStruct::CPrdStruct()
{
::CoInitialize(NULL);
Cnn_ERR=false;
Cls_ERR=false;
try
{
pDBCnn.CreateInstance(__uuidof(Connection));
pRstPrdStruct.CreateInstance(__uuidof(Recordset));
pDBCnn->Open("provider=sqloledb;server=zfzcomputer;database=xg_erp;uid=sa;pwd=","","",-1);
pRstPrdStruct->Open("select * from uv_PrdStructstorage order by nodeid",pDBCnn.GetInterfacePtr(),adOpenKeyset,adLockReadOnly,-1);
m_Count=pRstPrdStruct->RecordCount;
pRstPrdStruct->MoveFirst();
}
catch(...)
{
Cnn_ERR=true;
Cls_ERR=true;
}
return;
}
CPrdStruct::~CPrdStruct()
{
pRstPrdStruct->Close();
pRstPrdStruct.Release();
pDBCnn->Close();
pDBCnn.Release();
::CoUninitialize();
}
void CPrdStruct::getnode(long argNodeID)
{
// 获取指定结构节点的数据
long lDiff;
// argNodeID对应记录和当前记录的偏移量
Cls_ERR=false;
if (argNodeID==-1)
{
Cls_ERR=true;
}
else
{
try
{
lDiff = argNodeID - (long)(pRstPrdStruct->Fields->Item["NodeID"]->Value);
while (lDiff!=0)
{
if ((long)pRstPrdStruct->AbsolutePosition + lDiff < 1)
pRstPrdStruct->MoveFirst();
else
if ((long)pRstPrdStruct->AbsolutePosition + lDiff > m_Count)
pRstPrdStruct->MoveLast();
else
pRstPrdStruct->Move(lDiff);
lDiff = argNodeID - (long)(pRstPrdStruct->Fields->Item["NodeID"]->Value);
}
NodeID=argNodeID;
MtrlID=pRstPrdStruct->Fields->Item["MtrlID"]->Value;
firstsonID=pRstPrdStruct->Fields->Item["SonNode"]->Value;
firstson=pRstPrdStruct->Fields->Item["son"]->Value;
sonloss=pRstPrdStruct->Fields->Item["sonloss"]->Value;
sonscale=pRstPrdStruct->Fields->Item["sonscale"]->Value;
sonahead=pRstPrdStruct->Fields->Item["sonahead"]->Value;
sonsource=pRstPrdStruct->Fields->Item["sonsource"]->Value;
brotherID=pRstPrdStruct->Fields->Item["brothernode"]->Value;
brother=pRstPrdStruct->Fields->Item["brother"]->Value;
brotherscale=pRstPrdStruct->Fields->Item["brotherscale"]->Value;
brotherloss=pRstPrdStruct->Fields->Item["brotherloss"]->Value;
brotherahead=pRstPrdStruct->Fields->Item["brotherahead"]->Value;
brothersource=pRstPrdStruct->Fields->Item["brothersource"]->Value;
sonStorage=pRstPrdStruct->Fields->Item["sonStorage"]->Value;
brotherStorage=pRstPrdStruct->Fields->Item["brotherStorage"]->Value;
}
catch(...)
{
Cls_ERR=true;
}
}
return;
}
long CPrdStruct::getMtrl(long argMtrlID)
{
// 返回指定物料的结构节点编号,并获取相应的结构数据
_bstr_t sqlstr;
char strbuf[25];
/*
_itoa(argMtrlID,sqlstr,10);
sqlstr="MtrlID=" + sqlstr;
*/
sprintf(strbuf,"MtrlID = %d",argMtrlID);
sqlstr=strbuf;
Cls_ERR=false;
try
{
pRstPrdStruct->MoveFirst();
pRstPrdStruct->Find(sqlstr,0,adSearchForward,pRstPrdStruct->Bookmark);
if (pRstPrdStruct->EndOfFile)
{
Cls_ERR=true;
NodeID=-1;
pRstPrdStruct->MoveFirst();
}
else
{
NodeID=(long)(pRstPrdStruct->Fields->Item["NodeID"]->Value);
MtrlID=pRstPrdStruct->Fields->Item["MtrlID"]->Value;
firstsonID=pRstPrdStruct->Fields->Item["SonNode"]->Value;
firstson=pRstPrdStruct->Fields->Item["son"]->Value;
sonloss=pRstPrdStruct->Fields->Item["sonloss"]->Value;
sonscale=pRstPrdStruct->Fields->Item["sonscale"]->Value;
sonahead=pRstPrdStruct->Fields->Item["sonahead"]->Value;
sonsource=pRstPrdStruct->Fields->Item["sonsource"]->Value;
brotherID=pRstPrdStruct->Fields->Item["brothernode"]->Value;
brother=pRstPrdStruct->Fields->Item["brother"]->Value;
brotherscale=pRstPrdStruct->Fields->Item["brotherscale"]->Value;
brotherloss=pRstPrdStruct->Fields->Item["brotherloss"]->Value;
brotherahead=pRstPrdStruct->Fields->Item["brotherahead"]->Value;
brothersource=pRstPrdStruct->Fields->Item["brothersource"]->Value;
sonStorage=pRstPrdStruct->Fields->Item["sonStorage"]->Value;
brotherStorage=pRstPrdStruct->Fields->Item["brotherStorage"]->Value;
}
}
catch(...)
{
Cls_ERR=true;
NodeID=-1;
}
return(NodeID);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -