以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  流水账中如何区分产品和型号两种类别设计?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=20150)

--  作者:jxkqf
--  发布时间:2012/5/30 15:54:00
--  流水账中如何区分产品和型号两种类别设计?

在FOXTABLE帮助中,有一下流水账区分产品设计的例子。

但在实际中,可能要区分两类,比如产品下面还有区分型号进行流水账的设计,如何进行?

 

比如产品有手机,电脑等,手机又分为安卓的,寨班的。如何在流水账中设置能即时看到手机现在库存有多少?而寨班手机现在库存多少?


--  作者:狐狸爸爸
--  发布时间: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


--  作者:jxkqf
--  发布时间:2012/5/30 17:22:00
--  
这个还不能满足需求。我既要按产品查到即时库存,同时也要按型号查到即时库存。上述代码只能满足其中一种查阅方法。
--  作者:rjh4078
--  发布时间:2012/5/30 21:08:00
--  

把你的表上传上来看下


--  作者:jxkqf
--  发布时间:2012/5/31 8:05:00
--  

而且希望能即时看到本期库存,上期期末库存情况等。


--  作者:狐狸爸爸
--  发布时间: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

 

 


--  作者:jxkqf
--  发布时间:2012/5/31 8:47:00
--  

这正是我想要的,我好好再消化一下。


--  作者:jxkqf
--  发布时间:2012/6/8 8:11:00
--  

如果要分大类、中类、小类三种类别进行查看流水账,如何操作?


--  作者:狐狸爸爸
--  发布时间:2012/6/8 8:23:00
--  

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


--  作者:jxkqf
--  发布时间:2012/6/8 15:01:00
--  
以下是引用狐狸爸爸在2012-6-8 8:23:00的发言:

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

有点不明白,可否祥说一下?

 

是不是在停靠窗口设计三个按纽,分别设置按纽代码为全局变量设置为0、1、2?