📄 bomhcopy.cpp
字号:
scBomdProcess->LocateKey(s2);
s_ItemStr = GetDetailValue("BomdSn")+
"\t"+GetDetailValue("BomdGoods")+
"\t"+GetDetailValue("BomdGoodsName")+
"\t"+GetDetailValue("BomdGoodsSpec")+
"\t"+scBomdUnit->ItemData[0]+
"\t"+GetDetailValue("BomdQty")+
"\t"+GetDetailValue("BomdShl")+
"\t"+scBomdProcess->ItemData[2];
return s_ItemStr;
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomhCopy::DisplayBill()
{
if(comServer->RecordCount>0)
{
GetDataFromComObject(1);
FillGridWithData();
if(sgBomhCopy->RowCount >1)
{
AnsiString Keystr;
Keystr=seBomhGoods->Text+"\t"+sgBomhCopy->Cells[1][sgBomhCopy->Row];
comServer->LocateItemByKey(Keystr);
GetDataFromComObject(2);
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomhCopy::GetBill(AnsiString BillID)
{
bool iRow;
iRow=comServer->Find("BomhCode='"+BillID+"'");
if(iRow)
DisplayBill();
else
{
if(ShowMessageWindow("在数据库中没有查到记录:"+BillID+",要增加吗?",mwsConfirmation)==IDYES)
AddHeadRecord();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomhCopy::FillGridWithData()
{
int i;
AnsiString ItemStr;
sgBomhCopy->RowCount=1;
if(comServer->RecordCount>0)
{
for(i=0;i<comServer->ItemCount;i++)
{
comServer->LocateItemByIndex(i);
RefreshGridData(0);
}
}
else
ClearControl(2,false);
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomhCopy::FormClose(TObject *Sender,
TCloseAction &Action)
{
TGenBaseForm::FormClose(Sender,Action);
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomhCopy::FormShow(TObject *Sender)
{
ClearControl(1,false);
ClearControl(2,false);
//无修改明细行功能;
tbEditDetail->Visible=false;
muEditDetail->Visible=false;
TGenBaseForm::MoveToFirst();
ChangeToBrowseState(true);
//无单据审核功能;
tbCheck->Visible=false;
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomhCopy::sgBomhClick(TObject *Sender)
{
if (sgBomhCopy->Row > 0)
{
comServer->LocateItemByKey(sgBomhCopy->TextMatrix[sgBomhCopy->Row][1]+"\t"+GetHeadValue("BomhGoods")+"\t");
GetDataFromComObject(2); // Detail
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomhCopy::sgBomhCopyDblClick(TObject *Sender)
{
int iRow;
iRow=sgBomhCopy->Row;
if(iRow == 0)
return;
ChangeToBrowseState(false);
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomhCopy::ChangeToBrowseState(bool agree)
{
if(agree)
{
sgBomhCopy->Visible=true;
FloatPanel2->Visible=false;
sgBomhCopy->Align=alClient;
FloatPanel2->Align=alNone;
}
else
{
sgBomhCopy->Visible=false;
FloatPanel2->Visible=true;
sgBomhCopy->Align=alNone;
FloatPanel2->Align=alClient;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomhCopy::btnOKClick(TObject *Sender)
{
try{
if((CurrentState==caAddDetail)||(CurrentState==caAddBill))
{
if(DetailState==caAddDetail)
comServer->AddItem();
SendDataToComObject(2);
comServer->AddToObject();
ClearControl(2,false);
//连续增加时返回焦点
if(seBomdGoods->Enabled)
seBomdGoods->SetFocus();
}
else
ChangeToBrowseState(false);
}
catch(Exception &e)
{
throw Exception(e.Message);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomhCopy::btnCancelClick(TObject *Sender)
{
CancelChange();
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomhCopy::seBomhGoodsButtonClick(TObject *Sender)
{
if(OpenGoodsForm(" (GoodsType=1 or GoodsType=2) and GoodsFrom=2 " ))
{
seBomhGoods->Text=GetGoodsValue(gtOpenForm,"GoodsCode");
seBomhGoodsName->Text=GetGoodsValue(gtOpenForm,"GoodsName");
seBomhVer->Text=l_RsGoods->FieldValues["GoodsVer"];
seBomhModel->Text=l_RsGoods->FieldValues["GoodsModel"];
scBomhType->ItemIndex=StrToInt(l_RsGoods->FieldValues["GoodsType"])-1;
scBomhUnit->LocateKey(l_RsGoods->FieldValues["GoodsUnitCode"]);
seBomhEoq->Text=l_RsGoods->FieldValues["GoodsEoq"];
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomhCopy::seBomdGoodsButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="007[物料编码][物料名称][版本号][型号][类型][来源][计量单位]";
SqlStr+="Select GoodsCode,GoodsName,GoodsVer,GoodsModel,GoodsType,GoodsFrom,GoodsUnitCode from sdGoods where GoodsType<>1 and GoodsCode<>'"+seBomhGoods->Text+"' order by GoodsCode";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"子件物料数据查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
seBomdGoods->Text=p->ColData[1];;
seBomdGoodsName->Text=p->ColData[2];
seBomdVer->Text=p->ColData[3];
seBomdModel->Text=p->ColData[4];
scBomdType->ItemIndex=StrToInt(p->ColData[5])-1;
scBomdFrom->ItemIndex=StrToInt(p->ColData[6])-1;
scBomdUnit->Text=p->ColData[7];
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomhCopy::GenrateBill()
{
int BefoICount=comServer->ItemCount;
//try
//{
StartWaitForm("正在启动<物料单复制>界面...");
BomdCopyfrm = new TfrmBomdCopy(this);
BomdCopyfrm->SetcomServer(comServer);
BomdCopyfrm->BomhGoods=seBomhGoods->Text;
BomdCopyfrm->BomhGoodsName=seBomhGoodsName->Text;
EndWaitForm();
BomdCopyfrm->ShowModal();
if(comServer->ItemCount>BefoICount)
TGenBaseForm::SaveRecord();
else
CancelChange();
//}
//__finally
// {
// delete BomdCopyfrm;
// }
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomhCopy::seBomhGoodsExit(TObject *Sender)
{
AnsiString tempS;
tempS=seBomhGoods->Text;
if(tempS.IsEmpty())
return;
if(CurrentState==caAddHead)
{
if(InitRsGoods(tempS))
{
seBomhGoodsName->Text=GetGoodsValue(gtInitRs,"GoodsName");
seBomhVer->Text=GetGoodsValue(gtInitRs,"GoodsVer");
seBomhModel->Text=GetGoodsValue(gtInitRs,"GoodsModel");
scBomhType->ItemIndex=StrToInt(GetGoodsValue(gtInitRs,"GoodsType"))-1;
scBomhUnit->LocateKey(GetGoodsValue(gtInitRs,"GoodsUnitCode"));
seBomhEoq->Text=GetGoodsValue(gtInitRs,"GoodsEoq");
}
else
::MessageBox(Handle,"输入的物料编码不存在!","错误提示",MB_OK|MB_ICONSTOP);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomhCopy::seBomdGoodsExit(TObject *Sender)
{
AnsiString tempS;
tempS=seBomdGoods->Text;
if(!tempS.IsEmpty())
{
if(InitRsGoods(tempS))
{
seBomdGoodsName->Text=GetGoodsValue(gtInitRs,"GoodsName");
seBomdVer->Text=GetGoodsValue(gtInitRs,"GoodsVer");
seBomdModel->Text=GetGoodsValue(gtInitRs,"GoodsModel");
scBomdType->ItemIndex=StrToInt(GetGoodsValue(gtInitRs,"GoodsType"))-1;
scBomdFrom->ItemIndex=StrToInt(GetGoodsValue(gtInitRs,"GoodsFrom"))-1;
scBomdUnit->LocateKey(GetGoodsValue(gtInitRs,"GoodsUnitCode"));
}
else
::MessageBox(Handle,"输入的物料编码不存在!","错误提示",MB_OK|MB_ICONSTOP);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomhCopy::seBomhGoodsKeyDown(TObject *Sender,
WORD &Key, TShiftState Shift)
{
AnsiString pStr=seBomhGoods->Text;
if(Key==13 && !pStr.IsEmpty() && CurrentState==caNormal)
{
InitRsGoods(pStr);
comServer->LocateByKey(WideString(pStr));
DisplayBill();
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -