// //////////////////////////////////////////////////////////////////////// // PUBLIC METHODS // /// <summary> /// Load /// </summary> /// <param name="works">works</param> /// <param name="projectId">projectId</param> /// <param name="startDate">startDate</param> /// <param name="endDate">endDate</param> /// <param name="companyId">companyId</param> public void Load(ArrayList works, int projectId, DateTime startDate, DateTime endDate, int companyId) { int refId = 0; // Foreach of Works (FLL, RA, JL, PR, MH Rehab, MOB, Other) foreach (string work_ in works) { // Load Functions by Work ProjectCostingSheetAddFunctionListGateway projectCostingSheetAddFunctionListGateway = new ProjectCostingSheetAddFunctionListGateway(); projectCostingSheetAddFunctionListGateway.LoadByWork_(work_); // Foreach of Functions foreach (ProjectCostingSheetAddTDS.FunctionListRow functionListRow in (ProjectCostingSheetAddTDS.FunctionListDataTable)projectCostingSheetAddFunctionListGateway.Table) { ProjectCostingSheetAddUnitListGateway projectCostingSheetAddUnitListGateway = new ProjectCostingSheetAddUnitListGateway(Data); projectCostingSheetAddUnitListGateway.LoadByProjectIdStartDateEndDateWorkFunction(projectId, startDate, endDate, work_, functionListRow.Function_, companyId); foreach (ProjectCostingSheetAddTDS.UnitListRow unitListRow in (ProjectCostingSheetAddTDS.UnitListDataTable)projectCostingSheetAddUnitListGateway.Table) { DateTime newStartDate = new DateTime(); newStartDate = startDate; DateTime newEndDate = new DateTime(); newEndDate = endDate; ProjectCostingSheetAddUnitPayPeriodGateway ProjectCostingSheetAddUnitPayPeriodGateway = new ProjectCostingSheetAddUnitPayPeriodGateway(Data); ProjectCostingSheetAddUnitPayPeriodGateway.LoadByStartDateEndDateUnitId(startDate, endDate, unitListRow.UnitID); if (ProjectCostingSheetAddUnitPayPeriodGateway.Table.Rows.Count > 0) { foreach (ProjectCostingSheetAddTDS.UnitPayPeriodRow unitPayPeriodRow in (ProjectCostingSheetAddTDS.UnitPayPeriodDataTable)ProjectCostingSheetAddUnitPayPeriodGateway.Table) { newEndDate = unitPayPeriodRow.Date_.AddDays(-1); ProjectCostingSheetAddOriginalUnitGateway projectCostingSheetAddOriginalUnitGateway = new ProjectCostingSheetAddOriginalUnitGateway(Data); projectCostingSheetAddOriginalUnitGateway.Load(projectId, newStartDate, newEndDate, work_, functionListRow.Function_, unitListRow.UnitID); if (projectCostingSheetAddOriginalUnitGateway.Table.Rows.Count > 0) { ArrayList days = new ArrayList(); ArrayList daysTowed = new ArrayList(); double quantity = 0; bool isTowedUnitId = false; PrintProjectCostingGateway verifGateway = new PrintProjectCostingGateway(new DataSet()); foreach (ProjectCostingSheetAddTDS.OriginalUnitRow originalUnitRow in (ProjectCostingSheetAddTDS.OriginalUnitDataTable)projectCostingSheetAddOriginalUnitGateway.Table) { int towedUnitId = 0; if (!originalUnitRow.IsTowedUnitIDNull()) { towedUnitId = Convert.ToInt32(originalUnitRow.TowedUnitID); } if (originalUnitRow.UnitID != towedUnitId) { if (!days.Contains(originalUnitRow.Date_)) { int amountProjects = verifGateway.UnitSameDayUseSeveralProjects(originalUnitRow.Date_, originalUnitRow.UnitID); if (amountProjects > 1) { double tempQuantity = 1 / Convert.ToDouble(amountProjects); int amountFunctions = verifGateway.UnitSameDayUseSeveralWorkFunctions(projectId, originalUnitRow.Date_, originalUnitRow.UnitID); if (amountFunctions > 0) { tempQuantity = tempQuantity / Convert.ToDouble(amountFunctions); } quantity = quantity + tempQuantity; } else { double tempQuantity = 1; int amountFunctions = verifGateway.UnitSameDayUseSeveralWorkFunctions(projectId, originalUnitRow.Date_, originalUnitRow.UnitID); if (amountFunctions > 0) { tempQuantity = 1 / Convert.ToDouble(amountFunctions); } quantity = quantity + tempQuantity; } days.Add(originalUnitRow.Date_); } } else { isTowedUnitId = true; if (!daysTowed.Contains(originalUnitRow.Date_)) { int amountProjects = verifGateway.TowedUnitSameDayUseSeveralProjects(originalUnitRow.Date_, originalUnitRow.UnitID); if (amountProjects > 1) { double tempQuantity = 1 / Convert.ToDouble(amountProjects); int amountFunctions = verifGateway.TowedUnitSameDayUseSeveralWorkFunctions(projectId, originalUnitRow.Date_, originalUnitRow.UnitID); if (amountFunctions > 0) { tempQuantity = tempQuantity / Convert.ToDouble(amountFunctions); } quantity = quantity + tempQuantity; } else { double tempQuantity = 1; int amountFunctions = verifGateway.TowedUnitSameDayUseSeveralWorkFunctions(projectId, originalUnitRow.Date_, originalUnitRow.UnitID); if (amountFunctions > 0) { tempQuantity = 1 / Convert.ToDouble(amountFunctions); } quantity = quantity + tempQuantity; } daysTowed.Add(originalUnitRow.Date_); } } } ProjectCostingSheetAddTDS.UnitsInformationRow newRow = ((ProjectCostingSheetAddTDS.UnitsInformationDataTable)Table).NewUnitsInformationRow(); GetUnitData(newStartDate, newEndDate, unitListRow.UnitID, work_, newRow, isTowedUnitId); newRow.CostingSheetID = 0; newRow.Work_ = work_; newRow.UnitID = unitListRow.UnitID; newRow.RefID = refId++; newRow.Quantity = quantity; newRow.TotalCostCad = (Convert.ToDecimal(quantity) * newRow.CostCad); newRow.TotalCostUsd = (Convert.ToDecimal(quantity) * newRow.CostUsd); newRow.Deleted = false; newRow.InDatabase = false; newRow.COMPANY_ID = companyId; newRow.UnitCode = unitListRow.UnitCode; newRow.UnitDescription = unitListRow.Description; newRow.UnitOfMeasurement = unitListRow.UnitOfMeasurement; newRow.StartDate = newStartDate; newRow.EndDate = newEndDate; newRow.FromDatabase = true; newRow.Function_ = functionListRow.Function_; newRow.WorkFunction = work_ + " . " + functionListRow.Function_; ((ProjectCostingSheetAddTDS.UnitsInformationDataTable)Table).AddUnitsInformationRow(newRow); } newStartDate = newEndDate.AddDays(1); } if (newEndDate <= endDate) { ProjectCostingSheetAddOriginalUnitGateway projectCostingSheetAddOriginalUnitGateway = new ProjectCostingSheetAddOriginalUnitGateway(Data); projectCostingSheetAddOriginalUnitGateway.Load(projectId, newStartDate, endDate, work_, functionListRow.Function_, unitListRow.UnitID); if (projectCostingSheetAddOriginalUnitGateway.Table.Rows.Count > 0) { ArrayList days = new ArrayList(); ArrayList daysTowed = new ArrayList(); double quantity = 0; bool isTowedUnitId = false; PrintProjectCostingGateway verifGateway = new PrintProjectCostingGateway(new DataSet()); foreach (ProjectCostingSheetAddTDS.OriginalUnitRow originalUnitRow in (ProjectCostingSheetAddTDS.OriginalUnitDataTable)projectCostingSheetAddOriginalUnitGateway.Table) { int towedUnitId = 0; if (!originalUnitRow.IsTowedUnitIDNull()) { towedUnitId = Convert.ToInt32(originalUnitRow.TowedUnitID); } if (originalUnitRow.UnitID != towedUnitId) { if (!days.Contains(originalUnitRow.Date_)) { int amountProjects = verifGateway.UnitSameDayUseSeveralProjects(originalUnitRow.Date_, originalUnitRow.UnitID); if (amountProjects > 1) { double tempQuantity = 1 / Convert.ToDouble(amountProjects); int amountFunctions = verifGateway.UnitSameDayUseSeveralWorkFunctions(projectId, originalUnitRow.Date_, originalUnitRow.UnitID); if (amountFunctions > 0) { tempQuantity = tempQuantity / Convert.ToDouble(amountFunctions); } quantity = quantity + tempQuantity; } else { double tempQuantity = 1; int amountFunctions = verifGateway.UnitSameDayUseSeveralWorkFunctions(projectId, originalUnitRow.Date_, originalUnitRow.UnitID); if (amountFunctions > 0) { tempQuantity = 1 / Convert.ToDouble(amountFunctions); } quantity = quantity + tempQuantity; } days.Add(originalUnitRow.Date_); } } else { isTowedUnitId = true; if (!daysTowed.Contains(originalUnitRow.Date_)) { int amountProjects = verifGateway.TowedUnitSameDayUseSeveralProjects(originalUnitRow.Date_, originalUnitRow.UnitID); if (amountProjects > 1) { double tempQuantity = 1 / Convert.ToDouble(amountProjects); int amountFunctions = verifGateway.TowedUnitSameDayUseSeveralWorkFunctions(projectId, originalUnitRow.Date_, originalUnitRow.UnitID); if (amountFunctions > 0) { tempQuantity = tempQuantity / Convert.ToDouble(amountFunctions); } quantity = quantity + tempQuantity; } else { double tempQuantity = 1; int amountFunctions = verifGateway.TowedUnitSameDayUseSeveralWorkFunctions(projectId, originalUnitRow.Date_, originalUnitRow.UnitID); if (amountFunctions > 0) { tempQuantity = 1 / Convert.ToDouble(amountFunctions); } quantity = quantity + tempQuantity; } daysTowed.Add(originalUnitRow.Date_); } } } ProjectCostingSheetAddTDS.UnitsInformationRow newRow = ((ProjectCostingSheetAddTDS.UnitsInformationDataTable)Table).NewUnitsInformationRow(); GetUnitData(newStartDate, endDate, unitListRow.UnitID, work_, newRow, isTowedUnitId); newRow.CostingSheetID = 0; newRow.Work_ = work_; newRow.UnitID = unitListRow.UnitID; newRow.RefID = refId++; newRow.Quantity = quantity; newRow.TotalCostCad = (Convert.ToDecimal(quantity) * newRow.CostCad); newRow.TotalCostUsd = (Convert.ToDecimal(quantity) * newRow.CostUsd); newRow.Deleted = false; newRow.InDatabase = false; newRow.COMPANY_ID = companyId; newRow.UnitCode = unitListRow.UnitCode; newRow.UnitDescription = unitListRow.Description; newRow.UnitOfMeasurement = unitListRow.UnitOfMeasurement; newRow.StartDate = newStartDate; newRow.EndDate = endDate; newRow.FromDatabase = true; newRow.Function_ = functionListRow.Function_; newRow.WorkFunction = work_ + " . " + functionListRow.Function_; ((ProjectCostingSheetAddTDS.UnitsInformationDataTable)Table).AddUnitsInformationRow(newRow); } } } else { ProjectCostingSheetAddOriginalUnitGateway projectCostingSheetAddOriginalUnitGateway = new ProjectCostingSheetAddOriginalUnitGateway(Data); projectCostingSheetAddOriginalUnitGateway.Load(projectId, startDate, endDate, work_, functionListRow.Function_, unitListRow.UnitID); if (projectCostingSheetAddOriginalUnitGateway.Table.Rows.Count > 0) { ArrayList days = new ArrayList(); ArrayList daysTowed = new ArrayList(); double quantity = 0; bool isTowedUnitId = false; PrintProjectCostingGateway verifGateway = new PrintProjectCostingGateway(new DataSet()); foreach (ProjectCostingSheetAddTDS.OriginalUnitRow originalUnitRow in (ProjectCostingSheetAddTDS.OriginalUnitDataTable)projectCostingSheetAddOriginalUnitGateway.Table) { int towedUnitId = 0; if (!originalUnitRow.IsTowedUnitIDNull()) towedUnitId = Convert.ToInt32(originalUnitRow.TowedUnitID); if (originalUnitRow.UnitID != towedUnitId) { if (!days.Contains(originalUnitRow.Date_)) { int amountProjects = verifGateway.UnitSameDayUseSeveralProjects(originalUnitRow.Date_, originalUnitRow.UnitID); if (amountProjects > 1) { double tempQuantity = 1 / Convert.ToDouble(amountProjects); int amountFunctions = verifGateway.UnitSameDayUseSeveralWorkFunctions(projectId, originalUnitRow.Date_, originalUnitRow.UnitID); if (amountFunctions > 0) { tempQuantity = tempQuantity / Convert.ToDouble(amountFunctions); } quantity = quantity + tempQuantity; } else { double tempQuantity = 1; int amountFunctions = verifGateway.UnitSameDayUseSeveralWorkFunctions(projectId, originalUnitRow.Date_, originalUnitRow.UnitID); if (amountFunctions > 0) { tempQuantity = 1 / Convert.ToDouble(amountFunctions); } quantity = quantity + tempQuantity; } days.Add(originalUnitRow.Date_); } } else { isTowedUnitId = true; if (!daysTowed.Contains(originalUnitRow.Date_)) { int amountProjects = verifGateway.TowedUnitSameDayUseSeveralProjects(originalUnitRow.Date_, originalUnitRow.UnitID); if (amountProjects > 1) { double tempQuantity = 1 / Convert.ToDouble(amountProjects); int amountFunctions = verifGateway.TowedUnitSameDayUseSeveralWorkFunctions(projectId, originalUnitRow.Date_, originalUnitRow.UnitID); if (amountFunctions > 0) { tempQuantity = tempQuantity / Convert.ToDouble(amountFunctions); } quantity = quantity + tempQuantity; } else { double tempQuantity = 1; int amountFunctions = verifGateway.TowedUnitSameDayUseSeveralWorkFunctions(projectId, originalUnitRow.Date_, originalUnitRow.UnitID); if (amountFunctions > 0) { tempQuantity = 1 / Convert.ToDouble(amountFunctions); } quantity = quantity + tempQuantity; } daysTowed.Add(originalUnitRow.Date_); } } } ProjectCostingSheetAddTDS.UnitsInformationRow newRow = ((ProjectCostingSheetAddTDS.UnitsInformationDataTable)Table).NewUnitsInformationRow(); GetUnitData(startDate, endDate, unitListRow.UnitID, work_, newRow, isTowedUnitId); newRow.CostingSheetID = 0; newRow.Work_ = work_; newRow.UnitID = unitListRow.UnitID; newRow.RefID = refId++; newRow.Quantity = quantity; newRow.TotalCostCad = (Convert.ToDecimal(quantity) * newRow.CostCad); newRow.TotalCostUsd = (Convert.ToDecimal(quantity) * newRow.CostUsd); newRow.Deleted = false; newRow.InDatabase = false; newRow.COMPANY_ID = companyId; newRow.UnitCode = unitListRow.UnitCode; newRow.UnitDescription = unitListRow.Description; newRow.UnitOfMeasurement = unitListRow.UnitOfMeasurement; newRow.StartDate = startDate; newRow.EndDate = endDate; newRow.FromDatabase = true; newRow.Function_ = functionListRow.Function_; newRow.WorkFunction = work_ + " . " + functionListRow.Function_; ((ProjectCostingSheetAddTDS.UnitsInformationDataTable)Table).AddUnitsInformationRow(newRow); } } } } } }
/// <summary> /// ProcessDataForProject /// </summary> /// <para>Process de data from the original table for the Project Costing report</para> /// <param name="companyId">companyId</param> public void ProcessDataForProject(int companyId) { // Instanciate a new PrintProjectCostingGateway for the control of times that one unit is used in different projects PrintProjectCostingGateway verifGateway = new PrintProjectCostingGateway(new DataSet()); // Fill rows from original data PrintProjectCostingGateway originalGateway = new PrintProjectCostingGateway(Data); foreach (PrintProjectCostingTDS.OriginalRow originalRow in (PrintProjectCostingTDS.OriginalDataTable)originalGateway.Table) { PrintProjectCostingTDS.PrintProjectCostingRow newRow = ((PrintProjectCostingTDS.PrintProjectCostingDataTable)Table).NewPrintProjectCostingRow(); newRow.ClientID = originalRow.ClientID; newRow.ClientName = originalRow.ClientName; newRow.ProjectName = originalRow.ProjectName; newRow.CountryID = originalRow.CountryID; newRow.CountryName = originalRow.CountryName; newRow.EmployeeID = originalRow.EmployeeID; newRow.EmployeeName = originalRow.EmployeeName; newRow.Date_ = originalRow.Date_; if (!originalRow.IsWork_Null()) newRow.Work_ = originalRow.Work_; else newRow.SetWork_Null(); if (!originalRow.IsFunction_Null()) newRow.Function_ = originalRow.Function_; else newRow.SetFunction_Null(); if (!originalRow.IsFairWageNull()) newRow.FairWage = originalRow.FairWage; else newRow.FairWage = false; if (!originalRow.IsUnitNull()) newRow.Unit = originalRow.Unit; else newRow.SetUnitNull(); if (!originalRow.IsTowedNull()) newRow.Towed = originalRow.Towed; else newRow.SetTowedNull(); // ...Stablishing the country of the project if (originalRow.CountryID == 1) { newRow.TimeCA = originalRow.ProjectTime; newRow.TimeUS = 0; } else { newRow.TimeCA = 0; newRow.TimeUS = originalRow.ProjectTime; } // ...Stablishing the type of labour day: Sick Day, Holiday, Vacation or Normal work day if ((originalRow.WorkingDetails == "Sick Day") || (originalRow.WorkingDetails == "Holiday") || (originalRow.WorkingDetails == "Vacation / Other") || (originalRow.WorkingDetails == "Day Off - No Pay")) { newRow.WorkingDetails = originalRow.WorkingDetails; } else { newRow.WorkingDetails = ""; } // ...Stablishing the total and the meals, depending on the MealsCountry defined: Canada or United States if (!originalRow.IsMealsCountryNull()) { if (originalRow.MealsCountry == 1) { newRow.MealsCA = true; newRow.MealsUS = false; newRow.TotalCA = originalRow.MealsAllowance; newRow.TotalUS = 0; } else { newRow.MealsCA = false; newRow.MealsUS = true; newRow.TotalCA = 0; newRow.TotalUS = originalRow.MealsAllowance; } } else { newRow.MealsCA = false; newRow.MealsUS = false; newRow.TotalCA = 0; newRow.TotalUS = 0; } // ...Verifing if there is a comment or not if (!originalRow.IsCommentsNull()) { newRow.Comments = originalRow.Comments; } // ...Definition of project time state if (!originalRow.IsProjectTimeStateNull()) { newRow.ProjectTimeState = originalRow.ProjectTimeState; } else { newRow.ProjectTimeState = "For Approval"; } // ...Definition of variables that will help in the calculation of the cost column at the report decimal valCostUnit = 0.00M; decimal valCostTowedUnit = 0.00M; int amountProjectsTowedVerified = 0; int amountFunctionTowedVerified = 0; int amountProjectsUnitVerified = 0; int amountFunctionUnitVerified = 0; decimal? dailyRateTowed = 0M; decimal? dailyRateUnit = 0M; if (!originalRow.IsTowedUnitIDNull()) { amountProjectsTowedVerified = verifGateway.TowedUnitSameDayUseSeveralProjects(originalRow.Date_, originalRow.TowedUnitID); amountFunctionTowedVerified = verifGateway.TowedUnitSameDayUseSeveralWorkFunctions(originalRow.ProjectID, originalRow.Date_, originalRow.TowedUnitID); dailyRateTowed = GetUnitDailyRate(originalRow.Date_, originalRow.Date_, originalRow.TowedUnitID, originalRow.Work_, originalRow.ProjectID, originalRow.CountryID); } if (!originalRow.IsUnitIDNull()) { amountProjectsUnitVerified = verifGateway.UnitSameDayUseSeveralProjects(originalRow.Date_, originalRow.UnitID); amountFunctionUnitVerified = verifGateway.UnitSameDayUseSeveralWorkFunctions(originalRow.ProjectID, originalRow.Date_, originalRow.UnitID); dailyRateUnit = GetUnitDailyRate(originalRow.Date_, originalRow.Date_, originalRow.UnitID, originalRow.Work_, originalRow.ProjectID, originalRow.CountryID); } // ...If only a unit was used if (!originalRow.IsUnitIDNull() && originalRow.IsTowedUnitIDNull()) { valCostTowedUnit = 0.00M; if (UnitAlreadyProcessedInProjectWork_Function_(originalRow.ProjectName, originalRow.Date_, originalRow.UnitID, originalRow.Unit, companyId, originalRow.Work_, originalRow.Function_)) { valCostUnit = 0.00M; } else { decimal? dailyRate = null; if (GetUnitDailyRate(originalRow.Date_, originalRow.Date_, originalRow.UnitID, originalRow.Work_, originalRow.ProjectID, originalRow.CountryID).HasValue) dailyRate = GetUnitDailyRate(originalRow.Date_, originalRow.Date_, originalRow.UnitID, originalRow.Work_, originalRow.ProjectID, originalRow.CountryID).Value; if (amountProjectsUnitVerified > 1) { if (dailyRate.HasValue) { valCostUnit = Decimal.Round(dailyRate.Value / amountProjectsUnitVerified, 2); if (amountFunctionUnitVerified > 0) { valCostUnit = Decimal.Round(valCostUnit / amountFunctionUnitVerified, 2); } } else { valCostUnit = 0.00M; } } else { if (dailyRate.HasValue) { if (amountFunctionUnitVerified > 0) { valCostUnit = Decimal.Round(dailyRate.Value / amountFunctionUnitVerified, 2); } else { valCostUnit = dailyRate.Value; } } else { valCostTowedUnit = 0.00M; } } } } // ...If only a towed unit was used if (!originalRow.IsTowedUnitIDNull() && originalRow.IsUnitIDNull()) { valCostUnit = 0.00M; if (TowedUnitAlreadyProcessedInProjectWork_Function_(originalRow.ProjectName, originalRow.Date_, originalRow.TowedUnitID, originalRow.Towed, companyId, originalRow.Work_, originalRow.Function_)) { valCostTowedUnit = 0.00M; } else { if (amountProjectsTowedVerified > 1) { if (dailyRateTowed.HasValue) { valCostTowedUnit = Decimal.Round(dailyRateTowed.Value / amountProjectsTowedVerified, 2); if (amountFunctionTowedVerified > 0) { valCostTowedUnit = Decimal.Round(valCostTowedUnit / amountFunctionTowedVerified, 2); } } else { valCostTowedUnit = 0.00M; } } else { if (dailyRateTowed.HasValue) { if (amountFunctionTowedVerified > 0) { valCostTowedUnit = Decimal.Round(dailyRateTowed.Value / amountFunctionTowedVerified, 2); } else { valCostTowedUnit = dailyRateTowed.Value; } } else { valCostTowedUnit = 0.00M; } } } } // ...If towed unit and a unit were used if (!originalRow.IsTowedUnitIDNull() && !originalRow.IsUnitIDNull()) { if (UnitAlreadyProcessedInProjectWork_Function_(originalRow.ProjectName, originalRow.Date_, originalRow.UnitID, originalRow.Unit, companyId, originalRow.Work_, originalRow.Function_)) { valCostUnit = 0.00M; } else { if (amountProjectsUnitVerified > 1) { if (dailyRateUnit.HasValue) { valCostUnit = Decimal.Round(dailyRateUnit.Value / amountProjectsUnitVerified, 2); if (amountFunctionUnitVerified > 0) { valCostUnit = Decimal.Round(valCostUnit / amountFunctionUnitVerified, 2); } } else { valCostUnit = 0.00M; } } else { if (dailyRateUnit.HasValue) { if (amountFunctionUnitVerified > 0) { valCostUnit = Decimal.Round(dailyRateUnit.Value / amountFunctionUnitVerified, 2); } else { valCostUnit = dailyRateUnit.Value; } } else { valCostTowedUnit = 0.00M; } } } if (TowedUnitAlreadyProcessedInProjectWork_Function_(originalRow.ProjectName, originalRow.Date_, originalRow.TowedUnitID, originalRow.Towed, companyId, originalRow.Work_, originalRow.Function_)) { valCostTowedUnit = 0.00M; } else { if (amountProjectsTowedVerified > 1) { if (dailyRateTowed.HasValue) { valCostTowedUnit = Decimal.Round(dailyRateTowed.Value / amountProjectsTowedVerified, 2); if (amountFunctionTowedVerified > 0) { valCostTowedUnit = Decimal.Round(valCostTowedUnit / amountFunctionTowedVerified, 2); } } else { valCostTowedUnit = 0.00M; } } else { if (dailyRateTowed.HasValue) { if (amountFunctionTowedVerified > 0) { valCostTowedUnit = Decimal.Round(dailyRateTowed.Value / amountFunctionTowedVerified, 2); } else { valCostTowedUnit = dailyRateTowed.Value; } } else { valCostTowedUnit = 0.00M; } } } } // ...Summary of Unit and Towed cost if (!originalRow.IsUnitIDNull()) { if (!originalRow.IsTowedUnitIDNull()) { newRow.EquipmentCost = valCostUnit + valCostTowedUnit; } else { newRow.EquipmentCost = valCostUnit; } } else { if (!originalRow.IsTowedUnitIDNull()) { newRow.EquipmentCost = valCostTowedUnit; } else { newRow.EquipmentCost = 0.00M; } } ((PrintProjectCostingTDS.PrintProjectCostingDataTable)Table).AddPrintProjectCostingRow(newRow); } }