Foxtable(狐表)用户栏目专家坐堂 → [求助]窗口按钮代码修改


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

主题:[求助]窗口按钮代码修改

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


加好友 发短信
等级:二尾狐 帖子:534 积分:4414 威望:0 精华:0 注册:2012/11/28 16:03:00
[求助]窗口按钮代码修改  发帖心情 Post By:2015/12/26 10:10:00 [显示全部帖子]

老师你好,麻烦修改一下应付采购fa piao付款汇总表的窗口按钮代码:

出错如下:1,当月采购  金额 未能按供应商统计,201512 阿三磨床  数量1000 /金额50000

            2,付款统计出错:当月201512 张三/100 
                                      201512 赵六/200 
                                      201512 李四/300 
                                      201512 王五/400

                                        合计 1000

Dim s As String = e.Form.Controls("财务月份").Value
If s <> "" Then
    Tables("应付款按供应商汇总").StopRedraw() '停止重绘
    DataTables("应付款按供应商汇总").DataRows.Clear
    Dim dt_in As List(Of DataRow) = DataTables("应付款采购明细表").Select("供应商编号 is not null", "供应商编号,供应商名称,月份") '排序取出 应付采购 全部数据
    Dim drs_out As List(Of DataRow) = DataTables("应付款采购收piao明细表").Select("供应商编号 is not null", "供应商编号,供应商名称,月份") '排序取出 收piao 全部数据
    Dim drs_init As List(Of DataRow) = DataTables("应付款初始欠piao").Select("月份 <= " & s)
    Dim drs_init1 As List(Of DataRow) = DataTables("应付款初始账面应付款").Select("月份 <= " & s)
    Dim drs_in1 As List(Of DataRow) = DataTables("应付款付款明细表").Select("供应商编号 is not null", "供应商编号,供应商名称,月份")'排序取出 付款 全部数据
    Dim r As Row
    Dim sum_curr_money, sum_prev_money,sum_curr_money1 , sum_prev_money1  As Double
    Dim sum_curr_count, sum_prev_count As Single
    r = Tables("应付款按供应商汇总").AddNew
    r("供应商编号") = dt_in(0)("供应商编号")
    r("供应商名称") = dt_in(0)("供应商名称")
    If dt_in(0)("月份") < s Then '之前月
        sum_prev_count = sum_prev_count + dt_in(0)("数量")
        sum_prev_money = sum_prev_money + dt_in(0)("含税金额")
    Else If dt_in(0)("月份") = s Then '本月份
        sum_curr_money = sum_curr_money + dt_in(0)("含税金额")
        sum_curr_count = sum_curr_count + dt_in(0)("数量")
    End If
    For i As Single = 1 To dt_in.Count - 1 '写入供应商,同时统计采购数量和金额
        If dt_in(i)("供应商编号") <> dt_in(i-1)("供应商编号") OrElse dt_in(i)("供应商名称") <> dt_in(i-1)("供应商名称")  Then '不同供应商
            r("本期购货_数量") = sum_curr_count
            r("本期购货_金额") = sum_curr_money
            r("期初应付_尚未开piao_数量") = sum_prev_count '暂存
            r("期初应付_尚未开piao_金额") = sum_prev_money '暂存
            r = Tables("应付款按供应商汇总").AddNew '插入新数据
            r("供应商编号") = dt_in(i)("供应商编号")
            r("供应商名称") = dt_in(i)("供应商名称")
            sum_curr_money = 0
            sum_curr_count = 0
            sum_prev_count = 0
            sum_prev_money = 0
                       
        End If       
        If dt_in(i)("月份") < s Then '之前月
            sum_prev_count = sum_prev_count + dt_in(i)("数量")
            sum_prev_money = sum_prev_money + dt_in(i)("含税金额")
        Else If dt_in(i)("月份") = s Then '本月份
            sum_curr_money = sum_curr_money + dt_in(i)("含税金额")
            sum_curr_count = sum_curr_count + dt_in(i)("数量")
        End If
    Next
    For Each dr As DataRow In drs_init
        If DataTables("应付款按供应商汇总").find("供应商编号 = '" & dr("供应商编号") & "' And 供应商名称 = '" & dr("供应商名称") & "'") Is Nothing Then
            Dim nr = Tables("应付款按供应商汇总").AddNew '初始欠piao'
            nr("供应商编号") = dr("供应商编号")
            nr("供应商名称") = dr("供应商名称")
        End If
    Next
    For Each dr As DataRow In drs_init1
        If DataTables("应付款按供应商汇总").find("供应商编号 = '" & dr("供应商编号") & "' And 供应商名称 = '" & dr("供应商名称") & "'") Is Nothing Then
            Dim nr = Tables("应付款按供应商汇总").AddNew  '初始账面应付款'
            nr("供应商编号") = dr("供应商编号")
            nr("供应商名称") = dr("供应商名称")
        End If
    Next
    For Each dr As DataRow In drs_in1
        If DataTables("应付款按供应商汇总").find("供应商编号 = '" & dr("供应商编号") & "' And 供应商名称 = '" & dr("供应商名称") & "'") Is Nothing Then
            Dim nr = Tables("应付款按供应商汇总").AddNew  '从付款明细中
            nr("供应商编号") = dr("供应商编号")
            nr("供应商名称") = dr("供应商名称")
        End If
        Next
        r("本期支付_金额")  = sum_curr_money1
        r("期初应付_账面")  = sum_prev_money1 '暂存
       
        For Each dr As DataRow In DataTables("应付款按供应商汇总").DataRows '填充统计数据
            sum_curr_money = 0 '累计本月付款金额
            sum_prev_money = 0 '累计之前付款金额
           
            Dim filter As String = "供应商编号 = '" & dr("供应商编号") & "' And 供应商名称 = '" & dr("供应商名称") & "'"
            drs_in1 = DataTables("应付款付款明细表").Select(filter, "月份") '排序取出 付款 全部数据
            For Each dr_in1 As DataRow In drs_in1
                If dr_in1("月份") < s Then
                    sum_prev_money1 = sum_prev_money1 + dr_in1("付款金额")
                Else If dr_in1("月份") = s Then
                    sum_curr_money1 = sum_curr_money1 + dr_in1("付款金额")
                Else
                    Exit For
                End If
            Next
        Next
       
        For Each dr As DataRow In drs_out
            If DataTables("应付款按供应商汇总").find("供应商编号 = '" & dr("供应商编号") & "' And 供应商名称 = '" & dr("供应商名称") & "'") Is Nothing Then
                Dim nr = Tables("应付款按供应商汇总").AddNew  '采购收piao
                nr("供应商编号") = dr("供应商编号")
                nr("供应商名称") = dr("供应商名称")
            End If
        Next
        r("本期购货_数量") = sum_curr_count
        r("本期购货_金额") = sum_curr_money
        r("期初应付_尚未开piao_数量")  = sum_prev_count '暂存
        r("期初应付_尚未开piao_金额")  = sum_prev_money '暂存
        MessageBox.Show("供应商耗时: " & (Date.Now - st).TotalSeconds & "秒")
        st = Date.Now '用于计算时间
        For Each dr As DataRow In DataTables("应付款按供应商汇总").DataRows '填充统计数据
           
            sum_curr_count = 0 '累计本月开piao数量
            sum_prev_count = 0 '累计之前开piao数量
            sum_curr_money = 0 '累计本月开piao金额
            sum_prev_money = 0 '累计之前开piao金额
           
            Dim filter As String = "供应商编号 = '" & dr("供应商编号") & "' And 供应商名称 = '" & dr("供应商名称") & "'"
            drs_out = DataTables("应付款采购收piao明细表").Select(filter, "月份") '排序取出 开piao 全部数据
            For Each dr_out As DataRow In drs_out
                If dr_out("月份") < s Then
                    sum_prev_count = sum_prev_count + dr_out("开piao_数量")
                    sum_prev_money = sum_prev_money + dr_out("开piao_含税金额")
                Else If dr_out("月份") = s Then
                    sum_curr_count = sum_curr_count + dr_out("开piao_数量")
                    sum_curr_money = sum_curr_money + dr_out("开piao_含税金额")
                Else
                    Exit For
                End If
            Next
       
        Dim qcsl As Single = DataTables("应付款初始欠piao").compute("sum(入库_数量)", "供应商编号 = '" & dr("供应商编号") & "' And 供应商名称 = '" & dr("供应商名称") & "' and 月份 <= " & s)
        Dim qcsl1 As Single = DataTables("应付款初始欠piao").compute("sum(入库_含税金额)", "供应商编号 = '" & dr("供应商编号") & "' And 供应商名称 = '" & dr("供应商名称") & "' and 月份 <= " & s)
        Dim qcsl2 As Single = DataTables("应付款初始账面应付款").compute("sum(账面应付金额)", "供应商编号 = '" & dr("供应商编号") & "' And 供应商名称 = '" & dr("供应商名称") & "' and 月份 <= " & s)
       
        Dim sum_in_prev_count As Single = dr("期初应付_尚未开piao_数量")  '从表中取出暂存数据
        Dim sum_in_prev_money As Double = dr("期初应付_尚未开piao_金额")  '从表中取出暂存数据
        Dim sum_in_prev_money1 As Double = dr("期初应付_账面")
       
        dr("本期收piao_数量") = sum_curr_count
        dr("本期收piao_金额") = sum_curr_money
        dr("本期支付_金额") = sum_curr_money1
       
        dr("期初应付_账面") = sum_in_prev_money1 - sum_prev_money1 + qcsl2
        dr("期初应付_尚未开piao_数量")  = sum_in_prev_count - sum_prev_count + qcsl
        dr("期初应付_尚未开piao_金额")  = sum_in_prev_money - sum_prev_money + qcsl1
       
        dr("期末应付_账面") = dr("期初应付_账面") + dr("本期收piao_金额") - dr("本期支付_金额")
        dr("期末应付_尚未开piao_数量") = dr("期初应付_尚未开piao_数量") + dr("本期购货_数量") - dr("本期收piao_数量")
        dr("期末应付_尚未开piao_金额") = dr("期初应付_尚未开piao_金额") + dr("本期购货_金额") - dr("本期收piao_金额")
    Next
   
    Tables("应付款按供应商汇总").ResumeRedraw()
End If

 

 


图片点击可在新窗口打开查看此主题相关图片如下:应付采购fa piao付款汇总表(窗口按钮代码修改).png
图片点击可在新窗口打开查看

图片点击可在新窗口打开查看此主题相关图片如下:采购明细表.png
图片点击可在新窗口打开查看

图片点击可在新窗口打开查看此主题相关图片如下:12月份付款明细表.png
图片点击可在新窗口打开查看

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


加好友 发短信
等级:二尾狐 帖子:534 积分:4414 威望:0 精华:0 注册:2012/11/28 16:03:00
  发帖心情 Post By:2015/12/26 13:30:00 [显示全部帖子]

查不出呀

 回到顶部