运行达不到实际效果

shengmingweilai 2012-08-13 05:50:43

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+"'");
}

}
...全文
109 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
dataxdata 2012-08-14
  • 打赏
  • 举报
回复
实现将f转换成字符串再赋给SQL
shengmingweilai 2012-08-13
  • 打赏
  • 举报
回复
错误提示:
Project Test.exe raisd exception class EOleException with message’将数据类型varchar转换为numeric时出错。’
shengmingweilai 2012-08-13
  • 打赏
  • 举报
回复
怎样将double f =fh+ck+tx;
转化为字符串型
缘中人 2012-08-13
  • 打赏
  • 举报
回复
这句语法没有错,你看到的错误是什么提示
shengmingweilai 2012-08-13
  • 打赏
  • 举报
回复


FCommandList->Add("Update dbo.fnBalance Set fPrepAmount='f' where cCusCode='"+cCusCode+"'");
运行错误怎样更改
缘中人 2012-08-13
  • 打赏
  • 举报
回复
什么效果达不到

1,178

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder 数据库及相关技术
社区管理员
  • 数据库及相关技术社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧