private void masterParameters(mReport1 master)
        {
            DateTime startDate = DateTime.Parse(tkrdpStartDate.SelectedDate.Value.ToShortDateString());
            DateTime endDate = DateTime.Parse(tkrdpEndDate.SelectedDate.Value.ToShortDateString());
            int companyId = Int32.Parse(hdfCompanyId.Value);

            // ... set parameters to report
            if (master.Format == "pdf")
            {
                // ... ... client
                if (ddlClient.SelectedValue != "-1")
                {
                    int currentClientId = Int32.Parse(ddlClient.SelectedValue);
                    CompaniesGateway companiesGateway = new CompaniesGateway();
                    companiesGateway.LoadByCompaniesId(currentClientId, companyId);
                    master.SetParameter("Client", companiesGateway.GetName(currentClientId));
                }
                else
                {
                    master.SetParameter("Client", "All");
                }

                // ... ...  project
                if (ddlProject.SelectedValue != "-1")
                {
                    int currentProjectId = Int32.Parse(ddlProject.SelectedValue);
                    ProjectGateway projectGateway = new ProjectGateway();
                    projectGateway.LoadByProjectId(currentProjectId);
                    string name = projectGateway.GetName(currentProjectId);
                    master.SetParameter("Project", name);
                }
                else
                {
                    master.SetParameter("Project", "All");
                }

                // ... ... category
                if (ddlCategory.SelectedValue != "-1")
                {
                    string currentCategory = ddlCategory.SelectedValue;
                    master.SetParameter("Category", currentCategory);
                }
                else
                {
                    master.SetParameter("Category", "All");
                }

                // ... ... user
                LoginGateway loginGateway = new LoginGateway();
                loginGateway.LoadByLoginId(Convert.ToInt32(Session["loginID"]), companyId);
                string user = loginGateway.GetLastName(Convert.ToInt32(Session["loginID"]), companyId) + " " + loginGateway.GetFirstName(Convert.ToInt32(Session["loginID"]), companyId);
                master.SetParameter("User", user.Trim());

                // ... for start date
                string startDateParameter = startDate.Month.ToString() + "/" + startDate.Day.ToString() + "/" + startDate.Year.ToString();
                master.SetParameter("StartDate", startDateParameter);

                // ... for end date
                string endDateParameter = endDate.Month.ToString() + "/" + endDate.Day.ToString() + "/" + endDate.Year.ToString();
                master.SetParameter("EndDate", endDateParameter);
            }
        }
        private void LoadForSubcontractors(mReport1 master, string category, int clientId, int projectId, int companyId, DateTime startDate, DateTime endDate, ActualCostsReportTDS actualCostsReportTDS)
        {
            LiquiForce.LFSLive.BL.LabourHours.ActualCosts.ActualCostsReportGeneral actualCostsReportGeneral = new LiquiForce.LFSLive.BL.LabourHours.ActualCosts.ActualCostsReportGeneral(actualCostsReportTDS);
            actualCostsReportGeneral.LoadForSubcontractors(category, clientId, projectId, startDate, endDate, companyId, ckbxDates.Checked);
            LiquiForce.LFSLive.BL.LabourHours.ActualCosts.ActualCostsReportSubcontractorCosts actualCostsReportSubcontractorCosts = new LiquiForce.LFSLive.BL.LabourHours.ActualCosts.ActualCostsReportSubcontractorCosts(actualCostsReportTDS);

            // Set properties to master page
            master.Data = actualCostsReportSubcontractorCosts.Data;
            master.Table = actualCostsReportSubcontractorCosts.TableName;

            // Get report
            if (actualCostsReportSubcontractorCosts.Table.Rows.Count > 0)
            {
                if (master.Format == "pdf")
                {
                    master.Report = new ActualCostsReport();
                    masterParameters(master);
                }
                else
                {
                    master.Report = new ActualCostsReportExport();
                }

                // Make sections visible
                ((Section)master.Report.ReportDefinition.Sections["sDetailSubcontractorCosts"]).SectionFormat.EnableSuppress = false;
                ((Section)master.Report.ReportDefinition.Sections["sDetailHotelCosts"]).SectionFormat.EnableSuppress = true;
                ((Section)master.Report.ReportDefinition.Sections["sDetailsInsuranceCosts"]).SectionFormat.EnableSuppress = true;
                ((Section)master.Report.ReportDefinition.Sections["sDetailBondingCosts"]).SectionFormat.EnableSuppress = true;
                ((Section)master.Report.ReportDefinition.Sections["sDetailOtherCosts"]).SectionFormat.EnableSuppress = true;
            }
        }
        private void LoadForSubcontractors(mReport1 master, ActualCostsNavigatorTDS actualCostsNavigatorTDS)
        {
            LiquiForce.LFSLive.BL.LabourHours.ActualCosts.ActualCostsNavigatorSubcontractorCosts actualCostsNavigatorSubcontractorCosts = new LiquiForce.LFSLive.BL.LabourHours.ActualCosts.ActualCostsNavigatorSubcontractorCosts(actualCostsNavigatorTDS);
            if (actualCostsNavigatorSubcontractorCosts.Table.Rows.Count > 0)
            {
                // ... Set properties to master page
                master.Data = actualCostsNavigatorSubcontractorCosts.Data;
                master.Table = actualCostsNavigatorSubcontractorCosts.TableName;

                /*if (master.Format == "pdf")
                {*/
                    master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ActualCosts.ActualCostsPrintSearchResultsReport();

                    LoginGateway loginGateway = new LoginGateway();
                    int loginId = Convert.ToInt32(Session["loginID"]);
                    int companyId = Convert.ToInt32(Session["companyID"]);

                    loginGateway.LoadByLoginId(loginId, companyId);
                    string user = loginGateway.GetLastName(loginId, companyId) + " " + loginGateway.GetFirstName(loginId, companyId);
                    master.SetParameter("User", user.Trim());

                    // Report format
                    master.Report.PrintOptions.PaperOrientation = PaperOrientation.Landscape;
                    master.Report.PrintOptions.PaperSize = PaperSize.PaperLegal;

                    // Make sections visible
                    string category = Request.QueryString["category"];

                    // Load Data
                    if (category == "All")
                    {
                        ((Section)master.Report.ReportDefinition.Sections["sDetailSubcontractorCosts"]).SectionFormat.EnableSuppress = false;
                        ((Section)master.Report.ReportDefinition.Sections["sDetailHotelCosts"]).SectionFormat.EnableSuppress = false;
                        ((Section)master.Report.ReportDefinition.Sections["sDetailsInsuranceCosts"]).SectionFormat.EnableSuppress = false;
                        ((Section)master.Report.ReportDefinition.Sections["sDetailBondingCosts"]).SectionFormat.EnableSuppress = false;
                        ((Section)master.Report.ReportDefinition.Sections["sDetailOtherCosts"]).SectionFormat.EnableSuppress = false;
                    }
                    else
                    {
                        ((Section)master.Report.ReportDefinition.Sections["sDetailSubcontractorCosts"]).SectionFormat.EnableSuppress = false;
                        ((Section)master.Report.ReportDefinition.Sections["sDetailHotelCosts"]).SectionFormat.EnableSuppress = true;
                        ((Section)master.Report.ReportDefinition.Sections["sDetailsInsuranceCosts"]).SectionFormat.EnableSuppress = true;
                        ((Section)master.Report.ReportDefinition.Sections["sDetailBondingCosts"]).SectionFormat.EnableSuppress = true;
                        ((Section)master.Report.ReportDefinition.Sections["sDetailOtherCosts"]).SectionFormat.EnableSuppress = true;
                    }
                /*
                else
                {
                    master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ActualCosts.ActualCostsPrintSearchResultsReportExport();
                }*/
            }
        }
        private void GeneratePL(mReport1 master, string projectTimeState, string confirmedSize1, string confirmedSize2, string accessType, ref DateTime startDate, ref DateTime endDate, string work_, ref string function_, int companyId)
        {
            if (ddlPhase.SelectedValue == "PLInstall")
            {
                function_ = "Install";
            }

            if (ddlPhase.SelectedValue == "PLPrep")
            {
                function_ = "Prep";
            }

            int? countryId = null;

            if (ddlCountry.SelectedIndex > 0)
            {
                countryId = Convert.ToInt32(ddlCountry.SelectedValue);
            }

            LiquiForce.LFSLive.BL.LabourHours.ProjectTime.PrintManHoursPerPhasePL printManhoursPerPhase = new LiquiForce.LFSLive.BL.LabourHours.ProjectTime.PrintManHoursPerPhasePL();

            if (ddlClient.SelectedValue == "-1")
            {
                // ... For specific type of work and specific function
                printManhoursPerPhase.LoadByStartDateEndDateProjectTimeStateWorkFunction(countryId, startDate, endDate, projectTimeState, work_, function_, companyId, confirmedSize1, confirmedSize2, accessType);
            }
            else
            {
                if (ddlProject.SelectedValue == "-1")
                {
                    // ... For specific type of work and specific function
                    printManhoursPerPhase.LoadByCompaniesIdStartDateEndDateProjectTimeStateWorkFunction(int.Parse(ddlClient.SelectedValue), startDate, endDate, projectTimeState, work_, function_, companyId, confirmedSize1, confirmedSize2, accessType);
                }
                else
                {
                    // ... For specific type of work and specific function
                    printManhoursPerPhase.LoadByCompaniesIdProjectIdStartDateEndDateProjectTimeStateWorkFunction(int.Parse(ddlClient.SelectedValue), int.Parse(ddlProject.SelectedValue), startDate, endDate, projectTimeState, work_, function_, companyId, confirmedSize1, confirmedSize2, accessType);
                }
            }

            // ... set properties to master page
            master.Data = printManhoursPerPhase.Data;
            master.Table = printManhoursPerPhase.TableName;

            // Get report
            if (printManhoursPerPhase.Table.Rows.Count > 0)
            {
                if (master.Format == "pdf")
                {
                    switch (function_)
                    {
                        case "Install":
                            master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ProjectTime.PrintManhoursPerPhaseReportPLLInstall();
                            break;
                        case "Prep":
                            master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ProjectTime.PrintManhoursPerPhaseReportPLLPrep();
                            break;
                        case "Reinstate":
                            master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ProjectTime.PrintManhoursPerPhaseReportPLLReinstate();
                            break;
                    }
                }
                else
                {
                    switch (function_)
                    {
                        case "Install":
                            master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ProjectTime.PrintManhoursPerPhaseReportPLLInstall();
                            break;
                        case "Prep":
                            master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ProjectTime.PrintManhoursPerPhaseReportPLLPrep();
                            break;
                        case "Reinstate":
                            master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ProjectTime.PrintManhoursPerPhaseReportPLLReinstate();
                            break;
                    }
                }

                // ... set parameters to report
                if (master.Format == "pdf")
                {
                    // ... For report
                    // ... ... project time state
                    if (ddlProjectTimeState.SelectedValue == "(All)")
                    {
                        master.SetParameter("projectTimeState", "All");
                    }
                    else
                    {
                        master.SetParameter("projectTimeState", ddlProjectTimeState.SelectedItem.Text);
                    }

                    // ... ...  user
                    int loginId = Convert.ToInt32(Session["loginID"]);

                    LoginGateway loginGateway = new LoginGateway();
                    loginGateway.LoadByLoginId(loginId, companyId);
                    string user = loginGateway.GetLastName(loginId, companyId) + " " + loginGateway.GetFirstName(loginId, companyId);
                    master.SetParameter("User", user.Trim());

                    // ... ... client
                    if (ddlClient.SelectedValue == "-1")
                    {
                        master.SetParameter("client", "All");
                    }
                    else
                    {
                        CompaniesGateway companiesGateway = new CompaniesGateway();
                        companiesGateway.LoadByCompaniesId(Int32.Parse(ddlClient.SelectedValue), companyId);
                        string clientName = companiesGateway.GetName(Int32.Parse(ddlClient.SelectedValue));
                        master.SetParameter("client", clientName);
                    }

                    // ... ... project
                    if (ddlProject.SelectedValue == "-1")
                    {
                        master.SetParameter("project", "All");
                    }
                    else
                    {
                        int projectId2 = Int32.Parse(ddlProject.SelectedValue);
                        ProjectGateway projectGateway = new ProjectGateway();
                        projectGateway.LoadByProjectId(projectId2);
                        string project = projectGateway.GetName(projectId2);
                        master.SetParameter("project", project);
                    }

                    // ... ... phase / function
                    if (ddlPhase.SelectedValue == "(All)")
                    {
                        master.SetParameter("phase", "All");
                    }
                    else
                    {
                        master.SetParameter("phase", ddlPhase.SelectedItem.Text);
                    }

                    master.SetParameter("dateFrom", tkrdpStartDate.SelectedDate.Value.ToShortDateString());
                    master.SetParameter("dateTo", tkrdpEndDate.SelectedDate.Value.ToShortDateString());
                }
            }
        }
        private void GenerateMH(mReport1 master, string projectTimeState, ref DateTime startDate, ref DateTime endDate, string work_, string function_, int companyId)
        {
            LiquiForce.LFSLive.BL.LabourHours.ProjectTime.PrintManHoursPerPhaseMH printManhoursPerPhase = new LiquiForce.LFSLive.BL.LabourHours.ProjectTime.PrintManHoursPerPhaseMH();

            string shape = "%"; if (ddlShape.SelectedIndex > 0) shape = ddlShape.SelectedValue;
            string location = "%"; if (ddlLocation.SelectedIndex > 0) location = ddlLocation.SelectedValue;
            int conditionRating = 1;
            string material = "%"; if (ddlMaterial.SelectedIndex > 0) material = ddlMaterial.SelectedItem.Text;
            string crew = "%"; if (ddlCrew.SelectedIndex > 0) crew = ddlCrew.SelectedValue;

            int? countryId = null;

            if (ddlCountry.SelectedIndex > 0)
            {
                countryId = Convert.ToInt32(ddlCountry.SelectedValue);
            }

            if (ddlClient.SelectedValue == "-1")
            {
                // ... For specific type of work and specific function
                printManhoursPerPhase.LoadByStartDateEndDateProjectTimeStateWorkFunction(countryId, startDate, endDate, projectTimeState, work_, function_, companyId, shape, conditionRating, location, material, crew);
            }
            else
            {
                if (ddlProject.SelectedValue == "-1")
                {
                    // ... For specific type of work and specific function
                    printManhoursPerPhase.LoadByCompaniesIdStartDateEndDateProjectTimeStateWorkFunction(int.Parse(ddlClient.SelectedValue), startDate, endDate, projectTimeState, work_, function_, companyId, shape, conditionRating, location, material, crew);
                }
                else
                {
                    // ... For specific type of work and specific function
                    printManhoursPerPhase.LoadByCompaniesIdProjectIdStartDateEndDateProjectTimeStateWorkFunction(int.Parse(ddlClient.SelectedValue), int.Parse(ddlProject.SelectedValue), startDate, endDate, projectTimeState, work_, function_, companyId, shape, conditionRating, location, material, crew);
                }
            }

            // ... set properties to master page
            master.Data = printManhoursPerPhase.Data;
            master.Table = printManhoursPerPhase.TableName;

            // Get report
            if (printManhoursPerPhase.Table.Rows.Count > 0)
            {
                if (master.Format == "pdf")
                {
                    switch (function_)
                    {
                        case "Prep":
                            master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ProjectTime.PrintManhoursPerPhaseReportMHGeneral();
                            break;
                        case "Spray":
                            master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ProjectTime.PrintManhoursPerPhaseReportMHGeneral();
                            break;
                    }
                }
                else
                {
                    switch (function_)
                    {
                        case "Prep":
                            master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ProjectTime.PrintManhoursPerPhaseReportMHGeneralExport();
                            break;
                        case "Spray":
                            master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ProjectTime.PrintManhoursPerPhaseReportMHGeneralExport();
                            break;
                    }
                }

                // ... set parameters to report
                if (master.Format == "pdf")
                {
                    // ... For report
                    // ... ... project time state
                    if (ddlProjectTimeState.SelectedValue == "(All)")
                    {
                        master.SetParameter("projectTimeState", "All");
                    }
                    else
                    {
                        master.SetParameter("projectTimeState", ddlProjectTimeState.SelectedItem.Text);
                    }

                    // ... ...  user
                    int loginId = Convert.ToInt32(Session["loginID"]);

                    LoginGateway loginGateway = new LoginGateway();
                    loginGateway.LoadByLoginId(loginId, companyId);
                    string user = loginGateway.GetLastName(loginId, companyId) + " " + loginGateway.GetFirstName(loginId, companyId);
                    master.SetParameter("User", user.Trim());

                    // ... ... client
                    if (ddlClient.SelectedValue == "-1")
                    {
                        master.SetParameter("client", "All");
                    }
                    else
                    {
                        CompaniesGateway companiesGateway = new CompaniesGateway();
                        companiesGateway.LoadByCompaniesId(Int32.Parse(ddlClient.SelectedValue), companyId);
                        string clientName = companiesGateway.GetName(Int32.Parse(ddlClient.SelectedValue));
                        master.SetParameter("client", clientName);
                    }

                    // ... ... project
                    if (ddlProject.SelectedValue == "-1")
                    {
                        master.SetParameter("project", "All");
                    }
                    else
                    {
                        int projectId2 = Int32.Parse(ddlProject.SelectedValue);
                        ProjectGateway projectGateway = new ProjectGateway();
                        projectGateway.LoadByProjectId(projectId2);
                        string project = projectGateway.GetName(projectId2);
                        master.SetParameter("project", project);
                    }

                    // ... ... phase / function
                    if (ddlPhase.SelectedValue == "(All)")
                    {
                        master.SetParameter("phase", "All");
                    }
                    else
                    {
                        master.SetParameter("phase", ddlPhase.SelectedItem.Text);
                    }

                    // ... ... MH Shape
                    if (ddlShape.SelectedValue == "(All)")
                    {
                        master.SetParameter("Shape", "All");
                    }
                    else
                    {
                        master.SetParameter("Shape", ddlShape.SelectedValue);
                    }

                    // ... ... Condition Rating
                    if (ddlConditioningRating.SelectedValue == "-1")
                    {
                        master.SetParameter("ConditionRating", "All");
                    }
                    else
                    {
                        master.SetParameter("ConditionRating", ddlConditioningRating.SelectedValue);
                    }

                    // ... ... Location
                    if (ddlLocation.SelectedValue == "(All)")
                    {
                        master.SetParameter("Location", "All");
                    }
                    else
                    {
                        master.SetParameter("Location", ddlLocation.SelectedValue);
                    }

                    // ... ... Material
                    if (ddlMaterial.SelectedValue == "(All)")
                    {
                        master.SetParameter("Material", "All");
                    }
                    else
                    {
                        master.SetParameter("Material", ddlMaterial.SelectedItem.Text);
                    }

                    // ... ... Crew
                    if (ddlCrew.SelectedValue == "(All)")
                    {
                        master.SetParameter("Crew", "All");
                    }
                    else
                    {
                        master.SetParameter("Crew", ddlCrew.SelectedValue);
                    }

                    master.SetParameter("dateFrom", tkrdpStartDate.SelectedDate.Value.ToShortDateString());
                    master.SetParameter("dateTo", tkrdpEndDate.SelectedDate.Value.ToShortDateString());
                }
            }
        }
        private void GenerateJL(mReport1 master, string projectTimeState, ref DateTime startDate, ref DateTime endDate, string work_, string function_)
        {
            LiquiForce.LFSLive.BL.LabourHours.ProjectTime.PrintManhoursPerPhase printManhoursPerPhase = new LiquiForce.LFSLive.BL.LabourHours.ProjectTime.PrintManhoursPerPhase();

            int? countryId = null;

            if (ddlCountry.SelectedIndex > 0)
            {
                countryId = Convert.ToInt32(ddlCountry.SelectedValue);
            }

            if (ddlClient.SelectedValue == "-1")
            {
                printManhoursPerPhase.LoadByStartDateEndDateProjectTimeStateWorkFunction(countryId, startDate, endDate, projectTimeState, work_, function_);
            }
            else
            {
                if (ddlProject.SelectedValue == "-1")
                {
                    printManhoursPerPhase.LoadByCompaniesIdStartDateEndDateProjectTimeStateWorkFunction(int.Parse(ddlClient.SelectedValue), startDate, endDate, projectTimeState, work_, function_);
                }
                else
                {
                    printManhoursPerPhase.LoadByCompaniesIdProjectIdStartDateEndDateProjectTimeStateWorkFunction(int.Parse(ddlClient.SelectedValue), int.Parse(ddlProject.SelectedValue), startDate, endDate, projectTimeState, work_, function_);
                }
            }

            // ... set properties to master page
            master.Data = printManhoursPerPhase.Data;
            master.Table = printManhoursPerPhase.TableName;

            // Get report
            if (printManhoursPerPhase.Table.Rows.Count > 0)
            {
                if (master.Format == "pdf")
                {
                    switch (function_)
                    {
                        case "Install":
                            master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ProjectTime.PrintManhoursPerPhaseReport();
                            break;

                        case "Prep from Main":
                            master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ProjectTime.PrintManhoursPerPhaseReportJLPrepFromMain();
                            break;

                        case "Scoping":
                            master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ProjectTime.PrintManhoursPerPhaseReportJLScoping();
                            break;
                    }
                }
                else
                {
                    switch (function_)
                    {
                        case "Install":
                            master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ProjectTime.PrintManhoursPerPhaseReportExport();
                            break;

                        case "Prep from Main":
                            master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ProjectTime.PrintManhoursPerPhaseReportJLPrepFromMainExport();
                            break;

                        case "Scoping":
                            master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ProjectTime.PrintManhoursPerPhaseReportJLScopingExport();
                            break;
                    }
                }

                // ... set parameters to report
                if (master.Format == "pdf")
                {
                    // ... For report
                    // ... ... project time state
                    if (ddlProjectTimeState.SelectedValue == "(All)")
                    {
                        master.SetParameter("projectTimeState", "All");
                    }
                    else
                    {
                        master.SetParameter("projectTimeState", ddlProjectTimeState.SelectedItem.Text);
                    }

                    // ... ...  user
                    int loginId = Convert.ToInt32(Session["loginID"]);
                    int companyId = Convert.ToInt32(Session["companyID"]);

                    LoginGateway loginGateway = new LoginGateway();
                    loginGateway.LoadByLoginId(loginId, companyId);
                    string user = loginGateway.GetLastName(loginId, companyId) + " " + loginGateway.GetFirstName(loginId, companyId);
                    master.SetParameter("User", user.Trim());

                    // ... ... client
                    if (ddlClient.SelectedValue == "-1")
                    {
                        master.SetParameter("client", "All");
                    }
                    else
                    {
                        string clientName = ddlClient.SelectedItem.Text;
                        master.SetParameter("client", clientName);
                    }

                    // ... ... project
                    if (ddlProject.SelectedValue == "-1")
                    {
                        master.SetParameter("project", "All");
                    }
                    else
                    {
                        string project = ddlProject.SelectedItem.Text;
                        master.SetParameter("project", project);
                    }

                    // ... ... phase / function
                    if (ddlPhase.SelectedValue == "Scoping")
                    {
                        master.SetParameter("phase", "PreVideo & Locate (V1)");
                    }
                    else
                    {
                        master.SetParameter("phase", ddlPhase.SelectedValue);
                    }

                    // ... ... Dates Range
                    master.SetParameter("dateFrom", tkrdpStartDate.SelectedDate.Value.ToShortDateString());
                    master.SetParameter("dateTo", tkrdpEndDate.SelectedDate.Value.ToShortDateString());
                }
            }
        }