📄 dmah.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include "Dmah.h"
#include "Dmad.h"
//---------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "DateEdit"
#pragma link "fpanel"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma link "GenBaseForm"
#pragma resource "*.dfm"
TfrmDmah *frmDmah;
//---------------------------------------------------------------------------
__fastcall TfrmDmah::TfrmDmah(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
: TGenBaseForm(Owner,chWnd,MidCode,WhereStr)
{
//AutoCtl=seDmahCode;
SetAutoCodeString(seDmahCode,"ACM-027");
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmah::InitEditControl()
{
ClientGroup->AddComponent(1,false,false,true,fpDmah,fpDmah->Name);
ClientGroup->AddComponent(1,false,true,false,seDmahCode,seDmahCode->Name);
ClientGroup->AddComponent(1,true,true,true,scDmahFmonth,scDmahFmonth->Name);
ClientGroup->AddComponent(2,false,false,true,fpDmad,fpDmad->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,seDmadGmtCode,seDmadGmtCode->Name);
ClientGroup->AddComponent(2,true,true,true,plDmadGoods,plDmadGoods->Name);
//Dmah
FillComboBox(Handle,scDmahFmonth,"SELECT FcMonth FROM sdFc order by FcMonth","FcMonth");
FillComboBox(Handle,scDmahPosType,"SELECT PosTypeCode,PosTypeName FROM sdPosType where PosTypeFlg=3 order by PosTypeCode","PosTypeName","PosTypeCode");
FillEdit(Handle,seDmadLoc,"SELECT LocName,LocCode from sdLoc where LocType=2 order by LocCode","LocName","LocCode");
//Dmad
FillComboBox(Handle,scDmadUnit,"SELECT UnitName,UnitCode from sdUnit order by UnitCode","UnitName","UnitCode");
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmah::RefreshUpdateData(int MsgSrc,int MsgType)
{
/*
try
{
switch(MsgSrc)
{
case euSdFc:
if(ShowUpdateMessage(MsgSrc,MsgType)){
StartWaitForm("正在刷新引用数据!");
FillComboBox(Handle,scDmahFmonth,"SELECT FcMonth FROM sdFc order by FcMonth","FcMonth");
EndWaitForm();
break;
}
case euSdPosType:
if(ShowUpdateMessage(MsgSrc,MsgType)){
StartWaitForm("正在刷新引用数据!");
FillComboBox(Handle,scDmahPosType,"SELECT PosTypeCode,PosTypeName FROM sdPosType where PosTypeFlg=3 order by PosTypeCode","PosTypeName","PosTypeCode");
EndWaitForm();
break;
}
case euSdLoc:
if(ShowUpdateMessage(MsgSrc,MsgType)){
StartWaitForm("正在刷新引用数据!");
FillEdit(Handle,seDmadLoc,"SELECT LocName,LocCode from sdLoc where LocType=2 order by LocCode","LocName","LocCode");
EndWaitForm();
break;
}
case euSdUnit:
if(ShowUpdateMessage(MsgSrc,MsgType)){
StartWaitForm("正在刷新引用数据!");
FillComboBox(Handle,scDmadUnit,"SELECT UnitName,UnitCode from sdUnit order by UnitCode","UnitName","UnitCode");
EndWaitForm();
break;
}
default:
break;
}
}
__finally
{
//AddCode;
}
*/
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmah::ClearControl(int Section,bool BringToNext)
{
if(Section == 1)
{
if(!BringToNext)
{
seDmahCode->Text = "";
deDmahDate->Text = g_sdCurDate;
scDmahFmonth->LocateKey(g_sdMMonth);
scDmahPosType->ItemIndex = -1;
labUser->Caption = g_sdUserCode;
chkDmahCheck->Checked = false;
labChecker->Caption = "";
labCheckDate->Caption = "";
memDmahDesc->Text = "";
}
sgDmah->RowCount=1;
}
else
{
if(!BringToNext)
{
seDmadLine->Text=AnsiString(comServer->ItemCount+1);
seDmadGmtCode->Text="";
seDmadGmtdLine->Text=0;
seDmadLoc->ItemIndex = -1;
seDmadWoCode->Text="";
seDmadGoods->Text="";
seDmadGoodsName->Text="";
scDmadUnit->ItemIndex=-1;
seDmadQty->Text="0";
memDmadDesc->Text="";
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmah::GetDataFromComObject(int Section)
{
if(Section==1)
{
seDmahCode->Text=GetHeadValue("DmahCode");
deDmahDate->Text=GetHeadValue("DmahDate");
scDmahFmonth->LocateKey(GetHeadValue("DmahFmonth"));
scDmahPosType->LocateKey(GetHeadValue("DmahPosType"));
memDmahDesc->Text=GetHeadValue("DmahDesc");
labUser->Caption=GetHeadValue("DmahUser");
chkDmahCheck->Checked=GetHeadValue("DmahCheck")=="1";
labChecker->Caption=GetHeadValue("DmahChecker");
labCheckDate->Caption=GetHeadValue("DmahCheckDate");
if(chkDmahCheck->Checked)
SetCheckToolbarStatus(true);
else
SetCheckToolbarStatus(false);
}
else
{
seDmadLine->Text=GetDetailValue("DmadLine");
seDmadGmtCode->Text=GetDetailValue("DmadGmtCode");
seDmadGmtdLine->Text=GetDetailValue("DmadGmtdLine");
seDmadLoc->LocateKey(GetDetailValue("DmadLoc"));
seDmadWoCode->Text=GetDetailValue("DmadWoCode");
//物料相关资料
AnsiString FGoodsCode;
FGoodsCode=GetDetailValue("DmadGoods");
seDmadGoods->Text = FGoodsCode;
// l_RsGoods->LocateByKey(WideString(FGoodsCode));
InitRsGoods(seDmadGoods->Text);
seDmadGoodsName->Text=GetGoodsValue(gtInitRs,"GoodsName");
scDmadUnit->LocateKey(GetGoodsValue(gtInitRs,"GoodsUnitCode"));
//
seDmadQty->Text=GetDetailValue("DmadQty");
memDmadDesc->Text=GetDetailValue("DmadDesc");
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmah::SendDataToComObject(int Section)
{
if (Section==1)
{
SetHeadValue("DmahCode",seDmahCode->Text);
SetHeadValue("DmahDate",deDmahDate->Text);
SetHeadValue("DmahFmonth",scDmahFmonth->Text);
SetHeadValue("DmahPosType",scDmahPosType->ItemData[1]);
SetHeadValue("DmahUser",labUser->Caption);
SetHeadValue("DmahDesc",memDmahDesc->Text);
}
else
{
SetDetailValue("DmadCode",seDmahCode->Text);
SetDetailValue("DmadLine",seDmadLine->Text);
SetDetailValue("DmadGmtCode",seDmadGmtCode->Text);
SetDetailValue("DmadGmtdLine",seDmadGmtdLine->Text);
SetDetailValue("DmadWoCode",seDmadWoCode->Text);
SetDetailValue("DmadGoods",seDmadGoods->Text);
SetDetailValue("DmadGoodsName",seDmadGoodsName->Text);
SetDetailValue("DmadQty",seDmadQty->Text);
SetDetailValue("DmadDesc",memDmadDesc->Text);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmah::WaitUserInput(int Section)
{
if(Section ==1){
if(seDmahCode->Enabled)
seDmahCode->SetFocus();
else
deDmahDate->SetFocus();
}
else
{
ChangeToBrowseState(false);
if(seDmadLine->Enabled)
seDmadLine->SetFocus();
}
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmDmah::GetDataToGrid()
{
AnsiString ItemStr,s;
s = GetDetailValue("DmadUnit");
scDmadUnit->LocateKey(s);
ItemStr=GetDetailValue("DmadLine")+
"\t"+GetDetailValue("DmadWoCode")+
"\t"+GetDetailValue("DmadGoods")+
"\t"+GetDetailValue("DmadGoodsName")+
"\t"+GetDetailValue("DmadGoodsSpec")+
"\t"+scDmadUnit->ItemData[0]+
"\t"+GetDetailValue("DmadQty")+
"\t"+GetDetailValue("DmadLoc");
return ItemStr;
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmah::RefreshGridData(int mAction)
{
int i;
AnsiString ItemStr=GetDataToGrid();
switch(mAction)
{
case 0: //Add
sgDmah->AddItem(ItemStr);
sgDmah->Row=sgDmah->RowCount-1;
break;
case 1: //Edit
sgDmah->ChangeItem(ItemStr,sgDmah->Row);
break;
case 2: //Delete
sgDmah->RemoveItem(sgDmah->Row);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmah::FillGridWithData()
{
int i;
AnsiString ItemStr;
sgDmah->RowCount=1;
if(comServer->RecordCount > 0)
{
for(i=0;i<comServer->ItemCount;i++)
{
comServer->LocateItemByIndex(i);
RefreshGridData(0);
}
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -