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


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

主题:多栏式会计账

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


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

已经解决了。

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


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


图片点击可在新窗口打开查看此主题相关图片如下:070401.png
图片点击可在新窗口打开查看
我想把贷方金额引用到统计表中,红色标注代码并没执行,不能直接用把贷方金额摆到统计表中生成,如果摆进去,就要把它变成负数,我试过摆进去,结果不是我要的效果。
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.Build(True)
    .DataSource = b.BuildDataSource
    Dim ckb As DataTable = e.Form.Controls("Table1").Table.DataTable
    If ckb.DataCols.Contains("借方金额") = False And ckb.DataCols.Contains("贷方金额") = False Then
        ckb.DataCols.add("借方金额", Gettype(Double))
        ckb.DataCols.add("贷方金额", Gettype(Double))
    End If
    DataTables("多栏式明细账_Table1").DataCols("借方金额").SetFormat("#,###.##")
    DataTables("多栏式明细账_Table1").DataCols("贷方金额").SetFormat("#,###.##")
    For Each dr As DataRow In DataTables("多栏式明细账_Table1").DataRows
        Dim z As Double = 0
        For Each c As Col In .Cols
            Dim a As Double
            If c.name = "年" OrElse 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
                a = iif(dr.IsNull(c.name),0,dr(c.name))
                z = z + a
            End If
        Next
        dr("借方金额") = z
    Next
    Dim das As List(Of DataRow) = DataTables("多栏式明细账_Table1").Select("[年] Is Not Null And [月] Is Not Null And [日] Is Not Null")
    For Each da As DataRow In das
        Dim d As Date = New Date(da("年"),da("月"),da("日"))
        If da.IsNull("年") = False And da.IsNull("月") = False And da.IsNull("日") = False And da.IsNull("借方金额") Then
            da("贷方金额") = DataTables("财务数据源").Compute("Sum(贷方金额)","[日期] = #" & d & "# And [会计科目辅助列] = '管理费用' And [借或贷] = '贷'")
        End If
    Next
    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 = "摘要" Then
            e.Cancel = True
        Else
            s = s & "," & c.name
            DataTables("多栏式明细账_Table1").DataCols(c.name).SetFormat("#,###.##")
        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 = "摘要" 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|字号|35|凭证号|35|摘要|250|[其它]"
    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 * 3 - 30 * 2 - 250) / (t.cols.Count - 6)
    If w2 > 0 Then
        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 = "摘要" Then
                e.Cancel = True
            Else
                str = str & "|" & c.name & "|" & w2
            End If
        Next
        sa = sa.replace("[其它]",str.trim("|"))
        t.SetColVisibleWidth(sa)
    End If
    .AutoSizeRows()
End With

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


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

现在生成什么效果?实际应该是什么效果?

如果只是正负问题,计算结果乘于-1即可

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


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


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


图片点击可在新窗口打开查看此主题相关图片如下:qq图片20210704204645.png
图片点击可在新窗口打开查看
不要红色标注的条件,表中多了借方金额_1这列,加了红色标注的列,没了贷方金额,这样写数据都有了,但不好看,最好把贷方金额放到最后一列,代码就要如32楼那样写,由于把贷方没二级科目,因此表中同样多了借方金额_1列,请教应如何完善这代码呢?
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 日期,字号,凭证号,摘要,二级科目,借方金额, - 贷方金额 AS 贷方金额 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.HGroups.AddDef("贷方金额")
    b.VGroups.AddDef("二级科目","{0}")
    b.Totals.AddDef("借方金额")
    b.Filter = "[二级科目] Is Not Null"
    b.Build(True)
    .DataSource = b.BuildDataSource
    Dim ckb As DataTable = e.Form.Controls("Table1").Table.DataTable
    If ckb.DataCols.Contains("借方金额") = False Then
        ckb.DataCols.add("借方金额", Gettype(Double))
    End If
    DataTables("多栏式明细账_Table1").DataCols("借方金额").SetFormat("#,###.##")
    For Each dr As DataRow In DataTables("多栏式明细账_Table1").DataRows
        Dim z As Double = 0
        For Each c As Col In .Cols
            Dim a As Double
            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
                a = iif(dr.IsNull(c.name),0,dr(c.name))
                z = z + a
            End If
        Next
        dr("借方金额") = z
    Next
    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 = "摘要" Then
            e.Cancel = True
        Else
            s = s & "," & c.name
            DataTables("多栏式明细账_Table1").DataCols(c.name).SetFormat("#,###.##")
        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 = "摘要" 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|字号|35|凭证号|35|摘要|250|[其它]"
    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 * 3 - 30 * 2 - 250) / (t.cols.Count - 6)
    If w2 > 0 Then
        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 = "摘要" Then
                e.Cancel = True
            Else
                str = str & "|" & c.name & "|" & w2
            End If
        Next
        sa = sa.replace("[其它]",str.trim("|"))
        t.SetColVisibleWidth(sa)
    End If
    .AutoSizeRows()
End With
[此贴子已经被作者于2021/7/4 21:07:32编辑过]

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


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

借方金额_1这列不需要可以隐藏掉:http://www.foxtable.com/webhelp/topics/0572.htm


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


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

隐藏不了,还是显示。
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.HGroups.AddDef("贷方金额")
    b.VGroups.AddDef("二级科目","{0}")
    b.Totals.AddDef("借方金额")
    'b.Filter = "[二级科目] Is Not Null"
    b.Build(True)
    .DataSource = b.BuildDataSource
    .Cols("借方金额_1").Visible = False
    Dim ckb As DataTable = e.Form.Controls("Table1").Table.DataTable
    If ckb.DataCols.Contains("借方金额") = False Then
        ckb.DataCols.add("借方金额", Gettype(Double))
    End If
    DataTables("多栏式明细账_Table1").DataCols("借方金额").SetFormat("#,###.##")
    .Cols("贷方金额").Move(.Cols.count - 1)
    For Each dr As DataRow In DataTables("多栏式明细账_Table1").DataRows
        Dim z As Double = 0
        For Each c As Col In .Cols
            Dim a As Double
            If c.name = "年" OrElse 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
                a = iif(dr.IsNull(c.name),0,dr(c.name))
                z = z + a
            End If
        Next
        dr("借方金额") = z
    Next
    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 = "摘要" Then
            e.Cancel = True
        Else
            s = s & "," & c.name
            DataTables("多栏式明细账_Table1").DataCols(c.name).SetFormat("#,###.##")
        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 = "摘要" 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|字号|35|凭证号|35|摘要|250|[其它]"
    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 * 3 - 30 * 2 - 250) / (t.cols.Count - 6)
    If w2 > 0 Then
        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 = "摘要" Then
                e.Cancel = True
            Else
                str = str & "|" & c.name & "|" & w2
            End If
        Next
        sa = sa.replace("[其它]",str.trim("|"))
        t.SetColVisibleWidth(sa)
    End If
    .AutoSizeRows()
End With

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


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

"借方金额_1"是标题,不是列名

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


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


图片点击可在新窗口打开查看此主题相关图片如下:效果20210704.png
图片点击可在新窗口打开查看
现在的效果是这样的。

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


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

.Cols(6).Visible = False
这样写也不行,它是动态生成的列名,我也不知是什么。

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


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

任何查看真正列名:http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=169124&replyID=140232&skin=1

或者遍历所有列,判断标题是"借方金额_1"的列就隐藏

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