📄 bmhdl.cpp
字号:
m_sdBomd->AddNew();
if(CurStatus!=2)
SetActionID(5);
}
//---------------------------------------------------------------------------
void TsdBomh::InsertItem()
{
//m_sdField->AddNew();
//TsdField *p=new TsdField(m_SessionName,m_DatabaseName);
//p->Assign(m_sdField);
//if(CurStatus==2)
// m_sdField->AddRecord((void *)p,p->GetFieldValue(fiFieldName));
//else
// m_sdField->Update();
}
//---------------------------------------------------------------------------
void TsdBomh::EditItem()
{
m_sdBomd->Edit();
if(CurStatus==1)
{
SetActionID(6);
}
}
//---------------------------------------------------------------------------
void TsdBomh::DeleteItem()
{
if(CurStatus==2 || CurStatus==5)
m_sdBomd->DeleteRecord(m_sdBomd->Key);
else
m_sdBomd->Delete();
}
//---------------------------------------------------------------------------
void TsdBomh::RemoveItem()
{
if(CurStatus==2 || CurStatus==5)
m_sdBomd->RemoveRecord(m_sdBomd->Index);
else
m_sdBomd->Delete();
}
//---------------------------------------------------------------------------
void TsdBomh::ClearItem()
{
int iCount;
if(CurStatus==2)
m_sdBomd->ClearRecord();
else
{
iCount=m_sdBomd->Count;
for(int i=0;i<iCount;i++)
{
m_sdBomd->LocateByIndex(0);
m_sdBomd->Delete();
}
}
}
//---------------------------------------------------------------------------
void TsdBomh::CancelItem()
{
m_sdBomd->Cancel();
}
//---------------------------------------------------------------------------
void TsdBomh::RestoreItem()
{
m_sdBomd->RestoreValue();
}
//---------------------------------------------------------------------------
void TsdBomh::AddToObject()
{
TsdBomd *p=new TsdBomd();
p->Assign(m_sdBomd);
if(m_sdBomd->FindKey(m_sdBomd->GetOldFieldValue(fiBomdGoods)))
m_sdBomd->ChangeRecord((void *)p,p->GetFieldValue(fiBomdGoods),m_sdBomd->GetOldFieldValue(fiBomdGoods));
else
m_sdBomd->AddRecord((void *)p,p->GetFieldValue(fiBomdGoods));
}
//---------------------------------------------------------------------------
bool TsdBomh::LocateItemByIndex(int Index)
{
return m_sdBomd->LocateByIndex(Index);
}
//---------------------------------------------------------------------------
bool TsdBomh::LocateItemByKey(AnsiString Key)
{
return m_sdBomd->LocateByKey(Key);
}
//---------------------------------------------------------------------------
void TsdBomh::BackupValue()
{
b_sdBomd=m_sdBomd;
b_BomhGoods=m_BomhGoods;
b_BomhUnit=m_BomhUnit;
b_BomhType=m_BomhType;
b_BomhEoq=m_BomhEoq;
b_BomhRlt=m_BomhRlt;
b_BomhFpr=m_BomhFpr;
b_BomhPp=m_BomhPp;
b_BomhOp=m_BomhOp;
b_BomhUser=m_BomhUser;
b_BomhProducter=m_BomhProducter;
b_BomhEdate=m_BomhEdate;
b_BomhIdate=m_BomhIdate;
b_BomhDesc=m_BomhDesc;
b_BomhSysDate=m_BomhSysDate;
}
//---------------------------------------------------------------------------
void TsdBomh::RestoreValue()
{
m_sdBomd=b_sdBomd;
m_BomhGoods=b_BomhGoods;
m_BomhUnit=b_BomhUnit;
m_BomhType=b_BomhType;
m_BomhEoq=b_BomhEoq;
m_BomhRlt=b_BomhRlt;
m_BomhFpr=b_BomhFpr;
m_BomhPp=b_BomhPp;
m_BomhOp=b_BomhOp;
m_BomhUser=b_BomhUser;
m_BomhProducter=b_BomhProducter;
m_BomhEdate=b_BomhEdate;
m_BomhIdate=b_BomhIdate;
m_BomhDesc=b_BomhDesc;
m_BomhSysDate=b_BomhSysDate;
}
//---------------------------------------------------------------------------
void TsdBomh::EmptyValue(int Index)
{
switch(Index)
{
case 0:
m_sdBomd=NULL;
m_BomhGoods="";
m_BomhUnit="";
m_BomhType=0;
m_BomhEoq=0;
m_BomhRlt=0;
m_BomhFpr=0;
m_BomhPp=0;
m_BomhOp=0;
m_BomhUser="";
m_BomhProducter="";
m_BomhEdate="";
m_BomhIdate="";
m_BomhDesc="";
m_BomhSysDate="";
break;
case 1:
b_sdBomd=NULL;
b_BomhGoods="";
b_BomhUnit="";
b_BomhType=0;
b_BomhEoq=0;
b_BomhRlt=0;
b_BomhFpr=0;
b_BomhPp=0;
b_BomhOp=0;
b_BomhUser="";
b_BomhProducter="";
b_BomhEdate="";
b_BomhIdate="";
b_BomhDesc="";
b_BomhSysDate="";
break;
}
}
//---------------------------------------------------------------------------
void TsdBomh::BatchLetValue()
{
m_BomhGoods=m_Query->FieldValues["BomhGoods"];
m_BomhUnit=m_Query->FieldValues["BomhUnit"];
m_BomhType=m_Query->FieldValues["BomhType"];
m_BomhEoq=m_Query->FieldValues["BomhEoq"];
m_BomhRlt=m_Query->FieldValues["BomhRlt"];
m_BomhFpr=m_Query->FieldValues["BomhFpr"];
m_BomhPp=m_Query->FieldValues["BomhPp"];
m_BomhOp=m_Query->FieldValues["BomhOp"];
m_BomhUser=m_Query->FieldValues["BomhUser"];
m_BomhProducter=m_Query->FieldValues["BomhProducter"];
m_BomhEdate=m_Query->FieldValues["BomhEdate"];
m_BomhIdate=m_Query->FieldValues["BomhIdate"];
m_BomhDesc=m_Query->FieldValues["BomhDesc"];
m_BomhSysDate=m_Query->FieldValues["BomhSysDate"];
BackupValue();
}
//---------------------------------------------------------------------------
void TsdBomh::Assign(TsdBomh *p)
{
this->SetActionID(p->CurStatus);
this->m_sdBomd=p->m_sdBomd;
this->m_BomhGoods=p->m_BomhGoods;
this->m_BomhUnit=p->m_BomhUnit;
this->m_BomhType=p->m_BomhType;
this->m_BomhEoq=p->m_BomhEoq;
this->m_BomhRlt=p->m_BomhRlt;
this->m_BomhFpr=p->m_BomhFpr;
this->m_BomhPp=p->m_BomhPp;
this->m_BomhOp=p->m_BomhOp;
this->m_BomhUser=p->m_BomhUser;
this->m_BomhProducter=p->m_BomhProducter;
this->m_BomhEdate=p->m_BomhEdate;
this->m_BomhIdate=p->m_BomhIdate;
this->m_BomhDesc=p->m_BomhDesc;
this->m_BomhSysDate=p->m_BomhSysDate;
if(this->CurStatus==3)
{
this->b_sdBomd=p->b_sdBomd;
this->b_BomhGoods=p->b_BomhGoods;
this->b_BomhUnit=p->b_BomhUnit;
this->b_BomhType=p->b_BomhType;
this->b_BomhEoq=p->b_BomhEoq;
this->b_BomhRlt=p->b_BomhRlt;
this->b_BomhFpr=p->b_BomhFpr;
this->b_BomhPp=p->b_BomhPp;
this->b_BomhOp=p->b_BomhOp;
this->b_BomhUser=p->b_BomhUser;
this->m_BomhProducter=p->m_BomhProducter;
this->m_BomhEdate=p->m_BomhEdate;
this->m_BomhIdate=p->m_BomhIdate;
this->b_BomhDesc=p->b_BomhDesc;
this->b_BomhSysDate=p->b_BomhSysDate;
}
else
this->BackupValue();
}
//---------------------------------------------------------------------------
void TsdBomh::AssignValue()
{
TsdBomh *p=(TsdBomh *)Records(CurRecNo);
Assign(p);
}
//---------------------------------------------------------------------------
int TsdBomh::Query()
{
AnsiString m_SqlStr;
m_SqlStr=QueryString;
if(FilterString.IsEmpty()==false)
m_SqlStr=m_SqlStr+" where "+FilterString;
if(OrderString.IsEmpty()==false)
m_SqlStr=m_SqlStr+" Order by "+OrderString;
m_Query->Close();
m_Query->SQL->Clear();
m_Query->SQL->Add(m_SqlStr);
m_Query->Open();
for(int i=0;i<this->Count;i++)
{
this->LocateByIndex(i);
this->AssignValue();
delete m_sdBomd;
}
ClearRecord();
if(m_Query->RecordCount>0)
{
m_Query->First();
while(!m_Query->Eof)
{
BatchLetValue();
NewDetail();
m_sdBomd->FilterString=" BomdPgoods='"+m_BomhGoods+"'";
m_sdBomd->OrderString=" BomdPgoods,BomdSn ";
m_sdBomd->Query();
TsdBomh *p=new TsdBomh();
SetActionID(1);
p->Assign(this);
AddRecord((void *)p,p->BomhGoods);
m_Query->Next();
}
MoveFirst();
}
m_Query->Close();
return Count;
}
//---------------------------------------------------------------------------
bool TsdBomh::Find(AnsiString WhereStr)
{
AnsiString m_SqlStr;
if(WhereStr.IsEmpty()==true)
throw Exception("查找的条件表达式不能为空!");
m_SqlStr="select * from sdBomh where "+WhereStr;
m_Query->Close();
m_Query->SQL->Clear();
m_Query->SQL->Add(m_SqlStr);
m_Query->Open();
if(m_Query->RecordCount!=1)
{
m_Query->Close();
return false;
}
else
{
BatchLetValue();
m_sdBomd->FilterString=" BomdPgoods='"+m_BomhGoods+"'";
m_sdBomd->OrderString=" BomdPgoods,BomdSn ";
m_sdBomd->Query();
m_Query->Close();
return true;
}
}
//---------------------------------------------------------------------------
void TsdBomh::Execute(AnsiString Param)
{
if(Param=="1")
{
TStringList *m_GoodsList=new TStringList;
try
{
m_Query->Close();
m_Query->SQL->Clear();
m_Query->SQL->Add("select bomhGoods from sdBomh");
m_Query->Open();
m_Query->First();
while(!m_Query->Eof)
{
VerifyBom(m_Query->FieldValues["bomhGoods"],m_GoodsList);
m_Query->Next();
}
m_Query->Close();
}
__finally
{
delete m_GoodsList;
}
}
else
{
m_StoredProc->Close();
m_StoredProc->ProcedureName="sdBom_Calculate_Llc";
m_StoredProc->Parameters->Clear();
m_StoredProc->ExecProc();
m_StoredProc->Close();
}
}
//---------------------------------------------------------------------------
void __fastcall TsdBomh::VerifyBom(AnsiString GoodsCode,TStringList *GoodsList)
{
TADOQuery *p=new TADOQuery(DllApplication);
int index;
// try
// {
p->Connection=ADOConnection;
GoodsList->Add(GoodsCode);
p->SQL->Clear();
p->SQL->Add("select BomdGoods from sdBomd,sdGoods where BomdGoods=GoodsCode and BomdPGoods='"+GoodsCode+"' and GoodsFrom=2");
p->Open();
p->First();
while(!p->Eof)
{
index=GoodsList->IndexOf(p->FieldValues["BomdGoods"]);
if(index!=-1)
{
p->Close();
delete p;
throw Exception("产品:"+GoodsCode+" 包含有父件:"+GoodsList->Strings[index]+",产品结构表非法!");
}
VerifyBom(p->FieldValues["BomdGoods"],GoodsList);
p->Next();
}
index=GoodsList->IndexOf(GoodsCode);
if(index!=-1)
GoodsList->Delete(index);
p->Close();
delete p;
return;
}
//---------------------------------------------------------------------------
AnsiString TsdBomh::GetItemValue(euBomd FieldName)
{
return m_sdBomd->GetFieldValue(FieldName);
}
//---------------------------------------------------------------------------
void TsdBomh::SetItemValue(euBomd FieldName, AnsiString Value)
{
m_sdBomd->SetFieldValue(FieldName,Value);
}
//---------------------------------------------------------------------------
int __fastcall TsdBomh::GetItemCount()
{
if(m_sdBomd)
return m_sdBomd->Count;
else
return 0;
}
//---------------------------------------------------------------------------
int __fastcall TsdBomh::GetCurItemNo()
{
return m_sdBomd->CurRecNo;
}
//---------------------------------------------------------------------------
char __fastcall TsdBomh::GetCurItemStatus()
{
return m_sdBomd->CurStatus;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -