Foxtable(狐表)用户栏目专家坐堂 → [求助]自定义函数


  共有4102人关注过本帖树形打印复制链接

主题:[求助]自定义函数

帅哥哟,离线,有人找我吗?
fanjq8686
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:278 积分:2339 威望:0 精华:0 注册:2015/4/5 16:28:00
[求助]自定义函数  发帖心情 Post By:2022/2/18 16:45:00 [只看该作者]

下面代码想定义成函数,怎么写?怎么用?

'主检
Dim jb1 As New SQLJoinTableBuilder("查询表1","业务流程表")
jb1.C
jb1.AddTable("业务流程表","奖金代码","奖金方案表","奖金代码")
jb1.AddExp("部门","检验部门")
jb1.AddExp("姓名","检验主检")
jb1.AddCols("报告编号","样品名称","样品型号规格")
jb1.AddExp("工作岗位","case when 检验主检 is null Then '无' Else '主检' End")
jb1.AddExp("金额","检验奖金额")
jb1.AddExp("定额","检验工时定额")
jb1.Filter = FilterDate0 & " AND 检验主检 <> ''"
'辅检
Dim jb2 As New SQLJoinTableBuilder("查询表1","业务流程表")
jb2.C
jb2.AddTable("业务流程表","奖金代码","奖金方案表","奖金代码")
jb2.AddExp("部门","检验部门")
jb2.AddExp("姓名","检验辅检")
jb2.AddCols("报告编号","样品名称","样品型号规格")
jb2.AddExp("工作岗位","case when 检验辅检 is null Then '无' Else '辅检' End")
jb2.AddExp("金额","检验奖金额 * 0.5")
jb2.AddExp("定额","检验工时定额")
jb2.Filter = FilterDate0 & " AND 检验辅检 <> ''"
'文审
Dim jb3 As New SQLJoinTableBuilder("查询表1","业务流程表")
jb3.C
jb3.AddTable("业务流程表","奖金代码","奖金方案表","奖金代码")
jb3.AddExp("部门","文审部门")
jb3.AddExp("姓名","文审主审")
jb3.AddCols("报告编号","样品名称","样品型号规格")
jb3.AddExp("工作岗位","case when 文审主审 is null Then '无' Else '文审' End")
jb3.AddExp("金额","文审奖金额")
jb3.AddExp("定额","文审工时定额")
jb3.Filter = FilterDate0 & " AND 文审主审 <> ''"
'复核审核
Dim jb4 As New SQLJoinTableBuilder("查询表1","业务流程表")
jb4.C
jb4.AddTable("业务流程表","奖金代码","奖金方案表","奖金代码")
jb4.AddExp("部门","检验部门")
jb4.AddExp("姓名","检验记录复核人")
jb4.AddCols("报告编号","样品名称","样品型号规格")
jb4.AddExp("工作岗位","case when 检验记录复核人 is null Then '无' Else '审核' End")
jb4.AddExp("金额","审核奖金额")
jb4.AddExp("定额","审核工时定额")
jb4.Filter = FilterDate0 & " AND 检验记录复核人 <> ''"
'核查
Dim jb5 As New SQLJoinTableBuilder("查询表1","业务流程表")
jb5.C
jb5.AddTable("业务流程表","奖金代码","奖金方案表","奖金代码")
jb5.AddExp("部门","核查部门")
jb5.AddExp("姓名","核查主检")
jb5.AddCols("报告编号","样品名称","样品型号规格")
jb5.AddExp("工作岗位","case when 核查主检 is null Then '无' Else '核查' End")
jb5.AddExp("金额","核查奖金额")
jb5.AddExp("定额","核查工时定额")
jb5.Filter = FilterDate0 & " AND 核查主检 <> ''"
'档案管理
Dim jb6 As New SQLJoinTableBuilder("查询表1","业务流程表")
jb6.C
jb6.AddTable("业务流程表","奖金代码","奖金方案表","奖金代码")
jb6.AddExp("部门","'技术质量部'")
'jb6.AddExp("姓名","'李红'")
jb6.AddExp("姓名","资料管理员")
jb6.AddCols("报告编号","样品名称","样品型号规格")
'jb6.AddExp("工作岗位","'档案归档'")
jb6.AddExp("工作岗位","case when 归档入库日期 is null Then '无' Else '档案归档' End")
jb6.AddExp("金额","报告入库电子资料上报奖金额")
jb6.AddExp("定额","报告入库电子资料上报工时定额")
jb6.Filter = FilterDate0 & " AND 归档入库日期  Is Not Null"
'报告编制
Dim jb7 As New SQLJoinTableBuilder("查询表1","业务流程表")
jb7.C
jb7.AddTable("业务流程表","奖金代码","奖金方案表","奖金代码")
'jb7.AddExp("部门","case when 检验报告编制人 = '张爽' Then '技术质量部' when 检验报告编制人 = '张茜'OR 检验报告编制人 = '曹飒' Then '业务部' Else '技术审查室' End")
jb7.AddExp("部门","检验报告编制部门")
jb7.AddExp("姓名","检验报告编制人")
jb7.AddCols("报告编号","样品名称","样品型号规格")
jb7.AddExp("工作岗位","case when 检验报告编制人 is null Then '无' Else '报告编制' End")
jb7.AddExp("金额","报告编制奖金额")
jb7.AddExp("定额","报告编制工时定额")
jb7.Filter = FilterDate0 & " AND 检验报告编制人<> ''"
'任务管理
Dim jb8 As New SQLJoinTableBuilder("查询表1","业务流程表")
jb8.C
jb8.AddTable("业务流程表","奖金代码","奖金方案表","奖金代码")
jb8.AddExp("部门","'业务部'")
jb8.AddExp("姓名","受理接待人")
jb8.AddCols("报告编号","样品名称","样品型号规格")
jb8.AddExp("工作岗位","case when 受理接待人 is null Then '无' Else '任务管理' End")
jb8.AddExp("金额","任务管理奖金额")
jb8.AddExp("定额","任务管理工时定额")
jb8.Filter = FilterDate0 & " AND 受理接待人 <> ''"
'报告电子版制作
Dim jb9 As New SQLJoinTableBuilder("查询表1","业务流程表")
jb9.C
jb9.AddTable("业务流程表","奖金代码","奖金方案表","奖金代码")
'jb9.AddExp("部门","'技术质量部'")
jb9.AddExp("部门","报告电子版制作部门")
'jb9.AddExp("姓名","case when 报告上报人 is null Then '李红' Else 报告上报人 End")
jb9.AddExp("姓名","报告电子版制作人")
jb9.AddCols("报告编号","样品名称","样品型号规格")
jb9.AddExp("工作岗位","'电子版制作'")
jb9.AddExp("金额","报告入库电子资料上报奖金额")
jb9.AddExp("定额","报告入库电子资料上报工时定额")
jb9.Filter = FilterDate0 & " AND 报告电子版制作日期  Is Not Null"
'封样
Dim jb10 As New SQLJoinTableBuilder("查询表1","业务流程表")
jb10.C
jb10.AddTable("业务流程表","奖金代码","奖金方案表","奖金代码")
jb10.AddExp("部门","'业务部'")
'jb10.AddExp("姓名","'郑晓刚'")
jb10.AddExp("姓名","样品管理员")
jb10.AddCols("报告编号","样品名称","样品型号规格")
jb10.AddExp("工作岗位","'封样'")
jb10.AddExp("金额","封样奖金额")
jb10.AddExp("定额","封样工时定额")
jb10.Filter = FilterDate0 & " AND 封样日期  Is Not Null"
'大件样品运输
Dim jb11 As New SQLJoinTableBuilder("查询表1","业务流程表")
jb11.C
jb11.AddTable("业务流程表","奖金代码","奖金方案表","奖金代码")
jb11.AddExp("部门","'业务部'")
jb11.AddExp("姓名","case when 样品入库日期 is null Then '无' Else '佟孟龙' End")
jb11.AddCols("报告编号","样品名称","样品型号规格")
jb11.AddExp("工作岗位","case when 样品入库日期 is null Then '无' Else '大样运输' End")
jb11.AddExp("金额","大样运输奖金额")
jb11.AddExp("定额","大样运输工时定额")
jb11.Filter = FilterDate0 & " AND {业务流程表}.产品类别 = '低压成套'"
'审定
Dim jb12 As New SQLJoinTableBuilder("查询表1","业务流程表")
jb12.C
jb12.AddTable("业务流程表","奖金代码","奖金方案表","奖金代码")
jb12.AddExp("部门","'技术审查室'")
jb12.AddExp("姓名","文审记录审定人")
jb12.AddCols("报告编号","样品名称","样品型号规格")
jb12.AddExp("工作岗位","case when 文审记录审定人 is null Then '无' Else '审定' End")
jb12.AddExp("金额","审定批准奖金额")
jb12.AddExp("定额","审定批准工时定额")
jb12.Filter = FilterDate0 & " AND 文审记录审定人 <> ''"
'检验记录批准
Dim jb13 As New SQLJoinTableBuilder("查询表1","业务流程表")
jb13.C
jb13.AddTable("业务流程表","奖金代码","奖金方案表","奖金代码")
jb13.AddExp("部门","case when 检验记录批准人 = '王玉璋' Then '防爆一室' when 检验记录批准人 = '刘丹' Then '防爆一室' Else '主任室' End")
jb13.AddExp("姓名","检验记录批准人")
jb13.AddCols("报告编号","样品名称","样品型号规格")
jb13.AddExp("工作岗位","case when 检验记录批准人 is null Then '无' Else '批准' End")
jb13.AddExp("金额","审定批准奖金额")
jb13.AddExp("定额","审定批准工时定额")
jb13.Filter = FilterDate0 & " AND 检验记录批准人 <> ''"
'预审
Dim jb14 As New SQLJoinTableBuilder("查询表1","业务流程表")
jb14.C
jb14.AddTable("业务流程表","奖金代码","奖金方案表","奖金代码")
jb14.AddExp("部门","文审部门")
jb14.AddExp("姓名","文件预审人")
jb14.AddCols("报告编号","样品名称","样品型号规格")
jb14.AddExp("工作岗位","'文件预审'")
jb14.AddExp("金额","文审奖金额")
jb14.AddExp("定额","文审工时定额")
jb14.Filter = FilterDate0 & " AND 文件预审人 <> '' AND 文件预审日期  Is Not Null"
'报告电子版上报
Dim jb15 As New SQLJoinTableBuilder("查询表1","业务流程表")
jb15.C
jb15.AddTable("业务流程表","奖金代码","奖金方案表","奖金代码")
jb15.AddExp("部门","'技术质量部'")
'jb15.AddExp("部门","报告电子版制作部门")
'jb15.AddExp("姓名","case when 报告上报人 is null Then '李红' Else 报告上报人 End")
jb15.AddExp("姓名","报告上报人")
jb15.AddCols("报告编号","样品名称","样品型号规格")
jb15.AddExp("工作岗位","'电子版上报'")
jb15.AddExp("金额","报告入库电子资料上报奖金额")
jb15.AddExp("定额","报告入库电子资料上报工时定额")
'jb15.Filter = FilterDate0 & " AND 报告上报日期 <> ''"
jb15.Filter = FilterDate0 & " AND (任务来源 = 'CQC' OR 任务来源 = 'CQM')"
'防爆合格证上传
Dim jb16 As New SQLJoinTableBuilder("查询表1","业务流程表")
jb16.C
jb16.AddTable("业务流程表","奖金代码","奖金方案表","奖金代码")
jb16.AddExp("部门","'技术质量部'")
'jb16.AddExp("姓名","报告上报人")
jb16.AddExp("姓名","case when 流程记录 like '唐治燕: 防爆合格证上传' Then '唐治燕' Else '张露予' End")
jb16.AddCols("报告编号","样品名称","样品型号规格")
jb16.AddExp("工作岗位","'防爆合格证上传'")
jb16.AddExp("金额","报告入库电子资料上报奖金额")
jb16.AddExp("定额","报告入库电子资料上报工时定额")
jb16.Filter = FilterDate0 & " AND 业务流程表.检验分类 = '型式试验' AND 业务流程表.产品类别 = '防爆电气'"

jb1.Union(jb2,True) '组合jb2
jb1.Union(jb3,True) '组合jb3
jb1.Union(jb4,True) '组合jb4
jb1.Union(jb5,True) '组合jb5
jb1.Union(jb6,True) '组合jb6
jb1.Union(jb7,True) '组合jb7
jb1.Union(jb8,True) '组合jb8
jb1.Union(jb9,True) '组合jb9
jb1.Union(jb10,True) '组合jb10
jb1.Union(jb11,True) '组合jb11
jb1.Union(jb12,True) '组合jb12
jb1.Union(jb13,True) '组合jb13
jb1.Union(jb14,True) '组合jb14
jb1.Union(jb15,True) '组合jb15
jb1.Union(jb16,True) '组合jb15
jb1.Build

Return jb1
[此贴子已经被作者于2022/2/18 16:50:04编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:111390 积分:567014 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2022/2/18 16:59:00 [只看该作者]

全部丢函数里就行了。有啥问题?

 回到顶部
帅哥哟,离线,有人找我吗?
fanjq8686
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:278 积分:2339 威望:0 精华:0 注册:2015/4/5 16:28:00
  发帖心情 Post By:2022/2/18 17:11:00 [只看该作者]

不会使用

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:111390 积分:567014 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2022/2/18 17:13:00 [只看该作者]

http://www.foxtable.com/webhelp/topics/1486.htm

创建一个函数,编辑函数,全部放进代码编辑器里。然后确定

 回到顶部
帅哥哟,离线,有人找我吗?
fanjq8686
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:278 积分:2339 威望:0 精华:0 注册:2015/4/5 16:28:00
  发帖心情 Post By:2022/2/18 17:17:00 [只看该作者]

用这个调用报错
Functions.Execute("JJHS")


 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:111390 积分:567014 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2022/2/18 17:28:00 [只看该作者]

报什么错?

 回到顶部