📄 prech_n_i.cpp
字号:
double FVal,FTax,FQty,FPrice;
if(sePrecdQty->Text.IsEmpty())
sePrecdQty->Text="0";
if(sePrecdPrice->Text.IsEmpty())
sePrecdPrice->Text="0";
if(scPrechTaxCode->ItemIndex!=-1)
FTax=scPrechTaxCode->ItemData[cbItem3].ToDouble();
else
FTax=0;
FQty=sePrecdQty->Text.ToDouble();
FPrice=sePrecdPrice->Text.ToDouble();
FVal=(FQty*FPrice)/(1+FTax);
sePrecdAmt->Text=DataCarry(FVal,2,0);
sePrecdTAmt->Text=DataCarry(FVal*FTax,2,0);
反算单价
*/
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_N_I::sePrecdPoExit(TObject *Sender)
{
if(g_sdRsGoods->LocateByKey(WideString(sePrecdGoods->Text))==0)
{
sePrecdGoodsName->Text=GetGoodsValue("GoodsName");
if(GetGoodsValue("GoodsTrackSo")=="0")
{//该物料不跟踪订单,则锁定销售单号和行号
sePrecdSo->Enabled=false;
sePrecdSodLine->Enabled=false;
sePrecdSo->Text="";
sePrecdSodLine->Text="0";
}
else
{
sePrecdSo->Enabled=true;
sePrecdSodLine->Enabled=true;
}
if(GetGoodsValue("GoodsBatch")=="0")
{//该物料不采用批次管理,则锁定批号
scPrecdBatch->Enabled=false;
scPrecdBatch->ItemIndex=-1;
}
else
{
scPrecdBatch->Enabled=true;
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_N_I::sePrecdLocButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="002[货位编码][货位名称]select Loccode,LocName from sdLoc,sdLg where LocCode=lgLocCode and lgState=1 and ";
if(g_sdQuality == false) //无需质量管理
SqlStr+=" LocType=1 and lggoodscode='"+sePrecdGoods->Text+"' order by LocCode";
else //需要质量管理
SqlStr+=" LocType=3 and lggoodscode='"+sePrecdGoods->Text+"' order by LocCode";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"订单查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
sePrecdLoc->LocateKey(p->ColData[1]);
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_N_I::sePrecdSoButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="004[销售订单][订单行号][物料编码][销售数量]select sodcode,sodline,sodgoods,sodqty from sdsod where ";
SqlStr+="Sodgoods='"+sePrecdGoods->Text+"' order by SodCode";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"订单查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
sePrecdSo->Text=p->ColData[1];
sePrecdSodLine->Text=p->ColData[2];
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_N_I::sePrechCurrencyButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="002[货币代码][货币名称]select Currencycode,CurrencyName from sdCurrency,sdpsd where PsdCurrencyCode=CurrencyCode and ";
SqlStr+="PsdSupplyCode='"+scPrechSupply->ItemData[cbItem2]+"' order by CurrencyCode";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"货币查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
sePrechCurrency->LocateKey(p->ColData[1]);
sePrechEnrate->Text=sePrechCurrency->ItemData[cbItem3];
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_N_I::sePrechPsiteButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="003[货运地址代码][货运地址名称][联系人]select PsiteCode,PsiteName,psitelinkman from sdpsite where ";
SqlStr+="PsiteSupplyCode='"+scPrechSupply->ItemData[cbItem2]+"' order by PsiteCode";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"货运地址查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
sePrechPsite->LocateKey(p->ColData[1]);
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_N_I::sePrecdGoodsButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="003[物料编码][物料名称][计量单位]select GoodsCode,GoodsName,GoodsUnitCode from sdgoods,sdpgd where ";
SqlStr+="PgdSupplyCode='"+scPrechSupply->ItemData[1]+"' and PgdGoodsCode=GoodsCode order by GoodsCode";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"供应商物料查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
sePrecdGoods->Text=p->ColData[1];
SetDetail(sePrecdGoods->Text);
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_N_I::SetDetail(AnsiString gc)
{
int IsFound=g_sdRsGoods->LocateByKey(WideString(Trim(gc)));
if(IsFound != 0) //输入无效编码
{
sePrecdGoods->Text=pv_GoodsCode;
return;
}
sePrecdGoods->Text=GetGoodsValue("GoodsCode");
pv_GoodsCode=GetGoodsValue("GoodsCode");
sePrecdGoodsName->Text=GetGoodsValue("GoodsName");
sePrecdUnit->LocateKey(GetGoodsValue("GoodsUnitCode"));
if(GetGoodsValue("GoodsTrackSo")=="0")
{//该物料不跟踪订单,则锁定销售单号和行号
sePrecdSo->Enabled=false;
sePrecdSodLine->Enabled=false;
sePrecdSo->Text="";
sePrecdSodLine->Text="";
}
else
{
sePrecdSo->Enabled=true;
sePrecdSodLine->Enabled=true;
}
if(GetGoodsValue("GoodsBatch")=="0")
{//该物料不采用批次管理,则锁定批号
scPrecdBatch->Enabled=false;
scPrecdBatch->ItemIndex=-1;
}
else
{
scPrecdBatch->Enabled=true;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_N_I::sePrecdGoodsExit(TObject *Sender)
{
SetDetail(Trim(sePrecdGoods->Text));
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_N_I::sePrecdQtyExit(TObject *Sender)
{
double FVal,FTax,FQty,FPrice;
if(sePrecdQty->Text.IsEmpty())
sePrecdQty->Text="0";
if(sePrecdPrice->Text.IsEmpty())
sePrecdPrice->Text="0";
if(scPrechTaxCode->ItemIndex!=-1)
FTax=scPrechTaxCode->ItemData[cbItem3].ToDouble();
else
FTax=0;
FQty=sePrecdQty->Text.ToDouble();
FPrice=sePrecdPrice->Text.ToDouble();
FVal=(FQty*FPrice)/(1+FTax);
sePrecdAmt->Text=DataCarry(FVal,2,0);
sePrecdTAmt->Text=DataCarry(FVal*FTax,2,0);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_N_I::sePrechCurrencyExit(TObject *Sender)
{
if(sePrechCurrency->ItemData[cbItem4]=="1")
{
sePrechEnrate->Enabled=false;
sePrechEnrate->Text="1";
}
else
{
sePrechEnrate->Enabled=true;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_N_I::sePrecdUnitButtonClick(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='"+sePrecdGoods->Text+"' ";
SqlStr+=" order by GmuPrimary desc,GmuUnit ";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"计量单位查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
sePrecdUnit->LocateKey(p->ColData[1]);
sePrecdConv->Text=p->ColData[3];
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_N_I::scPrechSupplyChange(TObject *Sender)
{
sePrechCurrency->ItemIndex=-1;
sePrechEnrate->Text="1";
sePrechPsite->ItemIndex=-1;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_N_I::sePrechCodeExit(TObject *Sender)
{
if(CurrentState==caNormal && sePrechCode->Text != GetHeadValue(fiPrechCode))
{
comServer->LocateByKey(WideString(sePrechCode->Text));
DisplayBill();
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -