📄 commondata.cpp
字号:
this->m_FcPeriod=p->m_FcPeriod;
this->m_FcBegDate=p->m_FcBegDate;
this->m_FcEndDate=p->m_FcEndDate;
this->m_FcEndOfYear=p->m_FcEndOfYear;
this->m_FcCurrent=p->m_FcCurrent;
this->m_FcCurPeriod=p->m_FcCurPeriod;
this->m_FcPPost=p->m_FcPPost;
this->m_FcSPost=p->m_FcSPost;
this->m_FcMPost=p->m_FcMPost;
this->m_FcIPost=p->m_FcIPost;
this->BackupValue();
}
//---------------------------------------------------------------------------
void TsdFc::AssignValue()
{
TsdFc *p=(TsdFc *)Records(CurRecNo);
Assign(p);
}
//---------------------------------------------------------------------------
int TsdFc::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();
TsdFc *p=new TsdFc();
SetActionID(1);
p->Assign(this);
AddRecord((void *)p,p->FcMonth);
m_Query->Next();
}
MoveFirst();
}
m_Query->Close();
return Count;
}
//---------------------------------------------------------------------------
bool TsdFc::Find(AnsiString WhereStr)
{
AnsiString m_SqlStr;
if(WhereStr.IsEmpty()==true)
throw Exception("查找表达式不能为空");
m_SqlStr="select * from sdFc 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;
}
}/////////////////////////////////////////////////////////////////////
/////////税码编码维护 Tax implement
/////////////////////////////////////////////////////////////////////
void __fastcall TsdTax::SetTaxCode(AnsiString value)
{
if (value.IsEmpty() )
throw Exception("税码不能为空!");
if(value.Length()>18)
throw Exception("税码长度不能大于18");
if (value!=m_TaxCode)
{
m_Query->Close();
m_Query->SQL->Clear();
m_Query->SQL->Add("SELECT TAXCODE FROM SDTAX WHERE TAXCODE='" +value+"'");
m_Query->Open();
if(m_Query->RecordCount>0)
{
m_Query->Close();
throw Exception("税码'"+value+"'已存在");
}
m_Query->Close();
}
m_TaxCode=value;
}
void __fastcall TsdTax::SetTaxName(AnsiString value)
{
if(value.IsEmpty())
throw Exception("税名不能空");
if(value.Length()>20)
throw Exception("税名长度不大于20");
if(value!=m_TaxName)
{
m_Query->Close();
m_Query->SQL->Clear();
m_Query->SQL->Add("SELECT TAXCODE FROM SDTAX WHERE TAXName='" +value+"'");
m_Query->Open();
if(m_Query->RecordCount>0)
{
m_Query->Close();
throw Exception("税名'"+value+"'已存在");
}
m_Query->Close();
}
m_TaxName=value;
}
void __fastcall TsdTax::SetTaxDesc(AnsiString value)
{
if(value.Length()>40)
throw Exception("备注不能大于40");
m_TaxDesc=value;
}
void __fastcall TsdTax::SetTaxRate(double value)
{
if (value<=0)
throw Exception("税率不能小于等于零");
m_TaxRate=value;
}
void __fastcall TsdTax::SetTaxGlKm(AnsiString value)
{
if(!value.IsEmpty())
{
if(value.Length()>18)
throw Exception("科目编码长不能大于18");
if(m_TaxGlKm!=value)
{
m_Query->Close();
m_Query->SQL->Clear();
m_Query->SQL->Add("select * from sdGlkm where glkmcode='"+value+"' and glkmmx=1");
m_Query->Open();
if(m_Query->RecordCount<=0)
{
m_Query->Close();
throw Exception("科目编码不存在或不是明细科目");
}
m_Query->Close();
}
}
m_TaxGlKm=value;
}
void __fastcall TsdTax::SetTaxKmDir(int value)
{
if (value!=1 && value!=-1)
throw Exception("科目方向必须为 1,借;-1,贷");
m_TaxKmDir=value;
}
void __fastcall TsdTax::SetTaxDefault(int value)
{
if (value!=0 && value!=1)
throw Exception("税码默认标志必须为0,非默认;1,默认税码");
if(m_TaxDefault==0 && value==1)
{
m_Query->Close();
m_Query->SQL->Clear();
m_Query->SQL->Add("SELECT TAXCODE FROM SDTAX WHERE TAXDefault=1 and taxcode<>'"+m_TaxCode+"'");
m_Query->Open();
if(m_Query->RecordCount>0)
{
m_Query->Close();
throw Exception("已定义默认税码");
}
m_Query->Close();
}
m_TaxDefault=value;
}
TsdTax::TsdTax(TDataComm *DC)
:TsdStandard(DC)
{
try
{
EmptyValue(0);
EmptyValue(1);
QueryString="SELECT * FROM SDTAX";
FilterString="";
OrderString="TAXCODE";
}
catch(Exception &e)
{
throw Exception("构造函数出错");
}
}
TsdTax::TsdTax()
:TsdStandard()
{
try
{
EmptyValue(0);
EmptyValue(1);
QueryString="SELECT * FROM SDTAX";
FilterString="";
OrderString="TAXCODE";
}
catch(Exception &e)
{
throw Exception("构造函数出错");
}
}
AnsiString TsdTax::GetFieldValue(euTax sdFieldName)
{
switch(sdFieldName)
{
case fiTaxCode:
return TaxCode;
case fiTaxName:
return TaxName;
case fiTaxDesc:
return TaxDesc;
case fiTaxRate:
return AnsiString(TaxRate);
case fiTaxGlKm:
return TaxGlKm;
case fiTaxKmDir:
return AnsiString(TaxKmDir);
case fiTaxDefault:
return AnsiString(TaxDefault);
default:
throw Exception("当前未定义可取值");
}
}
void TsdTax::SetFieldValue(euTax sdFieldName, AnsiString value)
{
switch(sdFieldName)
{
case fiTaxCode:
TaxCode=value;
break;
case fiTaxName:
TaxName=value;
break;
case fiTaxDesc:
TaxDesc=value;
break;
case fiTaxRate:
TaxRate=value.ToDouble();
break;
case fiTaxGlKm:
TaxGlKm=value;
break;
case fiTaxKmDir:
TaxKmDir=value.ToInt();
break;
case fiTaxDefault:
TaxDefault=value.ToInt();
break;
default:
throw Exception("当前字段未定义可赋值");
}
}
void TsdTax::Update()
{
if(CurStatus==0||CurStatus==1)
throw Exception("当前不是编辑状态,不能进行存盘操作!");
if(m_TaxCode.IsEmpty()==true)
throw Exception("税务编码不能为空!");
m_StoredProc->Close();
if(CurStatus==2||CurStatus==4)
{
m_StoredProc->ProcedureName="sdTax_Insert";
m_StoredProc->Parameters->Clear();
m_StoredProc->Parameters->CreateParameter("@TaxCode",ftString,pdInput,18,m_TaxCode);
m_StoredProc->Parameters->CreateParameter("@TaxName",ftString,pdInput,20,m_TaxName);
m_StoredProc->Parameters->CreateParameter("@TaxDesc",ftString,pdInput,40,m_TaxDesc);
m_StoredProc->Parameters->CreateParameter("@TaxRate",ftFloat,pdInput,8,m_TaxRate);
m_StoredProc->Parameters->CreateParameter("@TaxGlKm",ftString,pdInput,18,m_TaxGlKm);
m_StoredProc->Parameters->CreateParameter("@TaxKmDir",ftFloat,pdInput,5,m_TaxKmDir);
m_StoredProc->Parameters->CreateParameter("@TaxDefault",ftInteger,pdInput,1,m_TaxDefault);
m_StoredProc->ExecProc();
m_StoredProc->Close();
}
else
{
m_StoredProc->ProcedureName="sdTax_Update";
m_StoredProc->Parameters->Clear();
m_StoredProc->Parameters->CreateParameter("@W_TaxCode",ftString,pdInput,18,b_TaxCode);
m_StoredProc->Parameters->CreateParameter("@TaxCode",ftString,pdInput,18,m_TaxCode);
m_StoredProc->Parameters->CreateParameter("@TaxName",ftString,pdInput,20,m_TaxName);
m_StoredProc->Parameters->CreateParameter("@TaxDesc",ftString,pdInput,40,m_TaxDesc);
m_StoredProc->Parameters->CreateParameter("@TaxRate",ftFloat,pdInput,8,m_TaxRate);
m_StoredProc->Parameters->CreateParameter("@TaxGlKm",ftString,pdInput,18,m_TaxGlKm);
m_StoredProc->Parameters->CreateParameter("@TaxKmDir",ftFloat,pdInput,5,m_TaxKmDir);
m_StoredProc->Parameters->CreateParameter("@TaxDefault",ftInteger,pdInput,1,m_TaxDefault);
m_StoredProc->ExecProc();
m_StoredProc->Close();
}
TsdTax *p=new TsdTax();
if(CurStatus==2) {
SetActionID(1); // for browsing only
p->Assign(this);
AddRecord((void *)p,p->TaxCode);
}
else {
SetActionID(1); // for browsing only
p->Assign(this);
ChangeRecord((void *)p,p->TaxCode,this->b_TaxCode);
}
}
void TsdTax::Delete()
{
if(CurStatus!=1)
throw Exception("当前状态不能进行删除操作!");
if(m_TaxCode.IsEmpty()==true)
throw Exception("当前没有记录可以删除!");
m_StoredProc->Close();
m_StoredProc->ProcedureName="sdTax_Delete";
m_StoredProc->Parameters->Clear();
m_StoredProc->Parameters->CreateParameter("@W_TaxCode",ftString,pdInput,18,b_TaxCode);
m_StoredProc->ExecProc();
m_StoredProc->Close();
DeleteRecord(this->b_TaxCode);
}
void TsdTax::BackupValue()
{
b_TaxCode=m_TaxCode;
b_TaxName=m_TaxName;
b_TaxDesc=m_TaxDesc;
b_TaxRate=m_TaxRate;
b_TaxGlKm=m_TaxGlKm;
b_TaxKmDir=m_TaxKmDir;
b_TaxDefault=m_TaxDefault;
}
void TsdTax::RestoreValue()
{
m_TaxCode=b_TaxCode;
m_TaxName=b_TaxName;
m_TaxDesc=b_TaxDesc;
m_TaxRate=b_TaxRate;
m_TaxGlKm=b_TaxGlKm;
m_TaxKmDir=b_TaxKmDir;
m_TaxDefault=b_TaxDefault;
}
void TsdTax::EmptyValue(int Index)
{
switch(Index)
{
case 0:
m_TaxCode="";
m_TaxName="";
m_TaxDesc="";
m_TaxRate=0;
m_TaxGlKm="";
m_TaxKmDir=1;
m_TaxDefault=0;
break;
case 1:
b_TaxCode="";
b_TaxName="";
b_TaxDesc="";
b_TaxRate=0;
b_TaxGlKm="";
b_TaxKmDir=1;
b_TaxDefault=0;
break;
}
}
void TsdTax::BatchLetValue()
{
m_TaxCode=m_Query->FieldValues["TaxCode"];
m_TaxName=m_Query->FieldValues["TaxName"];
m_TaxDesc=m_Query->FieldValues["TaxDesc"];
m_TaxRate=m_Query->FieldValues["TaxRate"];
m_TaxGlKm=m_Query->FieldValues["TaxGlKm"];
m_TaxKmDir=m_Query->FieldValues["TaxKmDir"];
m_TaxDefault=m_Query->FieldValues["TaxDefault"];
BackupValue();
}
void TsdTax::Assign(TsdTax *p)
{
this->SetActionID(p->CurStatus);
m_TaxCode=p->m_TaxCode;
m_TaxName=p->m_TaxName;
m_TaxDesc=p->m_TaxDesc;
m_TaxRate=p->m_TaxRate;
m_TaxGlKm=p->m_TaxGlKm;
m_TaxKmDir=p->m_TaxKmDir;
m_TaxDefault=p->m_TaxDefault;
BackupValue();
}
void TsdTax::AssignValue()
{
TsdTax *p=(TsdTax *)Records(CurRecNo);
this->SetActionID(p->CurStatus);
m_TaxCode=p->m_TaxCode;
m_TaxName=p->m_TaxName;
m_TaxDesc=p->m_TaxDesc;
m_TaxRate=p->m_TaxRate;
m_TaxGlKm=p->m_TaxGlKm;
m_TaxKmDir=p->m_TaxKmDir;
m_TaxDefault=p->m_TaxDefault;
BackupValue();
}
int TsdTax::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();
TsdTax *p=new TsdTax();
SetActionID(1); // for browsing only
p->Assign(this);
AddRecord((void *)p,p->TaxCode);
m_Query->Next();
}
MoveFirst();
}
m_Query->Close();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -