📄 pmdoc.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#define _YW_SDERP_DLL
#include "Pmdoc.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
//====================================================================
// (TsdPtype)供应商类别
//====================================================================
void __fastcall TsdPtype::SetPtypeCode(AnsiString value)
{
if(value.IsEmpty())
throw Exception("供应商类型编码不能为空!");
if(value.Length()>18)
throw Exception("供应商类型编码长度不能大于18");
if(value.UpperCase()!=m_PtypeCode.UpperCase())
{
m_Query->Close();
m_Query->SQL->Clear();
m_Query->SQL->Add("SELECT PTYPECODE FROM SDPTYPE WHERE PTYPECODE='" +value+"'");
m_Query->Open();
if(m_Query->RecordCount>0)
{
m_Query->Close();
throw Exception("供应商类型编码'"+value+"'已定义");
}
m_Query->Close();
}
m_PtypeCode = value;
}
void __fastcall TsdPtype::SetPtypeName(AnsiString value)
{
if(value.IsEmpty())
throw Exception("供应商类型名称不能为空");
if(value.Length()>20)
throw Exception("供应商类型名称长度不能大于20");
m_PtypeName = value;
}
void __fastcall TsdPtype::SetPtypeDesc(AnsiString value)
{
if(value.Length()>40)
throw Exception("备注长度不能大于40");
m_PtypeDesc = value;
}
TsdPtype::TsdPtype(TDataComm *DC)
:TsdStandard(DC)
{
try
{
QueryString="SELECT * FROM SDPTYPE";
FilterString="";
OrderString="PTYPECODE";
EmptyValue(0);
EmptyValue(1);
}
catch(Exception &e)
{
throw Exception("构函数出错");
}
}
TsdPtype::TsdPtype()
:TsdStandard()
{
try
{
QueryString="SELECT * FROM SDPTYPE";
FilterString="";
OrderString="PTYPECODE";
EmptyValue(0);
EmptyValue(1);
}
catch(Exception &e)
{
throw Exception("构函数出错");
}
}
AnsiString TsdPtype::GetFieldValue(euPtype sdFieldName)
{
switch(sdFieldName)
{
case fiPTypeCode:
return PtypeCode;
case fiPTypeName:
return PtypeName;
case fiPTypeDesc:
return PtypeDesc;
default:
throw Exception("当前未定义可取值");
}
}
void TsdPtype::SetFieldValue(euPtype sdFieldName, AnsiString Value)
{
switch(sdFieldName)
{
case fiPTypeCode:
PtypeCode=Value;
break;
case fiPTypeName:
PtypeName=Value;
break;
case fiPTypeDesc:
PtypeDesc=Value;
break;
default:
throw Exception("当前字段未定义可赋值");
}
}
void TsdPtype::Update()
{
if(CurStatus==0||CurStatus==1)
throw Exception("当前不是编辑状态,不能进行存盘操作!");
if(m_PtypeCode.IsEmpty()==true)
throw Exception("供应商编码不能为空!");
if(m_PtypeName.IsEmpty()==true)
throw Exception("供应商名称不能为空!");
m_StoredProc->Close();
if(CurStatus==2||CurStatus==4)
{
m_StoredProc->ProcedureName="sdPtype_Insert";
m_StoredProc->Parameters->Clear();
m_StoredProc->Parameters->CreateParameter("@PtypeCode",ftString,pdInput,18,m_PtypeCode);
m_StoredProc->Parameters->CreateParameter("@PtypeName",ftString,pdInput,20,m_PtypeName);
m_StoredProc->Parameters->CreateParameter("@PtypeDesc",ftString,pdInput,40,m_PtypeDesc);
m_StoredProc->ExecProc();
}
else
{
m_StoredProc->ProcedureName="sdPtype_Update";
m_StoredProc->Parameters->Clear();
m_StoredProc->Parameters->CreateParameter("@W_PtypeCode",ftString,pdInput,18,b_PtypeCode);
m_StoredProc->Parameters->CreateParameter("@PtypeCode",ftString,pdInput,18,m_PtypeCode);
m_StoredProc->Parameters->CreateParameter("@PtypeName",ftString,pdInput,20,m_PtypeName);
m_StoredProc->Parameters->CreateParameter("@PtypeDesc",ftString,pdInput,40,m_PtypeDesc);
m_StoredProc->ExecProc();
}
TsdPtype *p=new TsdPtype( );
if(CurStatus==2) {
SetActionID(1); // for browsing only
p->Assign(this);
AddRecord((void *)p,p->PtypeCode);
}
else {
SetActionID(1); // for browsing only
p->Assign(this);
ChangeRecord((void *)p,p->PtypeCode,this->b_PtypeCode);
}
}
void TsdPtype::Delete()
{
if(CurStatus!=1)
throw Exception("当前状态不能进行删除操作!");
if(m_PtypeCode.IsEmpty()==true)
throw Exception("当前没有记录可以删除!");
m_StoredProc->Close();
m_StoredProc->ProcedureName="sdPtype_Delete";
m_StoredProc->Parameters->Clear();
m_StoredProc->Parameters->CreateParameter("@W_PtypeCode",ftString,pdInput,18,b_PtypeCode);
m_StoredProc->ExecProc();
DeleteRecord(this->b_PtypeCode);
}
void TsdPtype::BackupValue()
{
b_PtypeCode=m_PtypeCode;
b_PtypeName=m_PtypeName;
b_PtypeDesc=m_PtypeDesc;
}
void TsdPtype::RestoreValue()
{
m_PtypeCode=b_PtypeCode;
m_PtypeName=b_PtypeName;
m_PtypeDesc=b_PtypeDesc;
}
void TsdPtype::EmptyValue(int Index)
{
switch(Index)
{
case 0:
m_PtypeCode="";
m_PtypeName="";
m_PtypeDesc="";
break;
case 1:
b_PtypeCode="";
b_PtypeName="";
b_PtypeDesc="";
break;
}
}
void TsdPtype::BatchLetValue()
{
m_PtypeCode=m_Query->FieldValues["PtypeCode"];
m_PtypeName=m_Query->FieldValues["PtypeName"];
m_PtypeDesc=m_Query->FieldValues["PtypeDesc"];
BackupValue();
}
void TsdPtype::Assign(TsdPtype *p)
{
this->SetActionID(p->CurStatus);
this->m_PtypeCode=p->m_PtypeCode;
this->m_PtypeName=p->m_PtypeName;
this->m_PtypeDesc=p->m_PtypeDesc;
this->BackupValue();
}
void TsdPtype::AssignValue()
{
TsdPtype *p=(TsdPtype *)Records(CurRecNo);
this->SetActionID(p->CurStatus);
this->m_PtypeCode=p->m_PtypeCode;
this->m_PtypeName=p->m_PtypeName;
this->m_PtypeDesc=p->m_PtypeDesc;
this->BackupValue();
}
int TsdPtype::Query()
{
AnsiString m_SqlStr;
m_SqlStr=QueryString;
if(FilterString.IsEmpty()==false)
m_SqlStr=m_SqlStr+" where "+FilterString;
if(OrderString.IsEmpty()==false)
m_SqlStr=m_SqlStr+" Order by "+OrderString;
m_Query->Close();
m_Query->SQL->Clear();
m_Query->SQL->Add(m_SqlStr);
m_Query->Open();
ClearRecord();
if(m_Query->RecordCount>0)
{
m_Query->First();
while(!m_Query->Eof)
{
BatchLetValue();
TsdPtype *p=new TsdPtype( );
SetActionID(1);
p->Assign(this);
AddRecord((void *)p,p->PtypeCode);
m_Query->Next();
}
MoveFirst();
}
m_Query->Close();
return Count;
}
bool TsdPtype::Find(AnsiString WhereStr)
{
AnsiString m_SqlStr;
if(WhereStr.IsEmpty()==true)
throw Exception("查找表达式不能为空");
m_SqlStr="SELECT * FROM SDPTYPE WHERE "+WhereStr;
m_Query->Close();
m_Query->SQL->Clear();
m_Query->SQL->Add(m_SqlStr);
m_Query->Open();
if(m_Query->RecordCount!=1)
{
m_Query->Close();
return false;
}
else
{
BatchLetValue();
m_Query->Close();
return true;
}
}
TsdPtype::~TsdPtype()
{
try{
}
catch(...)
{
throw Exception("析构函数出错");
}
}
//====================================================================
// (TsdPmode)采购方式
//===================================================================
void __fastcall TsdPmode::SetPmodeCode(AnsiString value)
{
if (value.IsEmpty() )
throw Exception("采购方式编码不能为空!");
if(value.Length()>18)
throw Exception("采购方式编码长度不能大于18");
if (value.UpperCase()!=m_PmodeCode.UpperCase())
{
m_Query->Close();
m_Query->SQL->Clear();
m_Query->SQL->Add("SELECT PmodeCODE FROM SDPmode WHERE PmodeCODE='" +value+"'");
m_Query->Open();
if(m_Query->RecordCount>0)
{
m_Query->Close();
throw Exception("采购方式编码'"+value+"'已定义");
}
m_Query->Close();
}
m_PmodeCode = value;
}
void __fastcall TsdPmode::SetPmodeName(AnsiString value)
{
if(value.IsEmpty())
throw Exception("采购方式名称不能为空");
if(value.Length()>20)
throw Exception("采购方式名称长度不能大于20");
m_PmodeName = value;
}
void __fastcall TsdPmode::SetPmodeDesc(AnsiString value)
{
if(value.Length()>40)
throw Exception("备注长度不能大于40");
m_PmodeDesc = value;
}
TsdPmode::TsdPmode(TDataComm *DC)
:TsdStandard(DC)
{
try
{
QueryString="SELECT * FROM SDPmode";
FilterString="";
OrderString="PmodeCODE";
EmptyValue(0);
EmptyValue(1);
}
catch(Exception &e)
{
throw Exception("构造函数出错");
}
}
TsdPmode::TsdPmode()
:TsdStandard()
{
try
{
QueryString="SELECT * FROM SDPmode";
FilterString="";
OrderString="PmodeCODE";
EmptyValue(0);
EmptyValue(1);
}
catch(Exception &e)
{
throw Exception("构造函数出错");
}
}
AnsiString TsdPmode::GetFieldValue(euPmode sdFieldName)
{
switch(sdFieldName)
{
case fiPmodeCode:
return PmodeCode;
case fiPmodeName:
return PmodeName;
case fiPmodeDesc:
return PmodeDesc;
default:
throw Exception("当前未定义可取值");
}
}
void TsdPmode::SetFieldValue(euPmode sdFieldName, AnsiString Value)
{
switch(sdFieldName)
{
case fiPmodeCode:
PmodeCode=Value;
break;
case fiPmodeName:
PmodeName=Value;
break;
case fiPmodeDesc:
PmodeDesc=Value;
break;
default:
throw Exception("当前字段未定义可赋值");
}
}
void TsdPmode::Update()
{
if(CurStatus==0||CurStatus==1)
throw Exception("当前不是编辑状态,不能进行存盘操作!");
if(m_PmodeCode.IsEmpty()==true)
throw Exception("采购方式编码不能为空!");
if(m_PmodeName.IsEmpty()==true)
throw Exception("采购方式名称不能为空!");
m_StoredProc->Close();
if(CurStatus==2||CurStatus==4)
{
m_StoredProc->ProcedureName="sdPmode_Insert";
m_StoredProc->Parameters->Clear();
m_StoredProc->Parameters->CreateParameter("@PmodeCode",ftString,pdInput,18,m_PmodeCode);
m_StoredProc->Parameters->CreateParameter("@PmodeName",ftString,pdInput,20,m_PmodeName);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -