Foxtable(狐表)用户栏目专家坐堂 → 多栏式会计账


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

主题:多栏式会计账

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


加好友 发短信
等级:超级版主 帖子:110333 积分:561507 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2021/6/24 10:08:00 [只看该作者]

Dim s As String = "年|35||35||35|字号|35|凭证号|35|摘要|300|[其它]|合计|60"

Dim ct As WinForm.Table = e.Form.Controls("Table1")
Dim t As Table = ct.Table
Dim str As String
Dim w2 As Integer = (ct.Width - 35*5-300-60) / (t .cols.Count-7)
if w2 > 0 then
For Each c As Col In .Cols
str = str & "|" & c.name & "|" & w2
next
s = s.replace("[其它]",str.trim("|"))
t.SetColVisibleWidth(s)
end if

 回到顶部
美女呀,离线,留言给我吧!
采菊东篱下
  22楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1881 积分:10374 威望:0 精华:0 注册:2019/4/6 8:45:00
  发帖心情 Post By:2021/6/24 10:37:00 [只看该作者]

写成红色代码报错,且没有了本年累计数据,改为下面黑字的代码直接报错不让保存,S已经定义了一次,重复定义了。
.NET Framework 版本:4.0.30319.17929
Foxtable 版本:2021.5.29.1
错误所在事件:窗口,多栏式明细账,Button1,Click
详细错误信息:
An item with the same key has already been added.





With Tables("多栏式明细账_Table1")
    For i As Integer = .Rows.count - 1 To 0 Step -1
        .Rows(i).Delete
    Next
    Dim g As Subtotalgroup
    .SubtotalGroups.Clear()
    Dim cmd As New SQLCommand
    Dim dt As DataTable
    cmd.CommandText = "Select 日期,字号,凭证号,摘要,二级科目,借方金额 fr om {财务数据源} Where [日期] >= #" & e.Form.Controls("StartDate").Value & "# And [日期] <= #" & e.Form.Controls("EndDate").Value & "# And [一级科目] = '" & e.Form.Controls("combobox1").Value & "'"
    dt = cmd.ExecuteReader()
    Dim b As New CrossTableBuilder("统计表1",dt)
    b.HGroups.AddDef("日期",DateGroupEnum.Year,"年")
    b.HGroups.AddDef("日期",DateGroupEnum.Month,"月")
    b.HGroups.AddDef("日期",DateGroupEnum.Day,"日")
    b.HGroups.AddDef("字号")
    b.HGroups.AddDef("凭证号")
    b.HGroups.AddDef("摘要")
    b.VGroups.AddDef("二级科目","{0}")
    b.Totals.AddDef("借方金额","借方金额")
    b.HorizontalTotal = True
    b.OrderByTotal = True
    b.Build(True)
    .DataSource = b.BuildDataSource
    Dim s As String = ""
    For Each c As Col In .Cols
        If c.Name Like "借方金额_*" Then
            s = s & "," & c.name
        End If
    Next
    g = New Subtotalgroup
    g.GroupOn = "月"
    g.TotalOn = s.Trim(",")
    g.Caption = "本月发生额"
    .SubtotalGroups.Add(g)
    g = New Subtotalgroup
    g.GroupOn = "月"
    g.Caption = "{0}月"
    .SubtotalGroups.Add(g)
    .Sort = "年,月"
    .Subtotal(True)
    Dim r As Row
    For i As Integer = 0 To .Rows.Count(True) - 1
        r = .Rows(i,True)
        If r.IsGroup AndAlso r("年") Like "*月" '如果是分组行
            Dim f As String = "年 = " & .Rows(i-2,True)("年") & " And 月 <= " & r("年").trim("月")
            r("年") = "本年累计"
            For Each c As Col In .Cols
                If c.name = c.Name Like "借方金额_*" Then
                    r(c.name) = .Compute("Sum(" & c.name & ")",f)
                End If
            Next
        End If
    Next

    Dim sa As String = "年|35|月|30|日|30|字号|30|凭证号|35|摘要|300|[其它]|合计|60"
    Dim ct As WinForm.Table = e.Form.Controls("Table1")
    Dim t As Table = ct.Table
    Dim str As String
    Dim w2 As Integer = (ct.Width - 35 - 30 * 4 - 300 - 60) / (t .cols.Count-7)
    If w2 > 0 Then
        For Each c As Col In .Cols
            str = str & "|" & c.name & "|" & w2
        Next
        sa = sa.replace("[其它]",str.trim("|"))
        t.SetColVisibleWidth(sa)
    End If

    Dim s As String = "年|35|月|30|日|30|字号|30|凭证号|35|摘要|300|[其它]|合计|60"
    Dim ct As WinForm.Table = e.Form.Controls("Table1")
    Dim t As Table = ct.Table
    Dim str As String
    Dim w2 As Integer = (ct.Width - 35 - 30 * 4 - 300 - 60) / (t .cols.Count-7)
    If w2 > 0 Then
        For Each c As Col In .Cols
            str = str & "|" & c.name & "|" & w2
        Next
        s = sa.replace("[其它]",str.trim("|"))
        t.SetColVisibleWidth(s)
    End If
End With
[此贴子已经被作者于2021/6/24 10:54:41编辑过]

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


加好友 发短信
等级:超级版主 帖子:110333 积分:561507 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2021/6/24 10:47:00 [只看该作者]

        For Each c As Col In .Cols
if c.name = "" orelse c.name = "" orelse .........
else
            str = str & "|" & c.name & "|" & w2
end if
        Next

 回到顶部
美女呀,离线,留言给我吧!
采菊东篱下
  24楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1881 积分:10374 威望:0 精华:0 注册:2019/4/6 8:45:00
  发帖心情 Post By:2021/6/24 11:08:00 [只看该作者]

还是一样报错,本年累计数据不见了!
.NET Framework 版本:4.0.30319.17929
Foxtable 版本:2021.5.29.1
错误所在事件:窗口,多栏式明细账,Button1,Click,
详细错误信息:
An item with the same key has already been added.

With Tables("多栏式明细账_Table1")
    For i As Integer = .Rows.count - 1 To 0 Step -1
        .Rows(i).Delete
    Next
    Dim g As Subtotalgroup
    .SubtotalGroups.Clear()
    Dim cmd As New SQLCommand
    Dim dt As DataTable
    cmd.CommandText = "Select 日期,字号,凭证号,摘要,二级科目,借方金额 fr om {财务数据源} Where [日期] >= #" & e.Form.Controls("StartDate").Value & "# And [日期] <= #" & e.Form.Controls("EndDate").Value & "# And [一级科目] = '" & e.Form.Controls("combobox1").Value & "'"
    dt = cmd.ExecuteReader()
    Dim b As New CrossTableBuilder("统计表1",dt)
    b.HGroups.AddDef("日期",DateGroupEnum.Year,"年")
    b.HGroups.AddDef("日期",DateGroupEnum.Month,"月")
    b.HGroups.AddDef("日期",DateGroupEnum.Day,"日")
    b.HGroups.AddDef("字号")
    b.HGroups.AddDef("凭证号")
    b.HGroups.AddDef("摘要")
    b.VGroups.AddDef("二级科目","{0}")
    b.Totals.AddDef("借方金额","借方金额")
    b.HorizontalTotal = True
    b.OrderByTotal = True
    b.Build(True)
    .DataSource = b.BuildDataSource
    Dim s As String = ""
    For Each c As Col In .Cols
        If c.Name Like "借方金额_*" Then
            s = s & "," & c.name
        End If
    Next
    g = New Subtotalgroup
    g.GroupOn = "月"
    g.TotalOn = s.Trim(",")
    g.Caption = "本月发生额"
    .SubtotalGroups.Add(g)
    g = New Subtotalgroup
    g.GroupOn = "月"
    g.Caption = "{0}月"
    .SubtotalGroups.Add(g)
    .Sort = "年,月"
    .Subtotal(True)
    Dim r As Row
    For i As Integer = 0 To .Rows.Count(True) - 1
        r = .Rows(i,True)
        If r.IsGroup AndAlso r("年") Like "*月" '如果是分组行
            Dim f As String = "年 = " & .Rows(i-2,True)("年") & " And 月 <= " & r("年").trim("月")
            r("年") = "本年累计"
            For Each c As Col In .Cols
                If c.name = c.Name Like "借方金额_*" Then
                    r(c.name) = .Compute("Sum(" & c.name & ")",f)
                End If
            Next
        End If
    Next
    Dim sa As String = "年|35|月|30|日|30|字号|30|凭证号|35|摘要|300|[其它]|合计|60"
    Dim ct As WinForm.Table = e.Form.Controls("Table1")
    Dim t As Table = ct.Table
    Dim str As String
    Dim w As Integer = 0
    Dim w2 As Integer = (ct.Width - 35 - 30 * 4 - 300 - 60) / (t .cols.Count-7)
    If w2 > 0 Then
        For Each c As Col In .Cols
            If c.name = "年" Then
                str = str & "|" & c.Name & "|35"
                w + = 35
            ElseIf c.name = "月" OrElse c.name = "日" OrElse c.name = "字号" OrElse c.name = "凭证号" Then
                str = str & "|" & c.Name & "|30"
                w + = 30
            ElseIf c.Name = "摘要" Then
                str = str & "|" & c.Name & "|300"
                w + = 300
            ElseIf c.Width = -1 Then
                str = str & "|" & c.Name & "|60"
                w + = 60
            Else
                str = str & "|" & c.name & "|" & w2
            End If
        Next
        sa = sa.replace("[其它]",str.trim("|"))
        t.SetColVisibleWidth(sa)
    End If
End With

 回到顶部
美女呀,离线,留言给我吧!
采菊东篱下
  25楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1881 积分:10374 威望:0 精华:0 注册:2019/4/6 8:45:00
  发帖心情 Post By:2021/6/24 11:20:00 [只看该作者]

改回我昨晚的代码,本年累计出现了,还是一样报错!应该是重复了红色代码的内容了。
.NET Framework 版本:4.0.30319.17929
Foxtable 版本:2021.5.29.1
错误所在事件:窗口,多栏式明细账,Button1,Click,
详细错误信息:
An item with the same key has already been added.


With Tables("多栏式明细账_Table1")
    For i As Integer = .Rows.count - 1 To 0 Step -1
        .Rows(i).Delete
    Next
    Dim g As Subtotalgroup
    .SubtotalGroups.Clear()
    Dim cmd As New SQLCommand
    Dim dt As DataTable
    cmd.CommandText = "Select 日期,字号,凭证号,摘要,二级科目,借方金额 fr om {财务数据源} Where [日期] >= #" & e.Form.Controls("StartDate").Value & "# And [日期] <= #" & e.Form.Controls("EndDate").Value & "# And [一级科目] = '" & e.Form.Controls("combobox1").Value & "'"
    dt = cmd.ExecuteReader()
    Dim b As New CrossTableBuilder("统计表1",dt)
    b.HGroups.AddDef("日期",DateGroupEnum.Year,"年")
    b.HGroups.AddDef("日期",DateGroupEnum.Month,"月")
    b.HGroups.AddDef("日期",DateGroupEnum.Day,"日")
    b.HGroups.AddDef("字号")
    b.HGroups.AddDef("凭证号")
    b.HGroups.AddDef("摘要")
    b.VGroups.AddDef("二级科目","{0}")
    b.Totals.AddDef("借方金额","借方金额")
    b.HorizontalTotal = True
    b.OrderByTotal = True
    b.Build(True)
    .DataSource = b.BuildDataSource
    Dim s As String = ""
    For Each c As Col In .Cols
        If c.name = "年" OrElse c.name = "月" OrElse c.name = "日" OrElse c.name = "字号" OrElse c.name = "凭证号" OrElse c.name = "摘要" OrElse c.name = "合计" Then
            e.Cancel = True
        Else
            s = s & "," & c.name
        End If
    Next
    g = New Subtotalgroup
    g.GroupOn = "月"
    g.TotalOn = s.Trim(",")
    g.Caption = "本月发生额"
    .SubtotalGroups.Add(g)
    g = New Subtotalgroup
    g.GroupOn = "月"
    g.Caption = "{0}月"
    .SubtotalGroups.Add(g)
    .Sort = "年,月"
    .Subtotal(True)
    Dim r As Row
    For i As Integer = 0 To .Rows.Count(True) - 1
        r = .Rows(i,True)
        If r.IsGroup AndAlso r("年") Like "*月" '如果是分组行
            Dim f As String = "年 = " & .Rows(i-2,True)("年") & " And 月 <= " & r("年").trim("月")
            r("年") = "本年累计"
            For Each c As Col In .Cols
                If c.name = "年" OrElse c.name = "月" OrElse c.name = "日" OrElse c.name = "字号" OrElse c.name = "凭证号" OrElse c.name = "摘要" OrElse c.name = "合计" Then
                    e.Cancel = True
                Else
                    r(c.name) = .Compute("Sum(" & c.name & ")",f)
                End If
            Next
        End If
    Next
    Dim sa As String = "年|35|月|30|日|30|字号|30|凭证号|35|摘要|300|[其它]|合计|60"
    Dim ct As WinForm.Table = e.Form.Controls("Table1")
    Dim t As Table = ct.Table
    Dim str As String
    Dim w As Integer = 0
    Dim w2 As Integer = (ct.Width - 35 - 30 * 4 - 300 - 60) / (t .cols.Count-7)
    If w2 > 0 Then
        For Each c As Col In .Cols
            If c.name = "年" Then
                str = str & "|" & c.Name & "|35"
                w + = 35
            ElseIf c.name = "月" OrElse c.name = "日" OrElse c.name = "字号" OrElse c.name = "凭证号" Then
                str = str & "|" & c.Name & "|30"
                w + = 30
            ElseIf c.Name = "摘要" Then
                str = str & "|" & c.Name & "|300"
                w + = 300
            ElseIf c.Width = -1 Then
                str = str & "|" & c.Name & "|60"
                w + = 60
            Else
                str = str & "|" & c.name & "|" & w2
            End If
        Next
        sa = sa.replace("[其它]",str.trim("|"))
        t.SetColVisibleWidth(sa)
    End If
End With

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


加好友 发短信
等级:超级版主 帖子:110333 积分:561507 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2021/6/24 11:26:00 [只看该作者]

去掉哪些所谓的昨晚代码

Dim s As String = "年|35|月|30|日|30|字号|30|凭证号|35|摘要|300|[其它]|合计|60"
    Dim ct As WinForm.Table = e.Form.Controls("Table1")
    Dim t As Table = ct.Table
    Dim str As String
    Dim w2 As Integer = (ct.Width - 35 - 30 * 4 - 300 - 60) / (t .cols.Count-7)
    If w2 > 0 Then
        For Each c As Col In .Cols
if c.name = "" orelse c.name = "" orelse ...固定的列自己补充完整.....
else
            str = str & "|" & c.name & "|" & w2
end if
        Next
        s = sa.replace("[其它]",str.trim("|"))
        t.SetColVisibleWidth(s)
    End If

 回到顶部
美女呀,离线,留言给我吧!
采菊东篱下
  27楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1881 积分:10374 威望:0 精华:0 注册:2019/4/6 8:45:00
  发帖心情 Post By:2021/6/24 11:41:00 [只看该作者]


图片点击可在新窗口打开查看此主题相关图片如下:qq图片20210624113958.png
图片点击可在新窗口打开查看
直接报错

    Dim ct As WinForm.Table = e.Form.Controls("Table1")
    Dim t As Table = ct.Table
    Dim str As String
    Dim w As Integer = 0
    Dim w2 As Integer = (ct.Width - 35 - 30 * 4 - 300 - 60) / (t .cols.Count-7)
    If w2 > 0 Then
        For Each c As Col In .Cols
            If c.name = "年" c.name = "月" OrElse c.name = "日" OrElse c.name = "字号" OrElse c.name = "凭证号" OrElse c.name = "摘要" OrElse c.name = "合计" Then
            Else
                str = str & "|" & c.name & "|" & w2
            End If
        Next
        sa = sa.replace("[其它]",str.trim("|"))
        t.SetColVisibleWidth(sa)
    End If
End With

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


加好友 发短信
等级:超级版主 帖子:110333 积分:561507 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2021/6/24 11:51:00 [只看该作者]

  If c.name = "年" OrElse c.name = "月" OrElse c.name

 回到顶部
美女呀,离线,留言给我吧!
采菊东篱下
  29楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1881 积分:10374 威望:0 精华:0 注册:2019/4/6 8:45:00
  发帖心情 Post By:2021/6/24 11:59:00 [只看该作者]

开始都提示这代码错:

图片点击可在新窗口打开查看此主题相关图片如下:qq图片20210624115801.png
图片点击可在新窗口打开查看


 回到顶部
美女呀,离线,留言给我吧!
采菊东篱下
  30楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1881 积分:10374 威望:0 精华:0 注册:2019/4/6 8:45:00
  发帖心情 Post By:2021/6/24 12:00:00 [只看该作者]

不要最后的then也一样

 回到顶部
总数 45 上一页 1 2 3 4 5 下一页