📄 pmhdl.cpp
字号:
// 9-25: from Yan
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#define _YW_SDERP_DLL
#include "Pmhdl.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
//**************************************
// (TsdPoh)采购单单头
//**************************************
void __fastcall TsdPoh::SetPohCode(AnsiString value)
{
if(value.IsEmpty())
throw Exception("采购单的编号不能为空!");
if(value.Length()>18)
throw Exception("采购单号长度不能大于18");
if (value != m_PohCode)
{
m_Query->Close();
m_Query->SQL->Clear();
m_Query->SQL->Add("select PohCode from sdPoh where PohCode='"+value+"'");
m_Query->Open();
if (m_Query->RecordCount>0)
{
m_Query->Close();
throw Exception("采购单号'"+value+"'已经存在");
}
m_Query->Close();
}
m_PohCode = value;
}
//---------------------------------------------------------------------------
void __fastcall TsdPoh::SetPohSupply(AnsiString value)
{
if(value.IsEmpty())
throw Exception("供应商编码不能为空");
if(value.Length()>18)
throw Exception("供应商编码长度不能大于18");
if(value!=m_PohSupply)
{
m_Query->Close();
m_Query->SQL->Clear();
m_Query->SQL->Add("select supplycode from sdsupply where supplycode='"+value+"'");
m_Query->Open();
if(m_Query->RecordCount<=0)
{
m_Query->Close();
throw Exception("供应商'"+value+"'未定义");
}
m_Query->Close();
}
m_PohSupply = value;
}
//---------------------------------------------------------------------------
void __fastcall TsdPoh::SetPohCurrency(AnsiString value)
{
if(value.IsEmpty())
throw Exception("货币代码不能为空");
if(value.Length()>18)
throw Exception("货币代码长度不能大于18");
if(value!=m_PohCurrency)
{
m_Query->Close();
m_Query->SQL->Clear();
m_Query->SQL->Add("select currencycode from sdcurrency where currencycode='"+value+"'");
m_Query->Open();
if(m_Query->RecordCount<=0)
{
m_Query->Close();
throw Exception("货币编码'"+value+"'未定义");
}
m_Query->Close();
}
m_PohCurrency = value;
}
//---------------------------------------------------------------------------
void __fastcall TsdPoh::SetPohEnrate(double value)
{
AnsiString FCurrency;
if(m_PohCurrency.IsEmpty())
throw Exception("币种代码不能为空");
m_Query->Close();
m_Query->SQL->Clear();
m_Query->SQL->Add("select currencycode from sdCurrency where currencylocal=1");
m_Query->Open();
if(m_Query->RecordCount<=0)
{
m_Query->Close();
throw Exception("本币未定义");
}
FCurrency=m_Query->FieldValues["currencycode"];
m_Query->Close();
if(FCurrency!=m_PohCurrency)
m_PohEnrate=value;
else
m_PohEnrate=1;
}
//---------------------------------------------------------------------------
void __fastcall TsdPoh::SetPohTaxCode(AnsiString value)
{
if(value.Length()>18)
throw Exception("税码长度不能大于18");
if(value!=m_PohTaxCode)
{
m_Query->Close();
m_Query->SQL->Clear();
m_Query->SQL->Add("select taxcode from sdtax where taxcode='"+value+"'");
m_Query->Open();
if(m_Query->RecordCount<=0)
{
m_Query->Close();
throw Exception("税码'"+value+"'未定义");
}
m_Query->Close();
}
m_PohTaxCode = value;
}
//---------------------------------------------------------------------------
void __fastcall TsdPoh::SetPohPmode(AnsiString value)
{
if(value.IsEmpty())
throw Exception("采购方式不能为空");
if(value.Length()>18)
throw Exception("采购方式代码长度不能大于18");
if(value!=m_PohPmode)
{
m_Query->Close();
m_Query->SQL->Clear();
m_Query->SQL->Add("Select PmodeCode from sdPmode where PmodeCode='"+value+"'");
m_Query->Open();
if(m_Query->RecordCount<=0)
{
m_Query->Close();
throw Exception("采购方式'"+value+"'未定义");
}
m_Query->Close();
}
m_PohPmode = value;
}
//---------------------------------------------------------------------------
void __fastcall TsdPoh::SetPohContract(AnsiString value)
{
if(value.Length()>18)
throw Exception("合同编号长度不能大于18");
m_PohContract = value;
}
//---------------------------------------------------------------------------
void __fastcall TsdPoh::SetPohBuyer(AnsiString value)
{
if(value.IsEmpty())
throw Exception("采购员代码不能为空");
if(value.Length()>18)
throw Exception("采购员代码长度不能大于18");
if(value!=m_PohBuyer)
{
m_Query->Close();
m_Query->SQL->Clear();
m_Query->SQL->Add("select buyercode from sdbuyer where buyercode='"+value+"'");
m_Query->Open();
if(m_Query->RecordCount<=0)
{
m_Query->Close();
throw Exception("采购员代码'"+value+"'未定义");
}
m_Query->Close();
}
m_PohBuyer = value;
}
//---------------------------------------------------------------------------
void __fastcall TsdPoh::SetPohDate(AnsiString value)
{
if(value.IsEmpty())
throw Exception("操作日期不能为空");
m_PohDate = Validate(value);
}
//---------------------------------------------------------------------------
void __fastcall TsdPoh::SetPohDesc(AnsiString value)
{
if(value.Length()>40)
throw Exception("备注长度不能大于40");
m_PohDesc = value;
}
//---------------------------------------------------------------------------
void __fastcall TsdPoh::SetPohSugDate(AnsiString value)
{
if(value.IsEmpty()==false)
m_PohSugDate = Validate(value);
else
m_PohSugDate="";
}
//---------------------------------------------------------------------------
void __fastcall TsdPoh::SetPohAmt(double value)
{
m_PohAmt = value;
}
//---------------------------------------------------------------------------
void __fastcall TsdPoh::SetPohPayTerm(int value)
{
if(value<0)
throw Exception("付款期限不能小于零");
m_PohPayTerm = value;
}
//---------------------------------------------------------------------------
void __fastcall TsdPoh::SetPohPrePayAmt(double value)
{
if(value<0)
throw Exception("预付定金不能小于零");
m_PohPrePayAmt = value;
}
//---------------------------------------------------------------------------
void __fastcall TsdPoh::SetPohSettleMode(AnsiString value)
{
if(value.IsEmpty())
throw Exception("结算方式不能为空");
if(value.Length()>18)
throw Exception("结算方式长度不能大于18");
if(value!=m_PohSettleMode)
{
m_Query->Close();
m_Query->SQL->Clear();
m_Query->SQL->Add("select SettleModeCode from sdSettleMode where SettleModeCode='"+value+"'");
m_Query->Open();
if(m_Query->RecordCount<=0)
{
m_Query->Close();
throw Exception("结算方式代码:"+value+"未定义");
}
m_Query->Close();
}
m_PohSettleMode = value;
}
//---------------------------------------------------------------------------
void __fastcall TsdPoh::SetPohCarriage(double value)
{
if(value<0)
throw Exception("运输费用不能小于零");
m_PohCarriage = value;
}
void __fastcall TsdPoh::SetPohCheck(int value)
{
if(value!=0 && value!=1)
throw Exception("审核标志只能取值:0-未审1-已审");
m_PohCheck=value;
}
void __fastcall TsdPoh::SetPohChecker(AnsiString value)
{
if(m_PohCheck==1)
{
if(value.IsEmpty())
throw Exception("审核员不能为空");
if(value.Length()>18)
throw Exception("审核员代码长度不能大于18");
if(value!=m_PohChecker)
{
m_Query->Close();
m_Query->SQL->Clear();
m_Query->SQL->Add("select buyercode from sdBuyer where Buyercode='"+value+"' and buyercheck=1");
m_Query->Open();
if(m_Query->RecordCount<=0)
{
m_Query->Close();
throw Exception("审核员'"+value+"'未定义或没有审核权限");
}
m_Query->Close();
}
m_PohChecker=value;
}
else
m_PohChecker="";
}
void __fastcall TsdPoh::SetPohCheckDate(AnsiString value)
{
if(m_PohCheck==1)
{
if(value.IsEmpty())
throw Exception("审核日期不能为空");
m_PohCheckDate=Validate(value);
}
else
m_PohCheckDate="";
}
void __fastcall TsdPoh::SetPohCancel(int value)
{
if(value!=0 && value!=1)
throw Exception("取消标志只能取值0-正常1-取消");
m_PohCancel=value;
}
void __fastcall TsdPoh::SetPohCanceler(AnsiString value)
{
if(m_PohCancel==1)
{
if(value.IsEmpty())
throw Exception("取消人不能为空");
if(value.Length()>18)
throw Exception("取消人代码长度不能大于18");
if(value!=m_PohCanceler)
{
m_Query->Close();
m_Query->SQL->Clear();
m_Query->SQL->Add("select buyercode from sdBuyer where Buyercode='"+value+"' and buyercancel=1");
m_Query->Open();
if(m_Query->RecordCount<=0)
{
m_Query->Close();
throw Exception("取消人'"+value+"'未定义或没有取消权限");
}
m_Query->Close();
}
m_PohCanceler=value;
}
else
m_PohCanceler="";
}
void __fastcall TsdPoh::SetPohCancelDate(AnsiString value)
{
if(m_PohCancel==1)
{
if(value.IsEmpty())
throw Exception("取消日期不能为空");
m_PohCancelDate=Validate(value);
}
else
m_PohCancelDate="";
}
void __fastcall TsdPoh::SetPohStop(int value)
{
if(value!=0 && value!=1)
throw Exception("中止标志只能取值0-正常1-中止");
m_PohStop=value;
}
void __fastcall TsdPoh::SetPohClose(int value)
{
if(value!=0 && value!=1)
throw Exception("结清标志只能取值0-未结清1-已结清");
m_PohClose=value;
}
void __fastcall TsdPoh::SetPohPsite(AnsiString value)
{
if(value.IsEmpty())
throw Exception("交货地点不能为空");
if(value.Length()>18)
throw Exception("交货地点编码长度不能大于18");
if(value!=m_PohPsite)
{
m_Query->Close();
m_Query->SQL->Clear();
m_Query->SQL->Add("select Psitecode from sdPsite where Psitecode='"+value+"' and PsiteSupplyCode='"+m_PohSupply+"'");
m_Query->Open();
if(m_Query->RecordCount<=0)
{
m_Query->Close();
throw Exception("供应商:"+m_PohSupply+"交货地点:"+value+"未定义");
}
m_Query->Close();
}
m_PohPsite=value;
}
void __fastcall TsdPoh::SetPohDeliver(AnsiString value)
{
if(value.IsEmpty())
throw Exception("交货方式不能为空");
if(value.Length()>18)
throw Exception("交货方式编码长度不能大于18");
if(value!=m_PohDeliver)
{
m_Query->Close();
m_Query->SQL->Clear();
m_Query->SQL->Add("select Delivercode from sdDeliver where Delivercode='"+value+"'");
m_Query->Open();
if(m_Query->RecordCount<=0)
{
m_Query->Close();
throw Exception("交货方式编码:"+value+"未定义");
}
m_Query->Close();
}
m_PohDeliver=value;
}
void __fastcall TsdPoh::SetPohTransMode(AnsiString value)
{
if(value.IsEmpty())
throw Exception("运输方式不能为空");
if(value.Length()>18)
throw Exception("运输方式编码长度不能大于18");
if(value!=m_PohTransMode)
{
m_Query->Close();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -