运行达不到实际效果
void __fastcall TfrmPage1::eChkMoney( AnsiString cCusCode, AnsiString cCusName)
{
TADOSet Set;
Set.eExecute("Use "+RzComboBox1->Values->operator [](RzComboBox1->ItemIndex));
//--------------------收款金额-----------------------------------------------
double fRecpAmount = 0, fPrepAmount=0, fDispedAmount=0;
Set.OpenSet("Select * from dbo.fnBalance where cCusCode='"+cCusCode+"'", true);
fRecpAmount = Set->FieldByName("fRecpAmount")->AsFloat;
fPrepAmount = Set->FieldByName("fPrepAmount")->AsFloat;
fDispedAmount = Set->FieldByName("fDispedAmount")->AsFloat;
Set.OpenSet("Select Sum(t2.fAmount) As fRecpAmount from dbo.fnReceipt As t1 inner join dbo.fnReceipts As t2 on t1.BillId=t2.BillId "
"where cCusCode='"+cCusCode+"' and IsNull(t1.bWasteFlag,0)=0 and IsNull(cChecker,'')<>'' and iRdTypeId in (3, 12, 20) ", true);
if( Set->FieldByName("fRecpAmount")->AsFloat != fRecpAmount)
{
rzGrid->RowCount += 1;
rzGrid->Rows[rzGrid->RowCount-2]->CommaText=","+cCusCode+","+cCusName+",收款单据,收款金额与余额表中不符";
FCommandList->Add("Update dbo.fnBalance Set fRecpAmount="+Set->FieldByName("fRecpAmount")->AsString
+" where cCusCode='"+cCusCode+"'");
}
//-----------发货总金额-------------------------------------------------------------------------------------
double fh=0, ck = 0, tx = 0;
//-----------发货单金额------------------------------------------------------------------------------
Set.OpenSet("Select Sum(IsNull(t2.fAmount,0)) As fh from dbo.fnReceipt As t1 inner join dbo.fnReceipts As t2 on t1.BillId=t2.BillId "
"where cCusCode='"+cCusCode+"' and IsNull(t1.bWasteFlag,0)=0 and IsNull(cChecker,'')<>'' and iRdTypeId=21", true);
fh = Set->FieldByName("fh")->AsFloat;
//-----------出库单金额---------------------------------------------------------------------------------
Set.OpenSet("Select Sum(t2.fQuantity*t2.fPrice) As ck from dbo.soDispedBill As t1 inner join dbo.soDispedBills As t2 on t1.BillId=t2.BillId "
"where cCusCode='"+cCusCode+"' and IsNull(t1.bWasteFlag,0)=0 and IsNull(cChecker,'')<>'' and IsNull(iApprovedState,0)>0", true);
ck = Set->FieldByName("ck")->AsFloat;
//-----------贴息金额-----------------------------------------------------------------------------
Set.OpenSet("Select Sum(IsNull(t2.fInterestAmount,0)) As tx from dbo.fnReceipt As t1 inner join dbo.fnReceipts As t2 on t1.BillId=t2.BillId "
"where cCusCode='"+cCusCode+"' and IsNull(t1.bWasteFlag,0)=0 and IsNull(cChecker,'')<>'' and iRdTypeId in (3,12)", true);
tx = Set->FieldByName("tx")->AsFloat;
double f =fh+ck+tx;
if( f != fPrepAmount)
{
rzGrid->RowCount += 1;
rzGrid->Rows[rzGrid->RowCount-2]->CommaText=","+cCusCode+","+cCusName+",,与余额表中发货总金额不符";
FCommandList->Add("Update dbo.fnBalance Set fPrepAmount='f' where cCusCode='"+cCusCode+"'");
}
//-----------余额-------------------------------------------------------------------------------------
double y=fRecpAmount-f;
if( y != fDispedAmount)
{
rzGrid->RowCount += 1;
rzGrid->Rows[rzGrid->RowCount-2]->CommaText=","+cCusCode+","+cCusName+",,与余额表中余额不符";
FCommandList->Add("Update dbo.fnBalance Set fDispedAmount='y' where cCusCode='"+cCusCode+"'");
}
}