📄 gmth_c.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include "Gmth_C.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_C *frmGmth_C;
//---------------------------------------------------------------------------
__fastcall TfrmGmth_C::TfrmGmth_C(TComponent* Owner)
: TBillBaseForm(Owner,euSdGmth_C,"")
{
AutoCtl=seGmthCode;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_C::InitEditControl()
{
ClientGroup->AddComponent(1,false,false,true,fpGmth,fpGmth->Name);
ClientGroup->AddComponent(1,true,true,true,scGmthType,scGmthType->Name);
ClientGroup->AddComponent(1,false,true,true,seGmthCode,seGmthCode->Name);
ClientGroup->AddComponent(1,true,true,true,scGmthFmonth,scGmthFmonth->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);
//
scGmthType->ClearAll();
scGmthType->AddItems("R-工单定额领料","1");
scGmthType->AddItems("W-工单自由领料","2");
scGmthType->AddItems("A-工单工序补料","3");
scGmthType->AddItems("C-共用材料领料","4");
scGmthType->AddItems("D-部门直接领料","5");
//Gmth
FillComboBox(scGmthFmonth,"SELECT FcMonth FROM sdFc order by FcMonth","FcMonth");
FillComboBox(scGmthPosType,"SELECT PosTypeCode,PosTypeName FROM sdPosType where PosTypeFlg=3 order by PosTypeCode","PosTypeName","PosTypeCode");
//Gmtd
FillComboBox(scGmtdUnit,"SELECT UnitName,UnitCode from sdUnit order by UnitCode","UnitName","UnitCode");
FillEdit(seGmtdSLoc,"SELECT LocCode,LocName from sdLoc where LocType=1 order by LocCode","LocName","LocCode");
FillEdit(seGmtdDLoc,"SELECT LocCode,LocName from sdLoc where LocType=2 order by LocCode","LocName","LocCode");
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_C::RefreshUpdateData(int MsgSrc,int MsgType)
{
try
{
switch (MsgSrc)
{
case euSdFc:
if(ShowUpdateMessage(MsgSrc,MsgType)){
StartWaitForm("正在刷新引用数据!");
FillComboBox(scGmthFmonth,"SELECT FcMonth FROM sdFc order by FcMonth","FcMonth");
EndWaitForm();
break;
}
case euSdPosType:
if(ShowUpdateMessage(MsgSrc,MsgType)){
StartWaitForm("正在刷新引用数据!");
FillComboBox(scGmthPosType,"SELECT PosTypeCode,PosTypeName FROM sdPosType order by PosTypeCode","PosTypeName","PosTypeCode");
EndWaitForm();
break;
}
case euSdUnit:
if(ShowUpdateMessage(MsgSrc,MsgType)){
StartWaitForm("正在刷新引用数据!");
FillComboBox(scGmtdUnit,"SELECT UnitName,UnitCode from sdUnit order by UnitCode","UnitName","UnitCode");
EndWaitForm();
break;
}
case euSdLoc:
if(ShowUpdateMessage(MsgSrc,MsgType)){
StartWaitForm("正在刷新引用数据!");
FillEdit(seGmtdSLoc,"SELECT LocCode,LocName from sdLoc WHERE LocType=1 order by LocCode","LocName","LocCode");
FillEdit(seGmtdDLoc,"SELECT LocCode,LocName from sdLoc WHERE LocType=2 order by LocCode","LocName","LocCode");
EndWaitForm();
break;
}
default:
break;
}
}
__finally
{
//AddCode;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_C::ClearControl(int Section,bool BringToNext)
{
if(Section == 1)
{
if(!BringToNext)
{
seGmthCode->Text="";
deGmthDate->Text=g_sdCurDate;
scGmthFmonth->LocateKey(g_sdMMonth);
scGmthPosType->ItemIndex=-1;
scGmthType->ItemIndex=3;
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->ItemIndex=-1;
seGmtdGoodsName->Text="";
scGmtdUnit->ItemIndex=-1;
scGmtdGoodsType->ItemIndex=-1;
scGmtdGoodsFrom->ItemIndex=-1;
seGmtdGoodsOoq->Text="";
seGmtdQty->Text="0.00";
seGmtdDLoc->ItemIndex=-1;
seGmtdSLoc->ItemIndex=-1;
memGmtdDesc->Text="";
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_C::GetDataFromComObject(int Section)
{
if(Section==1)
{
seGmthCode->Text=GetHeadValue(fiGmthCode);
deGmthDate->Text=GetHeadValue(fiGmthDate);
scGmthFmonth->LocateKey(GetHeadValue(fiGmthFmonth));
scGmthPosType->LocateKey(GetHeadValue(fiGmthPosType));
scGmthType->LocateKey(GetHeadValue(fiGmthType));
chkGmthCheck->Checked=GetHeadValue(fiGmthCheck)=="1" ;
if(chkGmthCheck->Checked)
SetCheckToolbarStatus(true);
else
SetCheckToolbarStatus(false);
labChecker->Caption=GetHeadValue(fiGmthChecker);
labCheckDate->Caption=GetHeadValue(fiGmthCheckDate);
memGmthDesc->Text=GetHeadValue(fiGmthDesc);
}
else
{
seGmtdLine->Text=GetDetailValue(fiGmtdLine);
seGmtdGoods->Text=GetDetailValue(fiGmtdGoods);
g_sdRsGoods->LocateByKey(WideString(GetDetailValue(fiGmtdGoods)));
seGmtdGoodsName->Text=GetGoodsValue("GoodsName");
scGmtdUnit->LocateKey(GetGoodsValue("GoodsUnitCode"));
if(GetGoodsValue("GoodsType")!="")
scGmtdGoodsType->ItemIndex=StrToInt(GetGoodsValue("GoodsType"))-1;
else
scGmtdGoodsType->ItemIndex=-1;
if(GetGoodsValue("GoodsFrom")!="")
scGmtdGoodsFrom->ItemIndex=StrToInt(GetGoodsValue("GoodsFrom"))-1;
else
scGmtdGoodsFrom->ItemIndex=-1;
seGmtdGoodsOoq->Text=GetGoodsValue("GoodsOoq");
seGmtdQty->Text=GetDetailValue(fiGmtdQty);
seGmtdDLoc->LocateKey(GetDetailValue(fiGmtdDLoc));
seGmtdSLoc->LocateKey(GetDetailValue(fiGmtdSLoc));
memGmtdDesc->Text=GetDetailValue(fiGmtdDesc);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_C::SendDataToComObject(int Section)
{
if(Section==1)
{
SetHeadValue(fiGmthCode,seGmthCode->Text);
SetHeadValue(fiGmthDate,deGmthDate->Text);
SetHeadValue(fiGmthFmonth,scGmthFmonth->Text);
SetHeadValue(fiGmthPosType,scGmthPosType->ItemData[1]);
SetHeadValue(fiGmthUser,labUser->Caption);
SetHeadValue(fiGmthDesc,memGmthDesc->Text);
}
else
{
SetDetailValue(fiGmtdCode,seGmthCode->Text);
SetDetailValue(fiGmtdLine,seGmtdLine->Text);
SetDetailValue(fiGmtdGoods,seGmtdGoods->Text);
SetDetailValue(fiGmtdQty,seGmtdQty->Text);
SetDetailValue(fiGmtdSLoc,seGmtdSLoc->ItemData[1]);
SetDetailValue(fiGmtdDLoc,seGmtdDLoc->ItemData[1]);
SetDetailValue(fiGmtdDesc,memGmtdDesc->Text);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_C::WaitUserInput(int Section)
{
if(Section == 1){
if(seGmthCode->Enabled)
seGmthCode->SetFocus();
else
deGmthDate->SetFocus();
}
else
{
ChangeToBrowseState(false);
if(seGmtdLine->Enabled)
seGmtdLine->SetFocus();
}
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmGmth_C::GetDataToGrid()
{
AnsiString ItemStr,s;
s=GetDetailValue(fiGmtdUnit);
scGmtdUnit->LocateKey(s);
ItemStr=GetDetailValue(fiGmtdLine)+
"\t"+GetDetailValue(fiGmtdGoods)+
"\t"+scGmtdUnit->ItemData[0]+
"\t"+GetDetailValue(fiGmtdQty)+
"\t"+GetDetailValue(fiGmtdSLoc)+
"\t"+GetDetailValue(fiGmtdDLoc);
return ItemStr;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_C::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_C::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_C::DisplayBill()
{
if(comServer->RecordCount>0)
{
GetDataFromComObject(1); //Gmth
FillGridWithData();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -