📄 pdmh.cpp
字号:
comServer->LocateItemByIndex(i);
RefreshGridData(0);
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPdmh::DisplayBill()
{
if(comServer->RecordCount>0)
{
GetDataFromComObject(1);
FillGridWithData();
if(sgPdmh->RowCount >1)
{
AnsiString Keystr;
Keystr=sgPdmh->Cells[0][sgPdmh->Row];
comServer->LocateItemByKey(WideString(Keystr));
GetDataFromComObject(2);
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPdmh::GetBill(AnsiString BillID)
{
bool iRow;
iRow=comServer->Find("PdmhCode='"+BillID+"'");
if(iRow) //FIND THIS BILL
DisplayBill();
else
{
if(ShowMessageWindow("在数据库中没有查到记录:"+BillID+",要增加吗?",mwsConfirmation)==IDYES)
AddHeadRecord();
}
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPdmh::GetHeadValue(int Index)
{
return ReadFieldValue(comServer,Index);
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPdmh::GetDetailValue(int Index)
{
return ReadItemValue(comServer,Index);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPdmh::SetHeadValue(int Index,AnsiString Value)
{
WriteFieldValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPdmh::SetDetailValue(int Index,AnsiString Value)
{
WriteItemValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPdmh::FormShow(TObject *Sender)
{
ClearControl(1,false);
ClearControl(2,false);
ChangeToBrowseState();
MoveToFirst();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPdmh::sgPdmhSelectCell(TObject *Sender, int ACol,
int ARow, bool &CanSelect)
{
if(ARow > 0)
comServer->LocateItemByKey(WideString(sgPdmh->TextMatrix[ARow][0]));
if(!comServer->Eof)
GetDataFromComObject(2);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPdmh::sgPdmhDblClick(TObject *Sender)
{
int iRow;
iRow=sgPdmh->Row;
if(iRow == 0)
return;
ChangeToBrowseState(false);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPdmh::ChangeToBrowseState(bool t_browse)
{
if(t_browse)
{
sgPdmh->Visible=true;
fpPdmd->Visible=false;
sgPdmh->Align=alClient;
fpPdmd->Align=alNone;
}
else
{
sgPdmh->Visible=false;
fpPdmd->Visible=true;
sgPdmh->Align=alNone;
fpPdmd->Align=alClient;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPdmh::btnOKClick(TObject *Sender)
{
try{
if(CurrentState==caAddDetail || CurrentState==caAddBill)
{
if(DetailState==caAddDetail)
comServer->AddItem();
SendDataToComObject(2);
comServer->AddToObject();
ClearControl(2,false);
sePdmdLine->SetFocus();
}
else
ChangeToBrowseState();
}
catch(Exception &e)
{
throw Exception(e.Message);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPdmh::btnCancelClick(TObject *Sender)
{
CancelChange();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPdmh::sePdmdGoodsButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="007[物料编码][物料名称][计量单位][领用数量][消耗数量][退料数量][已报废数]SELECT ";
SqlStr+=" WmdGoods,GoodsName,WmdUnit,WmdQty,WmdUQty,WmdBQty,WmdLQty from sdWmd,sdGoods where ";
SqlStr+=" GoodsCode=WmdGoods and WmdWoCode='"+sePdmhWo->Text+"' and WmdProcess='"+sePdmdProcess->ItemData[cbItem2]+"' order by WmdGoods";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"工序物料查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
sePdmdGoods->Text=p->ColData[1];
seGoodsName->Text=p->ColData[2];
scGoodsUnit->LocateKey(p->ColData[3]);
if(g_sdRsGoods->LocateByKey(WideString(sePdmdGoods->Text))==0)
{
seGoodsSpec->Text=GetGoodsValue("GoodsSpec");
seGoodsModel->Text=GetGoodsValue("GoodsModel");
scGoodsType->LocateKey(GetGoodsValue("GoodsType"));
scGoodsFrom->LocateKey(GetGoodsValue("GoodsFrom"));
}
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPdmh::sePdmdGoodsExit(TObject *Sender)
{
AnsiString tempS;
tempS=sePdmdGoods->Text;
if(!tempS.IsEmpty())
{
if(g_sdRsGoods->LocateByKey(WideString(tempS))==0){
seGoodsName->Text=GetGoodsValue("GoodsName");
scGoodsUnit->LocateKey(GetGoodsValue("GoodsUnitCode"));
seGoodsSpec->Text=GetGoodsValue("GoodsSpec");
seGoodsModel->Text=GetGoodsValue("GoodsModel");
if(GetGoodsValue("GoodsType")!="")
scGoodsType->ItemIndex=StrToInt(GetGoodsValue("GoodsType"))-1;
else
scGoodsType->ItemIndex=-1;
if(GetGoodsValue("GoodsFrom")!="")
scGoodsFrom->ItemIndex=StrToInt(GetGoodsValue("GoodsFrom"))-1;
else
scGoodsFrom->ItemIndex=-1;
}
else
::MessageBox(Handle,"输入的物料编码不存在!","错误提示",MB_OK|MB_ICONSTOP);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPdmh::sePdmhCodeKeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
AnsiString tempS=sePdmhCode->Text;
if(Key==13 && CurrentState==caNormal && !tempS.IsEmpty())
{
comServer->LocateByKey(WideString(tempS));
DisplayBill();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPdmh::sePdmhWoButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="006[加工单号][加工件码][要求数量][要求日期][订单单号][订单行号]SELECT WoCode,WoGoods,WoQty,WoRDate,";
SqlStr=SqlStr+"WoSoCode,WoSodLine from sdWo where WoCheck=1 and WoClose=0 ORDER BY WoCode";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"加工订单查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
sePdmhWo->Text=p->ColData[1];
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPdmh::sePdmdProcessButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="004[工序代码][工序名称][在制货位][货位名称]SELECT WrgProcess,ProcessName,WrgLoc,LocName FROM sdWrg,sdProcess,";
SqlStr+="sdLoc where WrgProcess=ProcessCode and WrgLoc=LocCode and WrgWo='"+sePdmhWo->Text+"' ORDER BY WrgProcess";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"工单工序资料查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
sePdmdProcess->LocateKey(p->ColData[1]);
sePdmdLoc->LocateKey(p->ColData[3]);
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPdmh::sePdmdQtyButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="007[物料编码][物料名称][计量单位][领用数量][消耗数量][退料数量][已报废数]SELECT ";
SqlStr+=" WmdGoods,GoodsName,WmdUnit,WmdQty,WmdUQty,WmdBQty,WmdLQty from sdWmd,sdGoods where ";
SqlStr+=" GoodsCode=WmdGoods and WmdWoCode='"+sePdmhWo->Text+"' and WmdProcess='"+sePdmdProcess->ItemData[cbItem2]+"' order by WmdGoods";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"工序物料查询",SqlStr);
}
__finally
{
EndWaitForm();
}
p->ShowModal();
delete p;
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -