📄 qmhdl.cpp
字号:
{
m_QcsdState=value;
}
void __fastcall TsdQcsd:: SetQcsdDesc(AnsiString value)
{
m_QcsdDesc=value;
}
//---------------------------------------------------------------------------
AnsiString TsdQcsd::GetFieldValue(euQcsd sdFieldName)
{
switch(sdFieldName)
{
case fiQcsdCode:
return QcsdCode;
case fiQcsdLine:
return QcsdLine;
case fiQcsdFLine:
return QcsdFLine;
case fiQcsdGoods:
return QcsdGoods;
case fiQcsdTrd:
return QcsdTrd;
case fiQcsdDQty:
return QcsdDQty;
case fiQcsdCQty:
return QcsdCQty;
case fiQcsdYQty:
return QcsdYQty;
case fiQcsdNQty:
return QcsdNQty;
case fiQcsdMode:
return QcsdMode;
case fiQcsdState:
return QcsdState;
case fiQcsdDesc:
return QcsdDesc;
default:
throw Exception("当前未定义可取值");
}
}
//---------------------------------------------------------------------------
AnsiString TsdQcsd::GetOldFieldValue(euQcsd sdFieldName)
{
switch(sdFieldName)
{
case fiQcsdCode:
return b_QcsdCode;
case fiQcsdLine:
return b_QcsdLine;
case fiQcsdFLine:
return b_QcsdFLine;
case fiQcsdGoods:
return b_QcsdGoods;
case fiQcsdTrd:
return b_QcsdTrd;
case fiQcsdDQty:
return b_QcsdDQty;
case fiQcsdCQty:
return b_QcsdCQty;
case fiQcsdYQty:
return b_QcsdYQty;
case fiQcsdNQty:
return b_QcsdNQty;
case fiQcsdMode:
return b_QcsdMode;
case fiQcsdState:
return b_QcsdState;
case fiQcsdDesc:
return b_QcsdDesc;
default:
throw Exception("当前未定义可取值");
}
}
//---------------------------------------------------------------------------
void TsdQcsd::SetFieldValue(euQcsd sdFieldName, AnsiString value)
{
value=Trim(value);
switch(sdFieldName)
{
case fiQcsdCode:
QcsdCode=value;
break;
case fiQcsdLine:
QcsdLine=value.ToInt();
break;
case fiQcsdFLine:
QcsdFLine=value.ToInt();
break;
case fiQcsdGoods:
QcsdGoods=value;
break;
case fiQcsdTrd:
QcsdTrd=value;
break;
case fiQcsdDQty:
QcsdDQty=value.ToDouble();
break;
case fiQcsdCQty:
QcsdCQty=value.ToDouble();
break;
case fiQcsdYQty:
QcsdYQty=value.ToDouble();
break;
case fiQcsdNQty:
QcsdNQty=value.ToDouble();
break;
case fiQcsdMode:
QcsdMode=value.ToInt();
break;
case fiQcsdState:
QcsdState=value.ToInt();
break;
case fiQcsdDesc:
QcsdDesc=value;
break;
default:
throw Exception("当前字段未定义可赋值");
}
}
//---------------------------------------------------------------------------
TsdQcsd::TsdQcsd(TDataComm *DC)
:TsdDetail(DC)
{
try
{
QueryString="SELECT * FROM sdQcsd";
FilterString="";
OrderString="QcsdLine";
EmptyValue(0);
EmptyValue(1);
}
catch(Exception &e)
{
ShowMessage(e.Message);
}
}
TsdQcsd::TsdQcsd()
:TsdDetail()
{
try
{
QueryString="SELECT * FROM sdQcsd";
FilterString="";
OrderString="QcsdLine";
EmptyValue(0);
EmptyValue(1);
}
catch(Exception &e)
{
ShowMessage(e.Message);
}
}
//---------------------------------------------------------------------------
TsdQcsd::~TsdQcsd()
{
try{
}
catch(...)
{
throw Exception("析构函数出错");
}
}
//---------------------------------------------------------------------------
void TsdQcsd::BackupValue()
{
b_QcsdCode=m_QcsdCode;
b_QcsdLine=m_QcsdLine;
b_QcsdFLine=m_QcsdFLine;
b_QcsdGoods=m_QcsdGoods;
b_QcsdTrd=m_QcsdTrd;
b_QcsdDQty=m_QcsdDQty;
b_QcsdCQty=m_QcsdCQty;
b_QcsdYQty=m_QcsdYQty;
b_QcsdNQty=m_QcsdNQty;
b_QcsdMode=m_QcsdMode;
b_QcsdState=m_QcsdState;
b_QcsdDesc=m_QcsdDesc;
}
//---------------------------------------------------------------------------
void TsdQcsd::RestoreValue()
{
m_QcsdCode=b_QcsdCode;
m_QcsdLine=b_QcsdLine;
m_QcsdFLine=b_QcsdFLine;
m_QcsdGoods=b_QcsdGoods;
m_QcsdTrd=b_QcsdTrd;
m_QcsdDQty=b_QcsdDQty;
m_QcsdCQty=b_QcsdCQty;
m_QcsdYQty=b_QcsdYQty;
m_QcsdNQty=b_QcsdNQty;
m_QcsdMode=b_QcsdMode;
m_QcsdState=b_QcsdState;
m_QcsdDesc=b_QcsdDesc;
}
//---------------------------------------------------------------------------
void TsdQcsd::EmptyValue(int Index)
{
switch(Index)
{
case 0:
m_QcsdCode="";
m_QcsdLine=0;
m_QcsdFLine=0;
m_QcsdGoods="";
m_QcsdTrd="";
m_QcsdDQty=0;
m_QcsdCQty=0;
m_QcsdYQty=0;
m_QcsdNQty=0;
m_QcsdMode=0;
m_QcsdState=0;
m_QcsdDesc="";
break;
case 1:
b_QcsdCode="";
b_QcsdLine=0;
b_QcsdFLine=0;
b_QcsdGoods="";
b_QcsdTrd="";
b_QcsdDQty=0;
b_QcsdCQty=0;
b_QcsdYQty=0;
b_QcsdNQty=0;
b_QcsdMode=0;
b_QcsdState=0;
b_QcsdDesc="";
break;
}
}
//---------------------------------------------------------------------------
void TsdQcsd::BatchLetValue()
{
m_QcsdCode=m_Query->FieldValues["QcsdCode"];
m_QcsdLine=m_Query->FieldValues["QcsdLine"];
m_QcsdFLine=m_Query->FieldValues["QcsdFLine"];
m_QcsdGoods=m_Query->FieldValues["QcsdGoods"];
m_QcsdTrd=m_Query->FieldValues["QcsdTrd"];
m_QcsdDQty=m_Query->FieldValues["QcsdDQty"];
m_QcsdCQty=m_Query->FieldValues["QcsdCQty"];
m_QcsdYQty=m_Query->FieldValues["QcsdYQty"];
m_QcsdNQty=m_Query->FieldValues["QcsdNQty"];
m_QcsdMode=m_Query->FieldValues["QcsdMode"];
m_QcsdState=m_Query->FieldValues["QcsdState"];
m_QcsdDesc=m_Query->FieldValues["QcsdDesc"];
BackupValue();
}
//---------------------------------------------------------------------------
void TsdQcsd::Update()
{
if(CurStatus==0||CurStatus==1)
throw Exception("当前不是编辑状态,不能进行存盘操作!");
if(m_QcsdLine<=0)
throw Exception("单行号不能小于零!");
if(m_QcsdCode.IsEmpty()==true)
throw Exception("单号不能为空!");
m_StoredProc->Close();
if(CurStatus==2||CurStatus==4)
{
m_StoredProc->ProcedureName="sdQcsd_Insert";
m_StoredProc->Parameters->Clear();
m_StoredProc->Parameters->CreateParameter("@QcsdCode",ftString,pdInput,18,m_QcsdCode);
m_StoredProc->Parameters->CreateParameter("@QcsdLine",ftInteger,pdInput,10,m_QcsdLine);
m_StoredProc->Parameters->CreateParameter("@QcsdFLine",ftInteger,pdInput,10,m_QcsdFLine);
m_StoredProc->Parameters->CreateParameter("@QcsdGoods",ftString,pdInput,18,m_QcsdGoods);
m_StoredProc->Parameters->CreateParameter("@QcsdTrd",ftString,pdInput,18,m_QcsdTrd);
m_StoredProc->Parameters->CreateParameter("@QcsdDQty",ftFloat,pdInput,12,m_QcsdDQty);
m_StoredProc->Parameters->CreateParameter("@QcsdCQty",ftFloat,pdInput,12,m_QcsdCQty);
m_StoredProc->Parameters->CreateParameter("@QcsdYQty",ftFloat,pdInput,12,m_QcsdYQty);
m_StoredProc->Parameters->CreateParameter("@QcsdNQty",ftFloat,pdInput,12,m_QcsdNQty);
m_StoredProc->Parameters->CreateParameter("@QcsdMode",ftInteger,pdInput,1,m_QcsdMode);
m_StoredProc->Parameters->CreateParameter("@QcsdState",ftInteger,pdInput,1,m_QcsdState);
m_StoredProc->Parameters->CreateParameter("@QcsdDesc",ftString,pdInput,40,m_QcsdDesc);
m_StoredProc->ExecProc();
}
else{
m_StoredProc->ProcedureName="sdQcsd_Update";
m_StoredProc->Parameters->Clear();
m_StoredProc->Parameters->CreateParameter("@W_QcsdCode",ftString,pdInput,18,b_QcsdCode);
m_StoredProc->Parameters->CreateParameter("@W_QcsdLine",ftString,pdInput,10,b_QcsdLine);
m_StoredProc->Parameters->CreateParameter("@QcsdCode",ftString,pdInput,18,m_QcsdCode);
m_StoredProc->Parameters->CreateParameter("@QcsdLine",ftInteger,pdInput,10,m_QcsdLine);
m_StoredProc->Parameters->CreateParameter("@QcsdFLine",ftInteger,pdInput,10,m_QcsdFLine);
m_StoredProc->Parameters->CreateParameter("@QcsdGoods",ftString,pdInput,18,m_QcsdGoods);
m_StoredProc->Parameters->CreateParameter("@QcsdTrd",ftString,pdInput,18,m_QcsdTrd);
m_StoredProc->Parameters->CreateParameter("@QcsdDQty",ftFloat,pdInput,12,m_QcsdDQty);
m_StoredProc->Parameters->CreateParameter("@QcsdCQty",ftFloat,pdInput,12,m_QcsdCQty);
m_StoredProc->Parameters->CreateParameter("@QcsdYQty",ftFloat,pdInput,12,m_QcsdYQty);
m_StoredProc->Parameters->CreateParameter("@QcsdNQty",ftFloat,pdInput,12,m_QcsdNQty);
m_StoredProc->Parameters->CreateParameter("@QcsdMode",ftInteger,pdInput,1,m_QcsdMode);
m_StoredProc->Parameters->CreateParameter("@QcsdState",ftInteger,pdInput,1,m_QcsdState);
m_StoredProc->Parameters->CreateParameter("@QcsdDesc",ftString,pdInput,40,m_QcsdDesc);
m_StoredProc->ExecProc();
}
m_StoredProc->Close();
TsdQcsd *p=new TsdQcsd();
SetActionID(1);
p->Assign(this);
ChangeRecord((void *)p,p->QcsdLine,this->QcsdLine);
}
//---------------------------------------------------------------------------
void TsdQcsd::Delete()
{
if(CurStatus!=1)
throw Exception("当前状态不能进行删除操作!");
if(m_QcsdCode.IsEmpty()==true)
throw Exception("当前没有记录可以删除!");
m_StoredProc->Close();
m_StoredProc->ProcedureName="sdQcsd_Delete";
m_StoredProc->Parameters->Clear();
m_StoredProc->Parameters->CreateParameter("@W_QcsdCode",ftString,pdInput,18,b_QcsdCode);
m_StoredProc->Parameters->CreateParameter("@W_QcsdLine",ftString,pdInput,10,b_QcsdLine);
m_StoredProc->ExecProc();
m_StoredProc->Close();
DeleteRecord(this->b_QcsdLine);
}
//---------------------------------------------------------------------------
void TsdQcsd::Assign(TsdQcsd *p)
{
this->SetActionID(p->CurStatus);
this->m_QcsdCode=p->m_QcsdCode;
this->m_QcsdLine=p->m_QcsdLine;
this->m_QcsdFLine=p->m_QcsdFLine;
this->m_QcsdGoods=p->m_QcsdGoods;
this->m_QcsdTrd=p->m_QcsdTrd;
this->m_QcsdDQty=p->m_QcsdDQty;
this->m_QcsdCQty=p->m_QcsdCQty;
this->m_QcsdYQty=p->m_QcsdYQty;
this->m_QcsdNQty=p->m_QcsdNQty;
this->m_QcsdMode=p->m_QcsdMode;
this->m_QcsdState=p->m_QcsdState;
this->m_QcsdDesc=p->m_QcsdDesc;
if(CurStatus==3)
{
this->b_QcsdCode=p->b_QcsdCode;
this->b_QcsdLine=p->b_QcsdLine;
this->b_QcsdFLine=p->b_QcsdFLine;
this->b_QcsdGoods=p->b_QcsdGoods;
this->b_QcsdTrd=p->b_QcsdTrd;
this->b_QcsdDQty=p->b_QcsdDQty;
this->b_QcsdCQty=p->b_QcsdCQty;
this->b_QcsdYQty=p->b_QcsdYQty;
this->b_QcsdNQty=p->b_QcsdNQty;
this->b_QcsdMode=p->b_QcsdMode;
this->b_QcsdState=p->b_QcsdState;
this->b_QcsdDesc=p->b_QcsdDesc;
}
this->BackupValue();
}
//---------------------------------------------------------------------------
void TsdQcsd::AssignValue()
{
TsdQcsd *p=(TsdQcsd *)Records(CurRecNo);
Assign(p);
}
//---------------------------------------------------------------------------
int TsdQcsd::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();
TsdQcsd *p=new TsdQcsd();
SetActionID(1);
p->Assign(this);
AddRecord((void *)p,p->QcsdLine);
m_Query->Next();
}
MoveFirst();
}
m_Query->Close();
return Count;
}
//---------------------------------------------------------------------------
bool TsdQcsd::Find(AnsiString WhereStr)
{
AnsiString m_SqlStr;
if(WhereStr.IsEmpty()==true)
throw Exception("查找表达式不能为空");
m_SqlStr="select * from sdQcsd 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;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -