📄 pgd.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Pgd.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "RecBaseForm"
#pragma link "fpanel"
#pragma link "SDGrid"
#pragma link "SDEdit"
#pragma link "SDComboBox"
#pragma resource "*.dfm"
TfrmPgd *frmPgd;
AnsiString LastPgdSupply;
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPgd::GetFieldValue(int FieldIndex)
{
WideString S;
S = ReadFieldValue(comServer,FieldIndex);
return(S);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPgd::ClearControl(bool BringToNext)
{
if(BringToNext)
{
return;
}
// StrFlg= false;
sePgdCode->Text ="";
sePgdName->Text ="";
sePgdGoodsCode->Text ="";
sePgdGoodsName->Text ="";
sePgdPot->Text ="0.00";
sePgdPoc->Text ="0.00";
}
//---------------------------------------------------------------------------
void __fastcall TfrmPgd::GetDataFromComObject()
{
sePgdCode->Text = GetFieldValue(fiPgdCode);
sgPgd->LocateGrid(1,GetFieldValue(fiPgdGoodsCode));
sePgdName->Text = GetFieldValue(fiPgdName);
g_sdRsGoods->LocateByKey(WideString(GetFieldValue(fiPgdGoodsCode)));
sePgdGoodsCode->Text = GetGoodsValue("GoodsCode");
sePgdGoodsName->Text = GetGoodsValue("GoodsName");
sePgdPot->Text = GetFieldValue(fiPgdPot);
sePgdPoc->Text = GetFieldValue(fiPgdPoc);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPgd::SendDataToComObject()
{
WriteFieldValue(comServer,fiPgdSupplyCode,WideString(scPgdSupplyCode->ItemData[1]));
WriteFieldValue(comServer,fiPgdCode,WideString(sePgdCode->Text));
WriteFieldValue(comServer,fiPgdName,WideString(sePgdName->Text));
WriteFieldValue(comServer,fiPgdGoodsCode,WideString(sePgdGoodsCode->Text));
if(sePgdPot->Text == "")
throw Exception("请输入可供应时间期限");
WriteFieldValue(comServer,fiPgdPot,WideString(sePgdPot->Text));
if(sePgdPoc->Text == "")
throw Exception("请输入可供应能力大小");
WriteFieldValue(comServer,fiPgdPoc,WideString(sePgdPoc->Text));
}
//---------------------------------------------------------------------------
void __fastcall TfrmPgd::WaitUserInput()
{
sePgdGoodsCode->SetFocus();
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPgd::GetDataToGrid()
{
AnsiString s;
s = "\t" + GetFieldValue(fiPgdGoodsCode)+
"\t" + GetFieldValue(fiPgdCode) +
"\t" + GetFieldValue(fiPgdName);
return(s);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPgd::RefreshGridData(int mAction)
{
AnsiString ItemStr;
ItemStr = GetDataToGrid();
if (mAction == 0)
{
sgPgd->AddItem(ItemStr);
}
else if(mAction == 1)
{
int i = sgPgd->Row;
sgPgd->ChangeItem(ItemStr,i);
}
else if(mAction == 2)
{
sgPgd->RemoveItem(sgPgd->Row);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPgd::FillGridWithData()
{
AnsiString ItemStr;
comServer->MoveFirst();
sgPgd->RowCount = 1;
while (comServer->Eof == 0)
{
ItemStr = GetDataToGrid();
sgPgd->AddItem(ItemStr);
comServer->MoveNext();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPgd::InitEditControl()
{
ClientGroup->AddComponent(2,true,true,false, sgPgd,sgPgd->Name);
ClientGroup->AddComponent(2,false,false,true, FloatPanel1,FloatPanel1->Name);
ClientGroup->AddComponent(2,true,true,false, scPgdSupplyCode,scPgdSupplyCode->Name);
ClientGroup->AddComponent(2,true,true,true, sePgdGoodsName,sePgdGoodsName->Name);
FillComboBox(scPgdSupplyCode,"SELECT SUPPLYCODE,supplyName FROM SDSUPPLY where supplycancel=0 order by SupplyCode","supplyName","SUPPLYCODE");
}
//---------------------------------------------------------------------------
__fastcall TfrmPgd::TfrmPgd(TComponent* Owner)
: TRecBaseForm(Owner,euSdPgd,"")
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmPgd::FormClose(TObject *Sender, TCloseAction &Action)
{
TRecBaseForm::FormClose(Sender,Action);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPgd::FormShow(TObject *Sender)
{
ClearControl(false);
LastPgdSupply="";
scPgdSupplyCodeClick(Sender);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPgd::scPgdSupplyCodeClick(TObject *Sender)
{
AnsiString s;
s = scPgdSupplyCode->ItemData[1];
if(s.IsEmpty())
return;
if(LastPgdSupply==s)
return;
LastPgdSupply=s;
s = "PgdSupplyCode = '" +s+"'";
comServer->FilterString = WideString(s);
comServer->Query();
FillGridWithData();
comServer->MoveFirst();
GetDataFromComObject();
StrFlg=true;
}
//---------------------------------------------------------------------------void __fastcall TfrmPgd::muAddDetailClick(TObject *Sender)
void __fastcall TfrmPgd::sePgdGoodsCodeButtonClick(TObject *Sender)
{
//供应商供货不能是成品或半成品且来源于采购
AnsiString SqlStr;
SqlStr="006[物料编码][物料名称][计量单位][多计量单位][批次管理][订单管理]";
SqlStr+=" select GoodsCode,GoodsName,GoodsUnitCode,GoodsMUnit,GoodsBatch,GoodsTrackSo from sdgoods where ";
SqlStr+=" goodstype<>1 and goodstype<>2 and goodsfrom=1 and goodsstate=2 and goodscancel=0 ";
SqlStr+=" order by GoodsCode";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"物料查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
sePgdGoodsCode->Text=p->ColData[1];
sePgdGoodsName->Text=p->ColData[2];
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPgd::sgPgdClick(TObject *Sender)
{
int ARow=sgPgd->Row;
AnsiString KeyStr;
if (ARow > 0) {
KeyStr=Trim(scPgdSupplyCode->ItemData[1])+Trim(sgPgd->TextMatrix[ARow][1]);
comServer->LocateByKey(WideString(KeyStr));
}
if (!comServer->Eof)
GetDataFromComObject();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPgd::sePgdGoodsCodeExit(TObject *Sender)
{
if(Trim(sePgdGoodsCode->Text)!="")
{
int GoodsFound;
GoodsFound=g_sdRsGoods->LocateByKey(WideString(Trim(sePgdGoodsCode->Text)));
if(GoodsFound != 0) //物料编码不存在
{
sePgdGoodsCode->Text="";
sePgdGoodsName->Text="";
return;
}
sePgdGoodsCode->Text=GetGoodsValue("GoodsCode");
sePgdGoodsName->Text=GetGoodsValue("GoodsName");
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPgd::RefreshUpdateData(int MsgSrc,int MsgType)
{
switch(MsgSrc)
{
case euSdSupply:
if(ShowUpdateMessage(MsgSrc,MsgType))
{
FillComboBox(scPgdSupplyCode,"SELECT SUPPLYCODE,supplyName FROM SDSUPPLY where supplycancel=0 order by SupplyCode","supplyName","SUPPLYCODE");
scPgdSupplyCodeClick(NULL);
}
break;
default:
break;
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -