DataTables("时间记录").DataRows.Clear() Dim jp As Integer = 0 Dim zdysj As Date = Date.Today & " " & "08" & ":" & "00" & ":" & "00" '自定义时间 For i As Integer = 1 To 5 Dim jp1 As String = DataTables("时间记录").SQLCompute("max(节拍)") If jp1 = "" Then jp = 1 Else jp = CInt(jp1) + 1 End If MessageBox.Show(jp) Dim f As New Filler f.SourceTable = DataTables("模板") f.SourceCols = "工位,工序编号" f.DataTable = DataTables("时间记录") f.DataCols = "工位,工序编号" f.Filter = "产品款号 = '123'" f.Distinct = False f.Fill() '填充节拍产量等 For Each dr As DataRow In DataTables("时间记录").DataRows If dr.IsNull("批次") Then dr("批次") = 1 dr("节拍") = jp DataTables("时间记录").Save() End If Next '填充开始结束时间 For Each gw As String In DataTables("时间记录").GetValues("工位","节拍 = '" & jp & "'") Dim xlfd As Double = Rand.Next(100 - 6,100 + 6) / 100 '效率浮动 Dim jpms2 As Integer = 10 * 60 * xlfd '浮动节拍秒时 Dim N2,h2,m2,s2 As Integer N2 = jpms2 h2 = N2 \ 3600 m2 = (N2 Mod 3600) \ 60 s2 = N2 Mod 60 Dim d2 As Date = Format(new Date(1,1,1,h2,m2,s2), "HH:mm:ss") Dim fdr = DataTables("时间记录").Find("工位 = '" & gw & "' and 开始时间 is not null", "[序号] Desc") '找出上一行 Dim kssj As Date If fdr Is Nothing Then kssj = zdysj Else kssj = fdr("结束时间") End If Dim drs As List(of DataRow) = DataTables("时间记录").Select("工位 = '" & gw & "' and 节拍 = '" & jp & "'") For Each mr As DataRow In drs mr("开始时间") = kssj '第一个节拍开始时间 mr("结束时间") = CDate(mr("开始时间")).AddSeconds(d2.Hour*3600 + d2.Minute*60 + d2.Second) '第一个节拍结束时间 Next Next Next With Tables("时间记录") .Position = .Rows.Count - 1 End With Tables("时间记录").AutoSizeCols() DataTables("时间记录").Save()
|