/// <summary> /// GetUnitData /// </summary> /// <param name="startDate">startDate</param> /// <param name="endDate">endDate</param> /// <param name="unitId">unitId</param> /// <param name="work_">work_</param> /// <param name="newRow">newRow</param> /// <param name="isTowedUnitId">isTowedUnitId</param> private void GetUnitData(DateTime startDate, DateTime endDate, int unitId, string work_, ProjectCostingSheetAddTDS.UnitsInformationRow newRow, bool isTowedUnitId) { ProjectCostingSheetAddUnitListGateway projectCostingSheetAddUnitListGateway = new ProjectCostingSheetAddUnitListGateway(); projectCostingSheetAddUnitListGateway.LoadByStartDateEndDateUnitIdWork_(startDate, endDate, unitId, work_); if (projectCostingSheetAddUnitListGateway.Table.Rows.Count <= 0) { projectCostingSheetAddUnitListGateway.LoadByStartDateEndDateUnitId(startDate, endDate, unitId); if (projectCostingSheetAddUnitListGateway.Table.Rows.Count <= 0) { projectCostingSheetAddUnitListGateway.LoadByStartDateUnitIdWork_(startDate, unitId, work_); if (projectCostingSheetAddUnitListGateway.Table.Rows.Count <= 0) { projectCostingSheetAddUnitListGateway.LoadByStartDateUnitId(startDate, unitId); if (projectCostingSheetAddUnitListGateway.Table.Rows.Count <= 0) { projectCostingSheetAddUnitListGateway.LoadByUnitId(unitId); } } } } DataRow unitRow = projectCostingSheetAddUnitListGateway.GetRow(unitId); if (isTowedUnitId) { try { newRow.CostCad = (decimal)unitRow["CostCad"] / 2; newRow.CostUsd = (decimal)unitRow["CostUsd"] / 2; } catch { newRow.CostCad = 0; newRow.CostUsd = 0; } } else { newRow.CostCad = (decimal)unitRow["CostCad"]; newRow.CostUsd = (decimal)unitRow["CostUsd"]; } }
/// <summary> /// GetUnitDailyRate /// </summary> /// <param name="startDate">startDate</param> /// <param name="endDate">endDate</param> /// <param name="unitId">unitId</param> /// <param name="work_">work_</param> /// <param name="projectId">projectId</param> /// <param name="countryId">countryId</param> /// <returns></returns> private decimal? GetUnitDailyRate(DateTime startDate, DateTime endDate, int unitId, string work_, int projectId, Int64 countryId) { decimal? dailyRate = null; ProjectCostingSheetAddUnitListGateway projectCostingSheetAddUnitListGateway = new ProjectCostingSheetAddUnitListGateway(); projectCostingSheetAddUnitListGateway.LoadByStartDateEndDateUnitIdWork_(startDate, endDate, unitId, work_); if (projectCostingSheetAddUnitListGateway.Table.Rows.Count <= 0) { projectCostingSheetAddUnitListGateway.LoadByStartDateEndDateUnitId(startDate, endDate, unitId); if (projectCostingSheetAddUnitListGateway.Table.Rows.Count <= 0) { projectCostingSheetAddUnitListGateway.LoadByStartDateUnitIdWork_(startDate, unitId, work_); if (projectCostingSheetAddUnitListGateway.Table.Rows.Count <= 0) { projectCostingSheetAddUnitListGateway.LoadByStartDateUnitId(startDate, unitId); if (projectCostingSheetAddUnitListGateway.Table.Rows.Count <= 0) { projectCostingSheetAddUnitListGateway.LoadByUnitId(unitId); } } } } if (countryId == 1) //Canada { decimal? costCad = projectCostingSheetAddUnitListGateway.GetCostCad(unitId); if (costCad.HasValue) { dailyRate = costCad; } } else { decimal? costUsd =projectCostingSheetAddUnitListGateway.GetCostUsd(unitId); if (costUsd.HasValue) { dailyRate = costUsd; } } return dailyRate; }