表属性,currentChanged事件,写代码
If e.Table.Current Is Nothing Then '如果Current为Nothing
Return '则返回
End If
If Forms("冲压生产计划追踪表").Opened = True Then
Dim zzan As WinForm.Button = Forms("冲压生产计划追踪表").Controls("终止")
If zzan.Text = "终止" Then
If e.Table.Current("状态") = "已终止" Then
zzan.text = "恢复"
End If
Else
If e.Table.Current("状态") <> "已终止" Then
zzan.text = "终止"
End If
End If
Dim kb As WinForm.SplitContainer = Forms("冲压生产计划追踪表").Controls("SplitContainer1")
If kb.Panel2.Collapsed = False Then
If ModifierKey <> Keys.Control Then
Dim t As Table = e.Table
Dim hdr = t.HeaderRows
For Each p As String In _ps
Dim ary() As String = p.Split(",")
If ary.Length = 2 Then
If ary(0) >= 0 AndAlso ary(1) >= 0 Then
If t.grid.Rows.count > ary(0) + hdr AndAlso t.grid.Cols.count > ary(1) + 1
t.Grid.SetCellStyle(ary(0) + hdr, ary(1)+1, "")
End If
End If
End If
Next
_ps.clear
t.refresh
DataTables("冲压生产计划追踪表_Table1").LoadFilter = "销售单号 = '" & e.Table.Current("制令单号") & "'"
DataTables("冲压生产计划追踪表_Table1").load()
DataTables("冲压生产计划追踪表_Table3").LoadFilter = "{进出库与制令单号关联表}.制令单号 = '" & e.Table.Current("制令单号") & "' and 出入库类型 = '出库'"
DataTables("冲压生产计划追踪表_Table3").load()
DataTables("冲压生产计划追踪表_Table4").LoadFilter = "{进出库与制令单号关联表}.制令单号 = '" & e.Table.Current("制令单号") & "' and 出入库类型 = '入库'"
DataTables("冲压生产计划追踪表_Table4").load()
Tables("冲压生产计划追踪表_Table1").AutoSizeRows()
Tables("冲压生产计划追踪表_Table3").AutoSizeRows()
Tables("冲压生产计划追踪表_Table4").AutoSizeRows()
If Tables("冲压生产计划追踪表_Table4").Current IsNot Nothing Then
Tables("冲压生产计划追踪表_Table4").Select(0,0)
End If
DataTables("冲压生产计划追踪表_Table5").DataRows.Clear()
Dim drs As new List(of DataRow)
Dim pd As Integer = 0
If Tables("冲压生产计划追踪表_Table3").Rows.Count >= Tables("冲压生产计划追踪表_Table4").Rows.Count Then
drs = DataTables("冲压生产计划追踪表_Table3").Select("","日期")
pd = 1
Else
drs = DataTables("冲压生产计划追踪表_Table4").Select("","日期")
pd = 2
End If
If drs.Count > 0 Then
If pd = 1 Then
For Each dr As DataRow In drs
Dim xdr As DataRow = DataTables("冲压生产计划追踪表_Table5").AddNew()
xdr("领料日期") = dr("日期")
xdr("领料数量") = dr("分到订单量")
xdr("领料批号") = ""
xdr("领料签收") = ""
xdr("制令单号") = dr("制令单号")
Next
drs = DataTables("冲压生产计划追踪表_Table4").Select("","日期")
For i As Integer = 0 To drs.Count - 1
Dim xdr As Row = Tables("冲压生产计划追踪表_Table5").Rows(i)
xdr("入库日期") = drs(i)("日期")
xdr("入库数量") = drs(i)("分到订单量")
xdr("入库签收") = ""
xdr("入库备注") = drs(i)("备注")
xdr("入库批号") = drs(i)("单号")
Next
Else If pd = 2 Then
For Each dr As DataRow In drs
Dim xdr As DataRow = DataTables("冲压生产计划追踪表_Table5").AddNew()
xdr("入库日期") = dr("日期")
xdr("入库数量") = dr("分到订单量")
xdr("入库签收") = ""
xdr("入库备注") = dr("备注")
xdr("入库批号") = dr("单号")
xdr("制令单号") = dr("制令单号")
Next
drs = DataTables("冲压生产计划追踪表_Table3").Select("","日期")
For i As Integer = 0 To drs.Count - 1
Dim xdr As Row = Tables("冲压生产计划追踪表_Table5").Rows(i)
xdr("领料日期") = drs(i)("日期")
xdr("领料数量") = drs(i)("分到订单量")
xdr("领料批号") = ""
xdr("领料签收") = ""
Next
End If
End If
End If
Else
Return
End If
End If