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

📄 mpish.cpp

📁 一个以前收集的基于C/S架构的ERP客户端源代码
💻 CPP
字号:
//---------------------------------------------------------------------------

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

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

#pragma package(smart_init)
TKSPish *sdPish;
//---------------------------------------------------------------------------
__fastcall TKSPish::TKSPish()
  :TKSMidBase()
{
}
//---------------------------------------------------------------------------
void __fastcall TKSPish::ValidHeadValues()
{

   AnsiString  m_PishCode;
   AnsiString  b_PishCode;
   m_PishCode=GetMasterValue("PishCode");
   b_PishCode=GetMasterOldValue("PishCode");
    if(m_PishCode.IsEmpty())
       throw Exception("入库单的入库单号不能为空!");
    if(m_PishCode.Length()>18)
      throw Exception("入库单号长度不能大于18");

    b_PishCode = m_PishCode;
    Query->Close();

   AnsiString  m_PishDate;
   m_PishDate=GetMasterValue("PishDate");
    if(m_PishDate.IsEmpty())
      throw Exception("入库日期不能为空");

   AnsiString  m_PishFmonth;
   AnsiString  b_PishFmonth;
   m_PishFmonth=GetMasterValue("PishFmonth");
   b_PishFmonth=GetMasterOldValue("PishFmonth");
    AnsiString s;
    if(m_PishFmonth.IsEmpty())
      throw Exception("财务月份不能为空");

    b_PishFmonth = m_PishFmonth;

   int m_PishType;
   int b_PishType;
   m_PishType=GetMasterValue("PishType");
    if(m_PishType!=1 && m_PishType!=2 && m_PishType!=3 && m_PishType!=4 && m_PishType!=5)
      throw Exception("入库类型只能取值1-采购收货,2-生产入库,3-销售退货,4-退料,5-其它入库");

   AnsiString  m_PishPosType;
   AnsiString  b_PishPosType;
   m_PishPosType=GetMasterValue("PishPosType");
   b_PishPosType=GetMasterOldValue("PishPosType");
    if(m_PishPosType.IsEmpty())
      throw Exception("收发存类代码不能为空");
    if(m_PishPosType.Length()>18)
      throw Exception("收发存类型代码长度不能大于18");
    if(m_PishPosType!=b_PishPosType)
    {
      Query->Close();
      Query->SQL->Clear();
      Query->SQL->Add("select PosTypeCode from sdPosType where PosTypeCode='"+m_PishPosType+"'");
      Query->Open();
      if(Query->RecordCount<=0)
      {
        Query->Close();
        throw Exception("收发存类型:"+m_PishPosType+"未定义");
      }
      Query->Close();
    }
    b_PishPosType = m_PishPosType;


   AnsiString  m_PishDept;
   AnsiString  b_PishDept;
   m_PishDept=GetMasterValue("PishDept");
   b_PishDept=GetMasterOldValue("PishDept");
    if(m_PishDept.IsEmpty())
      throw Exception("入库部门不能为空");
    if(m_PishDept.Length()>18)
      throw Exception("入库部门编码长度不能大于18");
    if(m_PishDept!=b_PishDept)
    {
      Query->Close();
      Query->SQL->Clear();
      Query->SQL->Add("select deptcode from sddept where deptcode='"+m_PishDept+"'");
      Query->Open();
      if(Query->RecordCount<=0)
      {
        Query->Close();
        throw Exception("部门编码:"+m_PishDept+"未定义");
      }
      Query->Close();
    }
    b_PishDept = m_PishDept;

   AnsiString  m_PishDesc;
   AnsiString  b_PishDesc;
   m_PishDesc=GetMasterValue("PishDesc");
   b_PishDesc=GetMasterOldValue("PishDesc");
    if(m_PishDesc.Length()>40)
      throw Exception("备注长度不能大于40");
    b_PishDesc = m_PishDesc;

 int m_PishRed;
   int b_PishRed;
   m_PishRed=GetMasterValue("PishRed");
    if(m_PishRed!=-1 && m_PishRed!=1)
       throw Exception("红字的标志只能为红字-1,非红字1.");


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


   AnsiString  m_PishCheckDate;
   m_PishCheckDate=GetMasterValue("PishCheckDate");
  // int   m_PishCheck;
   m_PishCheck=GetMasterValue("PishCheck");
    if(m_PishCheck==1)
    {
      if(m_PishCheckDate.IsEmpty())
        throw Exception("审核日期不能为空");
    }


   int m_PishPost;
   m_PishPost=GetMasterValue("PishPost");
    if(m_PishPost!=0 && m_PishPost!=1)
      throw Exception("记帐标志只能取值0-未记帐 1-已记帐");


   AnsiString  m_PishPostDate;
   m_PishPostDate=GetMasterValue("PishPostDate");
  // int   m_PishPost;
   m_PishPost=GetMasterValue("PishPost");
    if(m_PishPost==1)
    {
      if(m_PishPostDate.IsEmpty())
        throw Exception("记帐日期不能为空");
    }


   int m_PishCancel;
   m_PishCancel=GetMasterValue("PishCancel");
    if(m_PishCancel!=0 && m_PishCancel!=1)
      throw Exception("取消标志只能取值0-正常 1-取消");


   AnsiString  m_PishCancelDate;
   m_PishCancelDate=GetMasterValue("PishCancelDate");
   //int   m_PishCancel;
   m_PishCancel=GetMasterValue("PishCancel");
    if(m_PishCancel==1)
    {
      if(m_PishCancelDate.IsEmpty())
        throw Exception("取消日期不能为空");
    }
}
//---------------------------------------------------------------------------
void __fastcall TKSPish::ValidItemValues()
{

   AnsiString  m_PisdCode;
   AnsiString  b_PisdCode;
   m_PisdCode=GetDetailValue("PisdCode");
   b_PisdCode=GetDetailOldValue("PisdCode");
    if(m_PisdCode.IsEmpty())
       throw Exception("入库单行的入库单号不能为空!");
    if(m_PisdCode.Length()>18)
      throw Exception("入库单号长度不能大于18");
    b_PisdCode = m_PisdCode;


   int m_PisdLine;
   int b_PisdLine;
   m_PisdLine=GetDetailValue("PisdLine");
   b_PisdLine=GetDetailOldValue("PisdLine");
  // AnsiString   m_PisdCode;
   m_PisdCode=GetDetailValue("PisdCode");
    if(m_PisdCode < 1)
       throw Exception("入库单行必须大于0!");
    if(m_PisdLine != b_PisdLine)
    {
      Query->Close();
      Query->SQL->Clear();
      Query->SQL->Add("select PisdLine from sdPisd where PisdLine="+AnsiString(m_PisdLine)+" and PisdCode='"+m_PisdCode+"'");
      Query->Open();
      if(Query->RecordCount>0)
      {
        Query->Close();
        throw Exception("行号'"+AnsiString(m_PisdLine)+"'已经存在");
      }
      Query->Close();
    }

   AnsiString  m_PisdGoods;
   AnsiString  b_PisdGoods;
   m_PisdGoods=GetDetailValue("PisdGoods");
   b_PisdGoods=GetDetailOldValue("PisdGoods");
    if(m_PisdGoods.IsEmpty())
       throw Exception("入库货物编码不能为空!");
    if(m_PisdGoods.Length()>18)
      throw Exception("物料编码长度不能大于18");
    if(m_PisdGoods!=b_PisdGoods)
    {
        Query->Close();
        Query->SQL->Clear();
        Query->SQL->Add("Select GoodsCode,GoodsUnitCode from sdGoods Where GoodsCode='"+m_PisdGoods+"'");
        Query->Open();
        if(Query->RecordCount>0)
        {
           Query->Close();
        }
        else
        {
           Query->Close();
           throw Exception("货物编码:'"+m_PisdGoods+"'不存在.");
        }
    }


  double m_PisdQty;
  double b_PisdQty;
   m_PisdQty=GetDetailValue("PisdQty");
   if(m_PisdQty <= 0)
      throw Exception("入库数量不能小于等于零");


  double m_PisdPrice;
  double b_PisdPrice;
   m_PisdPrice=GetDetailValue("PisdPrice");
   if(m_PisdPrice<0)
      throw Exception("单价不能小于零");


  double m_PisdAmt;
   m_PisdAmt=GetDetailValue("PisdAmt");
   if(m_PisdAmt<0)
      throw Exception("入库金额不能小于零");


   AnsiString  m_PisdLoc;
   AnsiString  b_PisdLoc;
   m_PisdLoc=GetDetailValue("PisdLoc");
   b_PisdLoc=GetDetailOldValue("PisdLoc");
 //  AnsiString  m_PisdGoods;
   m_PisdGoods=GetDetailValue("PisdGoods");
    if(m_PisdGoods.IsEmpty())
      throw Exception("入库物料不能为空");
    if(m_PisdLoc.IsEmpty())
      throw Exception("入库货位不能为空");
    if(m_PisdLoc.Length()>18)
      throw Exception("入库货位长度不能大于18");
    if(m_PisdLoc!=b_PisdLoc)
    {
        Query->Close();
        Query->SQL->Clear();
        Query->SQL->Add("Select LocCode from sdLoc Where LocCode='"+m_PisdLoc+"'");
        Query->Open();
        if(Query->RecordCount<1)
        {
           Query->Close();
           throw Exception("入库的货位编码:'"+m_PisdLoc+"'不存在.");
        }
        Query->Close();
        Query->SQL->Clear();
        Query->SQL->Add("Select * from sdLg Where LgLocCode='"+m_PisdLoc+"' and LgGoodsCode='"+m_PisdGoods+"' and lgState=1");
        Query->Open();
        if(Query->RecordCount<1)
        {
           Query->Close();
           throw Exception("货位:'"+m_PisdLoc+"'不能存放物料:"+m_PisdGoods);
        }
        Query->Close();
    }
    b_PisdLoc = m_PisdLoc;


   int m_PisdFrom;
   m_PisdFrom=GetDetailValue("PisdFrom");
    if(m_PisdFrom!=0 && m_PisdFrom!=1)
      throw Exception("入库单行来源只能取值:0-手工录入,1-系统生成");


   AnsiString  m_PisdFromCode;
   AnsiString  b_PisdFromCode;
   int m_PisdFromLine;
   m_PisdFromCode=GetDetailValue("PisdFromCode");
  // int  m_PisdFrom;
   m_PisdFrom=GetDetailValue("PisdFrom");
    if(m_PisdFrom==1)
    {
      if(m_PisdFromCode.IsEmpty())
        throw Exception("行数据来源为系统生成时,来源单据号不能为空");
    }

 //  int m_PisdFromLine;
   int b_PisdFromLine;
   m_PisdFromLine=GetDetailValue("PisdFromLine");
  // int  m_PisdFrom;
   m_PisdFrom=GetDetailValue("PisdFrom");
   //AnsiString  m_PisdFromCode;
   m_PisdFromCode=GetDetailValue("PisdFromCode");
    if(m_PisdFrom==1)
    {
      if(m_PisdFromCode.IsEmpty())
        throw Exception("行数据来源为系统生成时,来源单据号不能为空");
    }


   int m_PisdState;


   AnsiString  m_PisdBatch;
   AnsiString  b_PisdBatch;
   m_PisdBatch=GetDetailValue("PisdBatch");
   b_PisdBatch=GetDetailOldValue("PisdBatch");
  // AnsiString  m_PisdGoods;
   m_PisdGoods=GetDetailValue("PisdGoods");
    int IsBatch;
    if(m_PisdGoods.IsEmpty())
      throw Exception("入库物料不能为空");
    if(m_PisdBatch.Length()>18)
      throw Exception("批号编码长度不能大于18");
    Query->Close();
    Query->SQL->Clear();
    Query->SQL->Add("select GoodsBatch from sdgoods where goodscode='"+m_PisdGoods+"'");
    Query->Open();
    if(Query->RecordCount<=0)
    {
      Query->Close();
      throw Exception("物料不存在");
    }
    else
    {
      IsBatch=Query->FieldValues["GoodsBatch"];
      Query->Close();
    }
    if(IsBatch==0)
    {
      if(!m_PisdBatch.IsEmpty())
        throw Exception("物料:"+m_PisdGoods+" 不需批次管理");
    }
    if(IsBatch==1)
    {
    if(m_PisdBatch.IsEmpty())
        throw Exception("物料:"+m_PisdGoods+" 需批次管理,请填上批号");
    }
    


   AnsiString  m_PisdSod;
   AnsiString  b_PisdSod;
   m_PisdSod=GetDetailValue("PisdSod");
   b_PisdSod=GetDetailOldValue("PisdSod");
   //AnsiString  m_PisdGoods;
   m_PisdGoods=GetDetailValue("PisdGoods");
    int TrackSo;
    if(m_PisdGoods.IsEmpty())
      throw Exception("物料不能为空");
    if(m_PisdSod.Length()>18)
      throw Exception("订单号长度不能大于18");
    Query->Close();
    Query->SQL->Clear();
    Query->SQL->Add("select GoodsTrackSo from sdgoods where goodscode='"+m_PisdGoods+"'");
    Query->Open();
    if(Query->RecordCount<=0)
    {
      Query->Close();
      throw Exception("物料不存在");
    }
    else
    {
      TrackSo=Query->FieldValues["GoodsTrackSo"];
      Query->Close();
    }
    if(TrackSo==0)
    {
      if(!m_PisdSod.IsEmpty())
        throw Exception("物料:"+m_PisdGoods+" 不需跟踪订单管理");
    }
    if(m_PisdSod.IsEmpty()==false && m_PisdSod!=b_PisdSod)
    {
      Query->Close();
      Query->SQL->Clear();
      Query->SQL->Add("select Sohcode from sdSoh where Sohcode='"+m_PisdSod+"'");
      Query->Open();
      if(Query->RecordCount<=0)
      {
        Query->Close();
        throw Exception("订单:"+m_PisdSod+"不存在");
      }
      Query->Close();
    }
    b_PisdSod = m_PisdSod;


   int m_PisdSodLine;
   int b_PisdSodLine;
   m_PisdSodLine=GetDetailValue("PisdSodLine");
   b_PisdSodLine=GetDetailOldValue("PisdSodLine");
   //AnsiString  m_PisdSod;
   m_PisdSod=GetDetailValue("PisdSod");
    if(m_PisdSod.IsEmpty()==false)
    {
      if(m_PisdSodLine<=0)
        throw Exception("订单行号不能小于等于零");
      if(m_PisdSodLine!=b_PisdSodLine)
      {
        Query->Close();
        Query->SQL->Clear();
        Query->SQL->Add("select SodLine from sdSod where SodLine="+AnsiString(m_PisdSodLine)+" and SodCode='"+m_PisdSod+"'");
        Query->Open();
        if(Query->RecordCount<=0)
        {
          Query->Close();
          throw Exception("订单行号不存在");
        }
        Query->Close();
      }
      b_PisdSodLine = m_PisdSodLine;
    }
    else
      b_PisdSodLine=0;

      
   AnsiString  m_PisdDesc;
   AnsiString  b_PisdDesc;
   m_PisdDesc=GetDetailValue("PisdDesc");
   b_PisdDesc=GetDetailOldValue("PisdDesc");
    if(m_PisdDesc.Length()>40)
      throw Exception("备注长度不能大于40");
    b_PisdDesc = m_PisdDesc;

}
//---------------------------------------------------------------------------
void __fastcall TKSPish::CmdExec(AnsiString Param)
{

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

⌨️ 快捷键说明

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