Foxtable(狐表)用户栏目专家坐堂 → 库存


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

主题:库存

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


加好友 发短信
等级:幼狐 帖子:195 积分:1395 威望:0 精华:0 注册:2014/1/21 9:45:00
库存  发帖心情 Post By:2014/12/24 13:02:00 [显示全部帖子]

If  e.DataCol.Name = "产品编号" Then
     Dim nms() As String = {"产品编号","产品名称","厂牌","产地"}
     If  e.NewValue Is Nothing Then 
         For Each nm As String In nms
             e.DataRow(nm) = Nothing 
         Next 
     Else 
         Dim dr As DataRow
         dr = DataTables("产品资料表").Find("[产品编号] = '" & e.NewValue & "'") 
         If  dr IsNot Nothing
             For Each nm As String In nms
                 e.DataRow(nm) = dr(nm)
             Next
         End If
     End If
 End If
'以上是引用产品资料
Select Case  e.DataCol.Name
    Case  "产品编号","入库数量","产地"
        Dim  dr As  DataRow
        Dim  dr1 As  DataRow '接收查找库存明细表的查找结果
        Dim  mr As  DataRow = e.DataRow
        Dim  drs As  List(of DataRow)
        dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") &  " And [产品编号] = '" &  mr("产品编号") &  "' And [产地] = '" &  mr("产地") &  "'", "[_SortKey] Desc") '找出上一行并给dr
        dr1 =  DataTables("库存余量表").Find("[产品编号] = '" & mr("产品编号") & "'And [产地] = '" &  mr("产地") &  "'")
        If dr Is Nothing Then    '如果没有找到上一行,说明本行就是第一行
            mr("累计入库数量") = mr("入库数量")                         '当前的累计数量就等于当前的入库数量
            dr = mr
            If dr1 Is Nothing Then                                      '如果没有找到余量表中相同编号的行
                Tables("库存余量表").AddNew()                                    '库存余量表增加一行
                Tables("库存余量表").Current("产品编号") = mr("产品编号")          '增加的行中赋值
                Tables("库存余量表").Current("产品名称") = mr("产品名称")
                Tables("库存余量表").Current("产地") = mr("产地")
                Tables("库存余量表").Current("入库数量") = mr("累计入库数量")  '余量表入库数量等于当前行的累计数量
            Else                                                               '否则
                dr1("入库数量") = mr("累计入库数量")                               '找到行的入库数量等于当前入库明细表的累计数量
            End If                                                              '结束
           
        End If
        drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") &  " And [产品编号] = '" &  dr("产品编号") &  "'And [产地] = '" &  mr("产地") &  "'", "[_SortKey]")
        For  i As  Integer = 1 To drs.Count - 1
            drs(i)("累计入库数量") = drs(i-1)("累计入库数量") + drs(i)("入库数量")
            If dr1 IsNot Nothing Then                                      '如果没有找到余量表中相同编号的行dr1不为空
                dr1("入库数量") = drs(i)("累计入库数量")                               '找到行的入库数量等于当前入库明细表上一行的累计数量
            End If                                                              '结束
        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 &  "'And [产地] = '" &  mr("产地") &  "'", "[_SortKey] Desc")
            If  dr Is Nothing Then
                dr = e.DataTable.Find("[产品编号] = '" & e.OldValue &  "'And [产地] = '" &  mr("产地") &  "'", "[_SortKey]")
                If dr IsNot Nothing Then
                    dr("累计入库数量") = dr("入库数量")
                    If dr1 Is Nothing Then                                      '如果没有找到余量表中相同编号的行
                        Tables("库存余量表").AddNew()                                    '库存余量表增加一行
                        Tables("库存余量表").Current("产品编号") = mr("产品编号")          '增加的行中赋值
                        Tables("库存余量表").Current("产品名称") = mr("产品名称")
                        Tables("库存余量表").Current("产地") = mr("产地")
                        Tables("库存余量表").Current("入库数量") = mr("累计入库数量")  '余量表入库数量等于当前行的累计数量
                    Else                                                               '否则
                        dr1("入库数量") = dr("累计入库数量")                               '找到行的入库数量等于当前入库明细表的累计数量
                    End If                                                              '结束
                End If
            End If
           
            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 &  "'And [产地] = '" &  mr("产地") &  "'", "[_SortKey] Desc")
                If  dr Is Nothing Then
                    dr = e.DataTable.Find("[产地] = '" & e.OldValue &  "'And [产品编码] = '" &  mr("产品编号") &  "'", "[_SortKey]")
                    If dr IsNot Nothing Then
                        dr("累计入库数量") = dr("入库数量")
                        If dr1 Is Nothing Then                                      '如果没有找到余量表中相同编号的行
                            Tables("库存余量表").AddNew()                                    '库存余量表增加一行
                            Tables("库存余量表").Current("产品编号") = mr("产品编号")          '增加的行中赋值
                            Tables("库存余量表").Current("产品名称") = mr("产品名称")
                            Tables("库存余量表").Current("产地") = mr("产地")
                            Tables("库存余量表").Current("入库数量") = mr("累计入库数量")  '余量表入库数量等于当前行的累计数量
                        Else                                                               '否则
                            dr1("入库数量") = dr("累计入库数量")                               '找到行的入库数量等于当前入库明细表的累计数量
                        End If                                                              '结束
                    End If
                End If
            End If
           
            If  dr IsNot Nothing Then
                drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") &  " And [产品编号] = '" &  dr("产品编号") &  "'And [产地] = '" &  mr("产地") &  "'", "[_SortKey]")
                For i As Integer = 1 To drs.Count - 1
                    drs(i)("累计入库数量") = drs(i-1)("累计入库数量") + drs(i)("入库数量")
                    If dr1 Is Nothing Then                                      '如果没有找到余量表中相同编号的行
                        Tables("库存余量表").AddNew()                                    '库存余量表增加一行
                        Tables("库存余量表").Current("产品编号") = mr("产品编号")          '增加的行中赋值
                        Tables("库存余量表").Current("产品名称") = mr("产品名称")
                        Tables("库存余量表").Current("产地") = mr("产地")
                        Tables("库存余量表").Current("入库数量") = mr("累计入库数量")  '余量表入库数量等于当前行的累计数量
                    Else                                                               '否则
                        dr1("入库数量") = drs(i)("累计入库数量")                               '找到行的入库数量等于当前入库明细表的累计数量
                    End If
                Next
            End If
        End If
End Select

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


加好友 发短信
等级:幼狐 帖子:195 积分:1395 威望:0 精华:0 注册:2014/1/21 9:45:00
  发帖心情 Post By:2014/12/26 14:43:00 [显示全部帖子]

不好意思怎么发重复了呢


 回到顶部