📄 mscraph.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "mScraph.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
TKSScraph *sdScraph;
//---------------------------------------------------------------------------
__fastcall TKSScraph::TKSScraph()
:TKSMidBase()
{
}
//---------------------------------------------------------------------------
void __fastcall TKSScraph::ValidHeadValues()
{
AnsiString m_ScraphCode;
AnsiString b_ScraphCode;
m_ScraphCode=GetMasterValue("ScraphCode");
b_ScraphCode=GetMasterOldValue("ScraphCode");
if(m_ScraphCode.IsEmpty())
throw Exception("报废单编码不能为空!");
if(m_ScraphCode.Length()>18)
throw Exception("报废单长度不能大于18");
b_ScraphCode = m_ScraphCode;
AnsiString m_ScraphDate;
m_ScraphDate=GetMasterValue("ScraphDate");
if(m_ScraphDate.IsEmpty())
throw Exception("报废日期不能为空");
AnsiString m_ScraphFmonth;
AnsiString b_ScraphFmonth;
m_ScraphFmonth=GetMasterValue("ScraphFmonth");
b_ScraphFmonth=GetMasterOldValue("ScraphFmonth");
AnsiString s;
if(m_ScraphFmonth.IsEmpty())
throw Exception("财务月份不能为空");
/*
if(m_ScraphFmonth!=b_ScraphFmonth)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select fcmonth from sdfc where fcmonth='"+m_ScraphFmonth+"'");
Query->Open();
if(Query->RecordCount<=0)
{
Query->Close();
throw Exception("财务月份:"+m_ScraphFmonth+"未定义");
}
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select fcmonth from sdfc where fccurrent=1");
Query->Open();
if(Query->RecordCount<=0)
{
Query->Close();
throw Exception("未定义当前财务月份");
}
s=Query->FieldValues["FcMonth"];
if(m_ScraphFmonth<s)
{
Query->Close();
throw Exception("财务月份不能小于当前月份");
}
Query->Close();
}
*/
b_ScraphFmonth = m_ScraphFmonth;
AnsiString m_ScraphPosType;
AnsiString b_ScraphPosType;
m_ScraphPosType=GetMasterValue("ScraphPosType");
b_ScraphPosType=GetMasterOldValue("ScraphPosType");
if(m_ScraphPosType.IsEmpty())
throw Exception("收发存类型不能为空");
if(m_ScraphPosType.Length()>18)
throw Exception("收发存类型编码长度不能大于18");
if(m_ScraphPosType!=b_ScraphPosType)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select postypecode from sdpostype where postypecode='"+m_ScraphPosType+"'");
Query->Open();
if(Query->RecordCount<=0)
{
Query->Close();
throw Exception("收发存类型编码:"+m_ScraphPosType+"未定义");
}
Query->Close();
}
b_ScraphPosType = m_ScraphPosType;
AnsiString m_ScraphDept;
AnsiString b_ScraphDept;
m_ScraphDept=GetMasterValue("ScraphDept");
b_ScraphDept=GetMasterOldValue("ScraphDept");
if(m_ScraphDept.IsEmpty())
throw Exception("报废部门不能为空");
if(m_ScraphDept.Length()>18)
throw Exception("报废部门编码长度不能大于18");
if(m_ScraphDept!=b_ScraphDept)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select deptcode from sddept where deptcode='"+m_ScraphDept+"'");
Query->Open();
if(Query->RecordCount<=0)
{
Query->Close();
throw Exception("部门编码:"+m_ScraphDept+"未定义");
}
Query->Close();
}
b_ScraphDept = m_ScraphDept;
AnsiString m_ScraphDesc;
AnsiString b_ScraphDesc;
m_ScraphDesc=GetMasterValue("ScraphDesc");
b_ScraphDesc=GetMasterOldValue("ScraphDesc");
if(m_ScraphDesc.Length()>40)
throw Exception("备注长度不能大于40");
b_ScraphDesc = m_ScraphDesc;
int m_ScraphCheck;
int b_ScraphCheck;
m_ScraphCheck=GetMasterValue("ScraphCheck");
b_ScraphCheck=GetMasterOldValue("ScraphCheck");
if(m_ScraphCheck!=0 && m_ScraphCheck!=1)
throw Exception("审核标志只能取值0-未审,1-已审");
b_ScraphCheck = m_ScraphCheck;
/*
AnsiString m_ScraphChecker;
AnsiString b_ScraphChecker;
m_ScraphChecker=GetMasterValue("ScraphChecker");
b_ScraphChecker=GetMasterOldValue("ScraphChecker");
int m_ScraphCheck;
m_ScraphCheck=GetMasterValue("ScraphCheck");
if(m_ScraphCheck==1)
{
if(m_ScraphChecker.IsEmpty())
throw Exception("审核员不能为空");
if(m_ScraphChecker.Length()>18)
throw Exception("审核员代码长度不能大于18");
if(m_ScraphChecker!=b_ScraphChecker)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select keepercode from sdkeeper where keepercode='"+m_ScraphChecker+"' and keepercheck=1");
Query->Open();
if(Query->RecordCount<=0)
{
Query->Close();
throw Exception("审核员:"+m_ScraphChecker+"不存在或没有审核权限");
}
Query->Close();
}
b_ScraphChecker = m_ScraphChecker;
}
else
b_ScraphChecker="";
*/
AnsiString m_ScraphCheckDate;
m_ScraphCheckDate=GetMasterValue("ScraphCheckDate");
m_ScraphCheck=GetMasterValue("ScraphCheck");
if(m_ScraphCheck==1)
{
if(m_ScraphCheckDate.IsEmpty())
throw Exception("审核日期不能为空");
}
int m_ScraphCancel;
int b_ScraphCancel;
m_ScraphCancel=GetMasterValue("ScraphCancel");
b_ScraphCancel=GetMasterOldValue("ScraphCancel");
if(m_ScraphCancel!=0 && m_ScraphCancel!=1)
throw Exception("取消标志只能取值0-正常,1-取消");
b_ScraphCancel = m_ScraphCancel;
AnsiString m_ScraphCancelDate;
m_ScraphCancelDate=GetMasterValue("ScraphCancelDate");
m_ScraphCancel=GetMasterValue("ScraphCancel");
if(m_ScraphCancel==1)
{
if(m_ScraphCancelDate.IsEmpty())
throw Exception("取消日期不能为空");
}
/*
AnsiString m_ScraphUser;
AnsiString b_ScraphUser;
m_ScraphUser=GetMasterValue("ScraphUser");
b_ScraphUser=GetMasterOldValue("ScraphUser");
if(m_ScraphUser.IsEmpty())
throw Exception("操作员编码不能为空");
if(m_ScraphUser.Length()>18)
throw Exception("操作员编码长度不能大于18");
if(m_ScraphUser!=b_ScraphUser)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select usercode from sduser where usercode='"+m_ScraphUser+"'");
Query->Open();
if(Query->RecordCount<=0)
{
Query->Close();
throw Exception("操作员代码:"+m_ScraphUser+"未定义");
}
Query->Close();
}
b_ScraphUser = m_ScraphUser;
*/
/*
AnsiString m_ScraphKeeper;
AnsiString b_ScraphKeeper;
m_ScraphKeeper=GetMasterValue("ScraphKeeper");
b_ScraphKeeper=GetMasterOldValue("ScraphKeeper");
if(m_ScraphKeeper.IsEmpty())
throw Exception("仓管员代码不能为空");
if(m_ScraphKeeper.Length()>18)
throw Exception("仓管员代码长度不能大于18");
if(m_ScraphKeeper!=b_ScraphKeeper)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select Keepercode from sdKeeper where Keepercode='"+m_ScraphKeeper+"'");
Query->Open();
if(Query->RecordCount<=0)
{
Query->Close();
throw Exception("仓管员代码:"+m_ScraphKeeper+"未定义");
}
Query->Close();
}
*/
}
//---------------------------------------------------------------------------
void __fastcall TKSScraph::ValidItemValues()
{
AnsiString m_ScrapdCode;
m_ScrapdCode=GetDetailValue("ScrapdCode");
if(m_ScrapdCode.IsEmpty())
throw Exception("报废单号不能为空!");
if(m_ScrapdCode.Length()>18)
throw Exception("报废单号长度不能大于18");
int m_ScrapdLine;
int b_ScrapdLine;
m_ScrapdLine=GetDetailValue("ScrapdLine");
b_ScrapdLine=GetDetailOldValue("ScrapdLine");
if(m_ScrapdLine<=0)
throw Exception("报废单行号不能小于等于零");
/* if(m_ScrapdLine!=b_ScrapdLine)
if(this->FindKey(m_ScrapdLine))
throw Exception("当前行号已存在"); */
AnsiString m_ScrapdGoods;
AnsiString b_ScrapdGoods;
AnsiString m_ScrapdUnit;
m_ScrapdGoods=GetDetailValue("ScrapdGoods");
b_ScrapdGoods=GetDetailOldValue("ScrapdGoods");
AnsiString m_ScrapdLoc;
m_ScrapdLoc=GetDetailValue("ScrapdLoc");
if(m_ScrapdLoc.IsEmpty())
throw Exception("报废货位不能为空");
if(m_ScrapdGoods.IsEmpty())
throw Exception("货物编码不能为空!");
if(m_ScrapdGoods.Length()>18)
throw Exception("物料编码长度不能大于18");
if(m_ScrapdGoods!=b_ScrapdGoods)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select GoodsUnitCode from sdGoods,sdLg where GoodsCode=LgGoodsCode and Lgstate=1 and GoodsCode='"+m_ScrapdGoods+"' and LgLocCode='"+m_ScrapdLoc+"'");
Query->Open();
if(Query->RecordCount <= 0)
{
Query->Close();
throw Exception("该物料编码:'"+m_ScrapdGoods+"'不存在!");
}
else
{
Query->Close();
}
}
m_ScrapdUnit=GetDetailValue("ScrapdUnit");
AnsiString b_ScrapdLoc;
m_ScrapdLoc=GetDetailValue("ScrapdLoc");
b_ScrapdLoc=GetDetailOldValue("ScrapdLoc");
if(m_ScrapdLoc.IsEmpty())
throw Exception("报废货位不能为空");
if(m_ScrapdLoc.Length()>18)
throw Exception("报废货位编码长度不能大于18");
if(m_ScrapdLoc!=b_ScrapdLoc)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("Select loccode from sdloc where loccode='"+m_ScrapdLoc+"'");
Query->Open();
if(Query->RecordCount<=0)
{
Query->Close();
throw Exception("货位:"+m_ScrapdLoc+"不存在");
}
}
double m_ScrapdQty;
m_ScrapdQty=GetDetailValue("ScrapdQty");
if(m_ScrapdQty<=0)
throw Exception("报废数量必须大于零");
double m_ScrapdHsAmt;
m_ScrapdHsAmt=GetDetailValue("ScrapdHsAmt");
if(m_ScrapdHsAmt < 0)
throw Exception("回收金额不能小于零");
AnsiString m_ScrapdDesc;
m_ScrapdDesc=GetDetailValue("ScrapdDesc");
if(m_ScrapdDesc.Length()>40)
throw Exception("备注长度不能大于40");
AnsiString m_ScrapdSr;
AnsiString b_ScrapdSr;
m_ScrapdSr=GetDetailValue("ScrapdSr");
b_ScrapdSr=GetDetailOldValue("ScrapdSr");
if(m_ScrapdSr.IsEmpty())
throw Exception("报废原因不能为空");
if(m_ScrapdSr.Length()>18)
throw Exception("报废原因代码长度不能大于18");
if(m_ScrapdSr!=b_ScrapdSr)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select srcode from sdsr where srcode='"+m_ScrapdSr+"'");
Query->Open();
if(Query->RecordCount<=0)
{
Query->Close();
throw Exception("报废原因:"+m_ScrapdSr+"不存在");
}
Query->Close();
}
}
//---------------------------------------------------------------------------
void __fastcall TKSScraph::CmdExec(AnsiString Param)
{
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -