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

📄 madjcoh.cpp

📁 科思ERP部分源码及控件
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop
#include "mAdjCoh.h"

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

#pragma package(smart_init)
TKSAdjCoh *sdAdjCoh;
//---------------------------------------------------------------------------
__fastcall TKSAdjCoh::TKSAdjCoh()
  :TKSMidBase()
{
}
//---------------------------------------------------------------------------
void __fastcall TKSAdjCoh::ValidHeadValues()
{
   AnsiString  l_AdjCohCode;
   AnsiString  b_AdjCohCode;
   l_AdjCohCode=GetMasterValue("AdjCohCode");
   b_AdjCohCode=GetMasterOldValue("AdjCohCode");
    if(l_AdjCohCode.IsEmpty())
        throw Exception("调整单号不能为空");
    if(l_AdjCohCode.Length()>18)
        throw Exception("调整单号长度不能超过18");

   AnsiString  l_AdjCohDate;
   l_AdjCohDate=GetMasterValue("AdjCohDate");
    if (l_AdjCohDate.IsEmpty())
      throw Exception("调整日期不能为空");
    if(l_AdjCohDate.Length()>10)
      throw Exception("调整日期长度不能超过10");

   AnsiString  l_AdjCohFmonth;
   l_AdjCohFmonth=GetMasterValue("AdjCohFmonth");
    if(l_AdjCohFmonth.IsEmpty()==true)
      throw Exception("财务月份不能为空");
    if(l_AdjCohFmonth.Length()>8)
      throw Exception("财务月份长度不能超过8");
      Query->Close();
      Query->SQL->Clear();
      Query->SQL->Add("SELECT Fcmonth FROM sdFc Where Fcmonth='"+l_AdjCohFmonth+"'");
      Query->Open();
      if(Query->RecordCount<=0)
      {
        Query->Close();
        throw Exception("财务月份 "+l_AdjCohFmonth+" 未定义");
      }
     Query->Close();

   AnsiString  l_AdjCohPosType;
   l_AdjCohPosType=GetMasterValue("AdjCohPosType");
    if (l_AdjCohPosType.IsEmpty())
      throw Exception("收发类型编码不能为空");
    if(l_AdjCohPosType.Length()>18)
      throw Exception("收发类型编码长度不能超过18");
      Query->Close();
      Query->SQL->Clear();
      Query->SQL->Add("select postypecode from sdpostype where postypecode='"+l_AdjCohPosType+"'");
      Query->Open();
      if(Query->RecordCount<1 )
      {
        Query->Close();
        throw Exception("收发类型编码 "+l_AdjCohPosType+" 未定义");
      }
      Query->Close();

   AnsiString  l_AdjCohDesc;
   l_AdjCohDesc=GetMasterValue("AdjCohDesc");
    if(l_AdjCohDesc.Length()>40)
      throw Exception("调整原因不能超过40");

/*
   AnsiString  l_AdjCohKeeper;
   l_AdjCohKeeper=GetMasterValue("AdjCohKeeper");
    if (l_AdjCohKeeper.IsEmpty())
      throw Exception("仓管员代码不能为空!");
    if(l_AdjCohKeeper.Length()>18)
      throw Exception("仓管员代码长度不能超过18");
    if (l_AdjCohKeeper!=b_AdjCohKeeper)
    {
      Query->Close();
      Query->SQL->Clear();
      Query->SQL->Add("select keepercode from sdkeeper ,sduser  where keepercode=usercode and keepercode='"+l_AdjCohKeeper+"'");
      Query->Open();
      if(Query->RecordCount<1 )
      {
        Query->Close();
        throw Exception("仓管员代码'"+l_AdjCohKeeper+"'未定义");
      }
      Query->Close();
    }*/

/*
   AnsiString  l_AdjCohUser;
   l_AdjCohUser=GetMasterValue("AdjCohUser");
    if(l_AdjCohUser.IsEmpty())
      throw Exception("操作员代码不能为空");
    if(l_AdjCohUser.Length()>18)
      throw Exception("操作员代码长度不能大于18");
    if(l_AdjCohUser!=b_AdjCohUser)
    {
      Query->Close();
      Query->SQL->Clear();
      Query->SQL->Add("select usercode from sduser where usercode='"+l_AdjCohUser+"'");
      Query->Open();
      if(Query->RecordCount<=0)
      {
        Query->Close();
        throw Exception("操作员代码'"+l_AdjCohUser+"'未定义");
      }
      Query->Close();
    }*/

   int l_AdjCohCheck;
   l_AdjCohCheck=GetMasterValue("AdjCohCheck");
   if(l_AdjCohCheck!=0&&l_AdjCohCheck!=1)
        throw Exception("审核标志只能取值0-未审核 1-审核");

/*   AnsiString  l_AdjCohChecker;
   int  l_AdjCohCheck;
   l_AdjCohChecker=GetMasterValue("AdjCohChecker");
   l_AdjCohCheck=GetMasterValue("AdjCohCheck");
    if(l_AdjCohCheck==1)
    {
      if(l_AdjCohChecker.IsEmpty())
        throw Exception("审核员代码不能为空");
      if(l_AdjCohChecker.Length()>18)
        throw Exception("审核员代码长度不能大于18");
        Query->Close();
        Query->SQL->Clear();
        Query->SQL->Add("select usercode from sduser where usercode='"+l_AdjCohChecker+"'");
        Query->Open();
        if(Query->RecordCount<=0)
        {
          Query->Close();
          throw Exception("审核员代码未定义或没有审核权限");
        }
        Query->Close();
      }*/

   AnsiString  l_AdjCohCheckDate;

   l_AdjCohCheckDate=GetMasterValue("AdjCohCheckDate");
   l_AdjCohCheck=GetMasterValue("AdjCohCheck");
    if(l_AdjCohCheck==1)
    {
      if(l_AdjCohCheckDate.IsEmpty())
        throw Exception("审核日期不能为空");
    }

   int l_AdjCohPost;
   l_AdjCohPost=GetMasterValue("AdjCohPost");
    if(l_AdjCohPost!=0&&l_AdjCohPost!=1)
        throw Exception("记帐标志只能取值0-末计帐 1-计帐");


/*
   AnsiString  l_AdjCohPoster;
   int   l_AdjCohPost;
   l_AdjCohPoster=GetMasterValue("AdjCohPoster");
   l_AdjCohPost=GetMasterValue("AdjCohPost");
    if(l_AdjCohPost==1)
    {
      if(l_AdjCohPoster.IsEmpty())
        throw Exception("记帐员代码不能为空");
      if(l_AdjCohPoster.Length()>18)
        throw Exception("记帐员代码长度不能大于18");
        Query->Close();
        Query->SQL->Clear();
        Query->SQL->Add("select keepercode from sdkeeper where keepercode='"+l_AdjCohPoster+"' and KeeperPost=1");
        Query->Open();
        if(Query->RecordCount<=0)
        {
          Query->Close();
          throw Exception("记帐员代码未定义或没有记帐权限");
        }
        Query->Close();
      }*/

   AnsiString  l_AdjCohPostDate;

   l_AdjCohPostDate=GetMasterValue("AdjCohPostDate");
   l_AdjCohPost=GetMasterValue("AdjCohPost");
    if(l_AdjCohPost==1)
    {
      if(l_AdjCohPostDate.IsEmpty())
        throw Exception("记帐日期不能为空");
    }

}
//---------------------------------------------------------------------------
void __fastcall TKSAdjCoh::ValidItemValues()
{

   AnsiString  l_AdjCodCode;
   l_AdjCodCode=GetDetailValue("AdjCodCode");
    if(l_AdjCodCode.IsEmpty())
         throw Exception("入库调整单不能为空");

   int l_AdjCodLine;

   l_AdjCodCode=GetDetailValue("AdjCodCode");
   l_AdjCodLine=GetDetailValue("AdjCodLine");
    if(l_AdjCodCode.IsEmpty())
         throw Exception("入库调整单不能为空");
    if(l_AdjCodLine<0)
         throw Exception("行号不能小于零");

   AnsiString  l_AdjCodGoods;
   AnsiString  b_AdjCodGoods;
   l_AdjCodGoods=GetDetailValue("AdjCodGoods");
   b_AdjCodGoods=GetDetailOldValue("AdjCodGoods");

   l_AdjCodCode=GetDetailValue("AdjCodCode");
    if(l_AdjCodGoods.IsEmpty())
      throw Exception("物料编码不能为空");
    if(l_AdjCodGoods.Length()>18)
      throw Exception("物料编码长度不能大于18");
      Query->Close();
      Query->SQL->Clear();
      Query->SQL->Add("select GOODSCODE,GoodsName,GoodsUnitCode from Sdcd,sdgoods,sdstock where goodscode=stockgoodscode and cdgoods=goodscode and GOODSCODE='"+l_AdjCodGoods+"'");
      Query->Open();
      if(Query->RecordCount<=0)
      {
        Query->Close();
        throw Exception("物料编码 "+l_AdjCodGoods+" 不存在或未初始化");
      }
    if(l_AdjCodGoods.LowerCase()!=b_AdjCodGoods.LowerCase())
    {
      Query->Close();
      Query->SQL->Clear();
      Query->SQL->Add("select  * from sdadjcod where adjcodcode='"+l_AdjCodCode+"' and adjcodgoods='"+l_AdjCodGoods+"'");
      Query->Open();
      if(Query->RecordCount>0)
      {
        Query->Close();
         throw Exception("物料 "+AnsiString(l_AdjCodGoods)+"已调整");
      }
      Query->Close();
   }

  double l_AdjCodAmt;
   l_AdjCodAmt=GetDetailValue("AdjCodAmt");
    if (l_AdjCodAmt<0)
       throw Exception("调整金额不能小于零");


  AnsiString  l_AdjCodBatch;

   l_AdjCodBatch=GetDetailValue("AdjCodBatch");
   l_AdjCodGoods=GetDetailValue("AdjCodGoods");

      Query->Close();      //是否需要批号管理
      Query->SQL->Clear();
      Query->SQL->Add("select goodsBatch from sdgoods where goodsCode='"+l_AdjCodGoods+"'");
      Query->Open();
      if(Query->RecordCount<1 )
      {
        Query->Close();
        if(l_AdjCodBatch.IsEmpty()==false)
          throw Exception("物料 "+l_AdjCodGoods+" 不需要批号管理!");
      }
      else
      {
        if(l_AdjCodBatch.IsEmpty())
        throw Exception("物料 "+l_AdjCodGoods+" 需要批号管理!");
          Query->Close();
          Query->SQL->Clear();
          Query->SQL->Add("SELECT BatchCode FROM sdBatch where BatchCode='"+l_AdjCodBatch+"'");
          Query->Open();
          if(Query->RecordCount<1 )
          {
           Query->Close();
           throw Exception("批号 "+l_AdjCodBatch+" 不存在!");
          }
          Query->Close();
        }
    if(l_AdjCodBatch.Length()>18)
      throw Exception("批号长度不能超过18");

   AnsiString  l_AdjCodDesc;
   l_AdjCodDesc=GetDetailValue("AdjCodDesc");
    if(l_AdjCodDesc.Length()>40)
      throw Exception("备注不能超过40");
}
//---------------------------------------------------------------------------
void __fastcall TKSAdjCoh::CmdExec(AnsiString Param)
{

}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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