📄 preth.cpp
字号:
TfrmWnQuery *p;
if(scPrethType->ItemIndex==0) //据采购单退货
{
SqlStr="008[收货单号][行号][物料编码][计量单位][换算系数][收货数量][已退数][单价]";
SqlStr+="select precdcode,precdline,precdgoods,precdunit,precdconv,precdqty,precdbqty,precdprice from sdprecd where ";
SqlStr+="precdcode='"+sePretdPrecCode->Text+"' and precdLine="+sePretdPrecdLine->Text;
}
else //据供应商退货
{
SqlStr="006[当前月份][货位名称][物料编码][物料名称][计量单位][当前数量]";
SqlStr+="select MaccFmonth,MaccLoc,MaccGoods,MaccGoodsName=GoodsName,MaccUnit=GoodsUnitCode,MaccAoyQty from sdMacc,sdGoods where GoodsCode=MaccGoods and MaccFmonth='"+g_sdPMonth+"'";
SqlStr+=" and MaccLoc='"+sePretdLoc->ItemData[1]+"' and MaccGoods='"+sePretdGoods->Text+"'";
}
try
{
StartWaitForm("正在查询,请稍候...");
if(scPrethType->ItemIndex==0)
p=new TfrmWnQuery(this,"收货单查询",SqlStr);
else
p=new TfrmWnQuery(this,"当前库存查询",SqlStr);
}
__finally
{
EndWaitForm();
}
p->ShowModal();
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPreth::sePretdLocButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="002[货位编码][货位名称]select Loccode,LocName from sdLoc,sdLg where LocCode=lgLocCode and lgState=1 and ";
SqlStr+="lggoodscode='"+sePretdGoods->Text+"' order by LocCode";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"货位查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
sePretdLoc->LocateKey(p->ColData[1]);
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPreth::sePrethSupplyButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="003[供应商编码][供应商名称][供应商地址]select supplycode,supplyname,supplyaddr from sdsupply order by supplycode";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"供应商查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
sePrethSupply->LocateKey(p->ColData[1]);
sePrethCurrency->ItemIndex=-1;
sePrethPsite->ItemIndex=-1;
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPreth::sePrethPsiteButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="003[货运地址代码][货运地址名称][联系人]select PsiteCode,PsiteName,psitelinkman from sdpsite where ";
SqlStr+="PsiteSupplyCode='"+sePrethSupply->ItemData[cbItem2]+"' order by PsiteCode";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"货运地址查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
sePrethPsite->LocateKey(p->ColData[1]);
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPreth::DynamicSetControlState()
{
if(scPrethType->ItemIndex==0)
{
tbGenDetail->Enabled=true;
ClientGroup->Remove(sePretdPrecCode->Name);
ClientGroup->AddComponent(2,false,true,true,sePretdPrecCode,sePretdPrecCode->Name);
ClientGroup->Remove(sePretdGoods->Name);
ClientGroup->AddComponent(2,true,true,true,sePretdGoods,sePretdGoods->Name);
ClientGroup->Remove(sePretdUnit->Name);
ClientGroup->AddComponent(2,true,true,true,sePretdUnit,sePretdUnit->Name);
ClientGroup->Remove(sePretdConv->Name);
ClientGroup->AddComponent(2,true,true,true,sePretdConv,sePretdConv->Name);
ClientGroup->Remove(sePretdBatch->Name);
ClientGroup->AddComponent(2,true,true,true,sePretdBatch,sePretdBatch->Name);
ClientGroup->Remove(sePretdSo->Name);
ClientGroup->AddComponent(2,true,true,true,sePretdSo,sePretdSo->Name);
ClientGroup->Remove(sePretdSodLine->Name);
ClientGroup->AddComponent(2,true,true,true,sePretdSodLine,sePretdSodLine->Name);
}
else
{
tbGenDetail->Enabled=false;
ClientGroup->Remove(sePretdPrecCode->Name);
ClientGroup->AddComponent(2,true,true,true,sePretdPrecCode,sePretdPrecCode->Name);
ClientGroup->Remove(sePretdGoods->Name);
ClientGroup->AddComponent(2,false,true,true,sePretdGoods,sePretdGoods->Name);
ClientGroup->Remove(sePretdUnit->Name);
ClientGroup->AddComponent(2,false,true,true,sePretdUnit,sePretdUnit->Name);
ClientGroup->Remove(sePretdConv->Name);
ClientGroup->AddComponent(2,false,true,true,sePretdConv,sePretdConv->Name);
ClientGroup->Remove(sePretdBatch->Name);
ClientGroup->AddComponent(2,false,true,true,sePretdBatch,sePretdBatch->Name);
ClientGroup->Remove(sePretdSo->Name);
ClientGroup->AddComponent(2,false,true,true,sePretdSo,sePretdSo->Name);
}
}
void __fastcall TfrmPreth::scPrethTypeClick(TObject *Sender)
{
DynamicSetControlState();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPreth::sePretdGoodsButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="006[物料编码][物料名称][计量单位][多计量单位][批次管理][订单管理]select GoodsCode,GoodsName,GoodsUnitCode,GoodsMUnit,GoodsBatch,GoodsTrackSo from sdgoods,sdpgd where ";
SqlStr+="PgdSupplyCode='"+sePrethSupply->ItemData[1]+"' and PgdGoodsCode=GoodsCode order by GoodsCode";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"供应商物料查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
sePretdGoods->Text=p->ColData[1];
SetDetail(sePretdGoods->Text);
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPreth::SetDetail(AnsiString gc)
{
int IsFound=g_sdRsGoods->LocateByKey(WideString(Trim(gc)));
if(IsFound != 0) //输入无效编码
{
sePretdGoods->Text=pv_GoodsCode;
return;
}
sePretdGoods->Text=GetGoodsValue("GoodsCode");
pv_GoodsCode=GetGoodsValue("GoodsCode");
labPretdGoodsName->Caption=GetGoodsValue("GoodsName");
sePretdUnit->LocateKey(GetGoodsValue("GoodsUnitCode"));
if(GetGoodsValue("GoodsTrackSo")=="0")
{//该物料不跟踪订单,则锁定销售单号和行号
sePretdSo->Enabled=false;
sePretdSodLine->Enabled=false;
sePretdSo->Text="";
sePretdSodLine->Text="";
}
else
{
sePretdSo->Enabled=true;
sePretdSodLine->Enabled=true;
}
if(GetGoodsValue("GoodsBatch")=="0")
{//该物料不采用批次管理,则锁定批号
sePretdBatch->Enabled=false;
sePretdBatch->ItemIndex=-1;
}
else
{
sePretdBatch->Enabled=true;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPreth::sePretdBatchButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="005[批次代码][批次说明][批量][生效日期][失效日期]select BatchCode,BatchDesc,BatchQty,BatchEffectDate,BatchAbateDate from sdBatch Order by BatchEffectDate";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"批次查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
sePretdBatch->Text=p->ColData[1];
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPreth::sePretdSoButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="004[订单号][订单行号][物料编码][数量]select sodcode,sodline,sodgoods,sodqty from sdSod,sdSoh where ";
SqlStr+=" SodCode=SohCode and SohCheck=1 and SohCancel=0 order by SodCode";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"销售订单查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
sePretdSo->Text=p->ColData[1];
sePretdSodLine->Text=p->ColData[2];
}
delete p;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall TfrmPreth::GenrateBill()
{
int TempCount;
TempCount = comServer->ItemCount;
StartWaitForm("正在启动生成界面");
TfrmPretd *p=new TfrmPretd(this);
try
{
p->GetComObject(comServer);
EndWaitForm();
p->ShowModal();
if (TempCount < comServer->ItemCount)
TGenBaseForm::SaveRecord();
else
CancelChange();
}
__finally
{
delete p;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPreth::sePretdUnitButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="004[计量单位代码][计量单位名称][换算系数][单位类型]";
SqlStr+=" select GmuUnit,UnitName,GmuConv,Prm=(case when GmuPrimary=1 then '主单位' else '辅助单位' end) ";
SqlStr+=" from sdGmu,sdUnit where GmuUnit=UnitCode and GmuGoods='"+sePretdGoods->Text+"' ";
SqlStr+=" order by GmuPrimary desc,GmuUnit ";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"计量单位查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
sePretdUnit->LocateKey(p->ColData[1]);
sePretdConv->Text=p->ColData[3];
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPreth::sePretdGoodsExit(TObject *Sender)
{
SetDetail(sePretdGoods->Text);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPreth::sePrethCodeExit(TObject *Sender)
{
if(CurrentState==caNormal && sePrethCode->Text != GetHeadValue(fiPrethCode))
{
comServer->LocateByKey(WideString(sePrethCode->Text));
DisplayBill();
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -