 Hoorray! I fixed it!!!!
Well when the procedure found a time over 4 hours for a day it used to skip the next records for that day
I am so proud that I can not resist to post the fixed method
Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
Dim i As Integer
Dim r As Integer
Dim sEmployeeID As String
Dim dDateFrom As DateTime = Convert.ToDateTime(DateFrom.Text)
Dim dDateTo As DateTime = Convert.ToDateTime(DateTo.Text)
Dim dDateCurrent As Date = dDateFrom
Dim sConsultantInfoDay As String = ""
Dim sProjectInfo1 As String = ""
Dim sProjectInfo2 As String = ""
Dim sProject As String = ""
Dim DateEnd As Object
Dim DaysNoticeExt As Object
Dim sColor1 As String = "#FFFFFF"
Dim sColor2 As String = "#FFFFFF"
Dim PreviousColor As String = "#FFFFFF"
Dim hl As New HyperLink
Dim lb As New Label
Dim lb2 As New Label
Dim iDayofWeek As Integer
Dim sDayName As String
Dim sExit As String
Dim bgColor As Drawing.Color
Dim sColorProject As String = "#FFFFFF"
Dim bTSClosed As Boolean
Dim Hours As Double
Dim HoursClientMonth As Double
Dim HoursMonth As Double
Dim HoursTBPMonth As Double
Dim HoursInternalMonth As Double
Dim DailyHoursTBP As Double
Dim TSID As Integer
Dim oEmpDateStart As Object
Dim oEmpDateEnd As Object
Dim bClientProject As Boolean = False
Dim bProjectFoundMonth As Boolean = False
Dim WorkPerc As Double
Dim sHoliday As String
Dim ProjectID As Integer
Dim TotalHoursMonth As Double
Dim dteRenewal, dteCurrentNotification, dteCurrentEndProj As DateTime
Dim intRenewalCpt As Integer = -1
Dim blnIsFirstTime As Boolean = True
Dim intRenewsEachNbMonths As Integer
Select Case e.Row.RowType
Case DataControlRowType.Header
Dim iMonth As Integer
e.Row.Cells(0).Visible = False
e.Row.Cells(1).Visible = False
e.Row.Cells(2).Visible = False
e.Row.Cells(3).Visible = False
e.Row.Cells(iColDaysStart - 1).Width = ConsultantColWidth
e.Row.Cells(iColDaysStart - 1).Text = sEmployeeHeader
e.Row.Cells(iColDaysStart - 1).Font.Size = iFontSizeEmployees
e.Row.Cells(iColDaysStart - 1).Font.Bold = True
e.Row.Cells(iColDaysStart - 1).ForeColor = Drawing.Color.White
e.Row.Cells(iColDaysStart - 1).BackColor = Drawing.Color.DarkBlue
i = iColDaysStart
Do While dDateCurrent <= dDateTo
iMonth = dDateCurrent.Month
sDayName = WeekdayName(DatePart("w", dDateCurrent), True, Microsoft.VisualBasic.FirstDayOfWeek.Sunday)
e.Row.Cells(i).Text = String.Concat(Left(sDayName, 2), String.Concat("<br /> ", Day(dDateCurrent).ToString))
e.Row.Cells(i).Font.Name = "Consolas, Courier New"
e.Row.Cells(i).Font.Size = iFontSizeHours
e.Row.Cells(i).BorderWidth = 1
e.Row.Cells(i).BorderColor = Drawing.Color.LightGray
e.Row.Cells(i).HorizontalAlign = HorizontalAlign.Center
iDayofWeek = Weekday(dDateCurrent)
sHoliday = sql.SQLValue("IsHoliday '" & dDateCurrent.Month.ToString & "/" & dDateCurrent.Day.ToString & "/" & dDateCurrent.Year.ToString & "'")
If sHoliday <> "N" Then
' Public Holiday
bgColor = Drawing.Color.Gray
Else
If iDayofWeek = 7 Or iDayofWeek = 1 Then
bgColor = Drawing.Color.Gray
Else
bgColor = Drawing.Color.DarkBlue
End If
End If
e.Row.Cells(i).ForeColor = Drawing.Color.White
e.Row.Cells(i).BackColor = bgColor
dDateCurrent = DateAdd(DateInterval.Day, 1, dDateCurrent)
If iMonth <> dDateCurrent.Month And Me.chkTotals.Checked Then
i = i + 1
e.Row.Cells(i).Text = "Total"
e.Row.Cells(i).Font.Size = iFontSizeHours
e.Row.Cells(i).ForeColor = Drawing.Color.White
e.Row.Cells(i).BackColor = Drawing.Color.DarkBlue
End If
i = i + 1
Loop
Case DataControlRowType.DataRow
Dim iMonth As Integer = 0
e.Row.Height = 25
e.Row.Cells(0).Visible = False ' EmployeeID
e.Row.Cells(1).Visible = False ' Customer
e.Row.Cells(2).Visible = False ' Department/Project
e.Row.Cells(3).Visible = False ' ProjectID
ProjectID = e.Row.Cells(3).Text
sEmployeeID = e.Row.Cells(0).Text
lb2.Text = " "
If sCustomerProject <> e.Row.Cells(1).Text & e.Row.Cells(2).Text And Me.optGroupBy.SelectedValue = 3 Then
' New Client/Project
e.Row.BackColor = Drawing.Color.White
e.Row.ForeColor = Drawing.Color.DarkBlue
e.Row.Cells(iColDaysStart - 1).Font.Size = iFontSizeEmployees ' Employees
e.Row.Cells(iColDaysStart - 1).Font.Bold = True
e.Row.Cells(iColDaysStart - 1).Text = e.Row.Cells(1).Text & " - " & e.Row.Cells(2).Text
e.Row.Style.Add("border-top-color", "Black")
e.Row.Style.Add("border-bottom-color", "White")
e.Row.Height = 25
sCustomerProject = e.Row.Cells(1).Text & e.Row.Cells(2).Text
e.Row.Cells(iColDaysStart - 1).Width = 210
e.Row.Cells(iColDaysStart - 1).Style.Add("cellspacing", "2")
e.Row.Cells(iColDaysStart - 1).Style.Add("background-color", "#FFFFCA")
e.Row.Cells(iColDaysStart - 1).Style.Add("color", "DarkBlue")
e.Row.Cells(iColDaysStart - 1).Style.Add("border-right-color", "#FFFFFD")
e.Row.Cells(iColDaysStart - 1).Style.Add("border-top-color", "#FFFFFD")
e.Row.Cells(iColDaysStart - 1).Style.Add("border-bottom-color", "#FFFFFD")
e.Row.Cells(iColDaysStart).Style.Add("border-left-color", "#FFFFFD")
i = iColDaysStart
Do While dDateCurrent <= dDateTo
iDayofWeek = Weekday(dDateCurrent)
e.Row.Cells(i).Style.Add("border-left-color", "White")
e.Row.Cells(i).Style.Add("border-right-color", "White")
dDateCurrent = DateAdd(DateInterval.Day, 1, dDateCurrent)
i = i + 1
Loop
Else
e.Row.Cells(iColDaysStart - 1).Font.Size = iFontSizeEmployees ' Employees
e.Row.Cells(iColDaysStart - 1).BackColor = Drawing.Color.Ivory
e.Row.Cells(iColDaysStart - 1).Width = ConsultantColWidth
Select Case Me.optGroupBy.SelectedValue
Case 1 ' Group By Department
lb.Text = " " & e.Row.Cells(2).Text & " - "
lb.ForeColor = Drawing.Color.Black
e.Row.Cells(iColDaysStart - 1).Controls.Add(lb)
hl.Text = e.Row.Cells(iColDaysStart - 1).Text ' Consultant
Case 2 ' Group By Consultant
hl.Text = Convert.ToString(cntConsultant) & ". " & e.Row.Cells(iColDaysStart - 1).Text ' Consultant
Case 3 ' Group By Client/Project
hl.Text = e.Row.Cells(iColDaysStart - 1).Text ' Consultant
lb.Text = " "
e.Row.Cells(iColDaysStart - 1).Controls.Add(lb)
End Select
hl.NavigateUrl = "EmployeeProjectsEdit.aspx?eid=" & e.Row.Cells(0).Text
e.Row.Cells(iColDaysStart - 1).Controls.Add(lb2)
e.Row.Cells(iColDaysStart - 1).Controls.Add(hl)
cntConsultant = cntConsultant + 1
i = iColDaysStart
sExit = ""
Dim dr() As DataRow
If Me.optGroupBy.SelectedValue = 3 Then
' Client/Project view
dr = dtProjectsTS.Select("EmployeeID = " & sEmployeeID) ' Get projects employee
Else
dr = dtProjectsTS.Select("EmployeeID = " & sEmployeeID) ' Get projects employee
End If
' Get Employee startdate / endate
If dr.GetUpperBound(0) > -1 Then
oEmpDateStart = dr(r)("EmpDateStart")
oEmpDateEnd = dr(r)("EmpDateEnd")
WorkPerc = dr(r)("WorkPerc")
Else
' No Projects assigned
oEmpDateStart = sql.SQLValue("SELECT DateStart FROM Employees WHERE EmployeeID = " & sEmployeeID)
oEmpDateEnd = sql.SQLValue("SELECT DateEnd FROM Employees WHERE EmployeeID = " & sEmployeeID)
End If
' Fake the dates to prevent Null error
If IsDBNull(oEmpDateStart) Then oEmpDateStart = Convert.ToDateTime("01/01/1950")
If IsDBNull(oEmpDateEnd) Then oEmpDateEnd = Convert.ToDateTime("01/01/2099")
HoursMonth = 0
HoursClientMonth = 0
HoursInternalMonth = 0
HoursTBPMonth = 0
bProjectFoundMonth = False
' Get days / Format days (colors, hours, 2 projects)
Do While dDateCurrent <= dDateTo
iMonth = dDateCurrent.Month
iDayofWeek = Weekday(dDateCurrent)
'Try
' Hours = Double.Parse(e.Row.Cells(i).Text.Replace("<span style=""color: Black;"">* </style>", "").Replace("<span style=""color: Black;"">*</style>", "").Replace(" ", ""))
'Catch
'End Try
If oEmpDateStart > dDateCurrent Or oEmpDateEnd < dDateCurrent Then
' Unemployed / no project
e.Row.Cells(i).ToolTip = "Unemployed"
e.Row.Cells(i).BackColor = Drawing.ColorTranslator.FromHtml("#FFFFFF")
e.Row.Cells(i).Style.Add("border-left-color", "White")
e.Row.Cells(i).Style.Add("border-right-color", "White")
Else
sColor1 = "#FFFFFF"
sProject = "No Assignment"
Hours = 0
DailyHoursTBP = 8
DaysNoticeExt = 0
bClientProject = False
If dr.GetUpperBound(0) > -1 Then ' Loop through employee projects
' Check for client project = main
For r = 0 To dr.GetUpperBound(0)
If dr(r)("Month") = dDateCurrent.Month And dr(r)("Year") = dDateCurrent.Year Then
bTSClosed = dr(r)("Closed")
If Me.optGroupBy.SelectedValue = 3 Then ' Client/Project view
If Server.HtmlDecode(e.Row.Cells(2).Text) = dr(r)("ProjectName") And dr(r)("ProjectTypeID") < 4 Then
bClientProject = True
End If
Else
If dr(r)("ProjectTypeID") < 4 Then ' Client project
bClientProject = True
End If
End If
End If
Next
Dim sInfo As String = ""
For r = 0 To dr.GetUpperBound(0)
' Employee Projects / Months
If dr(r)("Month") = dDateCurrent.Month And dr(r)("Year") = dDateCurrent.Year Then
bProjectFoundMonth = True
If Me.optGroupBy.SelectedValue < 3 Then
' Department / Employee view
If Not IsDBNull(dr(r)("DateStart")) And Not IsDBNull(dr(r)("DateEnd")) Then
If dDateCurrent >= dr(r)("DateStart") And dDateCurrent <= dr(r)("DateEnd") Then
If bClientProject Then
If dr(r)("ProjectTypeID") <= 3 Then 'Client Project
sProject = GetProjectInfoToolTip(dr, r)
sColor1 = dr(r)("ColorHtml")
If Not IsDBNull(dr(r)("FirstRenewalDate")) Then
If Not dDateCurrent < dr(r)("FirstRenewalDate") Then
If dteCurrentNotification < DateTime.Today() Then
dteRenewal = DateTime.Parse(dr(r)("FirstRenewalDate").ToString())
Do Until dteCurrentNotification >= DateTime.Today()
intRenewalCpt += 1
dteCurrentNotification = dteRenewal.AddMonths(intRenewalCpt * dr(r)("RenewEachNbMonths")).AddDays(-1 * dr(r)("DaysNoticeExt"))
dteCurrentEndProj = dteRenewal.AddMonths(intRenewalCpt * dr(r)("RenewEachNbMonths"))
Loop
End If
If dDateCurrent = dteCurrentEndProj And blnIsFirstTime Then
intRenewalCpt += 1
dteCurrentNotification = dteRenewal.AddMonths(intRenewalCpt * dr(r)("RenewEachNbMonths")).AddDays(-1 * dr(r)("DaysNoticeExt"))
dteCurrentEndProj = dteRenewal.AddMonths(intRenewalCpt * dr(r)("RenewEachNbMonths"))
intRenewsEachNbMonths = Integer.Parse(dr(r)("RenewEachNbMonths"))
blnIsFirstTime = False
End If
If dDateCurrent < dteCurrentEndProj And Not blnIsFirstTime Then
sColor1 = dr(r)("ColorHtmlExt")
ElseIf Not blnIsFirstTime Then
sColor1 = "#FFFFFF"
sProject = "No Assignment"
End If
End If
End If
DailyHoursTBP = dr(r)("DailyHoursTBP")
DateEnd = dr(r)("DateEnd")
DaysNoticeExt = dr(r)("DaysNoticeExt")
TotalHoursMonth = dr(r)("TotalHoursMonth")
End If
Else
If dr(r)("ProjectTypeID") >= 4 Then ' Internal Project
sProject = dr(r)("ProjectName")
sColor1 = dr(r)("ColorHtml")
DailyHoursTBP = dr(r)("DailyHoursTBP")
DateEnd = dr(r)("DateEnd")
DaysNoticeExt = dr(r)("DaysNoticeExt")
TotalHoursMonth = dr(r)("TotalHoursMonth")
End If
End If
End If
End If
If dr(r)(14 + dDateCurrent.Day) > 4 Then
If dr(r)("ProjectTypeID") >= 4 Then ' Internal Project
sProject = dr(r)("ProjectName")
Else
sProject = GetProjectInfoToolTip(dr, r)
End If
sColor1 = dr(r)("ColorHtml")
If Not IsDBNull(dr(r)("FirstRenewalDate")) Then
If Not dDateCurrent < dr(r)("FirstRenewalDate") Then
If dteCurrentNotification < DateTime.Today() Then
dteRenewal = DateTime.Parse(dr(r)("FirstRenewalDate").ToString())
Do Until dteCurrentNotification >= DateTime.Today()
intRenewalCpt += 1
dteCurrentNotification = dteRenewal.AddMonths(intRenewalCpt * dr(r)("RenewEachNbMonths")).AddDays(-1 * dr(r)("DaysNoticeExt"))
dteCurrentEndProj = dteRenewal.AddMonths(intRenewalCpt * dr(r)("RenewEachNbMonths"))
Loop
End If
If dDateCurrent = dteCurrentEndProj And blnIsFirstTime Then
intRenewalCpt += 1
dteCurrentNotification = dteRenewal.AddMonths(intRenewalCpt * dr(r)("RenewEachNbMonths")).AddDays(-1 * dr(r)("DaysNoticeExt"))
dteCurrentEndProj = dteRenewal.AddMonths(intRenewalCpt * dr(r)("RenewEachNbMonths"))
intRenewsEachNbMonths = Integer.Parse(dr(r)("RenewEachNbMonths"))
blnIsFirstTime = False
End If
If dDateCurrent < dteCurrentEndProj And Not blnIsFirstTime Then
sColor1 = dr(r)("ColorHtmlExt")
ElseIf Not blnIsFirstTime Then
sColor1 = "#FFFFFF"
sProject = "No Assignment"
End If
End If
End If
DailyHoursTBP = dr(r)("DailyHoursTBP")
DateEnd = dr(r)("DateEnd")
DaysNoticeExt = dr(r)("DaysNoticeExt")
TotalHoursMonth = dr(r)("TotalHoursMonth")
TSID = dr(r)("TSID")
If Me.optMonths.SelectedValue = 1 Then ' One month view
Hours = Hours + Math.Round(dr(r)(14 + dDateCurrent.Day), 2, MidpointRounding.AwayFromZero)
Else
Hours = Hours + Math.Round(dr(r)(14 + dDateCurrent.Day), 1, MidpointRounding.AwayFromZero)
End If
HoursMonth = HoursMonth + dr(r)(14 + dDateCurrent.Day)
'Exit For
Else
TSID = dr(r)("TSID")
If Me.optMonths.SelectedValue = 1 Then ' One month view
Hours = Hours + Math.Round(dr(r)(14 + dDateCurrent.Day), 2, MidpointRounding.AwayFromZero)
Else
Hours = Hours + Math.Round(dr(r)(14 + dDateCurrent.Day), 1, MidpointRounding.AwayFromZero)
End If
HoursMonth = HoursMonth + dr(r)(14 + dDateCurrent.Day)
End If
Else
' Client / Project view
If Not IsDBNull(dr(r)("DateStart")) And Not IsDBNull(dr(r)("DateEnd")) Then
If dDateCurrent >= dr(r)("DateStart") And dDateCurrent <= dr(r)("DateEnd") Then
If bClientProject Then
If dr(r)("ProjectTypeID") <= 3 Then 'Client Project
' START someone's name changes
If Server.HtmlDecode(e.Row.Cells(2).Text) = dr(r)("ProjectName") AndAlso Server.HtmlDecode(e.Row.Cells(1).Text) = dr(r)("CustomerName") Then
' STOP someone's name changes
sProject = GetProjectInfoToolTip(dr, r)
sColor1 = dr(r)("ColorHtml")
If Not IsDBNull(dr(r)("FirstRenewalDate")) Then
If Not dDateCurrent < dr(r)("FirstRenewalDate") Then
If dteCurrentNotification < DateTime.Today() Then
dteRenewal = DateTime.Parse(dr(r)("FirstRenewalDate").ToString())
Do Until dteCurrentNotification >= DateTime.Today()
intRenewalCpt += 1
dteCurrentNotification = dteRenewal.AddMonths(intRenewalCpt * dr(r)("RenewEachNbMonths")).AddDays(-1 * dr(r)("DaysNoticeExt"))
dteCurrentEndProj = dteRenewal.AddMonths(intRenewalCpt * dr(r)("RenewEachNbMonths"))
Loop
End If
If dDateCurrent = dteCurrentEndProj And blnIsFirstTime Then
intRenewalCpt += 1
dteCurrentNotification = dteRenewal.AddMonths(intRenewalCpt * dr(r)("RenewEachNbMonths")).AddDays(-1 * dr(r)("DaysNoticeExt"))
dteCurrentEndProj = dteRenewal.AddMonths(intRenewalCpt * dr(r)("RenewEachNbMonths"))
intRenewsEachNbMonths = Integer.Parse(dr(r)("RenewEachNbMonths"))
blnIsFirstTime = False
End If
If dDateCurrent < dteCurrentEndProj And Not blnIsFirstTime Then
sColor1 = dr(r)("ColorHtmlExt")
ElseIf Not blnIsFirstTime Then
sColor1 = "#FFFFFF"
sProject = "No Assignment"
End If
End If
End If
DailyHoursTBP = dr(r)("DailyHoursTBP")
DateEnd = dr(r)("DateEnd")
DaysNoticeExt = dr(r)("DaysNoticeExt")
TotalHoursMonth = dr(r)("TotalHoursMonth")
End If
End If
Else
End If
End If
End If
If dr(r)(14 + dDateCurrent.Day) > 4 Then
If Server.HtmlDecode(e.Row.Cells(2).Text) = dr(r)("ProjectName") Or dr(r)("ProjectTypeID") = 6 Then
sColor1 = dr(r)("ColorHtml")
If Not IsDBNull(dr(r)("FirstRenewalDate")) Then
If Not dDateCurrent < dr(r)("FirstRenewalDate") Then
If dteCurrentNotification < DateTime.Today() Then
dteRenewal = DateTime.Parse(dr(r)("FirstRenewalDate").ToString())
Do Until dteCurrentNotification >= DateTime.Today()
intRenewalCpt += 1
dteCurrentNotification = dteRenewal.AddMonths(intRenewalCpt * dr(r)("RenewEachNbMonths")).AddDays(-1 * dr(r)("DaysNoticeExt"))
dteCurrentEndProj = dteRenewal.AddMonths(intRenewalCpt * dr(r)("RenewEachNbMonths"))
Loop
End If
If dDateCurrent = dteCurrentEndProj And blnIsFirstTime Then
intRenewalCpt += 1
dteCurrentNotification = dteRenewal.AddMonths(intRenewalCpt * dr(r)("RenewEachNbMonths")).AddDays(-1 * dr(r)("DaysNoticeExt"))
dteCurrentEndProj = dteRenewal.AddMonths(intRenewalCpt * dr(r)("RenewEachNbMonths"))
intRenewsEachNbMonths = Integer.Parse(dr(r)("RenewEachNbMonths"))
blnIsFirstTime = False
End If
If dDateCurrent < dteCurrentEndProj And Not blnIsFirstTime Then
sColor1 = dr(r)("ColorHtmlExt")
ElseIf Not blnIsFirstTime Then
sColor1 = "#FFFFFF"
sProject = "No Assignment"
End If
End If
End If
DailyHoursTBP = dr(r)("DailyHoursTBP")
DateEnd = dr(r)("DateEnd")
DaysNoticeExt = dr(r)("DaysNoticeExt")
TotalHoursMonth = dr(r)("TotalHoursMonth")
TSID = dr(r)("TSID")
If Me.optMonths.SelectedValue = 1 Then ' One month view
Hours = Hours + Math.Round(dr(r)(14 + dDateCurrent.Day), 2, MidpointRounding.AwayFromZero)
Else
Hours = Hours + Math.Round(dr(r)(14 + dDateCurrent.Day), 1, MidpointRounding.AwayFromZero)
End If
HoursMonth = HoursMonth + dr(r)(14 + dDateCurrent.Day)
Exit For
End If
End If
TSID = dr(r)("TSID")
If Server.HtmlDecode(e.Row.Cells(2).Text) = dr(r)("ProjectName") Then
If Me.optMonths.SelectedValue = 1 Then ' One month view
Hours = Hours + Math.Round(dr(r)(14 + dDateCurrent.Day), 2, MidpointRounding.AwayFromZero)
Else
Hours = Hours + Math.Round(dr(r)(14 + dDateCurrent.Day), 1, MidpointRounding.AwayFromZero)
End If
If dr(r)("ProjectTypeID") >= 4 Then ' Internal Project
HoursInternalMonth = HoursInternalMonth + dr(r)(14 + dDateCurrent.Day)
End If
HoursClientMonth = HoursClientMonth + dr(r)(14 + dDateCurrent.Day)
HoursMonth = HoursMonth + dr(r)(14 + dDateCurrent.Day)
End If
End If
End If
Next ' Next record in Timesheets/Projects Employee
bgColor = Drawing.ColorTranslator.FromHtml(sColor1)
e.Row.Cells(i).BackColor = bgColor
If Me.GridView1.HeaderRow.Cells(i).BackColor <> Drawing.Color.Gray Then
If dDateCurrent = dteCurrentNotification And Not blnIsFirstTime Then
e.Row.Cells(i).ToolTip = "Passed this deadline, the contract will be automatically prolonged for " & _
intRenewsEachNbMonths & " month(s)"
Else
e.Row.Cells(i).ToolTip = sProject
End If
HoursTBPMonth = HoursTBPMonth + DailyHoursTBP
End If
e.Row.Cells(i).Font.Size = iFontSizeHours
e.Row.Cells(i).ForeColor = Drawing.Color.White
e.Row.Cells(i).HorizontalAlign = HorizontalAlign.Center
If Me.chkHours.Checked Then
If dDateCurrent = dteCurrentNotification And Not blnIsFirstTime Then
e.Row.Cells(i).Text = IIf(Hours > 0, "<span style=""color: Black;"">* </style>" + Hours.ToString, "<span style=""color: Black;"">*</style>")
Else
e.Row.Cells(i).Text = IIf(Hours > 0, Hours.ToString, "")
End If
End If
Else
' No projects assigned
e.Row.Cells(i).ToolTip = sProject
e.Row.Cells(i).BackColor = Drawing.ColorTranslator.FromHtml("#FFFFFF")
End If
If iDayofWeek = 7 Or iDayofWeek = 1 Then
e.Row.Cells(i).ToolTip = "Weekend"
e.Row.Cells(i).BackColor = Drawing.Color.Gray
e.Row.Cells(i).Width = 20
Else
If Me.GridView1.HeaderRow.Cells(i).BackColor = Drawing.Color.Gray Then
'Public Holiday
bgColor = Drawing.Color.Gray
e.Row.Cells(i).ToolTip = "Public Holiday"
e.Row.Cells(i).BackColor = bgColor
End If
e.Row.Cells(i).Width = DayWidth
End If
End If
dDateCurrent = DateAdd(DateInterval.Day, 1, dDateCurrent)
If iMonth <> dDateCurrent.Month And Me.chkTotals.Checked Then
' TOTALS: Total column month
i = i + 1
If bProjectFoundMonth = True Then
e.Row.Cells(i).Attributes("onmouseover") = "this.style.cursor='hand';this.style.textDecoration='underline';this.style.color='blue'"
e.Row.Cells(i).Attributes("OnClick") = "javascript:location.href='Timesheet.aspx?t=e&tsid=" & TSID.ToString & "'"
Dim sTSClosedLabel As String = ""
If HoursMonth < ((WorkPerc / 100) * HoursTBPMonth) Then
' Timesheet not completed, i.e. not all hours performed
If bTSClosed Then
e.Row.Cells(i).ForeColor = Drawing.ColorTranslator.FromHtml("#006464")
sTSClosedLabel = "Timesheet closed" & vbCrLf
e.Row.Cells(i).Attributes("onmouseout") = "this.style.textDecoration='none';this.style.color='#006464'"
e.Row.Cells(i).ToolTip = sTSClosedLabel & sb("Remaining hours: ", Math.Round(((WorkPerc / 100) * HoursTBPMonth) - HoursMonth, 2, MidpointRounding.AwayFromZero).ToString, vbCrLf, "Click to open the Timesheet")
Else
If Me.optGroupBy.SelectedValue = 3 Then ' Client/Project view
If TotalHoursMonth < ((WorkPerc / 100) * HoursTBPMonth) Then
e.Row.Cells(i).ForeColor = Drawing.ColorTranslator.FromHtml("#E60000")
e.Row.Cells(i).Attributes("onmouseout") = "this.style.textDecoration='none';this.style.color='#E60000'"
Else
e.Row.Cells(i).ForeColor = Drawing.Color.Black
e.Row.Cells(i).Attributes("onmouseout") = "this.style.textDecoration='none';this.style.color='black'"
End If
e.Row.Cells(i).ToolTip = "Click to open the Timesheet"
Else
' Display in red
e.Row.Cells(i).ForeColor = Drawing.ColorTranslator.FromHtml("#E60000")
e.Row.Cells(i).Attributes("onmouseout") = "this.style.textDecoration='none';this.style.color='#E60000'"
e.Row.Cells(i).ToolTip = sb("Remaining hours: ", Math.Round(((WorkPerc / 100) * HoursTBPMonth) - HoursMonth, 2, MidpointRounding.AwayFromZero).ToString, vbCrLf, "Click to open the Timesheet")
End If
End If
Else
' Timesheet completed, i.e. hours performed
If bTSClosed Then
' Timesheet closed
e.Row.Cells(i).ForeColor = Drawing.ColorTranslator.FromHtml("#006464")
sTSClosedLabel = "Timesheet closed" & vbCrLf
e.Row.Cells(i).Attributes("onmouseout") = "this.style.textDecoration='none';this.style.color='#006464'"
Else
e.Row.Cells(i).ForeColor = Drawing.Color.Black
e.Row.Cells(i).Attributes("onmouseout") = "this.style.textDecoration='none';this.style.color='black'"
End If
If HoursMonth > ((WorkPerc / 100) * HoursTBPMonth) Then
e.Row.Cells(i).ToolTip = sb("Additional hours: ", Math.Round(Math.Abs(((WorkPerc / 100) * HoursTBPMonth) - HoursMonth), 2, MidpointRounding.AwayFromZero).ToString, vbCrLf, sb(sTSClosedLabel, "Click to open the Timesheet"))
Else
e.Row.Cells(i).ToolTip = sTSClosedLabel & "Click to open the Timesheet"
End If
End If
e.Row.Cells(i).HorizontalAlign = HorizontalAlign.Right
e.Row.Cells(i).Font.Size = iFontSizeHours
e.Row.Cells(i).Font.Bold = True
HoursMonth = HoursMonth - HoursInternalMonth ' Test
If Me.optMonths.SelectedValue = 1 Then ' One month view
HoursMonth = Math.Round(HoursMonth, 2, MidpointRounding.AwayFromZero)
If InStr(HoursMonth.ToString, ".") = 0 Then
e.Row.Cells(i).Text = IIf(HoursMonth >= 0, HoursMonth.ToString & ".00", "")
Else
e.Row.Cells(i).Text = IIf(HoursMonth >= 0, HoursMonth.ToString("#.00"), "")
End If
Else
HoursMonth = Math.Round(HoursMonth, 1, MidpointRounding.AwayFromZero)
If InStr(HoursMonth.ToString, ".") = 0 Then
e.Row.Cells(i).Text = IIf(HoursMonth >= 0, HoursMonth.ToString & ".0", "")
Else
e.Row.Cells(i).Text = IIf(HoursMonth >= 0, HoursMonth.ToString, "")
End If
End If
End If
e.Row.Cells(i).BackColor = Drawing.ColorTranslator.FromHtml("#8ECBDD")
HoursMonth = 0
HoursTBPMonth = 0
End If
i = i + 1
Loop
End If
End Select
End Sub

|