以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  甘特图多时间段问题  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=77898)

--  作者:jamhuton
--  发布时间:2015/11/27 13:36:00
--  甘特图多时间段问题
If DrawGannt Then
    Dim r As Row  = Tables("进口业务进度表").Rows(e.Row.Index)
    Dim dt1 As Date = r("到港日期")
    Dim dt2 As Date = r("换单商检")
    Dim dt3 As Date = r("报关日期")
    Dim dt4 As Date = r("送货日期")
    Dim dt As Date = e.Col.Name.Replace("年","-").Replace("月_","-")
    If dt>=dt1 AndAlso dt<=dt2 Then
        e.StartDraw()
        If dt < Date.Today Then
            e.Graphics.FillRectangle(Brushes.Green,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
    If dt>=dt2 AndAlso dt<=dt3 Then
        e.StartDraw()
        If dt < Date.Today Then
            e.Graphics.FillRectangle(Brushes.Yellow,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
    If dt>=dt3 AndAlso dt<=dt4 Then
        e.StartDraw()
        If dt < Date.Today Then
            e.Graphics.FillRectangle(Brushes.Blue,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

--  作者:jamhuton
--  发布时间:2015/11/27 13:37:00
--  
dt4的日期不输入无法画图
--  作者:jamhuton
--  发布时间:2015/11/27 13:37:00
--  

图片点击可在新窗口打开查看此主题相关图片如下:2.png
图片点击可在新窗口打开查看

--  作者:jamhuton
--  发布时间:2015/11/27 13:37:00
--  

图片点击可在新窗口打开查看此主题相关图片如下:3.png
图片点击可在新窗口打开查看

--  作者:大红袍
--  发布时间:2015/11/27 14:34:00
--  

上面的代码没问题。

 

你右边的表,明细生成得不对,单元格就没有生成到最大的日期。


--  作者:jamhuton
--  发布时间:2015/11/27 15:32:00
--  
Dim tbl As Table = Tables("进口业务进度表")
Tables("业务进程_Table2").StopRedraw()
Dim StartDate As Date = tbl.Compute("Min(到港日期)", "到港日期 IS NOT NULL")
Dim EndDate As Date = tbl.Compute("Max(送货日期)","送货日期 IS NOT NULL")
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("业务进程_Table2").DataSource = Builder.buildDataSource
For Each cl As Col In Tables("业务进程_Table2").Cols
    cl.width = 20
Next
Functions.Execute("AddGanttRows")
Tables("业务进程_Table2").ResumeRedraw()

是不是这个代码中漏掉中间2个时间的设置?


--  作者:大红袍
--  发布时间:2015/11/27 15:58:00
--  

类似代码,细节自己调整

 

Dim StartDate As Date
Dim EndDate As Date

 

Dim ary(3) As Date
ary(0) = tbl.Compute("Min(到港日期)", "到港日期 IS NOT NULL")
ary(1) = tbl.Compute("Min(到港日期)", "到港日期 IS NOT NULL")
ary(2) = tbl.Compute("Min(到港日期)", "到港日期 IS NOT NULL")
ary(3) = tbl.Compute("Min(到港日期)", "到港日期 IS NOT NULL")
array.sort(ary)
startDate = ary(0)

 

ary(0) = tbl.Compute("max(到港日期)", "到港日期 IS NOT NULL")
ary(1) = tbl.Compute("max(到港日期)", "到港日期 IS NOT NULL")
ary(2) = tbl.Compute("max(到港日期)", "到港日期 IS NOT NULL")
ary(3) = tbl.Compute("max(到港日期)", "到港日期 IS NOT NULL")
array.sort(ary)
EndDate = ary(ary.length-1)


--  作者:jamhuton
--  发布时间:2015/11/27 16:17:00
--  

图片点击可在新窗口打开查看此主题相关图片如下:1.png
图片点击可在新窗口打开查看

如何把当天的日期作为正在进行的时间段的Max日期,否则只有dt1的时候还是无法画出图来的。

--  作者:大红袍
--  发布时间:2015/11/27 17:38:00
--  

EndDate = ary(ary.length-1)

 

If EndDate < Date.Today Then

    EndDate = Date.Today

End If


--  作者:jamhuton
--  发布时间:2015/11/27 22:14:00
--  
图片点击可在新窗口打开查看图片点击可在新窗口打开查看图片点击可在新窗口打开查看
谢谢老师
周末了 ,休息一下。