Foxtable(狐表)用户栏目专家坐堂 → 流水账中如何区分产品和型号两种类别设计?


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

主题:流水账中如何区分产品和型号两种类别设计?

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


加好友 发短信
等级:管理员 帖子:47497 积分:251403 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2012/5/30 16:04:00 [显示全部帖子]

做个表达式列,合并产品和型号一起到这个表达式列。

修改代码:

 

Select Case e.DataCol.Name
    Case "产品","型号","入库","出库"
        Dim dr As DataRow
        Dim mr As DataRow = e.DataRow
        Dim drs As List(of DataRow)
        dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [表达式列] = '" & mr("表达式列") & "'", "[_SortKey] Desc")
        If dr Is Nothing Then
            mr("库存") = mr("入库") - mr("出库")
            dr = mr
        End If
        drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [表达式列] = '" & dr("表达式列") & "'", "[_SortKey]")
        For i As Integer = 1 To drs.Count - 1
            drs(i)("库存") = drs(i-1)("库存") + drs(i)("入库") - drs(i)("出库")
        Next
        If e.DataCol.Name = "表达式列" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then
            dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [表达式列] = '" & e.OldValue & "'", "[_SortKey] Desc")
            If dr Is Nothing Then
                dr = e.DataTable.Find("[表达式列] = '" & e.OldValue & "'", "[_SortKey]")
                If dr IsNot Nothing Then
                    dr("库存") = dr("入库") - dr("出库")
                End If
            End If
            If dr IsNot Nothing Then
                drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [表达式列] = '" & dr("表达式列") & "'", "[_SortKey]")
                For i As Integer = 1 To drs.Count - 1
                    drs(i)("库存") = drs(i-1)("库存") + drs(i)("入库") - drs(i)("出库")
                Next
            End If
        End If
End Select


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


加好友 发短信
等级:管理员 帖子:47497 积分:251403 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2012/5/31 8:38:00 [显示全部帖子]

1、增加一个全局变量。

2、菜单加一个按钮:

 

全局变量= not 全局变量

DataTables("表名").DataCols("入库").RaiseDataColChanged

 

3、DataColChanged事件代码改为:

 

If 全局变量 = True Then
    Select Case e.DataCol.Name
        Case "品名","入库","出库"
            Dim dr As DataRow
            Dim mr As DataRow = e.DataRow
            Dim drs As List(of DataRow)
            dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [品名] = '" & mr("品名") & "'", "[_SortKey] Desc")
            If dr Is Nothing Then
                mr("库存") = mr("入库") - mr("出库")
                dr = mr
            End If
            drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [品名] = '" & dr("品名") & "'", "[_SortKey]")
            For i As Integer = 1 To drs.Count - 1
                drs(i)("库存") = drs(i-1)("库存") + drs(i)("入库") - drs(i)("出库")
            Next
            If e.DataCol.Name = "品名" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then
                dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [品名] = '" & e.OldValue & "'", "[_SortKey] Desc")
                If dr Is Nothing Then
                    dr = e.DataTable.Find("[品名] = '" & e.OldValue & "'", "[_SortKey]")
                    If dr IsNot Nothing Then
                        dr("库存") = dr("入库") - dr("出库")
                    End If
                End If
                If dr IsNot Nothing Then
                    drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [品名] = '" & dr("品名") & "'", "[_SortKey]")
                    For i As Integer = 1 To drs.Count - 1
                        drs(i)("库存") = drs(i-1)("库存") + drs(i)("入库") - drs(i)("出库")
                    Next
                End If
            End If
    End Select
Else
    Select Case e.DataCol.Name
        Case "规格","入库","出库"
            Dim dr As DataRow
            Dim mr As DataRow = e.DataRow
            Dim drs As List(of DataRow)
            dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [规格] = '" & mr("规格") & "'", "[_SortKey] Desc")
            If dr Is Nothing Then
                mr("库存") = mr("入库") - mr("出库")
                dr = mr
            End If
            drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [规格] = '" & dr("规格") & "'", "[_SortKey]")
            For i As Integer = 1 To drs.Count - 1
                drs(i)("库存") = drs(i-1)("库存") + drs(i)("入库") - drs(i)("出库")
            Next
            If e.DataCol.Name = "规格" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then
                dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [规格] = '" & e.OldValue & "'", "[_SortKey] Desc")
                If dr Is Nothing Then
                    dr = e.DataTable.Find("[规格] = '" & e.OldValue & "'", "[_SortKey]")
                    If dr IsNot Nothing Then
                        dr("库存") = dr("入库") - dr("出库")
                    End If
                End If
                If dr IsNot Nothing Then
                    drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [规格] = '" & dr("规格") & "'", "[_SortKey]")
                    For i As Integer = 1 To drs.Count - 1
                        drs(i)("库存") = drs(i-1)("库存") + drs(i)("入库") - drs(i)("出库")
                    Next
                End If
            End If
    End Select
End If

 

 


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


加好友 发短信
等级:管理员 帖子:47497 积分:251403 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2012/6/8 8:23:00 [显示全部帖子]

全局变量改为整数型,0、1、2分别表示大类、中类、小类


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


加好友 发短信
等级:管理员 帖子:47497 积分:251403 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2012/6/8 17:34:00 [显示全部帖子]


 回到顶部