📄 msrgh.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "mSrgh.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
TKSSrgh *sdSrgh;
//---------------------------------------------------------------------------
__fastcall TKSSrgh::TKSSrgh()
:TKSMidBase()
{
}
//---------------------------------------------------------------------------
void __fastcall TKSSrgh::ValidHeadValues()
{
AnsiString m_SrghCode;
AnsiString b_SrghCode;
m_SrghCode=GetMasterValue("SrghCode");
b_SrghCode=GetMasterOldValue("SrghCode");
if(m_SrghCode.IsEmpty())
throw Exception("物料释放单号不能为空");
if(m_SrghCode.Length()>18)
throw Exception("物料释放单号长度不能大于18");
AnsiString m_SrghDate;
m_SrghDate=GetMasterValue("SrghDate");
if(m_SrghDate.IsEmpty())
throw Exception("开单日期不能为空");
int m_SrghType;
m_SrghType=GetMasterValue("SrghType");
if(m_SrghType<1 || m_SrghType>3)
throw Exception("释放类型只能是:1-销售备货释放,2-生产备货释放,3-其它释放");
/*
AnsiString m_SrghUser;
AnsiString b_SrghUser;
m_SrghUser=GetMasterValue("SrghUser");
b_SrghUser=GetMasterOldValue("SrghUser");
if(m_SrghUser.IsEmpty())
throw Exception("操作员代码不能为空");
if(m_SrghUser.Length()>18)
throw Exception("操作员代码长度不能大于18");
if(m_SrghUser!=b_SrghUser)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("SELECT UserCode FROM SDUser WHERE UserCode='" +m_SrghUser+"'");
Query->Open();
if(Query->RecordCount<=0)
{
Query->Close();
throw Exception("操作员'"+m_SrghUser+"'未定义");
}
Query->Close();
}
*/
int m_SrghCheck;
m_SrghCheck=GetMasterValue("SrghCheck");
if(m_SrghCheck!=0 && m_SrghCheck!=1)
throw Exception("审核标志只能取值0-未审核1-已审");
/*
AnsiString m_SrghChecker;
AnsiString b_SrghChecker;
m_SrghChecker=GetMasterValue("SrghChecker");
b_SrghChecker=GetMasterOldValue("SrghChecker");
int m_SrghCheck;
m_SrghCheck=GetMasterValue("SrghCheck");
if(m_SrghCheck==1)
{
if(m_SrghChecker.IsEmpty())
throw Exception("审核员代码不能为空");
if(m_SrghChecker.Length()>18)
throw Exception("审核员代码长度不能大于18");
if(m_SrghChecker!=b_SrghChecker)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select keepercode from sdkeeper where keepercode='"+m_SrghChecker+"' and Keepercheck=1");
Query->Open();
if(Query->RecordCount<=0)
{
Query->Close();
throw Exception("审核员代码未定义或没有审核权限");
}
Query->Close();
}
}
else
b_SrghChecker="";
*/
AnsiString m_SrghCheckDate;
m_SrghCheckDate=GetMasterValue("SrghCheckDate");
m_SrghCheck=GetMasterValue("SrghCheck");
if(m_SrghCheck==1)
{
if(m_SrghCheckDate.IsEmpty())
throw Exception("审核日期不能为空");
}
AnsiString m_SrghDesc;
m_SrghDesc=GetMasterValue("SrghDesc");
if(m_SrghDesc.Length()>80)
throw Exception("释放原因长度不能大于80");
AnsiString m_SrghSysDate;
m_SrghSysDate=GetMasterValue("SrghSysDate");
}
//---------------------------------------------------------------------------
void __fastcall TKSSrgh::ValidItemValues()
{
AnsiString m_SrgdCode;
AnsiString b_SrgdCode;
m_SrgdCode=GetDetailValue("SrgdCode");
b_SrgdCode=GetDetailOldValue("SrgdCode");
if(m_SrgdCode.IsEmpty())
throw Exception("物料释放单号不能为空!");
if(m_SrgdCode.Length()>18)
throw Exception("物料释放单号长度不能大于18");
// b_SrgdCode=sdParent->GetFieldValue(fiSrghCode); ??????????????????
int m_SrgdLine;
int b_SrgdLine;
m_SrgdLine=GetDetailValue("SrgdLine");
b_SrgdLine=GetDetailOldValue("SrgdLine");
m_SrgdCode=GetDetailValue("SrgdCode");
if(m_SrgdLine<=0)
throw Exception("物料释放单行号不能小于等于零");
if(m_SrgdLine!=b_SrgdLine)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select Srgdline from sdSrgd where SrgdCode='"+m_SrgdCode+"' and Srgdline='"+m_SrgdLine+"'");
Query->Open();
if(Query->RecordCount > 0)
{
Query->Close();
throw Exception("物料释放单行号已存在!");
}
Query->Close();
}
AnsiString m_SrgdSug;
AnsiString b_SrgdSug;
m_SrgdSug=GetDetailValue("SrgdSug");
b_SrgdSug=GetDetailOldValue("SrgdSug");
if(m_SrgdSug.IsEmpty())
throw Exception("备货单号不能为空");
if(m_SrgdSug.Length()>18)
throw Exception("备货单号长度不能大于18");
if(m_SrgdSug!=b_SrgdSug)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("SELECT SughCode FROM SDSugh WHERE SughCode='" +m_SrgdSug+"'");
Query->Open();
if(Query->RecordCount<=0)
{
Query->Close();
throw Exception("备货单号'"+m_SrgdSug+"'未定义");
}
Query->Close();
}
int m_SrgdSugdLine;
int b_SrgdSugdLine;
m_SrgdSugdLine=GetDetailValue("SrgdSugdLine");
b_SrgdSugdLine=GetDetailOldValue("SrgdSugdLine");
m_SrgdSug=GetDetailValue("SrgdSug");
if(m_SrgdSugdLine<=0)
throw Exception("备货单行号不能为空");
if(m_SrgdSugdLine!=b_SrgdSugdLine)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("SELECT SugdLine FROM SDSugd WHERE SugdCode='" +m_SrgdSug+"' and SugdLine="+m_SrgdSugdLine);
Query->Open();
if(Query->RecordCount<=0)
{
Query->Close();
throw Exception("备货单行号'"+IntToStr(m_SrgdSugdLine)+"'未定义");
}
Query->Close();
}
AnsiString m_SrgdGoods;
AnsiString b_SrgdGoods;
m_SrgdGoods=GetDetailValue("SrgdGoods");
b_SrgdGoods=GetDetailOldValue("SrgdGoods");
if(m_SrgdGoods.Length()<=0)
throw Exception("释放物料不能为空");
if(m_SrgdGoods!=b_SrgdGoods)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("SELECT GoodsCode FROM SDGoods WHERE GoodsCode='"+m_SrgdGoods+"'");
Query->Open();
if(Query->RecordCount<=0)
{
Query->Close();
throw Exception("释放物料编码'"+m_SrgdGoods+"'未定义");
}
Query->Close();
}
AnsiString m_SrgdUnit;
AnsiString b_SrgdUnit;
m_SrgdUnit=GetDetailValue("SrgdUnit");
b_SrgdUnit=GetDetailOldValue("SrgdUnit");
if(m_SrgdUnit.Length()<=0)
throw Exception("计量单位不能为空");
if(m_SrgdUnit!=b_SrgdUnit)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("SELECT UnitCode FROM SDUnit WHERE UnitCode='"+m_SrgdUnit+"'");
Query->Open();
if(Query->RecordCount<=0)
{
Query->Close();
throw Exception("计量单位'"+m_SrgdUnit+"'未定义");
}
Query->Close();
}
AnsiString m_SrgdLoc;
m_SrgdLoc=GetDetailValue("SrgdLoc");
m_SrgdUnit=GetDetailValue("SrgdUnit");
if(m_SrgdLoc.Length()<=0)
throw Exception("货位不能为空");
if(m_SrgdLoc!=m_SrgdUnit)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("SELECT LocCode FROM SDLoc WHERE LocCode='"+m_SrgdLoc+"'");
Query->Open();
if(Query->RecordCount<=0)
{
Query->Close();
throw Exception("货位'"+m_SrgdLoc+"'未定义");
}
Query->Close();
}
double m_SrgdQty;
m_SrgdQty=GetDetailValue("SrgdQty");
m_SrgdSug=GetDetailValue("SrgdSug");
m_SrgdSugdLine=GetDetailValue("SrgdSugdLine");
if(m_SrgdQty<0)
throw Exception("释放数量不能小于零");
if(m_SrgdSug == "" || m_SrgdSugdLine <= 0)
throw Exception("未定义来源备货单行记录");
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select SugdQty from sdSugd where Sugdcode='"+m_SrgdSug+"' and SugdLine="+AnsiString(m_SrgdSugdLine));
Query->Open();
if(Query->RecordCount<=0)
{
Query->Close();
throw Exception("来源备货单行记录不存在");
}
if(m_SrgdQty > Query->FieldValues["SugdQty"])
{
Query->Close();
throw Exception("释放数量不能超过原备货数量");
}
Query->Close();
AnsiString m_SrgdDesc;
m_SrgdDesc=GetDetailValue("SrgdDesc");
if(m_SrgdDesc.Length()>40)
{
throw Exception("备注长度不能大于40");
}
}
//---------------------------------------------------------------------------
void __fastcall TKSSrgh::CmdExec(AnsiString Param)
{
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -