/// <summary>
        /// LoadByEmployeeTypeStartDateEndDateCountryIdEmployeeIdProjectTimeStateClientId
        /// </summary>
        /// <param name="employeeType">employeeType</param>
        /// <param name="startDate">startDate</param>
        /// <param name="endDate">endDate</param>
        /// <param name="countryId">countryId</param>
        /// <param name="employeeId">employeeId</param>
        /// <param name="projectTimeState">projectTimeState</param>
        /// <param name="clientId">clientId</param>
        public void LoadByEmployeeTypeStartDateEndDateCountryIdEmployeeIdProjectTimeStateClientId(string employeeType, DateTime startDate, DateTime endDate, Int64 countryId, int employeeId, string projectTimeState, int clientId, bool isNewReport, string personnelAgency)
        {
            PrintHoursForPayrollPeriodOriginalGateway originalGateway = new PrintHoursForPayrollPeriodOriginalGateway(Data);
            originalGateway.LoadByEmployeeTypeStartDateEndDateCountryIdEmployeeIdProjectTimeStateClientId(employeeType, startDate, endDate, countryId, employeeId, projectTimeState, clientId, personnelAgency);

            if (isNewReport)
            {
                this.FillData2();
            }
            else
            {
                this.FillData();
            }
        }
        /// <summary>
        /// FillData2
        /// </summary>
        private void FillData2()
        {
            PrintHoursForPayrollPeriodOriginalGateway originalGateway = new PrintHoursForPayrollPeriodOriginalGateway(Data);

            foreach (PrintHoursForPayrollPeriodTDS.OriginalRow originalRow in (PrintHoursForPayrollPeriodTDS.OriginalDataTable)originalGateway.Table)
            {
                PrintHoursForPayrollPeriodTDS.PrintHoursForPayrollPeriodRow newRow = ((PrintHoursForPayrollPeriodTDS.PrintHoursForPayrollPeriodDataTable)Table).NewPrintHoursForPayrollPeriodRow();

                newRow.EmployeeID = originalRow.EmployeeID;
                newRow.EmployeeName = originalRow.EmployeeName;
                newRow.CountryID = originalRow.CountryID;
                newRow.CountryName = originalRow.CountryName;
                newRow.Date_ = originalRow.Date_;
                newRow.ProjectName = originalRow.ProjectName;
                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.IsStartTimeNull()) newRow.StartTime = originalRow.StartTime; else newRow.SetStartTimeNull();
                if (!originalRow.IsEndTimeNull()) newRow.EndTime = originalRow.EndTime; else newRow.SetEndTimeNull();
                if (!originalRow.IsOffsetNull()) newRow.Offset = originalRow.Offset; else newRow.SetOffsetNull();
                newRow.FairWage = false;
                originalRow.FairWage = false;

                if (!originalRow.IsJobClassTypeNull()) newRow.JobClassType = originalRow.JobClassType; else newRow.JobClassType = " ";

                if (originalRow.CountryID == 1)
                {
                    newRow.TimeCA = originalRow.ProjectTime;
                    newRow.TimeUS = originalRow.ProjectTime;
                }
                else
                {
                    newRow.TimeCA = originalRow.ProjectTime;
                    newRow.TimeUS = originalRow.ProjectTime;
                }

                newRow.TimeFairWage = 0;
                newRow.TimeFairWageOt = 0;
                newRow.TimeMob = 0;
                newRow.TimeMobOt = 0;
                newRow.TimeStandard = 0;
                newRow.TimeStandardOt = 0;

                if (!originalRow.IsStartTimeNull() && !originalRow.IsEndTimeNull())
                {
                    if (originalRow.IsWork_Null()) originalRow.Work_ = "";
                    if (originalRow.IsFunction_Null()) originalRow.Function_ = "";
                    ProjectGateway projectGateway = new ProjectGateway(null);
                    ProjectTimeGateway projectTimeGateway = new ProjectTimeGateway();
                    projectTimeGateway.LoadByProjectTimeId(originalRow.ProjectTimeID);
                    if (projectGateway.IsFairWageProjectWorkFunction(projectTimeGateway.GetProjectId(originalRow.ProjectTimeID), originalRow.Work_, originalRow.Function_))
                    {
                        newRow.FairWage = true;
                        originalRow.FairWage = true;
                    }

                    int overtime = 40; //Default for USA

                    // Canada
                    if (originalRow.CountryID == 1)
                    {
                        switch (originalRow.Category)
                        {
                            case "Special Forces":
                                overtime = 50;
                                break;

                            case "Field":
                                overtime = 50;
                                break;

                            case "Field 44":
                                overtime = 44;
                                break;

                            case "Office/Admin":
                                overtime = 44;
                                break;

                            case "Mechanic/Manufactoring":
                                overtime = 44;
                                break;
                        }

                        if ((originalRow.Work_ == "Mobilization") && (originalRow.Function_ == "Prevail/Min Wage"))
                        {
                            double acumPeriod = GetTotalHoursByEmployeeIdPeriodId(originalRow.EmployeeID, originalRow.Date_, originalRow.ProjectTimeID);

                            if (acumPeriod > overtime)
                            {
                                newRow.TimeMob = 0;
                                newRow.TimeMobOt = originalRow.ProjectTime;
                            }
                            else
                            {
                                double newAcumPeriod = acumPeriod + originalRow.ProjectTime;

                                if (newAcumPeriod > overtime)
                                {
                                    newRow.TimeMobOt = newAcumPeriod - overtime;
                                    newRow.TimeMob = originalRow.ProjectTime - newRow.TimeMobOt;
                                }
                                else
                                {
                                    newRow.TimeMob = originalRow.ProjectTime;
                                    newRow.TimeMobOt = 0;
                                }
                            }
                        }
                        else
                        {
                            if ((originalRow.FairWage) && (originalRow.Work_ != "Mobilization"))
                            {
                                double acumPeriod = GetTotalHoursByEmployeeIdPeriodId(originalRow.EmployeeID, originalRow.Date_, originalRow.ProjectTimeID);

                                if (acumPeriod > overtime)
                                {
                                    newRow.TimeFairWage = 0;
                                    newRow.TimeFairWageOt = originalRow.ProjectTime;
                                }
                                else
                                {
                                    double newAcumPeriod = acumPeriod + originalRow.ProjectTime;

                                    if (newAcumPeriod > overtime)
                                    {
                                        newRow.TimeFairWageOt = newAcumPeriod - overtime;
                                        newRow.TimeFairWage = originalRow.ProjectTime - newRow.TimeFairWageOt;
                                    }
                                    else
                                    {
                                        newRow.TimeFairWage = originalRow.ProjectTime;
                                        newRow.TimeFairWageOt = 0;
                                    }
                                }
                            }
                            else
                            {
                                double acumPeriod = GetTotalHoursByEmployeeIdPeriodId(originalRow.EmployeeID, originalRow.Date_, originalRow.ProjectTimeID);

                                if (acumPeriod > overtime)
                                {
                                    newRow.TimeStandard = 0;
                                    newRow.TimeStandardOt = originalRow.ProjectTime;
                                }
                                else
                                {
                                    double newAcumPeriod = acumPeriod + originalRow.ProjectTime;

                                    if (newAcumPeriod > overtime)
                                    {
                                        newRow.TimeStandardOt = newAcumPeriod - overtime;
                                        newRow.TimeStandard = originalRow.ProjectTime - newRow.TimeStandardOt;
                                    }
                                    else
                                    {
                                        newRow.TimeStandard = originalRow.ProjectTime;
                                        newRow.TimeStandardOt = 0;
                                    }
                                }
                            }
                        }
                    }
                    else //USA
                    {
                        if ((originalRow.FairWage) && (originalRow.Work_ != "Mobilization"))
                        {
                            double acumPeriod = GetTotalHoursByEmployeeIdPeriodId(originalRow.EmployeeID, originalRow.Date_, originalRow.ProjectTimeID);

                            if (acumPeriod > overtime)
                            {
                                newRow.TimeFairWage = 0;
                                newRow.TimeFairWageOt = originalRow.ProjectTime;
                            }
                            else
                            {
                                double newAcumPeriod = acumPeriod + originalRow.ProjectTime;

                                if (newAcumPeriod > overtime)
                                {
                                    newRow.TimeFairWageOt = newAcumPeriod - overtime;
                                    newRow.TimeFairWage = originalRow.ProjectTime - newRow.TimeFairWageOt;
                                }
                                else
                                {
                                    newRow.TimeFairWage = originalRow.ProjectTime;
                                    newRow.TimeFairWageOt = 0;
                                }
                            }
                        }
                        else
                        {
                            double acumPeriod = GetTotalHoursByEmployeeIdPeriodId(originalRow.EmployeeID, originalRow.Date_, originalRow.ProjectTimeID);

                            if (acumPeriod > overtime)
                            {
                                newRow.TimeStandard = 0;
                                newRow.TimeStandardOt = originalRow.ProjectTime;
                            }
                            else
                            {
                                double newAcumPeriod = acumPeriod + originalRow.ProjectTime;

                                if (newAcumPeriod > overtime)
                                {
                                    newRow.TimeStandardOt = newAcumPeriod - overtime;
                                    newRow.TimeStandard = originalRow.ProjectTime - newRow.TimeStandardOt;
                                }
                                else
                                {
                                    newRow.TimeStandard = originalRow.ProjectTime;
                                    newRow.TimeStandardOt = 0;
                                }
                            }
                        }
                    }
                }

                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 = "";
                }

                newRow.ClientName = originalRow.ClientName;
                newRow.Location = originalRow.Location;

                if (!originalRow.IsMealsCountryNull())
                {
                    if (originalRow.MealsCountry == 1)
                    {
                        newRow.MealsCA = true;
                        newRow.MealsUS = false;
                    }
                    else
                    {
                        newRow.MealsCA = false;
                        newRow.MealsUS = true;
                    }
                }
                else
                {
                    newRow.MealsCA = false;
                    newRow.MealsUS = false;
                }

                if (!originalRow.IsMealsCountryNull())
                {
                    if (originalRow.MealsCountry == 1)
                    {
                        newRow.TotalCA = originalRow.MealsAllowance;
                        newRow.TotalUS = 0;
                    }
                    else
                    {
                        newRow.TotalCA = 0;
                        newRow.TotalUS = originalRow.MealsAllowance;
                    }
                }
                else
                {
                    newRow.TotalCA = 0;
                    newRow.TotalUS = 0;
                }

                if (!originalRow.IsProjectTimeStateNull())
                {
                    if (originalRow.ProjectTimeState == "Approved")
                    {
                        newRow.IsApproved = true;
                    }
                    else
                    {
                        newRow.IsApproved = false;
                    }
                }
                else
                {
                    newRow.IsApproved = false;
                }

                if (!originalRow.IsApprovedByNull())
                {
                    newRow.ApprovedBy = originalRow.ApprovedBy;
                }
                else
                {
                    newRow.ApprovedBy = "";
                }

                if (!originalRow.IsProjectTimeStateNull())
                {
                    string projectTimeState = originalRow.ProjectTimeState;

                    if (projectTimeState == "Approved")
                    {
                        newRow.ProjectTimeState = originalRow.ApprovedBy;
                    }
                    else
                    {
                        newRow.ProjectTimeState = "--";
                    }
                }
                else
                {
                    newRow.ProjectTimeState = "--";
                }

                if (!originalRow.IsJobClassProjectTimeNull())
                {
                    string jobClassProjectTime = originalRow.JobClassProjectTime;

                    switch (jobClassProjectTime)
                    {
                        case "Laborer Group 2":
                            originalRow.JobClassProjectTime = "Lab 2";
                            break;

                        case "Laborer Group 6":
                            originalRow.JobClassProjectTime = "Lab 6";
                            break;

                        case "Operator Group 1":
                            originalRow.JobClassProjectTime = "Op 1";
                            break;

                        case "Operator Group 2":
                            originalRow.JobClassProjectTime = "Op 2";
                            break;

                        case "Regular Rate":
                            originalRow.JobClassProjectTime = "Reg Rate";
                            break;
                    }
                }

                // Show or not Job Class Project Time
                if (!originalRow.IsWork_Null())
                {
                    if (originalRow.Work_ != "Mobilization")
                    {
                        if (!originalRow.IsJobClassProjectTimeNull())
                        {
                            newRow.JobClassProjectTime = originalRow.JobClassProjectTime;
                        }
                        else
                        {
                            newRow.JobClassProjectTime = "";
                        }
                    }
                    else
                    {
                        newRow.JobClassProjectTime = "";
                    }
                }
                else
                {
                    if (!originalRow.IsJobClassProjectTimeNull())
                    {
                        newRow.JobClassProjectTime = originalRow.JobClassProjectTime;
                    }
                    else
                    {
                        newRow.JobClassProjectTime = "";
                    }
                }

                if (!originalRow.IsCommentsNull()) newRow.Comments = originalRow.Comments; else newRow.SetCommentsNull();

                ((PrintHoursForPayrollPeriodTDS.PrintHoursForPayrollPeriodDataTable)Table).AddPrintHoursForPayrollPeriodRow(newRow);
            }
        }
        public void LoadBySalariedStartDateEndDateEmployeeIdProjectTimeStateClientIdProjectIdIncludeAllHours(DateTime startDate, DateTime endDate, int employeeId, string projectTimeState, int clientId, int projectId, bool isNewReport)
        {
            PrintHoursForPayrollPeriodOriginalGateway originalGateway = new PrintHoursForPayrollPeriodOriginalGateway(Data);
            originalGateway.LoadBySalariedStartDateEndDateEmployeeIdProjectTimeStateClientIdProjectIdIncludeAllHours(startDate, endDate, employeeId, projectTimeState, clientId, projectId);

            if (isNewReport)
            {
                this.FillData2();
            }
            else
            {
                this.FillData();
            }
        }
        /// <summary>
        /// FillData
        /// </summary>
        private void FillData()
        {
            PrintHoursForPayrollPeriodOriginalGateway originalGateway = new PrintHoursForPayrollPeriodOriginalGateway(Data);

            foreach (PrintHoursForPayrollPeriodTDS.OriginalRow originalRow in (PrintHoursForPayrollPeriodTDS.OriginalDataTable)originalGateway.Table)
            {
                PrintHoursForPayrollPeriodTDS.PrintHoursForPayrollPeriodRow newRow = ((PrintHoursForPayrollPeriodTDS.PrintHoursForPayrollPeriodDataTable)Table).NewPrintHoursForPayrollPeriodRow();

                newRow.EmployeeID = originalRow.EmployeeID;
                newRow.EmployeeName = originalRow.EmployeeName;
                newRow.CountryID = originalRow.CountryID;
                newRow.CountryName = originalRow.CountryName;
                newRow.Date_ = originalRow.Date_;
                newRow.ProjectName = originalRow.ProjectName;
                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.IsStartTimeNull()) newRow.StartTime = originalRow.StartTime; else newRow.SetStartTimeNull();
                if (!originalRow.IsEndTimeNull()) newRow.EndTime = originalRow.EndTime; else newRow.SetEndTimeNull();
                if (!originalRow.IsOffsetNull()) newRow.Offset = originalRow.Offset; else newRow.SetOffsetNull();
                if (!originalRow.IsFairWageNull()) newRow.FairWage = originalRow.FairWage; else newRow.FairWage = false;

                if (originalRow.CountryID == 1)
                {
                    newRow.TimeCA = originalRow.ProjectTime;
                    newRow.TimeUS = 0;
                }
                else
                {
                    newRow.TimeCA = 0;
                    newRow.TimeUS = originalRow.ProjectTime;
                }

                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 = "";
                }

                newRow.ClientName = originalRow.ClientName;
                newRow.Location = originalRow.Location;

                if (!originalRow.IsMealsCountryNull())
                {
                    if (originalRow.MealsCountry == 1)
                    {
                        newRow.MealsCA = true;
                        newRow.MealsUS = false;
                    }
                    else
                    {
                        newRow.MealsCA = false;
                        newRow.MealsUS = true;
                    }
                }
                else
                {
                    newRow.MealsCA = false;
                    newRow.MealsUS = false;
                }

                if (!originalRow.IsMealsCountryNull())
                {
                    if (originalRow.MealsCountry == 1)
                    {
                        newRow.TotalCA = originalRow.MealsAllowance;
                        newRow.TotalUS = 0;
                    }
                    else
                    {
                        newRow.TotalCA = 0;
                        newRow.TotalUS = originalRow.MealsAllowance;
                    }
                }
                else
                {
                    newRow.TotalCA = 0;
                    newRow.TotalUS = 0;
                }

                if (!originalRow.IsProjectTimeStateNull())
                {
                    if (originalRow.ProjectTimeState == "Approved")
                    {
                        newRow.IsApproved = true;
                    }
                    else
                    {
                        newRow.IsApproved = false;
                    }
                }
                else
                {
                    newRow.IsApproved = false;
                }

                if (!originalRow.IsApprovedByNull())
                {
                    newRow.ApprovedBy = originalRow.ApprovedBy;
                }
                else
                {
                    newRow.ApprovedBy = "";
                }

                if (!originalRow.IsProjectTimeStateNull())
                {
                    newRow.ProjectTimeState = originalRow.ProjectTimeState;
                }
                else
                {
                    newRow.ProjectTimeState = "New";
                }

                if (!originalRow.IsCommentsNull()) newRow.Comments = originalRow.Comments; else newRow.SetCommentsNull();

                newRow.TimeFairWage = 0;
                newRow.TimeFairWageOt = 0;
                newRow.TimeMob = 0;
                newRow.TimeMobOt = 0;
                newRow.TimeStandard = 0;
                newRow.TimeStandardOt = 0;

                ((PrintHoursForPayrollPeriodTDS.PrintHoursForPayrollPeriodDataTable)Table).AddPrintHoursForPayrollPeriodRow(newRow);
            }
        }
        /// <summary>
        /// LoadBySalariedStartDateEndDateCountryIdEmployeeIdProjectTimeState
        /// </summary>
        /// <param name="startDate">startDate</param>
        /// <param name="endDate">endDate</param>
        /// <param name="countryId">countryId</param>
        /// <param name="employeeId">employeeId</param>
        /// <param name="projectTimeState">projectTimeState</param>
        public void LoadBySalariedStartDateEndDateCountryIdEmployeeIdProjectTimeState(DateTime startDate, DateTime endDate, Int64 countryId, int employeeId, string projectTimeState, bool isNewReport)
        {
            PrintHoursForPayrollPeriodOriginalGateway originalGateway = new PrintHoursForPayrollPeriodOriginalGateway(Data);
            originalGateway.LoadBySalariedStartDateEndDateCountryIdEmployeeIdProjectTimeState(startDate, endDate, countryId, employeeId, projectTimeState);

            if (isNewReport)
            {
                this.FillData2();
            }
            else
            {
                this.FillData();
            }
        }