老师,代码改了下,但是显示不是按要求显示的如图1,正确的显示应该是绿色的开始日期/预计结束日期的时间段,统计和的没有显示出来,明细如图2,内部函数红色的是不是要改下,请帮忙看看,谢谢
If DrawGannt Then
Dim r As Row = Tables("排产显示_生产排产表").Rows(e.Row.Index)
Dim dt1 As Date = r("开始日期")
Dim dt2 As Date = r("预计结束日期")
Dim dt As Date = e.Col.Name.Replace("年", "-").Replace("月_", "-")
If dt >= dt1 AndAlso dt <= dt2 Then
e.StartDraw()
Dim Sum2 As Double = DataTables("工序跟踪表").sqlCompute("Sum(合格品)", "生产批次 = '" & r("生产批次") & "'")
Dim bh As Brush
If Sum2 > 0 Then
bh = Brushes.Green
Else
bh = Brushes.yellow
End If
If dt < Date.Today Then
e.Graphics.FillRectangle(bh, e.x , e.y + 5, e.Width, e.Height - 10)
Else
e.Graphics.FillRectangle(Brushes.Red, e.x , e.y + 3, e.Width, e.Height - 7)
End If
e.EndDraw()
End If
End If
BuildGanttTable内部函数代码:
Dim tbl As Table = Tables("排产显示_生产排产表")
Tables("排产显示_进度计划").StopRedraw()
Dim StartDate As Date = tbl.Compute("Min(开始日期)")
Dim EndDate As Date = tbl.Compute("max(实际完成日期)")
For Each c As Col In tbl.Cols
If c.Name.StartsWith("进度") Then
Dim temp As Date = tbl.Compute("Min(" & c.Name & ")")
If temp <> Nothing AndAlso temp < startDate Then
startDate = temp
End If
temp = tbl.Compute("max(" & c.Name & ")")
If temp <> Nothing AndAlso temp > EndDate Then
EndDate = temp
End If
End If
Next
Dim dt As Date = StartDate
Dim Builder As New DataTableBuilder("统计")
Do
Dim nm As String = dt.Year & "年" & dt.Month & "月_" & dt.Day
Builder.Adddef(nm,Gettype(String),1)
dt = dt.Adddays(1)
If dt > Enddate Then
Exit Do
End If
Loop
Tables("排产显示_进度计划").DataSource = Builder.BuildDataSource
For Each cl As Col In Tables("排产显示_进度计划").Cols
cl.width = 20
Next
Functions.Execute("AddGanttRows")
Tables("排产显示_进度计划").ResumeRedraw()
此主题相关图片如下:1.jpg
此主题相关图片如下:2.jpg
[此贴子已经被作者于2022/5/20 17:42:24编辑过]