📄 pmu.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include "Pmu.h"
#include "gvar.h"
#include "wnquery.h"
#include "commfunction.h"
#include "sdenumtype.h"
//---------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "DateEdit"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"
TfrmPmu *frmPmu;
//---------------------------------------------------------------------------
__fastcall TfrmPmu::TfrmPmu(TComponent* Owner)
: TStdBaseForm(Owner)
{
}
//---------------------------------------------------------------------------
__fastcall TfrmPmu::TfrmPmu(TComponent* Owner,int Checked,AnsiString WepCode,int WepdLine,AnsiString PmuWo)
: TStdBaseForm(Owner)
{
AnsiString SqlStr,ItemStr;
FChecked=Checked;
FPmuWepCode=WepCode;
FPmuWepdLine=WepdLine;
FPmuWoCode=PmuWo;
TComResultSet *RsPmu;
SqlStr="select WsgmGoods,GoodsName,WsgmLoc,WsgmGQty,WsgmUQty,WsgmRQty,WsgmLQty,PmuUQty=Coalesce(PmuUQty,0),PmuDQty=Coalesce(PmuDQty,0),PmuUdr=coalesce(PmuUdr,'') from sdWsgm,sdGoods,sdPmu where WsgmGoods=GoodsCode ";
SqlStr+=" and WsgmWo='"+PmuWo+"' and WsgmWo*=PmuWoCode and WsgmGoods*=PmuGoods and PmuWepCode='"+FPmuWepCode+"'";
SqlStr+=" and PmuWepdLine="+IntToStr(FPmuWepdLine)+" order by WsgmGoods";
sePmuWepCode->Text=WepCode;
sePmuWepdLine->Text=WepdLine;
sePmuWoCode->Text=PmuWo;
GroupBox1->Enabled=false;
RsPmu=NewResultSet();
RsPmu->Open(SqlStr,"");
RsPmu->MoveFirst();
sgPmu->RowCount=1;
while(RsPmu->Eof==0)
{
ItemStr = RsPmu->FieldByName("WsgmGoods")+
"\t" +RsPmu->FieldByName("Goodsname")+
"\t" +RsPmu->FieldByName("WsgmLoc")+
"\t" +RsPmu->FieldByName("WsgmGQty")+
"\t" +RsPmu->FieldByName("WsgmUQty")+
"\t" +RsPmu->FieldByName("WsgmRQty")+
"\t" +RsPmu->FieldByName("WsgmLQty")+
"\t" +RsPmu->FieldByName("PmuUQty")+
"\t" +RsPmu->FieldByName("PmuDQty")+
"\t" +RsPmu->FieldByName("PmuUdr");
sgPmu->AddItem(ItemStr);
RsPmu->MoveNext();
}
RsPmu->Close();
delete RsPmu;
if(FChecked==1)
{
bbOK->Enabled=false;
stPmuCheck->Visible=true;
sgPmu->ReadOnly=true;
}
else
{
bbOK->Enabled=false /*true*/;
stPmuCheck->Visible=false;
sgPmu->ReadOnly=true /*false*/;
}
if(sgPmu->RowCount<2)
bbOK->Enabled=false;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPmu::sgPmuDblClick(TObject *Sender)
{
AnsiString SqlStr;
TfrmWnQuery *p;
if(sgPmu->Col==9 && sgPmu->Row>0)
{
if(FChecked!=1)
{
SqlStr="002[原因代码][损坏原因]SELECT UdrCode,UdrDesc from sdUdr order by UdrCode";
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"损坏原因查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
sgPmu->Cells[9][sgPmu->Row]=p->ColData[1];
}
delete p;
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPmu::bbOKClick(TObject *Sender)
{
TComServer *comServer;
int ErrNum;
try
{
StartWaitForm("正在保存工序材料消耗数据,请稍候...");
if(sgPmu->RowCount>1)
{
try
{
comServer=NewDcomAppSvr(euSdPmu);
comServer->AddNew();
for(int i=1;i<sgPmu->RowCount;i++)
{
WriteFieldValue(comServer,fiPmuWepCode,FPmuWepCode);
WriteFieldValue(comServer,fiPmuWepdLine,FPmuWepdLine);
WriteFieldValue(comServer,fiPmuWoCode,FPmuWoCode);
WriteFieldValue(comServer,fiPmuGoods,sgPmu->Cells[0][i]);
WriteFieldValue(comServer,fiPmuLoc,sgPmu->Cells[2][i]);
if(sgPmu->Cells[7][i]!="")
WriteFieldValue(comServer,fiPmuUQty,sgPmu->Cells[7][i]);
else
WriteFieldValue(comServer,fiPmuUQty,"0");
if(sgPmu->Cells[8][i]!="")
WriteFieldValue(comServer,fiPmuDQty,sgPmu->Cells[8][i]);
else
WriteFieldValue(comServer,fiPmuDQty,"0");
WriteFieldValue(comServer,fiPmuUdr,sgPmu->Cells[9][i]);
WriteFieldValue(comServer,fiPmuDate,g_sdCurDate);
WriteFieldValue(comServer,fiPmuUser,g_sdUserCode);
comServer->AddToObject();
}
comServer->Post();
}
catch(Exception &e)
{
this->ModalResult=0;
delete comServer;
throw Exception(e.Message);
}
}
}
__finally
{
EndWaitForm();
}
Close();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPmu::bbCancelClick(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -