以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 麻烦老师看下这个计算公式哪里错了? (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=125175) |
||||
-- 作者:初心不改再说未来 -- 发布时间:2018/9/21 14:48:00 -- 麻烦老师看下这个计算公式哪里错了? 老师您好,计算代码我贴在2楼了 此主题相关图片如下:77777.jpg 如图,我得出的娟娟老师,(假设提成表我都按照0.2(百分之20)计算的话)本月应得提成为总额的20% 就是语文3200+数学1800+英语5000+体育6800=总计16800元 假设提成表我都按照0.2(百分之20)计算的话 提成应该是16800*0.2=3360元 为啥我计算出来的提成是5720元呢? 核心代码应该是在这里 For Each r3 As Row In t3.Rows v1=0 For Each c1 As String In Lms dr2 = DataTables("设置").Find("课程 =\'" & c1 & "\'") If dr2 IsNot Nothing Then v1+ = r3(c1 & "总学费") * dr2("提成")*r3(c1) End If Next c1 r3("提成总计金额")=v1 Next r3 百思不得其解······ |
||||
-- 作者:初心不改再说未来 -- 发布时间:2018/9/21 14:49:00 -- 完整代码: Dim dr2 As DataRow Dim Lms As String() ={"语文","数学","英语","体育"} Dim bd1 As New GroupTableBuilder("统计",DataTables("表A")) Dim dt1 As fxDataSource bd1.Groups.AddDef("语文老师", "姓名") bd1.Totals.AddDef("语文老师", AggregateEnum.Count, "语文") bd1.Totals.AddDef("总学费", AggregateEnum.sum, "语文总学费") dt1 = bd1.BuildDataSource() bd1 = New GroupTableBuilder("统计",DataTables("表A")) Dim dt2 As fxDataSource bd1.Groups.AddDef("数学老师", "姓名") bd1.Totals.AddDef("数学老师", AggregateEnum.Count, "数学") bd1.Totals.AddDef("总学费", AggregateEnum.sum, "数学总学费") dt2 = bd1.BuildDataSource() bd1 = New GroupTableBuilder("统计",DataTables("表A")) Dim dt3 As fxDataSource bd1.Groups.AddDef("英语老师", "姓名") bd1.Totals.AddDef("英语老师", AggregateEnum.Count, "英语") bd1.Totals.AddDef("总学费", AggregateEnum.sum, "英语总学费") dt3 = bd1.BuildDataSource() bd1 = New GroupTableBuilder("统计",DataTables("表A")) Dim dt4 As fxDataSource bd1.Groups.AddDef("体育老师", "姓名") bd1.Totals.AddDef("体育老师", AggregateEnum.Count, "体育") bd1.Totals.AddDef("总学费", AggregateEnum.sum, "体育总学费") dt4 = bd1.BuildDataSource() dt1.Combine("姓名",dt2,"姓名") dt1.Combine("姓名",dt3,"姓名") dt1.Combine("姓名",dt4,"姓名") Dim t3 As Table = Tables("窗口1_Table1") t3.DataSource = dt1 \'将统计结果绑定到Table t3.StopRedraw With t3.DataTable.DataCols \' .Add("提成总计金额",Gettype(Double)) End With Dim v1 As Double For Each r3 As Row In t3.Rows v1=0 For Each c1 As String In Lms dr2 = DataTables("设置").Find("课程 =\'" & c1 & "\'") If dr2 IsNot Nothing Then v1+ = r3(c1 & "总学费") * dr2("提成")*r3(c1) End If Next c1 r3("提成总计金额")=v1 Next r3 t3.ResumeRedraw
|
||||
-- 作者:有点甜 -- 发布时间:2018/9/21 15:13:00 --
[此贴子已经被作者于2018/9/21 15:14:21编辑过]
|
||||
-- 作者:初心不改再说未来 -- 发布时间:2018/9/21 15:15:00 -- v1+ = r3(c1 & "总学费") * dr2("提成")*r3(c1) *r3(c1) 这个条件再乘就不对了貌似
|
||||
-- 作者:有点甜 -- 发布时间:2018/9/21 15:15:00 -- v1+ = r3(c1 & "总学费") * dr2("提成")*r3(c1)
改成
v1+ = r3(c1 & "总学费") * dr2("提成") |
||||
-- 作者:初心不改再说未来 -- 发布时间:2018/9/21 15:18:00 -- OK 搞定了,就是后面多了个条件 |
||||
-- 作者:don -- 发布时间:2018/9/21 17:06:00 -- 用SQLGroupTableBuilder强大点
|