⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smhdl.cpp

📁 速达开源ERP系统
💻 CPP
📖 第 1 页 / 共 5 页
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#define _YW_SDERP_DLL
#include "smhdl.h"
//---------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)

////////////////////////////////////////////
//*******销售订单的单头维护*****************
////////////////////////////////////////////

void __fastcall TsdSoh::SetSohCode(AnsiString value)
{
    if(value.IsEmpty())
      throw Exception("销售订单号不能为空");
    if(value.Length()>18)
      throw Exception("销售订单号长度不能大于18");
    if(value != m_SohCode)
    {
        m_Query->Close();
        m_Query->SQL->Clear();
        m_Query->SQL->Add("select SohCode from sdSoh where SohCode='"+value+"'");
        m_Query->Open();
        if(m_Query->RecordCount>0)
        {
           m_Query->Close();
           throw Exception("该销售订单单号:'"+value+"'已经存在!");
        }
        m_Query->Close();
    }
    m_SohCode = value;
}
//---------------------------------------------------------------------------

void __fastcall TsdSoh::SetSohType(int value)
{
    if(value!=1 && value!=2)
      throw Exception("订单类型只能取值1-销售订单,2-来料加工订单");
    m_SohType = value;
}
//---------------------------------------------------------------------------
void __fastcall TsdSoh::SetSohDate(AnsiString value)
{
    if(value.IsEmpty())
      throw Exception("开单日期不能为空");
    m_SohDate = Validate(value);
}
//---------------------------------------------------------------------------
void __fastcall TsdSoh::SetSohClient(AnsiString value)
{
    if(value.IsEmpty())
        throw Exception("销售订单的客户编码不能为空!");
    if(value.Length()>18)
      throw Exception("销售订单客户代码长度不能大于18");
    if(value != m_SohCode)
    {
        m_Query->Close();
        m_Query->SQL->Clear();
        m_Query->SQL->Add("select ClientCode,ClientTaxCode,Clientcurrency from sdClient where ClientCode='"+value+"'");
        m_Query->Open();
        if(m_Query->RecordCount==0)
        {
           m_Query->Close();
           throw Exception("该客户编号:'"+value+"'不存在!");
        }
        m_Query->Close();
     }
    m_SohClient = value;
}
//---------------------------------------------------------------------------
void __fastcall TsdSoh::SetSohSaler(AnsiString value)
{
    if(value.IsEmpty())
      throw Exception("业务员不能为空");
    if(value.Length()>18)
      throw Exception("业务员代码长度不能大于18");
    if(value!=m_SohSaler)
    {
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add("select salercode from sdsaler where salercode='"+value+"'");
      m_Query->Open();
      if(m_Query->RecordCount<=0)
      {
        m_Query->Close();
        throw Exception("业务员代码:"+value+"未定义");
      }
      m_Query->Close();
    }
    m_SohSaler = value;
}
//---------------------------------------------------------------------------
void __fastcall TsdSoh::SetSohContract(AnsiString value)
{
    if(value.Length()>18)
      throw Exception("合同编号长度不能大于18");
    m_SohContract = value;
}
//---------------------------------------------------------------------------
void __fastcall TsdSoh::SetSohCurrency(AnsiString value)
{
    if(value.IsEmpty())
      throw Exception("交易币种不能为空");
    if(value.Length()>18)
      throw Exception("币种编码长度不能大于18");
    if(m_SohClient.IsEmpty())
      throw Exception("客户代码不能为空");
    if(value!=m_SohCurrency)
    {
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add("select currencycode,currencylocal from sdcurrency,sdssd where ssdcurrency=currencycode and currencycode='"+value+"' and ssdclient='"+m_SohClient+"'");
      m_Query->Open();
      if(m_Query->RecordCount<1)
      {
        m_Query->Close();
        throw Exception("当前客户未定义币种:"+value+"");
      }
      if(m_Query->FieldValues["CurrencyLocal"]==1)
        m_SohEnrate=1;
      m_Query->Close();
    }
    m_SohCurrency = value;
}
//---------------------------------------------------------------------------
void __fastcall TsdSoh::SetSohEnrate(double value)
{
    AnsiString FCurrency;
    if(m_SohClient.IsEmpty())
      throw Exception("客户代码不能为空");
    if(m_SohCurrency.IsEmpty())
      throw Exception("币种代码不能为空");
    if(value<=0)
      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.UpperCase()!=m_SohCurrency.UpperCase())
      m_SohEnrate=value;
    else
      m_SohEnrate=1;
}
//---------------------------------------------------------------------------
void __fastcall TsdSoh::SetSohTaxCode(AnsiString value)
{
    if(value.Length()>18)
      throw Exception("税名代码长度不能大于18");
    if(value.IsEmpty()==false && value!=m_SohTaxCode)
    {
      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_SohTaxCode = value;
}
//---------------------------------------------------------------------------
void __fastcall TsdSoh::SetSohSettleMode(AnsiString value)
{
    if(value.IsEmpty())
      throw Exception("结算方式不能为空");
    if(value.Length()>18)
      throw Exception("结算方式长度不能大于18");
    if(value!=m_SohSettleMode)
    {
      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_SohSettleMode = value;
}
//---------------------------------------------------------------------------
void __fastcall TsdSoh::SetSohDeliver(AnsiString value)
{
    if(value.IsEmpty())
      throw Exception("交货方式编码不能为空");
    if(value.Length()>18)
      throw Exception("交货方式编码长度不能大于18");
    if(value!=m_SohDeliver)
    {
      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_SohDeliver = value;
}
//---------------------------------------------------------------------------
void __fastcall TsdSoh::SetSohSsite(AnsiString value)
{
    if(m_SohClient.IsEmpty())
      throw Exception("订单客户未赋值");
    if(value.IsEmpty())
      throw Exception("交货地点不能为空");
    if(value.Length()>18)
      throw Exception("交货地点编码长度不能大于18");
    if(value!=m_SohSsite)
    {
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add("select Ssitecode from sdssite where ssitecode='"+value+"' and ssiteclient='"+m_SohClient+"'");
      m_Query->Open();
      if(m_Query->RecordCount<=0)
      {
        m_Query->Close();
        throw Exception("货运址:"+value+"未定义");
      }
      m_Query->Close();
    }
    m_SohSsite = value;
}
//---------------------------------------------------------------------------
void __fastcall TsdSoh::SetSohTransMode(AnsiString value)
{
    if(value.IsEmpty())
      throw Exception("运输方式不能为空!");
    if(value.Length()>18)
      throw Exception("运输方式编码长度不能大于18");
    if(value.IsEmpty()==false && value!=m_SohTransMode)
    {
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add("select transmodecode from sdtransmode where transmodecode='"+value+"'");
      m_Query->Open();
      if(m_Query->RecordCount<=0)
      {
        m_Query->Close();
        throw Exception("运输方式:"+value+"未定义");
      }
      m_Query->Close();
    }
    m_SohTransMode = value;
}
//---------------------------------------------------------------------------
void __fastcall TsdSoh::SetSohPayTrans(int value)
{
    if(value!=0 && value!=1)
      throw Exception("运费承付方式只能取值0-买方,1-卖方");
    m_SohPayTrans = value;
}
//---------------------------------------------------------------------------
void __fastcall TsdSoh::SetSohDj(double value)
{
    if(value<0)
     throw Exception("订金不能小于零");
    m_SohDj = value;
}
//---------------------------------------------------------------------------

void __fastcall TsdSoh::SetSohUser(AnsiString value)
{
    if(value.IsEmpty())
      throw Exception("操作员代码不能为空");
    if(value.Length()>18)
      throw Exception("操作员代码长度不能大于18");
    if(value!=m_SohUser)
    {
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add("select Usercode from sdUser where usercode='"+value+"'");
      m_Query->Open();
      if(m_Query->RecordCount<=0)
      {
        m_Query->Close();
        throw Exception("操作员:"+value+"未定义");
      }
      m_Query->Close();
      m_SohUser = value;
    }
}
//---------------------------------------------------------------------------

void __fastcall TsdSoh::SetSohDesc(AnsiString value)
{
    if(value.Length()>40)
      throw Exception("备注长度不能大于40");
    m_SohDesc = value;
}

void __fastcall TsdSoh::SetSohCrCode(AnsiString value)
{
    if(m_SohCancel==1)
    {
      if(value.IsEmpty())
        throw Exception("订单作废时,作废原因不能为空");
      if(value.Length()>18)
        throw Exception("作废原因代码长度不能大于18");
      if(value!=m_SohCrCode)
      {
        m_Query->Close();
        m_Query->SQL->Clear();
        m_Query->SQL->Add("select socrcode from sdsocr where socrcode='"+value+"'");
        m_Query->Open();
        if(m_Query->RecordCount<=0)
        {
          m_Query->Close();
          throw Exception("取消原因代码:"+value+"未定义");
        }
        m_Query->Close();
      }
      m_SohCrCode=value;
    }
    else
      m_SohCrCode="";
}


void __fastcall TsdSoh::SetSohCancel(int value)
{
  if(value!=0 && value!=1)
   throw Exception("取消标志只能为:0-未取消,1-取消");
  if(value!=b_SohCancel)
  {
  m_Query->Close();
  m_Query->SQL->Clear();
  m_Query->SQL->Add("Select SalerCode,SalerCheck,SalerCancel from sdSaler where SalerCode='"+g_sdUserCode+"'");
  m_Query->Open();
  if(m_Query->RecordCount<1)
  {
   m_Query->Close();
     throw Exception("您没在销售员表中定义!");
   }
   else
   {
   if(m_Query->FieldValues["SalerCancel"]==0)
     {
      m_Query->Close();
      throw Exception("您没有取消/反取消权限");
     }
     m_SohCancel=value;
   }
  }
}


void __fastcall TsdSoh::SetSohCancelDate(AnsiString value)
{
    if(m_SohCancel==1)
    {
      if(value.IsEmpty())
        throw Exception("取消日期不能为空");
      m_SohCancelDate=Validate(value);
    }
    else
      m_SohCancelDate="";
}

void __fastcall TsdSoh::SetSohCheck(int value)
{
 if(value!=0 && value!=1)
   throw Exception("审核标志只能为:0-未审核,1-审核");
   if(value!=b_SohCheck)
     {
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add("Select SalerCode,SalerCheck,SalerCancel from sdSaler where SalerCode='"+g_sdUserCode+"'");
      m_Query->Open();
      if(m_Query->RecordCount<1)
      {
       m_Query->Close();
         throw Exception("您没在销售员表中定义!");
       }
       else
       {
       if(m_Query->FieldValues["SalerCheck"]==0)
         {
          m_Query->Close();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -