📄 wsgm.cpp
字号:
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("WsgmUnit");
scWsgmUnit->LocateKey(s);
m_ItemStr = GetFieldValue("WsgmSn") +
"\t" + GetFieldValue("WsgmGoods")+
"\t" + GetFieldValue("WsgmGoodsName")+
"\t" + scWsgmUnit->ItemData[0]+
"\t" + GetFieldValue("WsgmQty") +
"\t" + GetFieldValue("WsgmShl") ;
return(m_ItemStr);
}
//---------------------------------------------------------------------------
void __fastcall TfrmWsgm::FormShow(TObject *Sender)
{
labWsgmWo->Caption=FWsgmWoCode;
labWsgmPgoods->Caption=FWsgmWoGoods;
FillGridWithData();
comServer->MoveFirst();
GetDataFromComObject();
tbControl->Enabled=false;
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)
{
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";
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(InitRsGoods(WideString(seWsgmGoods->Text)))
{
scWsgmUnit->LocateKey(GetGoodsValue(gtInitRs,"GoodsUnitCode"));
if(GetGoodsValue(gtInitRs,"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);
Query->Close();
Query->Execute("exec sdWsgm_Genrate '"+FWsgmWoCode+"','"+g_sdUserCode+"'");
// Query->ExecSQL();
comServer->Query();
FillGridWithData();
GetDataFromComObject();
}
__finally
{
EndWaitForm();
}
}
}
else
{
// FParam=FWsgmWoCode+'\t'+g_sdUserCode;
try
{
StartWaitForm("正在生成工单物料表,请稍候...");
// comServer->Execute(FParam);
Query->Close();
// Query->SQL->Clear();
// Query->SQL->Add("exec sdWsgm_Genrate '"+FWsgmWoCode+"','"+g_sdUserCode+"'");
// Query->ExecSQL();
Query->Execute("exec sdWsgm_Genrate '"+FWsgmWoCode+"','"+g_sdUserCode+"'");
comServer->Query();
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(Trim(labWsgmWo->Caption)+"\t"+Trim(sgWsgm->TextMatrix[ARow][1]));
if(comServer->RecordCount>0)
GetDataFromComObject();
}
//---------------------------------------------------------------------------
void __fastcall TfrmWsgm::sbtWsgmCopyClick(TObject *Sender)
{
//保存复制前的RecordCount
int BefoCount=comServer->RecordCount;
try{
StartWaitForm("正在启动<配套表复制>界面...");
WsgmCopyfrm = new TfrmWsgmCopy(this);
WsgmCopyfrm->FWsgmCopyWo=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(InitRsGoods(WideString(tempS)))
{
seWsgmGoodsName->Text=GetGoodsValue(gtInitRs,"GoodsName");
scWsgmUnit->LocateKey(GetGoodsValue(gtInitRs,"GoodsUnitCode"));
if(GetGoodsValue(gtInitRs,"GoodsBatch")=="1")
scWsgmBatch->Enabled=true;
else
scWsgmBatch->Enabled=false;
}
else
throw Exception("录入的物料编码:'"+tempS+"'不存在!");
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmWsgm::muEditDetailClick(TObject *Sender)
{
sgWsgmClick(Sender);
if(GetFieldValue("WsgmGQty")>0)
ShowMessage("本物料已领料,不能修改!");
else
{
TRecBaseForm::muEditDetailClick(Sender);
seWsgmSn->Enabled=true;
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -