📄 dml.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include "Dml.h"
#include "func.h"
//---------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "fpanel"
#pragma link "RecBaseForm"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"
TfrmDml *frmDml;
//---------------------------------------------------------------------------
__fastcall TfrmDml::TfrmDml(TComponent* Owner)
: TRecBaseForm(Owner,euSdDml,"")
{
}
//---------------------------------------------------------------------------
__fastcall TfrmDml::TfrmDml(TComponent* Owner,AnsiString FGmthCode,int FGmthCheck,
int FGmtdLine,AnsiString FGmtdWo,AnsiString FGmtdGoods,double FGmtdQty)
: TRecBaseForm(Owner,euSdDml,"DmlGmtCode='"+FGmthCode+"' and DmlGmtdLine='"+FGmtdLine+"'")
{
FDmlGmthCode=FGmthCode;
FDmlGmthCheck=FGmthCheck;
FDmlGmtdLine=FGmtdLine;
FDmlGmtdWo=FGmtdWo;
FDmlGmtdGoods=FGmtdGoods;
FDmlGmtdQty=FGmtdQty;
SetCheckToolbarStatus(FGmthCheck);
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmDml::GetFieldValue(int FieldIndex)
{
return ReadFieldValue(comServer,FieldIndex);
}
//---------------------------------------------------------------------------
void __fastcall TfrmDml::SetFieldValue(int iFieldIndex,AnsiString sFieldValue)
{
WriteFieldValue(comServer,iFieldIndex,sFieldValue);
}
//---------------------------------------------------------------------------
void __fastcall TfrmDml::ClearControl(bool BringToNext)
{
if(!BringToNext){
scDmlProcess->ItemIndex=-1;
scDmlProcess->Text="";
scDmlLoc->ItemIndex=-1;
scDmlLoc->Text="";
seDmlQty->Text="0.00";
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmDml::GetDataFromComObject()
{
scDmlProcess->LocateKey(GetFieldValue(fiDmlProcess));
//MoveFirst,MovePrority,MoveNext,MoveLast
sgDml->LocateGrid(0,GetFieldValue(fiDmlProcess));
scDmlLoc->LocateKey(GetFieldValue(fiDmlLoc));
seDmlQty->Text=GetFieldValue(fiDmlQty);
//当定额领料和工单领料已经审核时,不能做任何的操作。
if(FDmlGmthCheck==1)
{
SetCheckToolbarStatus(true);
tbAddHead->Enabled=false;
}
else
{
SetCheckToolbarStatus(false);
tbAddHead->Enabled=true;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmDml::SendDataToComObject()
{
SetFieldValue(fiDmlGmtCode,seDmlGmtCode->Text);
SetFieldValue(fiDmlGmtdLine,seDmlGmtdLine->Text);
SetFieldValue(fiDmlWoCode,seDmlWoCode->Text);
SetFieldValue(fiDmlProcess,scDmlProcess->ItemData[cbItem2]);
SetFieldValue(fiDmlGoods,scDmlGoods->Text);
SetFieldValue(fiDmlQty,seDmlQty->Text);
}
//---------------------------------------------------------------------------
void __fastcall TfrmDml::WaitUserInput()
{
scDmlProcess->SetFocus();
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmDml::GetDataToGrid()
{
AnsiString tempS;
tempS=GetFieldValue(fiDmlProcess)+
"\t" + GetFieldValue(fiDmlLoc)+
"\t" + GetFieldValue(fiDmlQty);
return(tempS);
}
//---------------------------------------------------------------------------
void __fastcall TfrmDml::RefreshGridData(int mAction)
{
AnsiString ItemStr;
ItemStr = GetDataToGrid();
if(mAction == 0)
{
sgDml->AddItem(ItemStr);
sgDml->Row=sgDml->RowCount-1;
}
else if(mAction == 1)
{
sgDml->ChangeItem(ItemStr,sgDml->Row);
}
else if(mAction == 2)
{
sgDml->RemoveItem(sgDml->Row);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmDml::FillGridWithData()
{
AnsiString ItemStr;
comServer->MoveFirst();
sgDml->RowCount = 1;
while(comServer->Eof == 0)
{
ItemStr = GetDataToGrid();
sgDml->AddItem(ItemStr);
comServer->MoveNext();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmDml::InitEditControl()
{
ClientGroup->AddComponent(2,false,false,true,FloatPanel1,FloatPanel1->Name);
ClientGroup->AddComponent(2,true,true,true,seDmlGmtCode,seDmlGmtCode->Name);
ClientGroup->AddComponent(2,true,true,true,seDmlGmtdLine,seDmlGmtdLine->Name);
ClientGroup->AddComponent(2,true,true,true,seDmlWoCode,seDmlWoCode->Name);
ClientGroup->AddComponent(2,true,true,true,scDmlGoods,scDmlGoods->Name);
ClientGroup->AddComponent(2,true,true,true,scDmlLoc,scDmlLoc->Name);
ClientGroup->AddComponent(2,true,true,false,sgDml,sgDml->Name);
ClientGroup->AddComponent(2,true,true,true,seDmlGmtdQty,seDmlGmtdQty->Name);
ClientGroup->AddComponent(2,true,true,true,Panel1,Panel1->Name);
FillComboBox(scDmlLoc,"select LocCode+ space(1)+'('+LocName+')' memo,LocCode from sdLoc Order by LocCode","memo","LocCode");
FillComboBox(scDmlGoodsUnit,"select UnitName,UnitCode from sdUnit Order by UnitCode","UnitName","UnitCode");
}
//---------------------------------------------------------------------------
void __fastcall TfrmDml::RefreshUpdateData(int MsgSrc,int MsgType)
{
try
{
switch (MsgSrc)
{
case euSdLoc:
if(ShowUpdateMessage(MsgSrc,MsgType)){
StartWaitForm("正在刷新引用数据!");
FillComboBox(scDmlLoc,"select LocCode+ space(1)+'('+LocName+')' memo,LocCode from sdLoc Order by LocCode","memo","LocCode");
EndWaitForm();
break;
}
case euSdUnit:
if(ShowUpdateMessage(MsgSrc,MsgType)){
StartWaitForm("正在刷新引用数据!");
FillComboBox(scDmlGoodsUnit,"select UnitName,UnitCode from sdUnit Order by UnitCode","UnitName","UnitCode");
EndWaitForm();
break;
}
default:
break;
}
}
__finally
{
//AddCode;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmDml::FormClose(TObject *Sender, TCloseAction &Action)
{
SetInifileValue(this->Name,"AutoQuery","1",ExtractFileDir(Application->ExeName)+"\\sdFormSet.dat");
TRecBaseForm::FormClose(Sender,Action);
}
//---------------------------------------------------------------------------
void __fastcall TfrmDml::FormCreate(TObject *Sender)
{
/*
AnsiString FormIniFile="D:\Test.Ini";
SetGridWidth(Name,sgDml,FormIniFile);
*/
}
//---------------------------------------------------------------------------
void __fastcall TfrmDml::FormShow(TObject *Sender)
{
ClearControl(false);
seDmlGmtCode->Text=FDmlGmthCode;
seDmlGmtdLine->Text=FDmlGmtdLine;
seDmlGmtdQty->Text=FDmlGmtdQty;
seDmlWoCode->Text=FDmlGmtdWo;
FillComboBox(scDmlProcess,"select WrgProcess+space(1)+'('+WrgName+')' memo,WrgProcess from sdWrg Where WrgWo='"+FDmlGmtdWo+"' Order by WrgProcess","memo","WrgProcess");
scDmlGoods->Text=FDmlGmtdGoods;
g_sdRsGoods->LocateByKey(WideString(FDmlGmtdGoods));
seDmlGoodsName->Text=GetGoodsValue("GoodsName");
scDmlGoodsUnit->LocateKey(GetGoodsValue("GoodsUnitCode"));
scDmlGoodsType->ItemIndex= StrToInt(GetGoodsValue("GoodsType"));
scDmlGoodsFrom->ItemIndex= StrToInt(GetGoodsValue("GoodsFrom"));
sgDml->RowCount=1;
if(comServer->RecordCount>0)
{
FillGridWithData();
GetDataFromComObject();
}
else
ClearControl(false);
}
//---------------------------------------------------------------------------
void __fastcall TfrmDml::scDmlProcessClick(TObject *Sender)
{
AnsiString tempS;
tempS=scDmlProcess->ItemData[cbItem2];
if(!tempS.IsEmpty())
{
SetFieldValue(fiDmlGmtCode,FDmlGmthCode);
SetFieldValue(fiDmlGmtdLine,FDmlGmtdLine);
SetFieldValue(fiDmlWoCode,FDmlGmtdWo);
SetFieldValue(fiDmlProcess,tempS);
scDmlLoc->LocateKey(GetFieldValue(fiDmlLoc));
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmDml::sgDmlClick(TObject *Sender)
{
int ARow;
ARow=sgDml->Row;
if(ARow > 0){
comServer->MoveFirst();
comServer->LocateByKey(seDmlGmtCode->Text+seDmlGmtdLine->Text+sgDml->TextMatrix[ARow][0]);
}
if(!comServer->Eof)
GetDataFromComObject();
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -