📄 mgosh.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "mGosh.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
TKSGosh *sdGosh;
//---------------------------------------------------------------------------
__fastcall TKSGosh::TKSGosh()
:TKSMidBase()
{
}
//---------------------------------------------------------------------------
void __fastcall TKSGosh::ValidHeadValues()
{
AnsiString m_GoshCode;
AnsiString b_GoshCode;
m_GoshCode=GetMasterValue("GoshCode");
b_GoshCode=GetMasterOldValue("GoshCode");
if(m_GoshCode.IsEmpty())
throw Exception("出库单的出库单号不能为空!");
if(m_GoshCode.Length()>18)
throw Exception("出库单号长度不能大于18");
b_GoshCode = m_GoshCode;
AnsiString m_GoshDate;
m_GoshDate=GetMasterValue("GoshDate");
if(m_GoshDate.IsEmpty())
throw Exception("出库日期不能为空");
AnsiString m_GoshFmonth;
AnsiString b_GoshFmonth;
m_GoshFmonth=GetMasterValue("GoshFmonth");
b_GoshFmonth=GetMasterOldValue("GoshFmonth");
AnsiString s;
if(m_GoshFmonth.IsEmpty())
throw Exception("财务月份不能为空");
b_GoshFmonth = m_GoshFmonth;
int m_GoshType;
int b_GoshType;
m_GoshType=GetMasterValue("GoshType");
if(m_GoshType!=1 && m_GoshType!=2 && m_GoshType!=3 && m_GoshType!=4)
throw Exception("出库类只能取值1-销售发货 2-采购退货 3-领料,4-其它出库");
AnsiString m_GoshPosType;
AnsiString b_GoshPosType;
m_GoshPosType=GetMasterValue("GoshPosType");
b_GoshPosType=GetMasterOldValue("GoshPosType");
if(m_GoshPosType.IsEmpty())
throw Exception("收发存类代码不能为空");
if(m_GoshPosType.Length()>18)
throw Exception("收发存类型代码长度不能大于18");
if(m_GoshPosType!=b_GoshPosType)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select PosTypeCode from sdPosType where Postypecode='"+m_GoshPosType+"'");
Query->Open();
if(Query->RecordCount<=0)
{
Query->Close();
throw Exception("收发存类型:"+m_GoshPosType+"未定义");
}
Query->Close();
}
b_GoshPosType = m_GoshPosType;
AnsiString m_GoshDept;
AnsiString b_GoshDept;
m_GoshDept=GetMasterValue("GoshDept");
b_GoshDept=GetMasterOldValue("GoshDept");
if(m_GoshDept.IsEmpty())
throw Exception("出库部门不能为空");
if(m_GoshDept.Length()>18)
throw Exception("出库部门编码长度不能大于18");
if(m_GoshDept!=b_GoshDept)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select deptcode from sddept where deptcode='"+m_GoshDept+"'");
Query->Open();
if(Query->RecordCount<=0)
{
Query->Close();
throw Exception("部门编码:"+m_GoshDept+"未定义");
}
Query->Close();
}
b_GoshDept = m_GoshDept;
AnsiString m_GoshDesc;
AnsiString b_GoshDesc;
m_GoshDesc=GetMasterValue("GoshDesc");
b_GoshDesc=GetMasterOldValue("GoshDesc");
if(m_GoshDesc.Length()>40)
throw Exception("备注长度不能大于40");
b_GoshDesc = m_GoshDesc;
int m_GoshRed;
int b_GoshRed;
m_GoshRed=GetMasterValue("GoshRed");
if(m_GoshRed!=-1 && m_GoshRed!=1)
throw Exception("红字的标志只能为红字-1,非红字1.");
int m_GoshCheck;
m_GoshCheck=GetMasterValue("GoshCheck");
if(m_GoshCheck!=0 && m_GoshCheck!=1)
throw Exception("审核标志只能取值0-未审1-已审");
AnsiString m_GoshCheckDate;
AnsiString b_GoshCheckDate;
m_GoshCheckDate=GetMasterValue("GoshCheckDate");
// int m_GoshCheck;
m_GoshCheck=GetMasterValue("GoshCheck");
if(m_GoshCheck==1)
{
if(m_GoshCheckDate.IsEmpty())
throw Exception("审核日期不能为空");
}
int m_GoshPost;
m_GoshPost=GetMasterValue("GoshPost");
if(m_GoshPost!=0 && m_GoshPost!=1)
throw Exception("记帐标志只能取值0-未记帐1-已记帐");
AnsiString m_GoshPostDate;
AnsiString b_GoshPostDate;
m_GoshPostDate=GetMasterValue("GoshPostDate");
//int m_GoshPost;
m_GoshPost=GetMasterValue("GoshPost");
if(m_GoshPost==1)
{
if(m_GoshPostDate.IsEmpty())
throw Exception("记帐日期不能为空");
}
int m_GoshCancel;
m_GoshCancel=GetMasterValue("GoshCancel");
if(m_GoshCancel!=0 && m_GoshCancel!=1)
throw Exception("取消标志只能取值0-正常1-取消");
AnsiString m_GoshCancelDate;
AnsiString b_GoshCancelDate;
m_GoshCancelDate=GetMasterValue("GoshCancelDate");
// int m_GoshCancel;
m_GoshCancel=GetMasterValue("GoshCancel");
if(m_GoshCancel==1)
{
if(m_GoshCancelDate.IsEmpty())
throw Exception("取消日期不能为空");
}
}
//---------------------------------------------------------------------------
void __fastcall TKSGosh::ValidItemValues()
{
AnsiString m_GosdCode;
AnsiString b_GosdCode;
m_GosdCode=GetDetailValue("GosdCode");
b_GosdCode=GetDetailOldValue("GosdCode");
if(m_GosdCode.IsEmpty())
throw Exception("出库单行的出库单号不能为空!");
if(m_GosdCode.Length()>18)
throw Exception("出库单号长度不能大于18");
b_GosdCode = m_GosdCode;
AnsiString m_GosdGoods;
AnsiString b_GosdGoods;
AnsiString m_GosdUnit;
m_GosdGoods=GetDetailValue("GosdGoods");
b_GosdGoods=GetDetailOldValue("GosdGoods");
if(m_GosdGoods.IsEmpty())
throw Exception("出库货物编码不能为空!");
if(m_GosdGoods.Length()>18)
throw Exception("物料编码长度不能大于18");
if(m_GosdGoods!=b_GosdGoods)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("Select GoodsCode,GoodsUnitCode from sdGoods Where GoodsCode='"+m_GosdGoods+"'");
Query->Open();
if(Query->RecordCount==0)
{
Query->Close();
throw Exception("出库的货物:'"+m_GosdGoods+"'不存在.");
}
else
{
m_GosdUnit=Query->FieldValues["GoodsUnitCode"];
Query->Close();
}
}
b_GosdGoods = m_GosdGoods;
int m_GosdLine;
int b_GosdLine;
m_GosdLine=GetDetailValue("GosdLine");
b_GosdLine=GetDetailOldValue("GosdLine");
// AnsiString m_GosdCode;
m_GosdCode=GetDetailValue("GosdCode");
if(m_GosdCode.IsEmpty())
throw Exception("出库单行的出库单号不能为空!");
if(m_GosdLine<=0)
throw Exception("出库单行号不能小于等于零");
double m_GosdQty;
m_GosdQty=GetDetailValue("GosdQty");
if(m_GosdQty <= 0)
throw Exception("出库数量不能小于等于零");
double m_GosdPrice;
m_GosdPrice=GetDetailValue("GosdPrice");
if(m_GosdPrice<0)
throw Exception("出库单价不能小于零");
AnsiString m_GosdLoc;
AnsiString b_GosdLoc;
m_GosdLoc=GetDetailValue("GosdLoc");
b_GosdLoc=GetDetailOldValue("GosdLoc");
// AnsiString m_GosdGoods;
m_GosdGoods=GetDetailValue("GosdGoods");
if(m_GosdGoods.IsEmpty())
throw Exception("出库物料不能为空");
if(m_GosdLoc.IsEmpty())
throw Exception("出库货位不能为空");
if(m_GosdLoc.Length()>18)
throw Exception("货位编码长度不能大于18");
if(m_GosdLoc!=b_GosdLoc)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("Select LocCode from sdLoc Where LocCode='"+m_GosdLoc+"'");
Query->Open();
if(Query->RecordCount<1)
{
Query->Close();
throw Exception("出库的货位编码:'"+m_GosdLoc+"'不存在.");
}
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("Select * from sdLg Where LgLocCode='"+m_GosdLoc+"' and LgGoodsCode='"+m_GosdGoods+"' and lgState=1");
Query->Open();
if(Query->RecordCount<1)
{
Query->Close();
throw Exception("货位:'"+m_GosdLoc+"'不能存放物料:"+m_GosdGoods);
}
Query->Close();
}
b_GosdLoc = m_GosdLoc;
int m_GosdFrom;
m_GosdFrom=GetDetailValue("GosdFrom");
if(m_GosdFrom!=0 && m_GosdFrom!=1)
throw Exception("出库单行来源只能取值:0-手工录入,1-系统生成");
AnsiString m_GosdFromCode;
AnsiString b_GosdFromCode;
m_GosdFromCode=GetDetailValue("GosdFromCode");
b_GosdFromCode=GetDetailOldValue("GosdFromCode");
int m_GosdFromLine;
// int m_GosdFrom;
m_GosdFrom=GetDetailValue("GosdFrom");
if(m_GosdFrom==1)
{
if(m_GosdFromCode.IsEmpty())
throw Exception("行数据来源为系统生成时,来源单据号不能为空");
}
else
{
b_GosdFromCode="";
m_GosdFromLine=0;
}
// int m_GosdFromLine;
int b_GosdFromLine;
m_GosdFromLine=GetDetailValue("GosdFromLine");
b_GosdFromLine=GetDetailOldValue("GosdFromLine");
// int m_GosdFrom;
m_GosdFrom=GetDetailValue("GosdFrom");
// AnsiString m_GosdFromCode;
m_GosdFromCode=GetDetailValue("GosdFromCode");
if(m_GosdFrom==1)
{
if(m_GosdFromCode.IsEmpty())
throw Exception("行数据来源为系统生成时,来源单据号不能为空");
/*
校验来源单据的合法性
if(sdParent->GetFieldValue(fiGoshType).ToInt()==1)
else if(sdParent->GetFieldValue(fiGoshType).ToInt()==2)
else if(sdParent->GetFieldValue(fiGoshType).ToInt()==3)
else if(sdParent->GetFieldValue(fiGoshType).ToInt()==4)
else if(sdParent->GetFieldValue(fiGoshType).ToInt()==5)
*/
}
else
{
m_GosdFromCode="";
b_GosdFromLine=0;
}
AnsiString m_GosdBatch;
AnsiString b_GosdBatch;
m_GosdBatch=GetDetailValue("GosdBatch");
b_GosdBatch=GetDetailOldValue("GosdBatch");
// AnsiString m_GosdLoc;
m_GosdLoc=GetDetailValue("GosdLoc");
// AnsiString m_GosdGoods;
m_GosdGoods=GetDetailValue("GosdGoods");
int IsBatch;
if(m_GosdLoc.IsEmpty())
throw Exception("货位不能为空");
if(m_GosdGoods.IsEmpty())
throw Exception("物料不能为空");
if(m_GosdBatch.Length()>18)
throw Exception("批号编码长度不能大于18");
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select GoodsBatch from sdgoods where goodscode='"+m_GosdGoods+"'");
Query->Open();
if(Query->RecordCount<=0)
{
Query->Close();
throw Exception("物料不存在");
}
else
{
IsBatch=Query->FieldValues["GoodsBatch"];
Query->Close();
}
if(IsBatch==0)
{
if(!Trim(m_GosdBatch).IsEmpty())
throw Exception("物料:"+m_GosdGoods+" 不需批次管理");
}
if(IsBatch==1&&Trim(m_GosdBatch).IsEmpty())
{
throw Exception("物料:"+m_GosdGoods+" 需批次管理,必须定义批次");
}
if(Trim(m_GosdBatch).IsEmpty()==false && m_GosdBatch!=b_GosdBatch)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select BthtBatch from sdBtht where BthtBatch='"+Trim(m_GosdBatch)+"'");
Query->Open();
if(Query->RecordCount<=0)
{
Query->Close();
throw Exception("批号编码:"+m_GosdBatch+"未定义");
}
Query->Close();
}
b_GosdBatch = m_GosdBatch;
AnsiString m_GosdSod;
AnsiString b_GosdSod;
m_GosdSod=GetDetailValue("GosdSod");
b_GosdSod=GetDetailOldValue("GosdSod");
// AnsiString m_GosdLoc;
m_GosdLoc=GetDetailValue("GosdLoc");
//AnsiString m_GosdGoods;
m_GosdGoods=GetDetailValue("GosdGoods");
int TrackSo;
if(m_GosdLoc.IsEmpty())
throw Exception("货位不能为空");
if(m_GosdGoods.IsEmpty())
throw Exception("物料不能为空");
if(m_GosdSod.Length()>18)
throw Exception("订单号长度不能大于18");
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select GoodsTrackSo from sdgoods where goodscode='"+m_GosdGoods+"'");
Query->Open();
if(Query->RecordCount<=0)
{
Query->Close();
throw Exception("物料不存在");
}
else
{
TrackSo=Query->FieldValues["GoodsTrackSo"];
Query->Close();
}
if(TrackSo==0)
{
if(!m_GosdSod.IsEmpty())
throw Exception("物料:"+m_GosdGoods+" 不需跟踪订单管理");
}
if(m_GosdSod.IsEmpty()==false && m_GosdSod!=b_GosdSod)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select Sohcode from sdSoh where Sohcode='"+m_GosdSod+"'");
Query->Open();
if(Query->RecordCount<=0)
{
Query->Close();
throw Exception("订单:"+m_GosdSod+"不存在");
}
Query->Close();
}
b_GosdSod = m_GosdSod;
int m_GosdSodLine;
int b_GosdSodLine;
m_GosdSodLine=GetDetailValue("GosdSodLine");
b_GosdSodLine=GetDetailOldValue("GosdSodLine");
//AnsiString m_GosdSod;
m_GosdSod=GetDetailValue("GosdSod");
if(m_GosdSod.IsEmpty()==false)
{
if(m_GosdSodLine<=0)
throw Exception("订单行号不正确");
if(m_GosdSodLine!=b_GosdSodLine)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select SodLine from sdSod where SodCode='"+m_GosdSod+"' and SodLine="+AnsiString(m_GosdSodLine));
Query->Open();
if(Query->RecordCount<=0)
{
Query->Close();
throw Exception("订单行号:'"+AnsiString(m_GosdSodLine)+"'不存在");
}
Query->Close();
}
}
else
b_GosdSodLine = 0;
AnsiString m_GosdDesc;
AnsiString b_GosdDesc;
m_GosdDesc=GetDetailValue("GosdDesc");
b_GosdDesc=GetDetailOldValue("GosdDesc");
if(m_GosdDesc.Length()>40)
throw Exception("备注长度不能大于40");
b_GosdDesc = m_GosdDesc;
int m_GosdState;
m_GosdState=GetDetailValue("GosdState");
// if(m_GosdState!=0 && m_GosdState!=1)
// throw Exception("出库单行状态只能取值:0-手工录入,1-系统生成");
}
//---------------------------------------------------------------------------
void __fastcall TKSGosh::CmdExec(AnsiString Param)
{
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -