Sub grpLaborDetail_Format If (phaseItemSummaryShown) Then ReportUtilities.SetSectionVisibility(rpt, "grpLaborDetail", False) Return End If If showDetail AndAlso (Not isCombinePrices) Then Dim width As Integer = 150 Dim c As System.Windows.Forms.Control = New System.Windows.Forms.Control() Dim g As Graphics = c.CreateGraphics() Dim laborTypes As List(Of LaborType) = ReportUtilities.GetProjectLaborTypes() Dim laborTypeOrders As List(Of Integer) = laborTypes.OrderBy(Function(l) l.Order).Select(Function(l) l.Order).Distinct().ToList() Dim nonOptionalLaborTypes As List(Of LaborType) = ReportUtilities.GetLaborTypeSummaries(True, False) Dim optionalLaborTypes As List(Of LaborType) = ReportUtilities.GetLaborTypeSummaries(False, True) Dim itmsLaborTypeSummary As New StringBuilder() Dim optsLaborTypeSumary As New StringBuilder() Dim laborTypeNames As New StringBuilder() Dim totalSummary As New StringBuilder() For Each laborTypeOrder As Integer In laborTypeOrders Dim laborTypeOrder2 As Integer = laborTypeOrder Dim laborType As LaborType = laborTypes.FirstOrDefault(Function(l) l.Order = laborTypeOrder2) Dim optItmLaborPrice As Double = optionalLaborTypes.Where(Function(l) l.Order = laborTypeOrder2).Sum(Function(l) l.AggregatedLaborPrice) Dim optItmLaborHrs As Decimal = optionalLaborTypes.Where(Function(l) l.Order = laborTypeOrder2).Sum(Function(l) l.AggregatedLaborHours) Dim itmLaborHrs As Decimal = nonOptionalLaborTypes.Where(Function(l) l.Order = laborTypeOrder2).Sum(Function(l) l.AggregatedLaborHours) Dim itmLaborPrice As Double = nonOptionalLaborTypes.Where(Function(l) l.Order = laborTypeOrder2).Sum(Function(l) l.AggregatedLaborPrice) Dim setLabor As String = "Labor" If (Not String.IsNullOrEmpty(laborDesc)) Then setLabor = laborDesc End If If Not isShowAdjustment Then Dim itmLaborAdjPrice As Double = nonOptionalLaborTypes.Where(Function(l) l.Order = laborTypeOrder2).Sum(Function(l) l.AggregatedLaborAdjustmentPrice) Dim optItmLaborAdjPrice As Double = optionalLaborTypes.Where(Function(l) l.Order = laborTypeOrder2).Sum(Function(l) l.AggregatedLaborAdjustmentPrice) itmLaborPrice = itmLaborPrice + itmLaborAdjPrice optItmLaborPrice = optItmLaborPrice + optItmLaborAdjPrice End If Dim lineFeed As String = "" Dim laborTypeString As String = String.Empty Dim laborTypeName As String = String.Empty If laborType IsNot Nothing Then laborTypeName = laborType.Name End If If showLaborHrsSummary Then If itmLaborHrs <> 0 AndAlso optItmLaborHrs <> 0 Then setLabor = String.Format("{0} ({1} hrs)", setLabor, ReportUtilities.ToDecimalPlaces2or4((itmLaborHrs + optItmLaborHrs))) ElseIf itmLaborHrs <> 0 Then setLabor = String.Format("{0} ({1} hrs)", setLabor, ReportUtilities.ToDecimalPlaces2or4(itmLaborHrs)) ElseIf optItmLaborHrs <> 0 Then setLabor = String.Format("{0} ({1} hrs)", setLabor, ReportUtilities.ToDecimalPlaces2or4(optItmLaborHrs)) End If laborTypeString = String.Format("{0} {1}:", laborTypeName, setLabor) Else laborTypeString = String.Format("{0} {1}:", laborTypeName, setLabor) End If Dim size As SizeF = g.MeasureString(laborTypeString, txtPhaseLaborText.Font) Dim noofLineFeed As Integer = CInt(((size.Width) \ width)) If noofLineFeed > 0 Then For i As Integer = 1 To noofLineFeed Step 1 lineFeed = String.Format("{0}{1}", lineFeed, Environment.NewLine) Next i End If If showLaborHrsSummary Then If (itmLaborPrice <> 0 OrElse itmLaborHrs <> 0) OrElse (optItmLaborPrice <> 0 OrElse optItmLaborHrs <> 0) Then laborTypeNames.AppendFormat("{0} {1}:{2}", laborTypeName, setLabor, Environment.NewLine) itmsLaborTypeSummary.AppendFormat("{2}{0:C}{1}", itmLaborPrice, Environment.NewLine, lineFeed) optsLaborTypeSumary.AppendFormat("{2}{0:C}{1}", optItmLaborPrice, Environment.NewLine, lineFeed) totalSummary.AppendFormat("{2}{0:C}{1}", optItmLaborPrice + itmLaborPrice, Environment.NewLine, lineFeed) End If Else If itmLaborPrice <> 0 OrElse optItmLaborPrice <> 0 Then laborTypeNames.AppendFormat("{0} {1}:{2}", laborTypeName, setLabor, Environment.NewLine) itmsLaborTypeSummary.AppendFormat("{2}{0:C}{1}", itmLaborPrice, Environment.NewLine, lineFeed) optsLaborTypeSumary.AppendFormat("{2}{0:C}{1}", optItmLaborPrice, Environment.NewLine, lineFeed) totalSummary.AppendFormat("{2}{0:C}{1}", optItmLaborPrice + itmLaborPrice, Environment.NewLine, lineFeed) End If End If Next ReportUtilities.SetTextBoxValue(rpt, "grpLaborDetail", "txtPhaseLaborText", laborTypeNames) ReportUtilities.SetTextBoxValue(rpt, "grpLaborDetail", "txtPhaseLaborValue", itmsLaborTypeSummary) ReportUtilities.SetTextBoxValue(rpt, "grpLaborDetail", "txtOptionalPhaseLaborValue", optsLaborTypeSumary) ReportUtilities.SetTextBoxValue(rpt, "grpLaborDetail", "txtGrandPhaseLaborValue", totalSummary) End If phaseItemSummaryShown = True ReportUtilities.SetSectionVisibility(rpt, "grpLaborDetail", showDetail AndAlso (Not isCombinePrices)) End Sub