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
|