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

📄 smdoc.cpp

📁 邮 电 公 司 erp源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#define _YW_SDERP_DLL
#include "SmDoc.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)

//销售基本资料模块(sdSmDoc.Dll)
//***************************************************************************
//    (TsdSmode)销售方式
//***************************************************************************
void __fastcall TsdSmode::SetSmodeCode(AnsiString value)
{
    if (value.IsEmpty() )
       throw Exception("销售方式编码不能为空!");
    if(value.Length()>18)
      throw Exception("销售方式编码长度不能大于18");
    if (value.UpperCase()!=m_SmodeCode.UpperCase())
    {
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add("SELECT SmodeCODE FROM SDSmode WHERE SmodeCODE='" +value+"'");
      m_Query->Open();
      if(m_Query->RecordCount>0)
      {
        m_Query->Close();
        throw Exception("销售方式编码'"+value+"'已存在");
      }
      m_Query->Close();
    }
    m_SmodeCode = value;
}
//---------------------------------------------------------------------------
void __fastcall TsdSmode::SetSmodeName(AnsiString value)
{
    if(value.IsEmpty())
      throw Exception("销售方式名称不能为空");
    if(value.Length()>20)
      throw Exception("销售方式名称长度不能大于20");
    m_SmodeName = value;
}

//---------------------------------------------------------------------------
void __fastcall TsdSmode::SetSmodeDesc(AnsiString value)
{
    if(value.Length()>40)
      throw Exception("备注长度不能大于40");
    m_SmodeDesc = value;
}
//---------------------------------------------------------------------------
TsdSmode::TsdSmode(TDataComm *DC)
            :TsdStandard(DC)
{
    try
    {
        QueryString="SELECT * FROM SDSmode";
        FilterString="";
        OrderString="SmodeCODE";
        EmptyValue(0);
        EmptyValue(1);

    }
    catch(Exception &e)
    {
        throw Exception("构造函数出错");
    }
}
TsdSmode::TsdSmode()
            :TsdStandard()
{
    try
    {
        QueryString="SELECT * FROM SDSmode";
        FilterString="";
        OrderString="SmodeCODE";
        EmptyValue(0);
        EmptyValue(1);

    }
    catch(Exception &e)
    {
        throw Exception("构造函数出错");
    }
}

//---------------------------------------------------------------------------
AnsiString TsdSmode::GetFieldValue(euSmode sdFieldName)
{
    switch(sdFieldName)
    {
      case fiSmodeCode:
        return SmodeCode;
      case fiSmodeName:
        return SmodeName;
      case fiSmodeDesc:
        return SmodeDesc;
      default:
        throw Exception("当前字段未定义可取值");  
    }
}
//---------------------------------------------------------------------------
void TsdSmode::SetFieldValue(euSmode sdFieldName, AnsiString Value)
{
    Value=Trim(Value);
    switch(sdFieldName)
    {
    case fiSmodeCode:
        SmodeCode=Value;
        break;
    case fiSmodeName:
        SmodeName=Value;
        break;
    case fiSmodeDesc:
        SmodeDesc=Value;
        break;
      default: 
        throw Exception("当前字段未定义可赋值");  
        
    }
}
//---------------------------------------------------------------------------

void TsdSmode::Update()
{
    if(CurStatus==0||CurStatus==1)
        throw Exception("当前不是编辑状态,不能进行存盘操作!");
    if(m_SmodeCode.IsEmpty()==true)
        throw Exception("销售方式编码不能为空!");
    if(m_SmodeName.IsEmpty()==true)
        throw Exception("销售方式名称不能为空!");
    m_StoredProc->Close();
    if(CurStatus==2||CurStatus==4)
    {
        m_StoredProc->ProcedureName="sdSmode_Insert";
        m_StoredProc->Parameters->Clear();
        m_StoredProc->Parameters->CreateParameter("@SmodeCode",ftString,pdInputOutput,18,m_SmodeCode);
        m_StoredProc->Parameters->CreateParameter("@SmodeName",ftString,pdInput,20,m_SmodeName);
        m_StoredProc->Parameters->CreateParameter("@SmodeDesc",ftString,pdInput,40,m_SmodeDesc);
        m_StoredProc->ExecProc();
        m_SmodeCode=m_StoredProc->Parameters->ParamValues["@SmodeCode"];
   }
  else
    {
        m_StoredProc->ProcedureName="sdSmode_Update";
        m_StoredProc->Parameters->Clear();
        m_StoredProc->Parameters->CreateParameter("@W_SmodeCode",ftString,pdInput,18,b_SmodeCode);
        m_StoredProc->Parameters->CreateParameter("@SmodeCode",ftString,pdInput,18,m_SmodeCode);
        m_StoredProc->Parameters->CreateParameter("@SmodeName",ftString,pdInput,20,m_SmodeName);
        m_StoredProc->Parameters->CreateParameter("@SmodeDesc",ftString,pdInput,40,m_SmodeDesc);

       m_StoredProc->ExecProc();
  }
    m_StoredProc->Close();
   TsdSmode *p=new TsdSmode();
    if(CurStatus==2)
    {
      SetActionID(1);
      p->Assign(this);
      AddRecord((void *)p,p->SmodeCode);
    }
    else
    {
      SetActionID(1);
      p->Assign(this);
      ChangeRecord((void *)p,p->SmodeCode,this->b_SmodeCode);
    }
}
//---------------------------------------------------------------------------

void TsdSmode::Delete()
{
    if(CurStatus!=1)
        throw Exception("当前状态不能进行删除操作!");
    if(m_SmodeCode.IsEmpty()==true)
        throw Exception("当前没有记录可以删除!");
    m_StoredProc->Close();
    m_StoredProc->ProcedureName="sdSmode_Delete";
    m_StoredProc->Parameters->Clear();
        m_StoredProc->Parameters->CreateParameter("@W_SmodeCode",ftString,pdInput,18,b_SmodeCode);
    m_StoredProc->ExecProc();
    m_StoredProc->Close();
    DeleteRecord(this->b_SmodeCode);

}
//---------------------------------------------------------------------------
void TsdSmode::BackupValue()
{
    b_SmodeCode=m_SmodeCode;
    b_SmodeName=m_SmodeName;
    b_SmodeDesc=m_SmodeDesc;
}
//---------------------------------------------------------------------------
void TsdSmode::RestoreValue()
{
    m_SmodeCode=b_SmodeCode;
    m_SmodeName=b_SmodeName;
    m_SmodeDesc=b_SmodeDesc;
}
//---------------------------------------------------------------------------
void TsdSmode::EmptyValue(int Index)
{
   switch(Index)
   {
   case 0:
      m_SmodeCode="";
      m_SmodeName="";
      m_SmodeDesc="";
      break;
   case 1:
      b_SmodeCode="";
      b_SmodeName="";
      b_SmodeDesc="";
      break;
    }
}
//---------------------------------------------------------------------------

void TsdSmode::BatchLetValue()
{
    m_SmodeCode=m_Query->FieldValues["SmodeCode"];
    m_SmodeName=m_Query->FieldValues["SmodeName"];
    m_SmodeDesc=m_Query->FieldValues["SmodeDesc"];

    BackupValue();
}
//---------------------------------------------------------------------------
void TsdSmode::Assign(TsdSmode *p)
{
    this->SetActionID(p->CurStatus);
    this->m_SmodeCode=p->m_SmodeCode;
    this->m_SmodeName=p->m_SmodeName;
    this->m_SmodeDesc=p->m_SmodeDesc;
    this->BackupValue();
}
//---------------------------------------------------------------------------
void TsdSmode::AssignValue()
{
    TsdSmode *p=(TsdSmode *)Records(CurRecNo);
    Assign(p);
}
//---------------------------------------------------------------------------
int TsdSmode::Query()
{
    AnsiString m_SqlStr;
    m_SqlStr=QueryString;
    if(FilterString.IsEmpty()==false)
        m_SqlStr=m_SqlStr+" where "+FilterString;
    if(OrderString.IsEmpty()==false)
        m_SqlStr=m_SqlStr+" Order by "+OrderString;
    m_Query->Close();
    m_Query->SQL->Clear();
    m_Query->SQL->Add(m_SqlStr);
    m_Query->Open();
    ClearRecord();
    if(m_Query->RecordCount>0)
    {
        m_Query->First();
        while(!m_Query->Eof)
        {
            BatchLetValue();
            TsdSmode *p=new TsdSmode();
            SetActionID(1);
            p->Assign(this);
            AddRecord((void *)p,p->SmodeCode);
            m_Query->Next();
        }
        MoveFirst();
    }
    m_Query->Close();
    return Count;
}
//---------------------------------------------------------------------------
bool TsdSmode::Find(AnsiString WhereStr)
{
    AnsiString m_SqlStr;
    if(WhereStr.IsEmpty()==true)
        throw Exception("查找表达式不能为空");
    m_SqlStr="SELECT * FROM SDSmode WHERE "+WhereStr;
    m_Query->Close();
    m_Query->SQL->Clear();
    m_Query->SQL->Add(m_SqlStr);
    m_Query->Open();
    if(m_Query->RecordCount!=1)
    {
        m_Query->Close();
        return false;
    }
    else
    {
        BatchLetValue();
        m_Query->Close();
        return true;
    }
}
//---------------------------------------------------------------------------
TsdSmode::~TsdSmode()
{
  try{
  }
  catch(...)
  {
    throw Exception("析构函数出错");
  }
}
//---------------------------------------------------------------------------


//***************************************************************************
//    (TsdSsite)客户交货地点
//***************************************************************************

//---------------------------------------------------------------------------
void __fastcall TsdSsite::SetSsiteCode(AnsiString value)
{
    if (value.IsEmpty() )
       throw Exception("客户的交货地点编码不能为空!");
    if(value.Length()>18)
      throw Exception("客户交货地点编码长度不能大于18");
    if (value.UpperCase()!=m_SsiteCode.UpperCase())
    {
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add("SELECT SsiteCODE FROM SDSsite WHERE SsiteCODE='" +value+"' and SSiteClient='"+m_SsiteClient+"'");
      m_Query->Open();
      if(m_Query->RecordCount>0)
      {
        m_Query->Close();
        throw Exception("客户的交货地点编码'"+value+"'已存在");
      }
      m_Query->Close();
    }
    m_SsiteCode = value;
}
//---------------------------------------------------------------------------

void __fastcall TsdSsite::SetSsiteClient(AnsiString value)
{
    if(value.IsEmpty())
      throw Exception("客户编码不能为空");
    if(value.Length()>18)
      throw Exception("客户编码长度不能大于18");
    if(value!=m_SsiteClient)
    {
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add("select clientcode from sdClient where ClientCode='"+value+"'");
      m_Query->Open();
      if(m_Query->RecordCount<=0)
      {
        m_Query->Close();
        throw Exception("客户编码:'"+value+"'未定义");
      }
      m_Query->Close();
    }
    m_SsiteClient=value;
}
//---------------------------------------------------------------------------

void __fastcall TsdSsite::SetSsiteName(AnsiString value)
{
    if(value.IsEmpty())
      throw Exception("交货地点名称不能为空");
    if(value.Length()>20)
      throw Exception("交货地点名称长度不能大于20");
    m_SsiteName   =   value;
}
//---------------------------------------------------------------------------

void __fastcall TsdSsite::SetSsiteAddr(AnsiString value)
{
    if(value.IsEmpty())
      throw Exception("交货地址不能为空");
    if(value.Length()>40)
      throw Exception("交货地址长度不能大于40");
    m_SsiteAddr=value;
}
//---------------------------------------------------------------------------

void __fastcall TsdSsite::SetSsiteLinkman(AnsiString value)
{
    if(value.Length()>20)
      throw Exception("联系人长度不能大于20");
    m_SsiteLinkman   =   value;
}
//---------------------------------------------------------------------------

void __fastcall TsdSsite::SetSsiteTel(AnsiString value)
{
    if(value.Length()>20)
      throw Exception("电话长度不能大于20");
    m_SsiteTel   =   value;
}
//---------------------------------------------------------------------------

void __fastcall TsdSsite::SetSsiteFax(AnsiString value)
{
    if(value.Length()>20)
      throw Exception("传真长度不能大于20");
    m_SsiteFax   =   value;
}
//---------------------------------------------------------------------------

void __fastcall TsdSsite::SetSsiteZip(AnsiString value)
{
   if(value.Length()>6)
    throw Exception("邮编长度不能大于6");
   m_SsiteZip   =   value;
}
//---------------------------------------------------------------------------

void __fastcall TsdSsite::SetSsiteEmail(AnsiString value)
{
    if(value.Length()>20)
      throw Exception("E-MAIL长度不能大于20");
    m_SsiteEmail   =   value;
}
//---------------------------------------------------------------------------

void __fastcall TsdSsite::SetSsiteTransMode(AnsiString value)
{

⌨️ 快捷键说明

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