以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]单元格绘图2  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=82911)

--  作者:狐作非为
--  发布时间:2016/3/27 16:48:00
--  [求助]单元格绘图2
假如在同一天,有两个项目,第二个项目接着第一个项目的时间去推移应该怎么绘制呢?


 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目6.zip


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


--  作者:大红袍
--  发布时间:2016/3/27 17:28:00
--  
If e.Col.name.StartsWith("时_") Then
    e.StartDraw()
    Dim ct As Integer = e.Row("项目时间")
    Dim t As Integer = e.Col.Name.Replace("时_", "")
    Dim pt As Integer = e.Table.Compute("sum(项目时间)", "_Identify < " & e.Row("_Identify"))
   
    If pt+ct > t-60 Then
        If pt >= t-60 AndAlso pt < t Then
            Dim x As Integer = (e.width-2) * (pt-t+60) / 60
            Dim width As Integer
            If pt+ct > t Then
                width = (e.width-2) *(t-pt) / 60
            Else
                width = (e.width-2) *(ct) / 60
            End If
            e.Graphics.FillRectangle(Brushes.Green,e.x + x + 1,e.y + 1, Width, e.Height - 2)
        ElseIf t > pt+60
            Dim x As Integer = 0
            Dim width As Integer
            If pt+ct > t Then
                width = e.width-2
            Else
                width = (e.width-2) *(pt+ct-t+60) / 60
            End If
            e.Graphics.FillRectangle(Brushes.Green,e.x + x + 1,e.y + 1, Width, e.Height - 2)
        End If
    End If
    e.EndDraw()
End If

--  作者:狐作非为
--  发布时间:2016/3/27 21:20:00
--  
谢谢袍版,但有点问题,那就是C项目不是和前面两个项目在一天的,所以应该也是日期的8:00开始,而不是往后接,我改了半天怎么也没有改对!!!
--  作者:狐作非为
--  发布时间:2016/3/27 21:40:00
--  
谢谢,搞定了
--  作者:狐作非为
--  发布时间:2016/3/28 19:42:00
--  
袍版,发现个问题,好像都少了一个小时,请问如何改下?
--  作者:大红袍
--  发布时间:2016/3/28 19:50:00
--  

少一小时什么意思?

 

If e.Col.name.StartsWith("时_") Then
    e.StartDraw()
    Dim ct As Integer = e.Row("项目时间")
    Dim t As Integer = e.Col.Name.Replace("时_", "")
    Dim pt As Integer = e.Table.Compute("sum(项目时间)", "_Identify < " & e.Row("_Identify") & " and 日期 = \'" & e.Row("日期") & "\'")
   
    If pt+ct > t-60 Then
        If pt >= t-60 AndAlso pt < t Then
            Dim x As Integer = (e.width-2) * (pt-t+60) / 60
            Dim width As Integer
            If pt+ct > t Then
                width = (e.width-2) *(t-pt) / 60
            Else
                width = (e.width-2) *(ct) / 60
            End If
            e.Graphics.FillRectangle(Brushes.Green,e.x + x + 1,e.y + 1, Width, e.Height - 2)
        ElseIf t > pt+60
            Dim x As Integer = 0
            Dim width As Integer
            If pt+ct > t Then
                width = e.width-2
            Else
                width = (e.width-2) *(pt+ct-t+60) / 60
            End If
            e.Graphics.FillRectangle(Brushes.Green,e.x + x + 1,e.y + 1, Width, e.Height - 2)
        End If
    End If
    e.EndDraw()
End If


--  作者:狐作非为
--  发布时间:2016/3/28 19:57:00
--  
比如第一行,80分钟,应该是9:00点这个单元格填充满,还要超


--  作者:狐作非为
--  发布时间:2016/3/28 20:00:00
--  
上面的代码也不对
--  作者:大红袍
--  发布时间:2016/3/28 20:00:00
--  

一个单元格一个小时啊。


--  作者:狐作非为
--  发布时间:2016/3/28 20:03:00
--  
是,不过看时间的话,时间好像不对