📄 mpmpc.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "mPmpc.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
TKSPmpc *sdPmpc;
//---------------------------------------------------------------------------
__fastcall TKSPmpc::TKSPmpc()
:TKSMidBase()
{
}
//---------------------------------------------------------------------------
void __fastcall TKSPmpc::ValidHeadValues()
{
AnsiString m_PmpcCode;
AnsiString b_PmpcCode;
m_PmpcCode=GetMasterValue("PmpcCode");
b_PmpcCode=GetMasterOldValue("PmpcCode");
if(m_PmpcCode.IsEmpty())
throw Exception("物料分类码不能为空");
if(m_PmpcCode.Length()>18)
throw Exception("物料分类码长度不能大于18");
if(m_PmpcCode != b_PmpcCode)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select PmpcCode from sdPmpc where PmpcCode='"+m_PmpcCode+"' ");
Query->Open();
if(Query->RecordCount>0)
{
Query->Close();
// throw Exception("物料分类码:'"+m_PmpcCode+"'已经存在");
}
Query->Close();
}
AnsiString m_PmpcName;
AnsiString b_PmpcName;
m_PmpcName=GetMasterValue("PmpcName");
b_PmpcName=GetMasterOldValue("PmpcName");
if(m_PmpcName.IsEmpty()==true)
throw Exception("物品类别编码名称不能为空。");
if(m_PmpcName.Length()>20)
throw Exception("物品类别编码名称长度不能超过20");
if(m_PmpcName.UpperCase()!=b_PmpcName.UpperCase())
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select pmpcname from sdpmpc where PmpcName='"+m_PmpcName+"'");
Query->Open();
if(Query->RecordCount>0)
{
Query->Close();
// throw Exception("类别名称:'"+m_PmpcName+"'已存在");
}
Query->Close();
}
AnsiString m_PmpcDesc;
m_PmpcDesc=GetMasterValue("PmpcDesc");
if(m_PmpcDesc.Length()>40)
throw Exception("备注长度不能大于40");
AnsiString m_PmpcItem;
m_PmpcItem=GetMasterValue("PmpcItem");
AnsiString m_PmpcUpperCode ;
m_PmpcUpperCode=GetMasterValue("PmpcUpperCode");
// AnsiString m_PmpcCode;
m_PmpcCode=GetMasterValue("PmpcCode");
if(m_PmpcItem.IsEmpty())
throw Exception("物品类别编码名不能为空");
if(m_PmpcItem.Length()+m_PmpcUpperCode.Length()>18)
throw Exception("物品类别编码长度超长");
if (m_PmpcUpperCode+m_PmpcItem.UpperCase()!=m_PmpcCode.UpperCase())
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("SELECT PmpcCode FROM SDPmPc WHERE PmPcCODE='"+Trim(m_PmpcUpperCode)+Trim(m_PmpcItem)+"'");
Query->Open();
if(Query->RecordCount>0)
{
Query->Close();
// throw Exception("物品类别编码'"+m_PmpcItem+"'已定义!");
}
Query->Close();
}
// AnsiString m_PmpcUpperCode;
m_PmpcUpperCode=GetMasterValue("PmpcUpperCode");
if(m_PmpcUpperCode.IsEmpty()==false)
{
if(m_PmpcUpperCode.Length()>18)
throw Exception("类别上级编码长度不能超过18");
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select * from sdPmpc where pmpccode='"+m_PmpcUpperCode+"'");
Query->Open();
if(Query->RecordCount<=0)
{
Query->Close();
//throw Exception("上级编码'"+m_PmpcUpperCode+"'未定义");
}
Query->Close();
}
int m_PmpcLevel;
m_PmpcLevel=GetMasterValue("PmpcLevel");
if(m_PmpcLevel<=0)
throw Exception("物料类别的层级码必须大于零!");
int m_PmpcEnd;
int b_PmpcEnd;
m_PmpcEnd=GetMasterValue("PmpcEnd");
b_PmpcEnd=GetMasterOldValue("PmpcEnd");
//AnsiString m_PmpcUpperCode ;
m_PmpcUpperCode=GetMasterValue("PmpcUpperCode");
//AnsiString m_PmpcItem ;
m_PmpcItem=GetMasterValue("PmpcItem");
if(m_PmpcEnd!=0&&m_PmpcEnd!=1)
throw Exception("末级标志只取值0-非末级 1-末级");
if(b_PmpcEnd==0 && m_PmpcEnd==1)
{
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("select * from sdPmpc where PmpcUpperCode='"+Trim(m_PmpcUpperCode)+Trim(m_PmpcItem)+"'");
Query->Open();
if(Query->RecordCount>0)
{
Query->Close();
throw Exception("已有下级不能设置为末级");
}
Query->Close();
}
}
//---------------------------------------------------------------------------
void __fastcall TKSPmpc::CmdExec(AnsiString Param)
{
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -