Foxtable(狐表)用户栏目专家坐堂 → 累计出库自动更新的问题?(已解决)


  共有10010人关注过本帖平板打印复制链接

主题:累计出库自动更新的问题?(已解决)

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


加好友 发短信
等级:五尾狐 帖子:1199 积分:7102 威望:0 精华:0 注册:2013/3/4 18:02:00
  发帖心情 Post By:2013/3/30 21:40:00 [只看该作者]

If e.DataCol.Name = "数量_本次交"
    e.DataRow("金额")= e.NewValue * e.DataRow("单价") '计算金额
    Dim dr As DataRow = DataTables("销售出库单主表").Find("出库单号='" & e.DataRow("出库单号") & "'")
    dr("总金额") = DataTables("销售出库单子表").Compute("sum(金额)","出库单号 ='" & e.DataRow("出库单号") & "'") '计算主表总金额
    '=======================================================================================================
    DataTables("临时销售出库单子表").LoadFilter="客户订单编号 = '" & e.DataRow("客户订单编号") & "' And 料号 ='" & e.DataRow("料号") & "'"
    DataTables("临时销售出库单子表").Load '加载历史入库单
    Dim vr As DataRow =  DataTables("临时销售出库单子表").Find("_Identify = '" & e.DataRow("_identify") & "'")
    Dim count As Integer = DataTables("临时销售出库单子表").DataRows.Count
    If vr Is Nothing  AndAlso count = 0
        e.DataRow("数量_累交数")  = e.NewValue
        e.DataRow("数量_未交数")  = e.DataRow("数量_订单数") - e.DataRow("数量_累交数")
    ElseIf vr Is Nothing AndAlso count <> 0
        For Each cr As DataRow In  DataTables("临时销售出库单子表").DataRows
            cr("数量_累交数")=  DataTables("临时销售出库单子表").Compute("sum(数量_本次交)") + e.NewValue
            cr("数量_未交数") = cr("数量_订单数") - cr("数量_累交数") '更新后台表单数据
            For Each mr As DataRow In DataTables("销售出库单子表").Select("客户订单编号 = '" & e.DataRow("客户订单编号") & "' And 料号 ='" & e.DataRow("料号") & "'")
                mr("数量_累交数") = cr("数量_累交数")
                mr("数量_未交数") = cr("数量_未交数")
            Next '更新前台表单数据
        Next
    ElseIf vr IsNot Nothing AndAlso count = 1
        e.DataRow("数量_累交数")  = e.NewValue
        e.DataRow("数量_未交数")  = e.DataRow("数量_订单数") - e.DataRow("数量_累交数")
        vr("数量_累交数") = e.NewValue
        vr("数量_本次交") = e.NewValue
        vr("数量_未交数") = vr("数量_订单数") - vr("数量_累交数")
    ElseIf vr IsNot Nothing AndAlso count > 1
        For Each ccr As DataRow In DataTables("临时销售出库单子表").DataRows
            ccr("数量_累交数") = DataTables("临时销售出库单子表").Compute("sum(数量_本次交)","[_Identify] <> '" & e.DataRow("_Identify") & "'") + e.NewValue
            ccr("数量_未交数") = ccr("数量_订单数") - ccr("数量_累交数")
            For Each mmr As DataRow In DataTables("销售出库单子表").Select("客户订单编号 = '" & e.DataRow("客户订单编号") & "' And 料号 ='" & e.DataRow("料号") & "'")
                mmr("数量_累交数") = ccr("数量_累交数")
                mmr("数量_未交数") = ccr("数量_未交数")
            Next '更新前台表单数据
        Next
        vr("数量_本次交") = e.NewValue
    End If
    Dim cmd As New SQLCommand
    cmd.C
    cmd.CommandText = "update {客户订单子表} SET 未交数 = '" & e.DataRow("数量_未交数") & "' where 客户订单编号 = '" & e.DataRow("客户订单编号") & "' And OPN = '" & e.DataRow("料号") & "'"
    cmd.ExecuteNonQuery()
    Dim cmd1 As New SQLCommand
    cmd1.C
    'Dim temp As Integer = DataTables("临时销售出库单子表").Compute("sum(数量_本次交)","客户订单编号 = '" & e.DataRow("客户订单编号") & "'And [_Identify] <> '" & e.DataRow("_Identify") & "'") + e.DataRow("数量_本次交")
    Dim cmd5 As New SQLCommand
    cmd5.C
    cmd5.CommandText = "select sum(未交数) from {客户订单子表} where 客户订单编号 = '" & e.DataRow("客户订单编号") & "'"
    Dim temp1 As Integer = cmd5.ExecuteScalar
    If temp1 >0
        cmd1.CommandText ="update {客户订单主表} SET 结案 = 0 Where 客户订单编号 = '" & e.DataRow("客户订单编号") & "'"
        cmd1.ExecuteNonQuery()
    ElseIf temp1 <= 0
        cmd1.CommandText ="update {客户订单主表} SET 结案 = 1 Where 客户订单编号 = '" & e.DataRow("客户订单编号") & "'"
        cmd1.ExecuteNonQuery()
    End If
    Dim cmd3 As New SQLCommand
    cmd3.C
    cmd3.CommandText="select 当前库存 from {产品资料子表} Where 料号 = '" & e.DataRow("料号") & "'"
    Dim kc As Integer = cmd3.ExecuteScalar
    Dim cmd2 As New SQLCommand
    cmd2.C
    cmd2.CommandText = "Update {产品资料子表} SET 当前库存 ='" & kc - e.NewValue + e.OldValue & "' where 料号 = '" & e.DataRow("料号") & "'"
    cmd2.ExecuteNonQuery()
End If

 回到顶部
总数 34 1 2 3 4 下一页