📄 gmth_a.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include "Gmth_A.h"
//---------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "BillBaseForm"
#pragma link "DateEdit"
#pragma link "fpanel"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"
TfrmGmth_A *frmGmth_A;
//---------------------------------------------------------------------------
__fastcall TfrmGmth_A::TfrmGmth_A(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
: TBillBaseForm(Owner,chWnd,MidCode,WhereStr)
{
//AutoCtl=seGmthCode;
SetAutoCodeString(seGmthCode,"ACM-007");
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::InitEditControl()
{
ClientGroup->AddComponent(1,false,false,true,fpGmth,fpGmth->Name);
ClientGroup->AddComponent(1,true,true,true,scGmthType,scGmthType->Name);
ClientGroup->AddComponent(1,false,true,false,seGmthCode,seGmthCode->Name);
ClientGroup->AddComponent(1,true,true,true,scGmthFmonth,scGmthFmonth->Name);
ClientGroup->AddComponent(1,false,true,true,seGmthWo,seGmthWo->Name);
ClientGroup->AddComponent(2,false,false,true,fpGmtd,fpGmtd->Name);
ClientGroup->AddComponent(2,false,false,false,btnCancel,btnCancel->Name);
ClientGroup->AddComponent(2,false,true,true,btnOK,btnOK->Name);
ClientGroup->AddComponent(2,false,true,true,seGmtdLine,seGmtdLine->Name);
ClientGroup->AddComponent(2,true,true,true,plGmtdGoods,plGmtdGoods->Name);
ClientGroup->AddComponent(2,true,true,true,seGmtdDLoc,seGmtdDLoc->Name);
ClientGroup->AddComponent(2,false,true,true,seGmtdGoods,seGmtdGoods->Name);
//
scGmthType->ClearAll();
scGmthType->AddItems("R-工单定额领料","1");
scGmthType->AddItems("W-工单自由领料","2");
scGmthType->AddItems("A-工单工序补料","3");
scGmthType->AddItems("C-共用材料领料","4");
scGmthType->AddItems("D-部门直接领料","5");
//Gmth
FillComboBox(Handle,scGmthFmonth,"SELECT FcMonth FROM sdFc order by FcMonth","FcMonth");
FillComboBox(Handle,scGmthPosType,"SELECT PosTypeCode,PosTypeName FROM sdPosType where PosTypeFlg=3 order by PosTypeCode","PosTypeName","PosTypeCode");
//Gmtd
FillEdit(Handle,seGmtdProcess,"SELECT ProcessCode,ProcessName from sdProcess order by ProcessCode","ProcessName","ProcessCode");
FillEdit(Handle,seGmtdSLoc,"SELECT LocCode,LocName from sdLoc where LocType=1 order by LocCode","LocName","LocCode");
FillEdit(Handle,seGmtdDLoc,"SELECT LocCode,LocName from sdLoc where LocType=2 order by LocCode","LocName","LocCode");
FillComboBox(Handle,scGmtdUnit,"SELECT UnitName,UnitCode from sdUnit order by UnitCode","UnitName","UnitCode");
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::RefreshUpdateData(int MsgSrc,int MsgType)
{
/*
try
{
switch (MsgSrc)
{
case euSdFc:
if(ShowUpdateMessage(MsgSrc,MsgType)){
StartWaitForm("正在刷新引用数据!");
FillComboBox(Handle,scGmthFmonth,"SELECT FcMonth FROM sdFc order by FcMonth","FcMonth");
EndWaitForm();
break;
}
case euSdPosType:
if(ShowUpdateMessage(MsgSrc,MsgType)){
StartWaitForm("正在刷新引用数据!");
FillComboBox(Handle,scGmthPosType,"SELECT PosTypeCode,PosTypeName FROM sdPosType order by PosTypeCode","PosTypeName","PosTypeCode");
EndWaitForm();
break;
}
case euSdUnit:
if(ShowUpdateMessage(MsgSrc,MsgType)){
StartWaitForm("正在刷新引用数据!");
FillComboBox(Handle,scGmtdUnit,"SELECT UnitName,UnitCode from sdUnit order by UnitCode","UnitName","UnitCode");
EndWaitForm();
break;
}
case euSdLoc:
if(ShowUpdateMessage(MsgSrc,MsgType)){
StartWaitForm("正在刷新引用数据!");
FillEdit(Handle,seGmtdSLoc,"SELECT LocCode,LocName from sdLoc where LocType=1 order by LocCode","LocName","LocCode");
FillEdit(Handle,seGmtdDLoc,"SELECT LocCode,LocName from sdLoc where LocType=2 order by LocCode","LocName","LocCode");
EndWaitForm();
break;
}
case euSdProcess:
if(ShowUpdateMessage(MsgSrc,MsgType)){
StartWaitForm("正在刷新引用数据!");
FillEdit(Handle,seGmtdProcess,"SELECT ProcessCode,ProcessName from sdProcess order by ProcessCode","ProcessName","ProcessCode");
EndWaitForm();
break;
}
default:
break;
}
}
__finally
{
//EndWaitForm();
}
*/
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::ClearControl(int Section,bool BringToNext)
{
if(Section == 1){
if(!BringToNext){
seGmthCode->Text="";
deGmthDate->Text=g_sdCurDate;
scGmthFmonth->LocateKey(g_sdMMonth);
scGmthPosType->ItemIndex=-1;
scGmthPosType->Text="";
scGmthType->ItemIndex=2;
seGmthWo->Text = "";
labUser->Caption=g_sdUserCode;
chkGmthCheck->Checked=false;
labChecker->Caption="";
labCheckDate->Caption="";
memGmthDesc->Text="";
}
sgGmth->RowCount=1;
}
else{
if(!BringToNext){
seGmtdLine->Text=AnsiString(comServer->ItemCount+1);
seGmtdGoods->Text="";
seGmtdGoodsName->Text="";
scGmtdUnit->ItemIndex=-1;
scGmtdGoodsType->ItemIndex=-1;
scGmtdGoodsFrom->ItemIndex=-1;
seGmtdGoodsOoq->Text="";
seGmtdQty->Text="0.00";
seGmtdProcess->ItemIndex=-1;
seGmtdDLoc->Text="";//ItemIndex=-1;
seGmtdSLoc->ItemIndex=-1;
memGmtdDesc->Text="";
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::GetDataFromComObject(int Section)
{
if(Section==1)
{
seGmthCode->Text=GetHeadValue("GmthCode");
deGmthDate->Text=GetHeadValue("GmthDate");
scGmthFmonth->LocateKey(GetHeadValue("GmthFmonth"));
scGmthPosType->LocateKey(GetHeadValue("GmthPosType"));
scGmthType->LocateKey(GetHeadValue("GmthType"));
seGmthWo->Text=GetHeadValue("GmthWoCode");
chkGmthCheck->Checked=GetHeadValue("GmthCheck")=="1" ;
if(chkGmthCheck->Checked)
SetCheckToolbarStatus(true);
else
SetCheckToolbarStatus(false);
labChecker->Caption=GetHeadValue("GmthChecker");
labCheckDate->Caption=GetHeadValue("GmthCheckDate");
memGmthDesc->Text=GetHeadValue("GmthDesc");
}
else
{
seGmtdLine->Text=GetDetailValue("GmtdLine");
seGmtdGoods->Text=GetDetailValue("GmtdGoods");
InitRsGoods(GetDetailValue("GmtdGoods"));
// l_RsGoods->LocateByKey(GetDetailValue("GmtdGoods"));
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");
seGmtdQty->Text=GetDetailValue("GmtdQty");
seGmtdProcess->LocateKey(GetDetailValue("GmtdProcess"));
seGmtdDLoc->Text=GetDetailValue("GmtdDLoc");//LocateKey(GetDetailValue("GmtdDLoc"));
seGmtdSLoc->LocateKey(GetDetailValue("GmtdSLoc"));
memGmtdDesc->Text=GetDetailValue("GmtdDesc");
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::SendDataToComObject(int Section)
{
if(Section==1)
{
SetHeadValue("GmthCode",seGmthCode->Text);
SetHeadValue("GmthDate",deGmthDate->Text);
SetHeadValue("GmthFmonth",scGmthFmonth->Text);
SetHeadValue("GmthPosType",scGmthPosType->ItemData[1]);
SetHeadValue("GmthWoCode",seGmthWo->Text);
SetHeadValue("GmthUser",labUser->Caption);
SetHeadValue("GmthDesc",memGmthDesc->Text);
}
else
{
SetDetailValue("GmtdCode",seGmthCode->Text);
SetDetailValue("GmtdLine",seGmtdLine->Text);
SetDetailValue("GmtdGoods",seGmtdGoods->Text);
SetDetailValue("GmtdGoodsName",seGmtdGoodsName->Text);
SetDetailValue("GmtdUnit",scGmtdUnit->ItemData[1]);
SetDetailValue("GmtdQty",seGmtdQty->Text);
SetDetailValue("GmtdWoCode",seGmthWo->Text);
SetDetailValue("GmtdProcess",seGmtdProcess->ItemData[1]);//领料工序
SetDetailValue("GmtdDLoc",seGmtdDLoc->Text);//ItemData[1]); //领料货位
SetDetailValue("GmtdSLoc",seGmtdSLoc->ItemData[1]); //发料货位
SetDetailValue("GmtdDesc",memGmtdDesc->Text);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::WaitUserInput(int Section)
{
if(Section ==1){
if(CurrentState==caAddHead)
seGmthCode->SetFocus();
else
deGmthDate->SetFocus();
}
else
{
ChangeToBrowseState(false);
if(seGmtdLine->Enabled)
seGmtdLine->SetFocus();
}
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmGmth_A::GetDataToGrid()
{
AnsiString ItemStr,s,s1;
s1=GetDetailValue("GmtdUnit");
scGmtdUnit->LocateKey(s1);
ItemStr=GetDetailValue("GmtdLine")+
"\t"+GetDetailValue("GmtdGoods")+
"\t"+GetDetailValue("GmtdGoodsName")+
"\t"+GetDetailValue("GmtdGoodsSpec")+
"\t"+scGmtdUnit->ItemData[0]+
"\t"+GetDetailValue("GmtdQty")+
"\t"+GetDetailValue("GmtdSLoc")+
"\t"+GetDetailValue("GmtdDLoc")+
"\t"+GetDetailValue("GmtdProcess");
return ItemStr;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::RefreshGridData(int mAction)
{
int i;
AnsiString ItemStr=GetDataToGrid();
switch(mAction)
{
case 0: //Add
sgGmth->AddItem(ItemStr);
sgGmth->Row=sgGmth->RowCount-1;
break;
case 1: //Edit
sgGmth->ChangeItem(ItemStr,sgGmth->Row);
break;
case 2: //Delete
sgGmth->RemoveItem(sgGmth->Row);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::FillGridWithData()
{
int i;
AnsiString ItemStr;
sgGmth->RowCount=1;
if(comServer->RecordCount > 0)
{
for (i=0;i<comServer->ItemCount;i++)
{
comServer->LocateItemByIndex(i);
RefreshGridData(0);
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::DisplayBill()
{
if(comServer->RecordCount>0){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -