📄 wsgm.cpp
字号:
}
//---------------------------------------------------------------------------
void __fastcall TfrmWsgm::RefreshGridData(int mAction)
{
int i;
AnsiString m_ItemStr;
m_ItemStr=GetDataToGrid();
switch(mAction)
{
case 0: //Add
sgWsgm->AddItem(m_ItemStr);
sgWsgm->Row=sgWsgm->RowCount-1;
break;
case 1: //Edit
i = sgWsgm->Row;
sgWsgm->ChangeItem(m_ItemStr,i);
break;
case 2: //Del
sgWsgm->RemoveItem(sgWsgm->Row);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmWsgm::FillGridWithData()
{
AnsiString m_ItemStr;
comServer->MoveFirst();
sgWsgm->RowCount = 1;
while(comServer->Eof == 0)
{
m_ItemStr =GetDataToGrid();
sgWsgm->AddItem(m_ItemStr);
comServer->MoveNext();
}
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmWsgm::GetDataToGrid()
{
AnsiString m_ItemStr,s;
s=GetFieldValue(fiWsgmUnit);
scWsgmUnit->LocateKey(s);
m_ItemStr = GetFieldValue(fiWsgmSn) +
"\t" + GetFieldValue(fiWsgmGoods)+
"\t" + scWsgmUnit->ItemData[0]+
"\t" + GetFieldValue(fiWsgmQty) +
"\t" + GetFieldValue(fiWsgmShl) ;
return(m_ItemStr);
}
//---------------------------------------------------------------------------
void __fastcall TfrmWsgm::FormShow(TObject *Sender)
{
labWsgmWo->Caption=FWsgmWoCode;
labWsgmPgoods->Caption=FWsgmWoGoods;
FillGridWithData();
comServer->MoveFirst();
GetDataFromComObject();
if(FWsgmFrom==1)
{
tbAddHead->Enabled=false;
tbDeleteHead->Enabled=false;
tbEditHead->Enabled=false;
sbtWsgmCopy->Enabled=false;
}
else
tbGenrate->Visible=false;
}
//---------------------------------------------------------------------------
void __fastcall TfrmWsgm::FormClose(TObject *Sender,
TCloseAction &Action)
{
SetInifileValue(this->Name,"AutoQuery","1",ExtractFileDir(Application->ExeName)+"\\sdFormSet.dat");
TRecBaseForm::FormClose(Sender,Action);
}
//---------------------------------------------------------------------------
void __fastcall TfrmWsgm::seWsgmGoodsButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="007[物料编码][物料名称][版本号][型号][类型][来源][计量单位]";
SqlStr+="Select GoodsCode,GoodsName,GoodsVer,GoodsModel,GoodsType,GoodsFrom,GoodsUnitCode from sdGoods where GoodsType<>1 and order by GoodsCode";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"子件物料数据查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
seWsgmGoods->Text=p->ColData[1];
seWsgmGoodsName->Text=p->ColData[2];
if(g_sdRsGoods->LocateByKey(WideString(seWsgmGoods->Text))==0)
{
scWsgmUnit->LocateKey(GetGoodsValue("GoodsUnitCode"));
if(GetGoodsValue("GoodsBatch")=="1")
scWsgmBatch->Enabled=true;
else
scWsgmBatch->Enabled=false;
}
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmWsgm::GenrateDoc()
{
AnsiString FParam;
int FErrNum;
if(FWsgmFrom!=1)
{
ShowMessage("非物料清单方式不能生成!");
return;
}
if(comServer->RecordCount>0)
{
if(MessageDlg("是否重新生成工单物料表?", mtWarning, TMsgDlgButtons() << mbYes << mbNo, 0) == mrYes)
{
try
{
StartWaitForm("正在生成工单物料表,请稍候...");
FParam=FWsgmWoCode+'\t'+g_sdUserCode;
comServer->Execute(FParam);
FillGridWithData();
GetDataFromComObject();
}
__finally
{
EndWaitForm();
}
}
}
else
{
FParam=FWsgmWoCode+'\t'+g_sdUserCode;
try
{
StartWaitForm("正在生成工单物料表,请稍候...");
comServer->Execute(FParam);
FillGridWithData();
GetDataFromComObject();
}
__finally
{
EndWaitForm();
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmWsgm::muCancelClick(TObject *Sender)
{
TRecBaseForm::muCancelClick(Sender);
if(FWsgmFrom==1)
{
tbAddHead->Enabled=false;
tbDeleteHead->Enabled=false;
tbEditHead->Enabled=false;
sbtWsgmCopy->Enabled=false;
}
else
tbGenrate->Enabled=false;
}
//---------------------------------------------------------------------------
void __fastcall TfrmWsgm::muSaveClick(TObject *Sender)
{
TRecBaseForm::muSaveClick(Sender);
if(FWsgmFrom==1)
{
tbAddHead->Enabled=false;
tbDeleteHead->Enabled=false;
tbEditHead->Enabled=false;
sbtWsgmCopy->Enabled=false;
}
else
tbGenrate->Enabled=false;
}
//---------------------------------------------------------------------------
void __fastcall TfrmWsgm::sgWsgmClick(TObject *Sender)
{
int ARow;
ARow=sgWsgm->Row;
if(ARow > 0)
comServer->LocateByKey(WideString(Trim(labWsgmWo->Caption)+Trim(sgWsgm->TextMatrix[ARow][1])));
if(!comServer->Eof)
GetDataFromComObject();
}
//---------------------------------------------------------------------------
void __fastcall TfrmWsgm::sbtWsgmCopyClick(TObject *Sender)
{
//保存复制前的RecordCount
int BefoCount=comServer->RecordCount;
try{
StartWaitForm("正在启动<配套表复制>界面...");
WsgmCopyfrm = new TfrmWsgmCopy(this,FWsgmWoCode);
WsgmCopyfrm->SetcomServer(comServer);
EndWaitForm();
WsgmCopyfrm->ShowModal();
if(comServer->RecordCount>BefoCount){
FillGridWithData();
SetControlState(caSave);
}
else
CancelChange();
}
__finally{
delete WsgmCopyfrm;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmWsgm::seWsgmGoodsKeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
AnsiString tempS=seWsgmGoods->Text;
if(Key==13 && !tempS.IsEmpty())
{
if(g_sdRsGoods->LocateByKey(WideString(tempS))==0)
{
seWsgmGoodsName->Text=GetGoodsValue("GoodsName");
scWsgmUnit->LocateKey(GetGoodsValue("GoodsUnitCode"));
if(GetGoodsValue("GoodsBatch")=="1")
scWsgmBatch->Enabled=true;
else
scWsgmBatch->Enabled=false;
}
else
throw Exception("录入的物料编码:'"+tempS+"'不存在!");
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -