📄 gmth_a.cpp
字号:
GetDataFromComObject(1);
FillGridWithData();
if(sgGmth->RowCount >1)
{
AnsiString Keystr;
Keystr=seGmthCode->Text+"\t"+ sgGmth->Cells[0][sgGmth->Row];
comServer->LocateItemByKey(Keystr);
GetDataFromComObject(2);
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::GetBill(AnsiString BillID)
{
bool iRow;
iRow=comServer->Find("GmthCode='"+BillID+"'");
if(iRow) //FIND THIS BILL
DisplayBill();
else
{
if(ShowMessageWindow("在数据库中没有查到记录:"+BillID+",要增加吗?",mwsConfirmation)==IDYES)
AddHeadRecord();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::FormClose(TObject *Sender,
TCloseAction &Action)
{
TBillBaseForm::FormClose(Sender,Action);
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::FormShow(TObject *Sender)
{
ClearControl(1,false);
ClearControl(2,false);
ChangeToBrowseState();
MoveToFirst();
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::sgGmthDblClick(TObject *Sender)
{
int iRow;
iRow=sgGmth->Row;
if(iRow == 0)
return;
ChangeToBrowseState(false);
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::ChangeToBrowseState(bool t_browse)
{
if(t_browse){
sgGmth->Visible=true;
fpGmtd->Visible=false;
sgGmth->Align=alClient;
fpGmtd->Align=alNone;
}
else{
sgGmth->Visible=false;
fpGmtd->Visible=true;
sgGmth->Align=alNone;
fpGmtd->Align=alClient;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::btnOKClick(TObject *Sender)
{
try{
if(CurrentState==caAddDetail||CurrentState==caAddBill)
{
if(DetailState==caAddDetail)
comServer->AddItem();
SendDataToComObject(2);
comServer->AddToObject();
ClearControl(2,false);
seGmtdLine->SetFocus();
}
else
ChangeToBrowseState();
}
catch(Exception &e)
{
throw Exception(e.Message);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::btnCancelClick(TObject *Sender)
{
CancelChange();
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::seGmtdGoodsButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="006[物料编码][物料名称][类型][来源方式][计量单位][批量]";
SqlStr+="Select GoodsCode,GoodsName,case GoodsType when 1 then '1-成品' when 2 then '2-半成品' when 3 then '3-材料'";
SqlStr+="when 4 then '4-备用件' when 5 then '5-虚拟件' when 6 then '6-费用件' end";
SqlStr+=" , case GoodsFrom when 1 then '1-采购件' when 2 then '2-制造件' end,GoodsUnitCode,GoodsEoq from sdGoods,sdWsgm where GoodsCode=WsgmGoods and WsgmWo='"+seGmthWo->Text+"' order by GoodsCode";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"物料数据查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
seGmtdGoods->Text=p->ColData[1];
if(InitRsGoods(WideString(seGmtdGoods->Text)))
{
seGmtdGoodsName->Text = GetGoodsValue(gtInitRs,"GoodsName");
scGmtdUnit->LocateKey(GetGoodsValue(gtInitRs,"GoodsUnitCode"));
if(GetGoodsValue(gtInitRs,"GoodsType")!="")
scGmtdGoodsType->ItemIndex=StrToInt(GetGoodsValue(gtInitRs,"GoodsType"))-1;
else
scGmtdGoodsType->ItemIndex=-1;
if(GetGoodsValue(gtInitRs,"GoodsFrom")!="")
scGmtdGoodsFrom->ItemIndex=StrToInt(GetGoodsValue(gtInitRs,"GoodsFrom"))-1;
else
scGmtdGoodsFrom->ItemIndex=-1;
seGmtdGoodsOoq->Text=GetGoodsValue(gtInitRs,"GoodsOoq");
}
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::seGmtdGoodsExit(TObject *Sender)
{
AnsiString tempS;
tempS=seGmtdGoods->Text;
if(!tempS.IsEmpty())
{
if(InitRsGoods(tempS))
{
seGmtdGoodsName->Text=GetGoodsValue(gtInitRs,"GoodsName");
scGmtdUnit->LocateKey(GetGoodsValue(gtInitRs,"GoodsUnitCode"));
if(GetGoodsValue(gtInitRs,"GoodsType")!="")
scGmtdGoodsType->ItemIndex=StrToInt(GetGoodsValue(gtInitRs,"GoodsType"))-1;
else
scGmtdGoodsType->ItemIndex=-1;
if(GetGoodsValue(gtInitRs,"GoodsFrom")!="")
scGmtdGoodsFrom->ItemIndex=StrToInt(GetGoodsValue(gtInitRs,"GoodsFrom"))-1;
else
scGmtdGoodsFrom->ItemIndex=-1;
seGmtdGoodsOoq->Text=GetGoodsValue(gtInitRs,"GoodsOoq");
}
else
::MessageBox(Handle,"输入的物料编码不存在!","错误提示",MB_OK|MB_ICONSTOP);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::seGmthCodeKeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
AnsiString tempS=seGmthCode->Text;
if(Key==13 && CurrentState==caNormal && !tempS.IsEmpty())
{
comServer->LocateByKey(WideString(tempS));
DisplayBill();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::seGmthWoButtonClick(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)
{
seGmthWo->Text=p->ColData[1];
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::seGmtdProcessButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="004[序号][工序代码][工序名称][货位编码]SELECT WrgNo,WrgProcess,ProcessName,WrgLoc FROM sdWrg,sdProcess ";
SqlStr=SqlStr+"where WrgProcess=ProcessCode and WrgWo='"+seGmthWo->Text+"' ORDER BY WrgNo";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"工序资料查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
seGmtdProcess->LocateKey(p->ColData[2]);
//seGmtdDLoc->LocateKey(p->ColData[4]);
seGmtdDLoc->Text= p->ColData[4];
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::seGmtdSLocButtonClick(TObject *Sender)
{
AnsiString SqlStr;
TfrmWnQuery *p;
SqlStr="007[当前月份][货位编码][货位名称][物料编码][物料名称][计量单位][当前数量]";
SqlStr+="select MaccFmonth,MaccLoc,LocName,MaccGoods,MaccGoodsName=GoodsName,MaccUnit=GoodsUnitCode,";
SqlStr+=" MaccAoyQty from sdMacc,sdGoods,sdLg,sdLoc where LocCode=lgLocCode and LocCode=MaccLoc";
SqlStr+=" and LgGoodsCode=MaccGoods and GoodsCode=MaccGoods and MaccFmonth='"+g_sdMMonth+"'";
SqlStr+=" and MaccGoods='"+seGmtdGoods->Text+"' and LocType=1 order by LocCode";
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"存储货位库存查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
seGmtdSLoc->LocateKey(p->ColData[2]);
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::seGmtdQtyButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="003[当前月份][计量单位][库存数量]";
SqlStr+="select MaccFmonth,GoodsUnitCode,MaccAoyQty from sdMacc,sdGoods where MaccGoods=GoodsCode and ";
SqlStr+=" MaccFmonth='"+g_sdMMonth+"' and MaccLoc='"+seGmtdSLoc->ItemData[cbItem2]+"' and MaccGoods='"+seGmtdGoods->Text+"'";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"库存查询",SqlStr);
}
__finally
{
EndWaitForm();
}
p->ShowModal();
delete p;
}
//---------------------------------------------------------------------------
bool __fastcall TfrmGmth_A::BeforeCheck()
{
SetHeadValue("GmthCheck",1);
SetHeadValue("GmthChecker",g_sdUserCode);
SetHeadValue("GmthCheckDate",g_sdCurDate);
return true;
}
//---------------------------------------------------------------------------
bool __fastcall TfrmGmth_A::BeforeUnCheck()
{
SetHeadValue("GmthCheck",0);
SetHeadValue("GmthChecker","");
SetHeadValue("GmthCheckDate",NULL);
return true;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::sgGmthClick(TObject *Sender)
{
if(sgGmth->Row > 0)
{
comServer->LocateItemByKey(seGmthCode->Text+"\t"+sgGmth->TextMatrix[sgGmth->Row][0]);
GetDataFromComObject(2);
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -