📄 msoh.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "mSoh.h"
#include "zcomfun.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
TKSSoh *sdSoh;
//---------------------------------------------------------------------------
__fastcall TKSSoh::TKSSoh()
:TKSMidBase()
{
}
//---------------------------------------------------------------------------
void __fastcall TKSSoh::ValidMasterField(int FieldNo)
{
switch(FieldNo)
{
case 1: //订单号
ValidSohCode();
break;
case 2: //订单类型
ValidSohType();
break;
case 3: //制单日期
ValidSohDate();
break;
case 4: //客户编码
ValidSohClient();
break;
case 5: //销售合同
ValidSohContract();
break;
case 6: //币种
ValidSohCurrency();
break;
case 7: //汇率
ValidSohEnrate();
break;
case 8: //税名
ValidSohTaxCode();
break;
case 9: //结算方式
ValidSohSettleMode();
break;
case 10: //销售定金
ValidSohDj();
break;
case 11: //运费承付方式
ValidSohPayTrans();
break;
case 12: //交货地址
ValidSohSsite();
break;
case 13: //交货方式
ValidSohDeliver();
break;
case 14: //运输方式
ValidSohTransMode();
break;
case 15: //备注
ValidSohDesc();
break;
case 16: //业务员
ValidSohSaler();
break;
case 17: //制单
ValidSohUser();
break;
case 18: //审核
ValidSohCheck();
break;
case 19: //审核人
ValidSohChecker();
break;
case 20: //审核日期
ValidSohCheckDate();
break;
case 21: //结清
ValidSohClose();
break;
case 22: //取消
ValidSohCancel();
break;
case 23: //取消原因
ValidSohCrCode();
break;
}
}
//---------------------------------------------------------------------------
void __fastcall TKSSoh::ValidSohCode() //订单号
{
/* AnsiString m_SohCode;
AnsiString b_SohCode;
m_SohCode=ReturnNeedValue(GetMasterValue("SohCode"),"");
b_SohCode=ReturnNeedValue(GetMasterOldValue("SohCode"),"");
if(m_SohCode.IsEmpty())
throw Exception("销售订单号不能为空");
if(m_SohCode.Length()>18)
throw Exception("销售订单号长度不能大于18");
if(m_SohCode != b_SohCode)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select SohCode from sdSoh where SohCode='"+m_SohCode+"'");
Query->Open();
if(Query->RecordCount>0)
{
Query->Close();
throw Exception("该销售订单单号:'"+m_SohCode+"'已经存在!");
}
Query->Close();
}
*/}
//---------------------------------------------------------------------------
void __fastcall TKSSoh::ValidSohType() //订单类型
{
int m_SohType;
m_SohType=ReturnNeedValue(GetMasterValue("SohType"),0);
if(m_SohType!=1 && m_SohType!=2)
throw Exception("订单类型只能取值1-销售订单,2-来料加工订单");
}
//---------------------------------------------------------------------------
void __fastcall TKSSoh::ValidSohDate() //制单日期
{
AnsiString m_SohDate;
m_SohDate=ReturnNeedValue(GetMasterValue("SohDate"),"");
if(m_SohDate.IsEmpty())
throw Exception("开单日期不能为空");
}
//---------------------------------------------------------------------------
void __fastcall TKSSoh::ValidSohClient() //客户编码
{
/* AnsiString m_SohClient;
AnsiString b_SohClient;
m_SohClient=ReturnNeedValue(GetMasterValue("SohClient"),"");
b_SohClient=ReturnNeedValue(GetMasterOldValue("SohClient"),"");
if(m_SohClient.IsEmpty())
throw Exception("销售订单的客户编码不能为空!");
if(m_SohClient.Length()>18)
throw Exception("销售订单客户代码长度不能大于18");
if(m_SohClient != b_SohClient)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select ClientCode,ClientTaxCode,Clientcurrency from sdClient where ClientCode='"+m_SohClient+"'");
Query->Open();
if(Query->RecordCount==0)
{
Query->Close();
throw Exception("该客户编号:'"+m_SohClient+"'不存在!");
}
Query->Close();
}
*/}
//---------------------------------------------------------------------------
void __fastcall TKSSoh::ValidSohContract() //销售合同
{
AnsiString m_SohContract;
m_SohContract=ReturnNeedValue(GetMasterValue("SohContract"),"");
if(m_SohContract.Length()>18)
throw Exception("合同编号长度不能大于18");
}
//---------------------------------------------------------------------------
void __fastcall TKSSoh::ValidSohCurrency() //币种
{
AnsiString m_SohCurrency;
AnsiString b_SohCurrency;
AnsiString m_SohClient=ReturnNeedValue(GetMasterValue("sohClient"),"");
m_SohCurrency=ReturnNeedValue(GetMasterValue("SohCurrency"),"");
b_SohCurrency=ReturnNeedValue(GetMasterOldValue("SohCurrency"),"");
if(m_SohCurrency.IsEmpty())
throw Exception("交易币种不能为空");
if(m_SohCurrency.Length()>18)
throw Exception("币种编码长度不能大于18");
if(m_SohClient.IsEmpty())
throw Exception("客户代码不能为空");
if(m_SohCurrency!=b_SohCurrency)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select currencycode,currencylocal from sdcurrency,sdssd where ssdcurrency=currencycode and currencycode='"+m_SohCurrency+"' and ssdclient='"+m_SohClient+"'");
Query->Open();
if(Query->RecordCount<1)
{
Query->Close();
throw Exception("当前客户未定义币种:"+m_SohCurrency+"");
}
// if(Query->FieldValues["CurrencyLocal"]==1)
// SetMasterValue("SohEnrate",1);
Query->Close();
}
}
//---------------------------------------------------------------------------
void __fastcall TKSSoh::ValidSohEnrate() //汇率
{
/* double m_SohEnrate;
AnsiString m_SohClient=ReturnNeedValue(GetMasterValue("sohClient"),0);
AnsiString m_SohCurrency=ReturnNeedValue(GetMasterValue("SohCurrency"),0);
m_SohEnrate=ReturnNeedValue(GetMasterValue("SohEnrate"),0);
AnsiString FCurrency;
if(m_SohClient.IsEmpty())
throw Exception("客户代码不能为空");
if(m_SohCurrency.IsEmpty())
throw Exception("币种代码不能为空");
if(m_SohEnrate<=0)
throw Exception("汇率不能小于等于零");
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select currencycode from sdCurrency where currencylocal=1");
Query->Open();
if(Query->RecordCount<=0)
{
Query->Close();
throw Exception("本币未定义");
}
FCurrency=Query->FieldValues["currencycode"];
Query->Close();
*/}
//---------------------------------------------------------------------------
void __fastcall TKSSoh::ValidSohTaxCode() //税名
{
/* AnsiString m_SohTaxCode;
AnsiString b_SohTaxCode;
m_SohTaxCode=ReturnNeedValue(GetMasterValue("SohTaxCode"),"");
b_SohTaxCode=ReturnNeedValue(GetMasterOldValue("SohTaxCode"),"");
if(m_SohTaxCode.Length()>18)
throw Exception("税名代码长度不能大于18");
if(m_SohTaxCode.IsEmpty()==false && m_SohTaxCode!=b_SohTaxCode)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select taxcode from sdtax where taxcode='"+m_SohTaxCode+"'");
Query->Open();
if(Query->RecordCount<=0)
{
Query->Close();
throw Exception("税码:"+m_SohTaxCode+"未定义");
}
Query->Close();
}
b_SohTaxCode = m_SohTaxCode;
*/}
//---------------------------------------------------------------------------
void __fastcall TKSSoh::ValidSohSettleMode() //结算方式
{
/* AnsiString m_SohSettleMode;
AnsiString b_SohSettleMode;
m_SohSettleMode=ReturnNeedValue(GetMasterValue("SohSettleMode"),"");
b_SohSettleMode=ReturnNeedValue(GetMasterOldValue("SohSettleMode"),"");
if(m_SohSettleMode.IsEmpty())
throw Exception("结算方式不能为空");
if(m_SohSettleMode.Length()>18)
throw Exception("结算方式长度不能大于18");
if(m_SohSettleMode!=b_SohSettleMode)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select settlemodecode from sdsettlemode where settlemodecode='"+m_SohSettleMode+"'");
Query->Open();
if(Query->RecordCount<=0)
{
Query->Close();
throw Exception("结算方式:"+m_SohSettleMode+"未定义");
}
Query->Close();
}
*/}
//---------------------------------------------------------------------------
void __fastcall TKSSoh::ValidSohDj() //销售定金
{
double m_SohDj;
m_SohDj=ReturnNeedValue(GetMasterValue("SohDj"),0);
if(m_SohDj<0)
throw Exception("订金不能小于零");
}
//---------------------------------------------------------------------------
void __fastcall TKSSoh::ValidSohPayTrans() //运费承付方式
{
int m_SohPayTrans;
m_SohPayTrans=ReturnNeedValue(GetMasterValue("SohPayTrans"),-1);
if(m_SohPayTrans!=0 && m_SohPayTrans!=1)
throw Exception("运费承付方式只能取值0-买方,1-卖方");
}
//---------------------------------------------------------------------------
void __fastcall TKSSoh::ValidSohSsite() //交货地址
{
AnsiString m_SohSsite;
AnsiString b_SohSsite;
AnsiString m_SohClient=ReturnNeedValue(GetMasterValue("sohClient"),"");
m_SohSsite=ReturnNeedValue(GetMasterValue("SohSsite"),"");
b_SohSsite=ReturnNeedValue(GetMasterOldValue("SohSsite"),"");
if(m_SohClient.IsEmpty())
throw Exception("订单客户未赋值");
if(m_SohSsite.IsEmpty())
throw Exception("交货地点不能为空");
if(m_SohSsite.Length()>18)
throw Exception("交货地点编码长度不能大于18");
if(m_SohSsite!=b_SohSsite)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select Ssitecode from sdssite where ssitecode='"+m_SohSsite+"' and ssiteclient='"+m_SohClient+"'");
Query->Open();
if(Query->RecordCount<=0)
{
Query->Close();
throw Exception("货运址:"+m_SohSsite+"未定义");
}
Query->Close();
}
}
//---------------------------------------------------------------------------
void __fastcall TKSSoh::ValidSohDeliver() //交货方式
{
/* AnsiString m_SohDeliver;
AnsiString b_SohDeliver;
m_SohDeliver=ReturnNeedValue(GetMasterValue("SohDeliver"),"");
b_SohDeliver=ReturnNeedValue(GetMasterOldValue("SohDeliver"),"");
if(m_SohDeliver.IsEmpty())
throw Exception("交货方式编码不能为空");
if(m_SohDeliver.Length()>18)
throw Exception("交货方式编码长度不能大于18");
if(m_SohDeliver!=b_SohDeliver)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select delivercode from sddeliver where delivercode='"+m_SohDeliver+"'");
Query->Open();
if(Query->RecordCount<=0)
{
Query->Close();
throw Exception("交货方式:"+m_SohDeliver+"未定义");
}
Query->Close();
}
*/}
//---------------------------------------------------------------------------
void __fastcall TKSSoh::ValidSohTransMode() //运输方式
{
/* AnsiString m_SohTransMode;
AnsiString b_SohTransMode;
m_SohTransMode=ReturnNeedValue(GetMasterValue("SohTransMode"),"");
if(GetMasterOldValue("SohTransMode").IsNull())
b_SohTransMode="";
else
b_SohTransMode=GetMasterOldValue("SohTransMode");
if(m_SohTransMode.IsEmpty())
throw Exception("运输方式不能为空!");
if(m_SohTransMode.Length()>18)
throw Exception("运输方式编码长度不能大于18");
if(m_SohTransMode.IsEmpty()==false && m_SohTransMode!=b_SohTransMode)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select transmodecode from sdtransmode where transmodecode='"+m_SohTransMode+"'");
Query->Open();
if(Query->RecordCount<=0)
{
Query->Close();
throw Exception("运输方式:"+m_SohTransMode+"未定义");
}
Query->Close();
}
*/}
//---------------------------------------------------------------------------
void __fastcall TKSSoh::ValidSohDesc() //备注
{
}
//---------------------------------------------------------------------------
void __fastcall TKSSoh::ValidSohSaler() //业务员
{
/* AnsiString m_SohSaler;
AnsiString b_SohSaler;
m_SohSaler=ReturnNeedValue(GetMasterValue("SohSaler"),"");
b_SohSaler=ReturnNeedValue(GetMasterOldValue("SohSaler"),"");
if(m_SohSaler.IsEmpty())
throw Exception("业务员不能为空");
if(m_SohSaler.Length()>18)
throw Exception("业务员代码长度不能大于18");
if(m_SohSaler!=b_SohSaler)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select salercode from sdsaler where salercode='"+m_SohSaler+"'");
Query->Open();
if(Query->RecordCount<=0)
{
Query->Close();
throw Exception("业务员代码:"+m_SohSaler+"未定义");
}
Query->Close();
}
*/}
//---------------------------------------------------------------------------
void __fastcall TKSSoh::ValidSohUser() //制单
{
/* AnsiString m_SohUser;
AnsiString b_SohUser;
m_SohUser=GetMasterValue("SohUser");
b_SohUser=GetMasterOldValue("SohUser");
if(m_SohUser.IsEmpty())
throw Exception("操作员代码不能为空");
if(m_SohUser.Length()>18)
throw Exception("操作员代码长度不能大于18");
if(m_SohUser!=b_SohUser)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select Usercode from sdUser where usercode='"+m_SohUser+"'");
Query->Open();
if(Query->RecordCount<=0)
{
Query->Close();
throw Exception("操作员:"+m_SohUser+"未定义");
}
Query->Close();
}*/
}
//---------------------------------------------------------------------------
void __fastcall TKSSoh::ValidSohCheck() //审核
{
}
//---------------------------------------------------------------------------
void __fastcall TKSSoh::ValidSohChecker() //审核人
{
}
//---------------------------------------------------------------------------
void __fastcall TKSSoh::ValidSohCheckDate() //审核日期
{
}
//---------------------------------------------------------------------------
void __fastcall TKSSoh::ValidSohClose() //结清
{
int m_SohClose;
m_SohClose=GetMasterValue("SohClose");
int b_SohClose;
b_SohClose=GetMasterOldValue("SohClose");
if(m_SohClose!=b_SohClose)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("Select SalerCode,SalerCheck,SalerClose from sdSaler where SalerCode='"+GetMasterValue("SohUser")+"'");
Query->Open();
if(Query->RecordCount<1)
{
Query->Close();
throw Exception("您没在销售员表中定义!");
}
else
{
if(Query->FieldValues["SalerClose"]==0)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -