📄 qmdoc.cpp
字号:
void __fastcall TsdQdl:: SetQdlCode(AnsiString value)
{
if(value.IsEmpty())
throw Exception("缺陷等级代码不能为空");
if(value.Length()>18)
throw Exception("缺陷等级代码不能大于18");
if(value.UpperCase()!=m_QdlCode.UpperCase())
{
m_Query->Close();
m_Query->SQL->Clear();
m_Query->SQL->Add("select QdlCode from sdQdl where QdlCode='"+value+"'");
m_Query->Open();
if(m_Query->RecordCount>0)
{
m_Query->Close();
throw Exception("缺陷等级代码"+value+"已存在");
}
m_Query->Close();
}
m_QdlCode=value;
}
void __fastcall TsdQdl:: SetQdlName(AnsiString value)
{
if(value.Length()>20)
throw Exception("缺陷等级名称不能大于18");
if(value != m_QdlName)
{
m_Query->Close();
m_Query->SQL->Clear();
m_Query->SQL->Add("select QdlName from sdQdl where QdlName='"+value+"'");
m_Query->Open();
if(m_Query->RecordCount>0)
{
m_Query->Close();
throw Exception("缺陷等级名称 "+value+" 已存在");
}
m_Query->Close();
}
m_QdlName=value;
}
void __fastcall TsdQdl:: SetQdlDesc(AnsiString value)
{
if(value.Length()>40)
throw Exception("备注不能大于40");
m_QdlDesc=value;
}
//---------------------------------------------------------------------------
AnsiString TsdQdl::GetFieldValue(euQdl sdFieldName)
{
switch(sdFieldName)
{
case fiQdlCode:
return QdlCode;
case fiQdlName:
return QdlName;
case fiQdlDesc:
return QdlDesc;
default:
throw Exception("当前未定义返可取值");
}
}
//---------------------------------------------------------------------------
void TsdQdl::SetFieldValue(euQdl sdFieldName, AnsiString value)
{
value=Trim(value);
switch(sdFieldName)
{
case fiQdlCode:
QdlCode=value;
break;
case fiQdlName:
QdlName=value;
break;
case fiQdlDesc:
QdlDesc=value;
break;
default:
throw Exception("当前字段未定义可赋值");
}
}
//---------------------------------------------------------------------------
TsdQdl::TsdQdl(TDataComm *DC)
:TsdStandard(DC)
{
try
{
QueryString="SELECT * FROM sdQdl";
FilterString="";
OrderString="QdlCode";
EmptyValue(0);
EmptyValue(1);
}
catch(Exception &e)
{
ShowMessage(e.Message);
}
}
TsdQdl::TsdQdl()
:TsdStandard()
{
try
{
QueryString="SELECT * FROM sdQdl";
FilterString="";
OrderString="QdlCode";
EmptyValue(0);
EmptyValue(1);
}
catch(Exception &e)
{
ShowMessage(e.Message);
}
}
//---------------------------------------------------------------------------
TsdQdl::~TsdQdl()
{
try{
}
catch(...)
{
throw Exception("析构函数出错");
}
}
//---------------------------------------------------------------------------
void TsdQdl::BackupValue()
{
b_QdlCode=m_QdlCode;
b_QdlName=m_QdlName;
b_QdlDesc=m_QdlDesc;
}
//---------------------------------------------------------------------------
void TsdQdl::RestoreValue()
{
m_QdlCode=b_QdlCode;
m_QdlName=b_QdlName;
m_QdlDesc=b_QdlDesc;
}
//---------------------------------------------------------------------------
void TsdQdl::EmptyValue(int Index)
{
switch(Index)
{
case 0:
m_QdlCode="";
m_QdlName="";
m_QdlDesc="";
break;
case 1:
b_QdlCode="";
b_QdlName="";
b_QdlDesc="";
break;
}
}
//---------------------------------------------------------------------------
void TsdQdl::BatchLetValue()
{
m_QdlCode=m_Query->FieldValues["QdlCode"];
m_QdlName=m_Query->FieldValues["QdlName"];
m_QdlDesc=m_Query->FieldValues["QdlDesc"];
BackupValue();
}
//---------------------------------------------------------------------------
void TsdQdl::Update()
{
if(CurStatus==0||CurStatus==1)
throw Exception("当前不是编辑状态,不能进行存盘操作!");
if(m_QdlCode.IsEmpty()==true)
throw Exception("单号不能为空!");
m_StoredProc->Close();
if(CurStatus==2||CurStatus==4)
{
m_StoredProc->ProcedureName="sdQdl_Insert";
m_StoredProc->Parameters->Clear();
m_StoredProc->Parameters->CreateParameter("@QdlCode",ftString,pdInput,18,m_QdlCode);
m_StoredProc->Parameters->CreateParameter("@QdlName",ftString,pdInput,20,m_QdlName);
m_StoredProc->Parameters->CreateParameter("@QdlDesc",ftString,pdInput,40,m_QdlDesc);
m_StoredProc->ExecProc();
}
else
{
m_StoredProc->ProcedureName="sdQdl_Update";
m_StoredProc->Parameters->Clear();
m_StoredProc->Parameters->CreateParameter("@W_QdlCode",ftString,pdInput,18,b_QdlCode);
m_StoredProc->Parameters->CreateParameter("@QdlCode",ftString,pdInput,18,m_QdlCode);
m_StoredProc->Parameters->CreateParameter("@QdlName",ftString,pdInput,20,m_QdlName);
m_StoredProc->Parameters->CreateParameter("@QdlDesc",ftString,pdInput,40,m_QdlDesc);
m_StoredProc->ExecProc();
}
m_StoredProc->Close();
TsdQdl *p=new TsdQdl();
if(CurStatus==2)
{
SetActionID(1);
p->Assign(this);
AddRecord((void *)p,p->QdlCode);
}
else
{
SetActionID(1);
p->Assign(this);
ChangeRecord((void *)p,p->QdlCode,this->b_QdlCode);
}
}
//---------------------------------------------------------------------------
void TsdQdl::Delete()
{
if(CurStatus!=1)
throw Exception("当前状态不能进行删除操作!");
if(m_QdlCode.IsEmpty()==true)
throw Exception("当前没有记录可以删除!");
m_StoredProc->Close();
m_StoredProc->ProcedureName="sdQdl_Delete";
m_StoredProc->Parameters->Clear();
m_StoredProc->Parameters->CreateParameter("@W_QdlCode",ftString,pdInput,18,b_QdlCode);
m_StoredProc->ExecProc();
m_StoredProc->Close();
DeleteRecord(this->b_QdlCode);
}
//---------------------------------------------------------------------------
void TsdQdl::Assign(TsdQdl *p)
{
this->SetActionID(p->CurStatus);
this->m_QdlCode=p->m_QdlCode;
this->m_QdlName=p->m_QdlName;
this->m_QdlDesc=p->m_QdlDesc;
this->BackupValue();
}
//---------------------------------------------------------------------------
void TsdQdl::AssignValue()
{
TsdQdl *p=(TsdQdl *)Records(CurRecNo);
Assign(p);
}
//---------------------------------------------------------------------------
int TsdQdl::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();
TsdQdl *p=new TsdQdl();
SetActionID(1);
p->Assign(this);
AddRecord((void *)p,p->QdlCode);
m_Query->Next();
}
MoveFirst();
}
m_Query->Close();
return Count;
}
//---------------------------------------------------------------------------
bool TsdQdl::Find(AnsiString WhereStr)
{
AnsiString m_SqlStr;
if(WhereStr.IsEmpty()==true)
throw Exception("查找表达式不能为空");
m_SqlStr="select * from sdQdl 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;
}
}
//完成
//类体
//**************************************
// TsdRqr 重检原因
//**************************************
//--------------------------------------------------------------
void __fastcall TsdRqr:: SetRqrCode(AnsiString value)
{
if(value.IsEmpty())
throw Exception("重检原因代码不能为空");
if(value.Length()>18)
throw Exception("重检原因代码不能大于18");
if(value.UpperCase()!=m_RqrCode.UpperCase())
{
m_Query->Close();
m_Query->SQL->Clear();
m_Query->SQL->Add("select RqrCode from sdRqr where RqrCode='"+value+"'");
m_Query->Open();
if(m_Query->RecordCount>0)
{
m_Query->Close();
throw Exception("缺陷等级代码"+value+"已存在");
}
m_Query->Close();
}
m_RqrCode=value;
}
void __fastcall TsdRqr:: SetRqrName(AnsiString value)
{
if(value.Length()>20)
throw Exception("重检原因名称不能大于20");
if(value != m_RqrName)
{
m_Query->Close();
m_Query->SQL->Clear();
m_Query->SQL->Add("select RqrName from sdRqr where RqrName='"+value+"'");
m_Query->Open();
if(m_Query->RecordCount>0)
{
m_Query->Close();
throw Exception("重检原因名称 "+value+" 已存在");
}
m_Query->Close();
}
m_RqrName=value;
}
void __fastcall TsdRqr:: SetRqrDesc(AnsiString value)
{
if(value.Length()>40)
throw Exception("备注不能大于40");
m_RqrDesc=value;
}
//---------------------------------------------------------------------------
AnsiString TsdRqr::GetFieldValue(euRqr sdFieldName)
{
switch(sdFieldName)
{
case fiRqrCode:
return RqrCode;
case fiRqrName:
return RqrName;
case fiRqrDesc:
return RqrDesc;
default:
throw Exception("当前未定义返可取值");
}
}
//---------------------------------------------------------------------------
void TsdRqr::SetFieldValue(euRqr sdFieldName, AnsiString value)
{
value=Trim(value);
switch(sdFieldName)
{
case fiRqrCode:
RqrCode=value;
break;
case fiRqrName:
RqrName=value;
break;
case fiRqrDesc:
RqrDesc=value;
break;
default:
throw Exception("当前字段未定义可赋值");
}
}
//---------------------------------------------------------------------------
TsdRqr::TsdRqr(TDataComm *DC)
:TsdStandard(DC)
{
try
{
QueryString="SELECT * FROM sdRqr";
FilterString="";
OrderString="RqrCode";
EmptyValue(0);
EmptyValue(1);
}
catch(Exception &e)
{
ShowMessage(e.Message);
}
}
TsdRqr::TsdRqr()
:TsdStandard()
{
try
{
QueryString="SELECT * FROM sdRqr";
FilterString="";
OrderString="RqrCode";
EmptyValue(0);
EmptyValue(1);
}
catch(Exception &e)
{
ShowMessage(e.Message);
}
}
//---------------------------------------------------------------------------
TsdRqr::~TsdRqr()
{
try{
}
catch(...)
{
throw Exception("析构函数出错");
}
}
//---------------------------------------------------------------------------
void TsdRqr::BackupValue()
{
b_RqrCode=m_RqrCode;
b_RqrName=m_RqrName;
b_RqrDesc=m_RqrDesc;
}
//---------------------------------------------------------------------------
void TsdRqr::RestoreValue()
{
m_RqrCode=b_RqrCode;
m_RqrName=b_RqrName;
m_RqrDesc=b_RqrDesc;
}
//---------------------------------------------------------------------------
void TsdRqr::EmptyValue(int Index)
{
switch(Index)
{
case 0:
m_RqrCode="";
m_RqrName="";
m_RqrDesc="";
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -