📄 bomdcopy.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include "BomdCopy.h"
#include "BomhCopy.h"
//---------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "fpanel"
#pragma link "SDGrid"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma resource "*.dfm"
TfrmBomdCopy *frmBomdCopy;
//---------------------------------------------------------------------------
__fastcall TfrmBomdCopy::TfrmBomdCopy(TComponent* Owner)
: TStdBaseForm(Owner)
{
sgBomd->RowCount=1;
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomdCopy::scBomhGoodsFClick(TObject *Sender)
{
if(scBomhGoodsF->ItemIndex==-1)
{
::MessageBox(Handle,"生成时的来源父件编码不能为空!","错误",MB_OK|MB_ICONSTOP);
return;
}
else
{
sgBomd->RowCount=1;
AnsiString s_GoodsF=Trim(scBomhGoodsF->ItemData[1]);
seBomhGoodsNameF->Text=scBomhGoodsF->ItemData[2];
FillGridWithData(s_GoodsF);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomdCopy::FillGridWithData(AnsiString s_GoodsCode)
{
AnsiString tempSQL,ItemStr;
Rst=NewResultSet();
tempSQL=AnsiString("Select BomdSn,BomdGoods,GoodsName,BomdUnit,BomdType,BomdFrom,")+
AnsiString("BomdQty,BomdShl,BomdOp,BomdPp,BomdProcess,BomdCfg,BomdLot,BomdRepFlg,BomdLlc ")+
AnsiString("from sdBomd,sdGoods Where BomdGoods=GoodsCode and BomdPgoods='"+s_GoodsCode+"' Order By BomdSn");
Rst->Open(WideString(tempSQL),WideString("BomdSn"));
Rst->MoveFirst();
while( Rst->Eof == 0 )
{
ItemStr=AnsiString("√") +
"\t"+ Rst->FieldByName("BomdSn")+
"\t"+ Rst->FieldByName("BomdGoods")+
"\t"+ Rst->FieldByName("GoodsName")+
"\t"+ Rst->FieldByName("BomdUnit")+
"\t"+ Rst->FieldByName("BomdQty")+
"\t"+ Rst->FieldByName("BomdShl");
sgBomd->AddItem(ItemStr);
Rst->MoveNext();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomdCopy::SetcomServer(TComServer *value)
{
comServer=value;
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomdCopy::sgBomdSelectCell(TObject *Sender, int ACol,
int ARow, bool &CanSelect)
{
if(ARow>0 && ACol==0)
{
if(sgBomd->Cells[0][ARow]=="")
sgBomd->Cells[0][ARow]="√";
else
sgBomd->Cells[0][ARow]="";
}
if(ARow>0)
{
AnsiString m_Key;
m_Key=sgBomd->Cells[1][ARow];
Rst->LocateByKey(WideString(m_Key));
SetValueToControl();
}
else
CanSelect=false;
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomdCopy::SetValueToControl()
{
scBomdFrom->ItemIndex=StrToInt(Rst->FieldByName("BomdFrom"))-1;
scBomdOp->ItemIndex=StrToInt(Rst->FieldByName("BomdOp"))-1;
scBomdPp->ItemIndex=StrToInt(Rst->FieldByName("BomdPp"))-1;
scBomdProcess->LocateKey(Rst->FieldByName("BomdProcess"));
scBomdCfg->ItemIndex=StrToInt(Rst->FieldByName("BomdCfg"))-1;
seBomdLot->Text=Rst->FieldByName("BomdLot");
chkBomdRepFlg->Checked=Rst->FieldByName("BomdRepFlg")=="1";
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomdCopy::btnCancelClick(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomdCopy::FormShow(TObject *Sender)
{
seBomhGoodsT->Text = FBomhGoods;
seBomhGoodsNameT->Text = FBomhGoodsName;
seBomhGoodsT->Enabled=false;
seBomhGoodsNameT->Enabled=false;
seBomhGoodsNameF->Enabled=false;
Panel1->Enabled=false;
FillComboBox(scBomhGoodsF,"select memo='('+GoodsCode+')'+space(1)+GoodsName,GoodsCode,GoodsName from sdGoods,sdBomh where BomhGoods=GoodsCode order by GoodsCode ","memo","GoodsCode","GoodsName");
FillComboBox(scBomdProcess,"Select ProcessCode,memo='('+ProcessCode+')'+space(1)+ProcessName from sdProcess order by ProcessCode","memo","ProcessCode");
InitEditControl();
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomdCopy::SetDetailValue(int Index,AnsiString Value)
{
WriteItemValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomdCopy::InitEditControl()
{
scBomhGoodsF->ItemIndex=-1;
seBomhGoodsNameF->Text="";
scBomdFrom->ItemIndex=-1;
scBomdOp->ItemIndex=-1;
scBomdPp->ItemIndex=-1;
scBomdProcess->ItemIndex=-1;
scBomdCfg->ItemIndex=-1;
seBomdLot->Text="";
chkBomdRepFlg->Checked=false;
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomdCopy::btnOKClick(TObject *Sender)
{
if(sgBomd->RowCount>0)
{
int j;
j=comServer->ItemCount-1;
if(j>0)
{
comServer->LocateItemByIndex(j);
j=StrToInt(frmBomhCopy->GetDetailValue(fiBomdSn));
j=j+1;
}
else
j=1;
for(int i=1;i<sgBomd->RowCount;i++)
{
if(sgBomd->Cells[0][i]=="√")
{
AnsiString m_Keystr;
m_Keystr=sgBomd->Cells[1][i];
Rst->LocateByKey(WideString(m_Keystr));
comServer->AddItem();
SetDetailValue(fiBomdPgoods,frmBomhCopy->seBomhGoods->Text);
SetDetailValue(fiBomdSn,AnsiString(j));
SetDetailValue(fiBomdGoods,Rst->FieldByName("BomdGoods"));
SetDetailValue(fiBomdQty,Rst->FieldByName("BomdQty"));
SetDetailValue(fiBomdShl,Rst->FieldByName("BomdShl"));
SetDetailValue(fiBomdOp,Rst->FieldByName("BomdOp"));
SetDetailValue(fiBomdPp,Rst->FieldByName("BomdPp"));
SetDetailValue(fiBomdProcess,Rst->FieldByName("BomdProcess"));
SetDetailValue(fiBomdCfg,Rst->FieldByName("BomdCfg"));
SetDetailValue(fiBomdLot,Rst->FieldByName("BomdLot"));
SetDetailValue(fiBomdRepFlg,Rst->FieldByName("BomdRepFlg"));
try
{
comServer->AddToObject();
}
catch(Exception &e)
{
comServer->Cancel();
this->ModalResult=0;
throw Exception(e.Message);
}
j=j+1;
}
}
}
Close();
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomdCopy::FormClose(TObject *Sender,
TCloseAction &Action)
{
delete Rst;
Close();
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -