// ////////////////////////////////////////////////////////////////////////
        // PUBLIC METHODS
        //
        /// <summary>
        /// Load all TeamProjectTimeDetails by TeamProjectTimeId
        /// </summary>
        /// <param name="teamProjectTimeId">teamProjectTimeId</param>
        public void LoadAllByTeamProjectTimeId(int teamProjectTimeId)
        {
            Table.Rows.Clear();

            TeamProjectTime2DetailGateway teamProjectTime2DetailGateway = new TeamProjectTime2DetailGateway(Data);
            teamProjectTime2DetailGateway.LoadAllByTeamProjectTimeId(teamProjectTimeId);

            foreach (TeamProjectTime2TDS.LFS_TEAM_PROJECT_TIME_DETAILRow row in ((TeamProjectTime2TDS.LFS_TEAM_PROJECT_TIME_DETAILDataTable)teamProjectTime2DetailGateway.Table))
            {
                TeamProjectTime2TDS.LFS_TEAM_PROJECT_TIME_DETAIL_TEMPRow newRow = ((TeamProjectTime2TDS.LFS_TEAM_PROJECT_TIME_DETAIL_TEMPDataTable)Table).NewLFS_TEAM_PROJECT_TIME_DETAIL_TEMPRow();

                newRow.TeamProjectTimeID = row.TeamProjectTimeID;
                newRow.DetailID = row.DetailID;
                newRow.EmployeeID = row.EmployeeID;
                newRow.CompaniesID = row.CompaniesID;
                newRow.ProjectID = row.ProjectID;
                newRow.Date_ = row.Date_;
                if (row.IsStartTimeNull()) newRow.SetStartTimeNull(); else newRow.StartTime = row.StartTime;
                if (row.IsEndTimeNull()) newRow.SetEndTimeNull(); else newRow.EndTime = row.EndTime;
                if (row.IsOffsetNull()) newRow.SetOffsetNull(); else newRow.Offset = row.Offset;
                newRow.ProjectTime = row.ProjectTime;
                if (row.IsWorkingDetailsNull()) newRow.SetWorkingDetailsNull(); else newRow.WorkingDetails = row.WorkingDetails;
                if (row.IsLocationNull()) newRow.SetLocationNull(); else newRow.Location = row.Location;
                if (row.IsMealsCountryNull()) newRow.SetMealsCountryNull(); else newRow.MealsCountry = row.MealsCountry;
                newRow.MealsAllowance = false; if (row.MealsAllowance > 0) newRow.MealsAllowance = true;
                if (row.IsUnitIDNull()) newRow.SetUnitIDNull(); else newRow.UnitID = row.UnitID;
                if (row.IsTowedUnitIDNull()) newRow.SetTowedUnitIDNull(); else newRow.TowedUnitID = row.TowedUnitID;
                newRow.ProjectTimeState = row.ProjectTimeState;
                if (row.IsCommentsNull()) newRow.SetCommentsNull(); else newRow.Comments = row.Comments;
                newRow.Deleted = row.Deleted;

                newRow.SetWork_Null(); if (!row.IsNull("Work_")) newRow.Work_ = row.Work_;
                newRow.SetFunction_Null(); if (!row.IsNull("Function_")) newRow.Function_ = row.Function_;
                newRow.SetWorkFunctionConcatNull();

                if ((!row.IsNull("Work_")) && (!row.IsNull("Function_")))
                {
                    newRow.WorkFunctionConcat = row.Work_ + " . " + row.Function_;
                }

                newRow.FairWage = row.FairWage;
                if(row.IsJobClassTypeNull()) newRow.SetJobClassTypeNull(); else newRow.JobClassType = row.JobClassType;

                ((TeamProjectTime2TDS.LFS_TEAM_PROJECT_TIME_DETAIL_TEMPDataTable)Table).AddLFS_TEAM_PROJECT_TIME_DETAIL_TEMPRow(newRow);
            }
        }
        /// <summary>
        /// Update
        /// </summary>
        /// <param name="teamProjectTimeId">teamProjectTimeId</param>
        /// <param name="teamProjectTimeIdForReplace">teamProjectTimeIdForReplace</param>
        /// <param name="teamProjectTime2TDSToSave">teamProjectTime2TDSToSave</param>
        public void Update(int teamProjectTimeId, int teamProjectTimeIdForReplace, TeamProjectTime2TDS teamProjectTime2TDSToSave)
        {
            // Load existing rows
            TeamProjectTime2DetailGateway teamProjectTime2DetailGateway = new TeamProjectTime2DetailGateway(teamProjectTime2TDSToSave);
            teamProjectTime2DetailGateway.LoadAllByTeamProjectTimeId(teamProjectTimeIdForReplace);

            // Delete existing rows
            foreach (TeamProjectTime2TDS.LFS_TEAM_PROJECT_TIME_DETAILRow detailExistingRow in ((TeamProjectTime2TDS)teamProjectTime2DetailGateway.Data).LFS_TEAM_PROJECT_TIME_DETAIL)
            {
                detailExistingRow.Deleted = true;
            }

            // Insert or update detail rows
            foreach (TeamProjectTime2TDS.LFS_TEAM_PROJECT_TIME_DETAILRow detailRow in ((TeamProjectTime2TDS)Data).LFS_TEAM_PROJECT_TIME_DETAIL)
            {
                int detailId = detailRow.DetailID;
                int employeeId = detailRow.EmployeeID;
                int companiesId = detailRow.CompaniesID;
                int projectId = detailRow.ProjectID;
                DateTime date_ = detailRow.Date_;
                string startTimeDetail = ""; if (!detailRow.IsNull("StartTime")) startTimeDetail = detailRow.StartTime;
                string endTimeDetail = null; if (!detailRow.IsNull("EndTime")) endTimeDetail = detailRow.EndTime;
                double? offset = null; if (!detailRow.IsNull("Offset")) offset = detailRow.Offset;
                double projectTime = detailRow.ProjectTime;
                string workingDetails = ""; if (!detailRow.IsNull("WorkingDetails")) workingDetails = detailRow.WorkingDetails;
                string location = ""; if (!detailRow.IsNull("Location")) location = detailRow.Location;
                Int64? mealsCountry = null; if (!detailRow.IsNull("MealsCountry")) mealsCountry = detailRow.MealsCountry;
                string mealsAllowanceType = ""; if (!detailRow.IsNull("MealsAllowanceType")) mealsAllowanceType = detailRow.MealsAllowanceType;
                decimal mealsAllowance = detailRow.MealsAllowance;
                int? unitId = null; if (!detailRow.IsNull("UnitID")) unitId = detailRow.UnitID;
                int? towedUnitId = null; if (!detailRow.IsNull("TowedUnitID")) towedUnitId = detailRow.TowedUnitID;
                string ProjectTimeState = detailRow.ProjectTimeState;
                string comments = ""; if (!detailRow.IsNull("Comments")) comments = detailRow.Comments;
                bool deleted = detailRow.Deleted;
                bool fairWage = detailRow.FairWage;
                string jobClassType = ""; if (!detailRow.IsNull("JobClassType")) jobClassType = detailRow.JobClassType;

                // ... Get row if exists
                TeamProjectTime2TDS.LFS_TEAM_PROJECT_TIME_DETAILRow oldDetailRow = null;

                try
                {
                    oldDetailRow = (TeamProjectTime2TDS.LFS_TEAM_PROJECT_TIME_DETAILRow)teamProjectTime2DetailGateway.GetRow(teamProjectTimeIdForReplace, detailId);
                }
                catch
                {
                    oldDetailRow = null;
                }

                // ... Row check
                TeamProjectTime2Detail teamProjectTime2DetailToSave = new TeamProjectTime2Detail(teamProjectTime2TDSToSave);
                if (oldDetailRow != null)
                {
                    teamProjectTime2DetailToSave.Update(teamProjectTimeIdForReplace, detailId, employeeId, companiesId, projectId, date_, startTimeDetail, endTimeDetail, offset, projectTime, workingDetails, location, mealsCountry, mealsAllowanceType, mealsAllowance, unitId, towedUnitId, ProjectTimeState, comments, deleted, fairWage, jobClassType);
                }
                else
                {
                    teamProjectTime2DetailToSave.Insert(teamProjectTimeIdForReplace, employeeId, companiesId, projectId, date_, startTimeDetail, endTimeDetail, offset, workingDetails, location, mealsCountry, mealsAllowanceType, mealsAllowance, ProjectTimeState, comments, fairWage, jobClassType);
                }
            }
        }