📄 pdmh.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include "Pdmh.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"
TfrmPdmh *frmPdmh;
//---------------------------------------------------------------------------
__fastcall TfrmPdmh::TfrmPdmh(TComponent* Owner)
: TBillBaseForm(Owner,euSdPdmh,"")
{
AutoCtl=sePdmhCode;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPdmh::InitEditControl()
{
ClientGroup->AddComponent(1,false,false,true,fpPdmh,fpPdmh->Name);
ClientGroup->AddComponent(1,false,true,true,sePdmhCode,sePdmhCode->Name);
ClientGroup->AddComponent(1,true,true,true,scPdmhFmonth,scPdmhFmonth->Name);
ClientGroup->AddComponent(1,false,true,true,sePdmhWo,sePdmhWo->Name);
ClientGroup->AddComponent(2,false,false,true,fpPdmd,fpPdmd->Name);
ClientGroup->AddComponent(2,false,true,true,sePdmdProcess,sePdmdProcess->Name);
ClientGroup->AddComponent(2,true,true,true,sePdmdLoc,sePdmdLoc->Name);
ClientGroup->AddComponent(2,false,false,false,btnCancel,btnCancel->Name);
ClientGroup->AddComponent(2,false,true,true,btnOK,btnOK->Name);
ClientGroup->AddComponent(2,true,true,true,plPdmdGoods,plPdmdGoods->Name);
//Pdmh
FillComboBox(scPdmhFmonth,"SELECT FcMonth FROM sdFc order by FcMonth","FcMonth");
FillComboBox(scPdmhPosType,"SELECT PosTypeCode,PosTypeName FROM sdPosType where PosTypeFlg=3 order by PosTypeCode","PosTypeName","PosTypeCode");
FillEdit(sePdmdLoc,"SELECT LocName,LocCode from sdLoc where LocType=2 order by LocCode","LocName","LocCode");
FillEdit(sePdmdProcess,"SELECT ProcessName,ProcessCode from sdProcess ","ProcessName","ProcessCode");
//Pdmd
FillComboBox(scGoodsUnit,"SELECT UnitName,UnitCode from sdUnit order by UnitCode","UnitName","UnitCode");
scPdmdType->ClearAll();
scPdmdType->AddItems("1-工废","1");
scPdmdType->AddItems("2-料废","2");
}
//---------------------------------------------------------------------------
void __fastcall TfrmPdmh::RefreshUpdateData(int MsgSrc,int MsgType)
{
try
{
switch (MsgSrc)
{
case euSdFc:
if(ShowUpdateMessage(MsgSrc,MsgType)){
StartWaitForm("正在刷新引用数据!");
FillComboBox(scPdmhFmonth,"SELECT FcMonth FROM sdFc order by FcMonth","FcMonth");
EndWaitForm();
break;
}
case euSdPosType:
if(ShowUpdateMessage(MsgSrc,MsgType)){
StartWaitForm("正在刷新引用数据!");
FillComboBox(scPdmhPosType,"SELECT PosTypeCode,PosTypeName FROM sdPosType order by PosTypeCode","PosTypeName","PosTypeCode");
EndWaitForm();
break;
}
case euSdUnit:
if(ShowUpdateMessage(MsgSrc,MsgType)){
StartWaitForm("正在刷新引用数据!");
FillComboBox(scGoodsUnit,"SELECT UnitName,UnitCode from sdUnit order by UnitCode","UnitName","UnitCode");
EndWaitForm();
break;
}
case euSdLoc:
if(ShowUpdateMessage(MsgSrc,MsgType)){
StartWaitForm("正在刷新引用数据!");
FillEdit(sePdmdLoc,"SELECT LocName,LocCode from sdLoc where LocType=2 order by LocCode","LocName","LocCode");
EndWaitForm();
break;
}
case euSdProcess:
if(ShowUpdateMessage(MsgSrc,MsgType)){
StartWaitForm("正在刷新引用数据!");
FillEdit(sePdmdProcess,"SELECT ProcessName,ProcessCode from sdProcess order by ProcessCode","ProcessName","ProcessCode");
EndWaitForm();
break;
}
default:
break;
}
}
__finally
{
//AddCode;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPdmh::ClearControl(int Section,bool BringToNext)
{
if(Section == 1)
{
if(!BringToNext)
{
sePdmhCode->Text="";
dePdmhDate->Text=g_sdCurDate;
scPdmhFmonth->LocateKey(g_sdMMonth);
scPdmhPosType->ItemIndex=-1;
sePdmhWo->Text="";
labUser->Caption=g_sdUserCode;
chkPdmhCheck->Checked=false;
labChecker->Caption="";
labCheckDate->Caption="";
memPdmhDesc->Text="";
}
sgPdmh->RowCount=1;
}
else
{
if(!BringToNext)
{
sePdmdLine->Text=AnsiString(comServer->ItemCount+1);
sePdmdProcess->ItemIndex=-1;
sePdmdLoc->ItemIndex=-1;
sePdmdGoods->Text="";
seGoodsName->Text="";
scGoodsUnit->ItemIndex=-1;
seGoodsSpec->Text="";
seGoodsModel->Text="";
scGoodsType->ItemIndex=-1;
scGoodsFrom->ItemIndex=-1;
sePdmdQty->Text="0";
memPdmdDesc->Text="";
scPdmdType->ItemIndex=0;
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPdmh::GetDataFromComObject(int Section)
{
if(Section==1)
{
sePdmhCode->Text=GetHeadValue(fiPdmhCode);
dePdmhDate->Text=GetHeadValue(fiPdmhDate);
scPdmhFmonth->LocateKey(GetHeadValue(fiPdmhFMonth));
scPdmhPosType->LocateKey(GetHeadValue(fiPdmhPosType));
sePdmhWo->Text=GetHeadValue(fiPdmhWo);
chkPdmhCheck->Checked=GetHeadValue(fiPdmhCheck)=="1" ;
if(chkPdmhCheck->Checked)
SetCheckToolbarStatus(true);
else
SetCheckToolbarStatus(false);
labChecker->Caption=GetHeadValue(fiPdmhChecker);
labCheckDate->Caption=GetHeadValue(fiPdmhCheckDate);
memPdmhDesc->Text=GetHeadValue(fiPdmhDesc);
}
else
{
sePdmdLine->Text=GetDetailValue(fiPdmdLine);
sePdmdProcess->LocateKey(GetDetailValue(fiPdmdProcess));
sePdmdLoc->LocateKey(GetDetailValue(fiPdmdLoc));
sePdmdGoods->Text=GetDetailValue(fiPdmdGoods);
g_sdRsGoods->LocateByKey(WideString(GetDetailValue(fiPdmdGoods)));
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;
sePdmdQty->Text=GetDetailValue(fiPdmdQty);
scPdmdType->LocateKey(GetDetailValue(fiPdmdType));
memPdmdDesc->Text=GetDetailValue(fiPdmdDesc);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPdmh::SendDataToComObject(int Section)
{
if(Section==1)
{
SetHeadValue(fiPdmhCode,sePdmhCode->Text);
SetHeadValue(fiPdmhDate,dePdmhDate->Text);
SetHeadValue(fiPdmhFMonth,scPdmhFmonth->Text);
SetHeadValue(fiPdmhPosType,scPdmhPosType->ItemData[1]);
SetHeadValue(fiPdmhWo,sePdmhWo->Text);
SetHeadValue(fiPdmhUser,labUser->Caption);
SetHeadValue(fiPdmhDesc,memPdmhDesc->Text);
}
else
{
SetDetailValue(fiPdmdCode,sePdmhCode->Text);
SetDetailValue(fiPdmdLine,sePdmdLine->Text);
SetDetailValue(fiPdmdProcess,sePdmdProcess->ItemData[1]);
SetDetailValue(fiPdmdLoc,sePdmdLoc->ItemData[1]);
SetDetailValue(fiPdmdGoods,sePdmdGoods->Text);
SetDetailValue(fiPdmdQty,sePdmdQty->Text);
SetDetailValue(fiPdmdType,scPdmdType->ItemData[1]);
SetDetailValue(fiPdmdDesc,memPdmdDesc->Text);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPdmh::WaitUserInput(int Section)
{
if(Section ==1){
if(sePdmhCode->Enabled)
sePdmhCode->SetFocus();
else
dePdmhDate->SetFocus();
}
else
{
ChangeToBrowseState(false);
if(sePdmdLine->Enabled)
sePdmdLine->SetFocus();
}
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPdmh::GetDataToGrid()
{
AnsiString ItemStr,s;
s=GetDetailValue(fiPdmdUnit);
scGoodsUnit->LocateKey(s);
g_sdRsGoods->LocateByKey(WideString(GetDetailValue(fiPdmdGoods)));
ItemStr=GetDetailValue(fiPdmdLine)+
"\t"+GetDetailValue(fiPdmdGoods)+
"\t"+GetGoodsValue("GoodsName")+
"\t"+scGoodsUnit->ItemData[0]+
"\t"+GetDetailValue(fiPdmdQty);
return ItemStr;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPdmh::RefreshGridData(int mAction)
{
int i;
AnsiString ItemStr=GetDataToGrid();
switch(mAction)
{
case 0: //Add
sgPdmh->AddItem(ItemStr);
sgPdmh->Row=sgPdmh->RowCount-1;
break;
case 1: //Edit
sgPdmh->ChangeItem(ItemStr,sgPdmh->Row);
break;
case 2: //Delete
sgPdmh->RemoveItem(sgPdmh->Row);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPdmh::FillGridWithData()
{
int i;
AnsiString ItemStr;
sgPdmh->RowCount=1;
if(comServer->RecordCount > 0)
{
for(i=0;i<comServer->ItemCount;i++)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -