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

📄 imhdl.cpp

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

//**************************************
//     (TsdAlfh)调拨单单头
//**************************************

void __fastcall TsdAlfh::SetAlfhCode(AnsiString value)
{
    if(value.IsEmpty())
        throw Exception("调拔单编码不能为空!");
    if(value.Length()>18)
      throw Exception("调拔单号长度不能大于18");
    if(value.UpperCase()    !=  m_AlfhCode.UpperCase())
    {
        m_Query->Close();
        m_Query->SQL->Clear();
        m_Query->SQL->Add("SELECT AlfhCODE FROM SDAlfh WHERE AlfhCODE='" +value+"'");
        m_Query->Open();
        if(m_Query->RecordCount>0)
        {
            m_Query->Close();
            throw Exception("调拔单号'"+value+"'已存在");
        }
        m_Query->Close();
    }

    m_AlfhCode = value;
}

void __fastcall TsdAlfh::SetAlfhDate(AnsiString value)
{
    if(value.IsEmpty())
      throw Exception("调拔日期不能为空");
    m_AlfhDate=Validate(value);
}

void __fastcall TsdAlfh::SetAlfhODept(AnsiString value)
{
    if(value.IsEmpty())
      throw Exception("转出部门编码不能为空");
    if(value.Length()>18)
      throw Exception("转出部门编码长度不能大于18");
    if(value!=m_AlfhODept)
    {
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add("select deptcode from sddept where deptcode='"+value+"'");
      m_Query->Open();
      if(m_Query->RecordCount<=0)
      {
        m_Query->Close();
        throw Exception("转出部门编码:"+value+"未定义");
      }
      m_Query->Close();
    }
    m_AlfhODept=value;
}


void __fastcall TsdAlfh::SetAlfhPosType(AnsiString value)
{
    if(value.IsEmpty())
      throw Exception("收发存项目编码不能为空");
    if(value.Length()>18)
      throw Exception("项目编码长度不能大于18");
    if(value!=m_AlfhPosType)
    {
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add("select postypecode from sdpostype where postypecode='"+value+"'");
      m_Query->Open();
      if(m_Query->RecordCount<=0)
      {
        m_Query->Close();
        throw Exception("收发存项目编码:"+value+"未定义");
      }
      m_Query->Close();
    }
    m_AlfhPosType=value;
}


void __fastcall TsdAlfh::SetAlfhIDept(AnsiString value)
{
    if(value.IsEmpty())
      throw Exception("转入部门编码不能为空");
    if(value.Length()>18)
      throw Exception("转入部门编码长度不能大于18");
    if(value!=m_AlfhIDept)
    {
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add("select deptcode from sddept where deptcode='"+value+"'");
      m_Query->Open();
      if(m_Query->RecordCount<=0)
      {
        m_Query->Close();
        throw Exception("转入部门编码:"+value+"未定义");
      }
      m_Query->Close();
    }
    m_AlfhIDept=value;
}


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


void __fastcall TsdAlfh::SetAlfhCheck(int value)
{
    if(value!=0 && value!=1)
      throw Exception("审核标志只能取值0-未审核1-已审");
    m_AlfhCheck=value;
}


void __fastcall TsdAlfh::SetAlfhChecker(AnsiString value)
{
    if(m_AlfhCheck==1)
    {
      if(value.IsEmpty())
        throw Exception("审核员代码不能为空");
      if(value.Length()>18)
        throw Exception("审核员代码长度不能大于18");
      if(value!=m_AlfhChecker)
      {
        m_Query->Close();
        m_Query->SQL->Clear();
        m_Query->SQL->Add("select keepercode from sdkeeper where keepercode='"+value+"' and Keepercheck=1");
        m_Query->Open();
        if(m_Query->RecordCount<=0)
        {
          m_Query->Close();
          throw Exception("审核员代码未定义或没有审核权限");
        }
        m_Query->Close();
      }
      m_AlfhChecker=value;
    }
    else
      m_AlfhChecker="";
}

void __fastcall TsdAlfh::SetAlfhCheckDate(AnsiString value)
{
    if(m_AlfhCheck==1)
    {
      if(value.IsEmpty())
        throw Exception("审核日期不能为空");
      m_AlfhCheckDate=Validate(value);
    }
    else
      m_AlfhCheckDate="";
}


void __fastcall TsdAlfh::SetAlfhInvFlg(int value)
{
    //库存控制不能录入
    //m_AlfhInvFlg=value;
}
void __fastcall TsdAlfh::SetAlfhFmonth(AnsiString value)
{
//    AnsiString s;
    if(value.IsEmpty())
      throw Exception("财务月份不能为空");
/*
    if(value!=m_AlfhFmonth)
    {
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add("select fcmonth from sdfc where fcmonth='"+value+"'");
      m_Query->Open();
      if(m_Query->RecordCount<=0)
      {
        m_Query->Close();
        throw Exception("财务月份:"+value+"未定义");
      }
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add("select fcmonth from sdfc where fccurrent=1");
      m_Query->Open();
      if(m_Query->RecordCount<=0)
      {
        m_Query->Close();
        throw Exception("未定义当前财务月份");
      }
      s=m_Query->FieldValues["FcMonth"];
      if(value<s)
      {
        m_Query->Close();
        throw Exception("财务月份不能小于当前月份");
      }
      m_Query->Close();
    }
*/    
    m_AlfhFmonth=value;
}


void __fastcall TsdAlfh::SetAlfhUser(AnsiString value)
{
    if(value.IsEmpty())
      throw Exception("操作员代码不能为空");
    if(value.Length()>18)
      throw Exception("操作员代码长度不能大于18");
    if(value!=m_AlfhUser)
    {
      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_AlfhUser=value;
}

void __fastcall TsdAlfh::SetAlfhKeeper(AnsiString value)
{
    if(value.IsEmpty())
      throw Exception("仓管员代码不能为空");
    if(value.Length()>18)
      throw Exception("仓管员代码长度不能大于18");
    if(value!=m_AlfhKeeper)
    {
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add("select keepercode from sdkeeper where keepercode='"+value+"'");
      m_Query->Open();
      if(m_Query->RecordCount<=0)
      {
        m_Query->Close();
        throw Exception("仓管员:"+value+"未定义");
      }
      m_Query->Close();
    }
    m_AlfhKeeper=value;
}

void __fastcall TsdAlfh::SetAlfhCancel(int value)
{
    if(value!=0 && value!=1)
      throw Exception("取消标志只能取值0-正常 1-取消");
    m_AlfhCancel=value;
}

void __fastcall TsdAlfh::SetAlfhCancelDate(AnsiString value)
{
    if(m_AlfhCancel==1)
    {
      if(value.IsEmpty())
        throw Exception("取消日期不能为空");
      m_AlfhCancelDate=Validate(value);
    }
    else
      m_AlfhCancelDate="";
}

void __fastcall TsdAlfh::SetAlfhType(int value)
{
    if(value!=1)
      throw Exception("调拔类型只能取值1-库存调拔");
    m_AlfhType=value;
}


//---------------------------------------------------------------------------
AnsiString TsdAlfh::GetFieldValue(euAlfh sdFieldName)
{
    switch(sdFieldName)
    {
      case fiAlfhCode:
        return  AlfhCode;
      case fiAlfhDate:
        return  AlfhDate;
      case fiAlfhODept:
        return  AlfhODept;
      case fiAlfhIDept:
        return  AlfhIDept;
      case fiAlfhPosType:
        return  AlfhPosType;
      case fiAlfhDesc:
        return  AlfhDesc;
      case fiAlfhCheck:
        return  AlfhCheck;
      case fiAlfhChecker:
        return  AlfhChecker;
      case fiAlfhCheckDate:
        return  AlfhCheckDate;
      case fiAlfhInvFlg:
        return  AlfhInvFlg;
      case fiAlfhFmonth:
        return  AlfhFmonth;
      case fiAlfhUser:
        return  AlfhUser;
      case fiAlfhKeeper:
        return AlfhKeeper;
      case fiAlfhCancel:
        return  AlfhCancel;
      case fiAlfhCancelDate:
        return  AlfhCancelDate;
      case fiAlfhSysDate:
        return  AlfhSysDate;
      case fiAlfhType:
        return  AlfhType;
      default:
        throw Exception("没有定义该字段的返回值");
    }
}
//---------------------------------------------------------------------------

void TsdAlfh::SetFieldValue(euAlfh sdFieldName, AnsiString Value)
{
    switch(sdFieldName)
    {
        case fiAlfhCode:
          AlfhCode =Value;
          break;
        case fiAlfhDate:
          AlfhDate=Value;
          break;
        case fiAlfhODept:
          AlfhODept=Value;
          break;
        case fiAlfhPosType:
          AlfhPosType=Value;
          break;
        case fiAlfhIDept:
          AlfhIDept=Value;
          break;
        case fiAlfhDesc:
          AlfhDesc=Value;
          break;
        case fiAlfhCheck:
          AlfhCheck=Value.ToInt();
          break;
        case fiAlfhChecker:
          AlfhChecker=Value;
          break;
        case fiAlfhCheckDate:
          AlfhCheckDate=Value;
          break;
        case fiAlfhInvFlg:
          AlfhInvFlg=Value.ToInt();
          break;
        case fiAlfhFmonth:
          AlfhFmonth=Value;
          break;
        case fiAlfhUser:
          AlfhUser=Value;
          break;
        case fiAlfhKeeper:
          AlfhKeeper=Value;
          break;
        case fiAlfhCancel:
          AlfhCancel=Value.ToInt();
          break;
        case fiAlfhCancelDate:
          AlfhCancelDate=Value;
          break;
        case fiAlfhType:
          AlfhType=Value.ToInt();
          break;
        default:
          throw Exception("该字段未定义成可赋值类型");
    }
}
//---------------------------------------------------------------------------

TsdAlfh::TsdAlfh(TDataComm *DC)
                :TsdHead(DC)
{
    try
    {
        QueryString="SELECT * FROM SDAlfh";
        FilterString="";
        OrderString="AlfhCODE";
        m_sdAlfd=NULL;
        EmptyValue(0);
        EmptyValue(1);
    }
    catch(Exception &e)
    {
        throw Exception("初始化出错");
    }
}

//---------------------------------------------------------------------------
TsdAlfh::TsdAlfh()
                :TsdHead()
{
    try
    {
        QueryString="SELECT * FROM SDAlfh";
        FilterString="";
        OrderString="AlfhCODE";
        m_sdAlfd=NULL;
        EmptyValue(0);
        EmptyValue(1);
    }
    catch(Exception &e)
    {
        throw Exception("初始化出错");
    }
}

//---------------------------------------------------------------------------

TsdAlfh::~TsdAlfh()
{
  try{
    for(int i=0;i<this->Count;i++)
    {
      LocateByIndex(i);
      AssignValue();
      delete m_sdAlfd;
    }

⌨️ 快捷键说明

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