Foxtable(狐表)用户栏目专家坐堂 → [求助]平均分配时间


  共有2560人关注过本帖树形打印复制链接

主题:[求助]平均分配时间

帅哥哟,离线,有人找我吗?
有点色
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2016/12/11 10:42:00 [显示全部帖子]

dataColChanged事件

 

If e.DataCol.Name = "要求完成时间" AndAlso e.DataRow.Isnull("要求完成时间") = False Then
    If e.DataRow.IsNull("办单号") OrElse e.DataRow.IsNull("办房部位") Then
        msgbox("请先输入数据")
    Else
        If e.DataRow("工艺序号") <> 1 Then
            Dim fdrFirst As DataRow = e.DataTable.Find("办单号 = '" & e.DataRow("办单号") & "' and 办房部位 = '" & e.DataRow("办房部位") & "'", "工艺序号")
            If fdrFirst IsNot Nothing Then
                If fdrFirst.isnull("要求完成时间") Then
                    e.DataRow("要求完成时间") = Nothing
                    msgbox("请先输入第一道工序时间")
                Else
                    Dim fdr As DataRow = e.DataTable.Find("办单号 = '" & e.DataRow("办单号") & "' and 办房部位 = '" & e.DataRow("办房部位") & "' and 要求完成时间 is not null and 工艺序号 < " & e.DataRow("工艺序号"), "工艺序号 desc")
                    If fdr IsNot Nothing Then
                        Dim num1 As Integer = fdr("工艺序号")
                        Dim num2 As Integer = e.DataRow("工艺序号")
                        If num2-num1 > 1 Then
                            Dim stime As Date = fdr("要求完成时间")
                            Dim etime As Date = e.DataRow("要求完成时间")
                            Dim seconds As Double = 0
                            If Format(etime, "yyyyMMdd") = Format(stime, "yyyyMMdd") Then
                                seconds = (etime-stime).TotalSeconds
                            Else
                                seconds = (new Date(stime.Year, stime.Month, stime.Day, 22, 0, 0) - stime).TotalSeconds
                                seconds += 14 * 3600 * (etime.Day - stime.Day - 1)
                                seconds += (etime-new Date(etime.Year, etime.Month, etime.Day, 8, 0, 0)).TotalSeconds
                            End If
                           
                            Dim second As Double = seconds / (num2-num1)
                            Dim temp As Date = stime
                            systemready = False
                            For i As Integer = num1+1 To num2-1
                                fdr = e.DataTable.Find("办单号 = '" & e.DataRow("办单号") & "' and 办房部位 = '" & e.DataRow("办房部位") & "' and 工艺序号 = " & i)
                                Dim t As Date = temp.AddSeconds(second)
                                If Format(temp, "yyyyMMdd") <> Format(t, "yyyyMMdd") OrElse t.Hour >= 22 Then
                                    temp = t.AddHours(10 * math.Ceiling((t-temp).Totaldays))
                                Else
                                    temp = t
                                End If
                                fdr("要求完成时间") = temp
                            Next
                            systemready = True
                        End If
                    End If
                End If
            End If
        End If
    End If
End If

 


 回到顶部
帅哥哟,离线,有人找我吗?
有点色
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2016/12/12 9:58:00 [显示全部帖子]

'如果不是同一天,就执行下面代码

seconds = (new Date(stime.Year, stime.Month, stime.Day, 22, 0, 0) - stime).TotalSeconds '得到第一天的时间 22时 减去 开始时间

seconds += 14 * 3600 * (etime.Day - stime.Day - 1)   '中间的时间等于14(22-8)乘以天数
seconds += (etime-new Date(etime.Year, etime.Month, etime.Day, 8, 0, 0)).TotalSeconds '得到最后一天的时间
 
'最后得到间隔的时间,平均给中间的每一行

 回到顶部