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


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

主题:求助自定义函数

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


加好友 发短信
等级:超级版主 帖子:109489 积分:557107 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/6/1 9:04:00 [显示全部帖子]

函数
Dim T1 As Table = args(0)

Dim nms() As string = args(1)

Dim tn As string = args(2)

Dim cmd As new SQLCommand

cmd.C

Dim r As Row

    Dim i As Integer = 0

    Dim dlg As New OpenFileDialog '定义一个新的OpenFileDialog

    dlg.Filter= "Excel2007文件|*.xlsx"

    If dlg.ShowDialog = DialogResult.Ok Then

        Dim Book As New XLS.Book(dlg.FileName)

        Dim Sheet As XLS.Sheet = Book.Sheets(0)

        For n As Integer = 1 To Sheet.Rows.Count -1

            If sheet(n,0).Text <> "" Then

                If sheet(n,25).Text.trim() <> "已通过"  Then

                    MessageBox.Show("差旅费列表中存在没有审批通过的记录,请处理!")

                    'Exit For

                    Return -1

                End If

            Else

                Exit For

            End If

        Next

        For n As Integer = 1 To Sheet.Rows.Count -1

            Dim spbh As String = sheet(n,0).Text

            If spbh.Length < 2 Then

                Exit For

            End If

            cmd.CommandText = "select count(*) f rom {" & tn & "} where 审批编号=  '" & spbh & "'"

            If cmd.ExecuteScalar = 0 Then

                r = T1.AddNew

                For m As Integer = 0 To nms.Length - 1

                    If r(nms(m)).IsBoolean Then '处理逻辑列

                        r(nms(m)) = False

                    ElseIf r(nms(m)).IsNumeric andalso Sheet(n,m).Value like "*元*" Then '处理诸费用列

                        r(nms(m)) = Sheet(n,m).Value.split("元")(0)

                    Else

                        r(nms(m)) = Sheet(n,m).Value

                    End If

                Next

                i = i + 1

            End If

        Next

    End If

    MessageBox.Show("审批表添加完毕,共添加" & i & "行")

End If



调用

Dim cm As WinForm.ComboBox = e.Form.Controls("ComboBox2")

Dim T1 As Table = e.Form.Controls("Table1").Table

If cm.Value = "差旅费" Then

Dim nms() As String = {"审批编号","提交时间","申请人","申请人部门","申请人账号","部门","出差人员","出差任务","出发时间","出发地","到达时间","到达地","当日返回","车费","油补","过道费","餐补","宿费","其他费用","费用小计","详情说明","总费用小计","预借金额","预借金额大写","报销总额","当前审批状态","审批人","抄送人","审批流程","已打印","已领取","已报销","备注"}

Dim tn As String = "差旅费记录表1"

    Functions.Execute("xx函数",T1,nms,tn )

End If

 回到顶部