/// <summary>
        /// Insert TeamProjectTimeDetailTemp
        /// </summary>
        /// <param name="teamProjectTimeId">teamProjectTimeId</param>
        /// <param name="employeeId">employeeId</param>
        /// <param name="companiesId">companiesId</param>
        /// <param name="projectId">projectId</param>
        /// <param name="date_">date_</param>
        /// <param name="startTime">startTime</param>
        /// <param name="endTime">endTime</param>
        /// <param name="offset">offset</param>
        /// <param name="workingDetails">workingDetails</param>
        /// <param name="location">location</param>
        /// <param name="mealsCountry">mealsCountry</param>
        /// <param name="mealsAllowance">mealsAllowance</param>
        /// <param name="projectTimeState">projectTimeState</param>
        /// <param name="comments">comments</param>
        /// <param name="fairWage">fairWage</param>
        public void Insert(int teamProjectTimeId, int employeeId, int companiesId, int projectId, DateTime date_, string startTime, string endTime, double? offset, string workingDetails, string location, Int64? mealsCountry, bool mealsAllowance, string projectTimeState, string comments, bool fairWage, string jobClassType)
        {
            TeamProjectTime2TDS.LFS_TEAM_PROJECT_TIME_DETAIL_TEMPRow teamProjectTimeDetailRow = ((TeamProjectTime2TDS.LFS_TEAM_PROJECT_TIME_DETAIL_TEMPDataTable)Table).NewLFS_TEAM_PROJECT_TIME_DETAIL_TEMPRow();

            teamProjectTimeDetailRow.TeamProjectTimeID = teamProjectTimeId;
            teamProjectTimeDetailRow.DetailID = GetNewDetailId();
            teamProjectTimeDetailRow.EmployeeID = employeeId;
            teamProjectTimeDetailRow.CompaniesID = companiesId;
            teamProjectTimeDetailRow.ProjectID = projectId;
            teamProjectTimeDetailRow.Date_ = date_;
            if (startTime != "") teamProjectTimeDetailRow.StartTime = startTime; else teamProjectTimeDetailRow.SetStartTimeNull();
            if (endTime != "") teamProjectTimeDetailRow.EndTime = endTime; else teamProjectTimeDetailRow.SetEndTimeNull();
            if (offset.HasValue) teamProjectTimeDetailRow.Offset = (double)offset; else teamProjectTimeDetailRow.SetOffsetNull();
            teamProjectTimeDetailRow.ProjectTime = 0;
            if (workingDetails != "") teamProjectTimeDetailRow.WorkingDetails = workingDetails; else teamProjectTimeDetailRow.SetWorkingDetailsNull();
            if (location != "") teamProjectTimeDetailRow.Location = location; else teamProjectTimeDetailRow.SetLocationNull();
            if (mealsCountry.HasValue) teamProjectTimeDetailRow.MealsCountry = (Int64)mealsCountry; else teamProjectTimeDetailRow.SetMealsCountryNull();
            teamProjectTimeDetailRow.MealsAllowance = mealsAllowance;
            teamProjectTimeDetailRow.SetUnitIDNull();
            teamProjectTimeDetailRow.SetTowedUnitIDNull();
            teamProjectTimeDetailRow.ProjectTimeState = projectTimeState;
            if (comments != "") teamProjectTimeDetailRow.Comments = comments; else teamProjectTimeDetailRow.SetCommentsNull();
            teamProjectTimeDetailRow.Deleted = false;
            teamProjectTimeDetailRow.FairWage = fairWage;
            if (jobClassType != "") teamProjectTimeDetailRow.JobClassType = jobClassType; else teamProjectTimeDetailRow.SetJobClassTypeNull();

            ((TeamProjectTime2TDS.LFS_TEAM_PROJECT_TIME_DETAIL_TEMPDataTable)Table).AddLFS_TEAM_PROJECT_TIME_DETAIL_TEMPRow(teamProjectTimeDetailRow);

            // Insert real detail
            string mealsAllowanceType2 = ""; if (mealsAllowance) mealsAllowanceType2 = "Full Day";
            decimal mealsAllowance2 = MealsAllowance.GetMealsAllowance(mealsCountry, mealsAllowance, mealsAllowanceType2);

            TeamProjectTime2Detail teamProjectTime2Detail = new TeamProjectTime2Detail(Data);
            teamProjectTime2Detail.Insert(teamProjectTimeId, employeeId, companiesId, projectId, date_, startTime, endTime, offset, workingDetails, location, mealsCountry, mealsAllowanceType2, mealsAllowance2, projectTimeState, comments, fairWage, jobClassType);
        }
        /// <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);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Insert
        /// </summary>
        /// <param name="teamProjectTimeId">teamProjectTimeId</param>
        /// <param name="newTemplateName">newTemplateName</param>
        /// <param name="teamProjectTime2TDSToSave">teamProjectTime2TDSToSave</param>
        public void Insert(int teamProjectTimeId, string newTemplateName, TeamProjectTime2TDS teamProjectTime2TDSToSave)
        {
            // Insert master row
            TeamProjectTime2TDS.LFS_TEAM_PROJECT_TIMERow masterRow = GetRow(teamProjectTimeId);

            int companiesId = masterRow.CompaniesID;
            int projectId = masterRow.ProjectID;
            DateTime date_ = masterRow.Date_;
            DateTime? startTime = null; if (!masterRow.IsNull("StartTime")) startTime = masterRow.StartTime;
            DateTime? endTime = null; if (!masterRow.IsNull("EndTime")) endTime = masterRow.EndTime;
            double? offset = null; if (!masterRow.IsNull("Offset")) offset = masterRow.Offset;
            string workingDetails = ""; if (!masterRow.IsNull("WorkingDetails")) workingDetails = masterRow.WorkingDetails;
            string location = ""; if (!masterRow.IsNull("Location")) location = masterRow.Location;
            Int64? mealsCountry = null; if (!masterRow.IsNull("MealsCountry")) mealsCountry = masterRow.MealsCountry;
            String mealsAllowanceType = ""; if (!masterRow.IsNull("MealsAllowanceType")) mealsAllowanceType = masterRow.MealsAllowanceType;
            decimal mealsAllowance = masterRow.MealsAllowance;
            int? unitId = null; if (!masterRow.IsNull("UnitID")) unitId = masterRow.UnitID;
            int? towedUnitId = null; if (!masterRow.IsNull("TowedUnitID")) towedUnitId = masterRow.TowedUnitID;
            string comments = ""; if (!masterRow.IsNull("Comments")) comments = masterRow.Comments;
            string type = "Template";
            string state = "Done";
            int loginId = masterRow.LoginID;
            bool deleted = false;
            string work_ = masterRow.Work_;
            string function_ = masterRow.Function_;
            bool fairWage = masterRow.FairWage;

            TeamProjectTime2 teamProjectTime2ToSave = new TeamProjectTime2(teamProjectTime2TDSToSave);
            teamProjectTime2ToSave.Insert(0, newTemplateName, companiesId, projectId, date_, startTime, endTime, offset, workingDetails, location, mealsCountry, mealsAllowanceType, mealsAllowance, unitId, towedUnitId, comments, type, state, loginId, deleted, work_, function_, fairWage);

            // Insert detail rows
            TeamProjectTime2Detail teamProjectTime2Detail = new TeamProjectTime2Detail(Data);
            teamProjectTime2Detail.Insert(teamProjectTimeId, teamProjectTime2TDSToSave);
        }
        /// <summary>
        /// Insert
        /// </summary>
        /// <param name="teamProjectTimeId">teamProjectTimeId</param>
        /// <param name="teamProjectTime2TDSToSave">teamProjectTime2TDSToSave</param>
        public void Insert(int teamProjectTimeId, TeamProjectTime2TDS teamProjectTime2TDSToSave)
        {
            foreach (TeamProjectTime2TDS.LFS_TEAM_PROJECT_TIME_DETAILRow detailRow in ((TeamProjectTime2TDS)Data).LFS_TEAM_PROJECT_TIME_DETAIL)
            {
                if (!detailRow.Deleted)
                {
                    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;
                    string ProjectTimeState = detailRow.ProjectTimeState;
                    string comments = ""; if (!detailRow.IsNull("Comments")) comments = detailRow.Comments;
                    bool fairWage = detailRow.FairWage;
                    string jobClassType = ""; if (!detailRow.IsNull("JobClassType")) jobClassType = detailRow.JobClassType;

                    TeamProjectTime2Detail teamProjectTime2DetailToSave = new TeamProjectTime2Detail(teamProjectTime2TDSToSave);
                    teamProjectTime2DetailToSave.Insert(0, employeeId, companiesId, projectId, date_, startTimeDetail, endTimeDetail, offset, workingDetails, location, mealsCountry, mealsAllowanceType, mealsAllowance, ProjectTimeState, comments, fairWage, jobClassType);
                }
            }
        }