private void Generate()
        {
            mReport1 master = (mReport1)this.Master;

            // Get Data
            JlLiningPlanTDS jlLiningPlanTDS = (JlLiningPlanTDS)Session["jlLiningPlanTDS"];
            JlLiningPlan jlLiningPlan = new JlLiningPlan();
            jlLiningPlan.ProcessForReport(jlLiningPlanTDS);

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

            // Get report
            if (jlLiningPlan.Table.Rows.Count > 0)
            {
                master.Report = new JlLiningPlanReport();

                // ... for client
                int companyId = Int32.Parse(Session["companyID"].ToString());
                int currentClientId = Int32.Parse(hdfCurrentClientId.Value);
                CompaniesGateway companiesGateway = new CompaniesGateway();
                companiesGateway.LoadByCompaniesId(currentClientId, companyId);
                master.SetParameter("Client", companiesGateway.GetName(currentClientId));

                // ... for project
                int currentProjectId = Int32.Parse(hdfCurrentProjectId.Value);
                ProjectGateway projectGateway = new ProjectGateway();
                projectGateway.LoadByProjectId(currentProjectId);
                string name = projectGateway.GetName(currentProjectId);
                master.SetParameter("Project", projectGateway.GetProjectNumber(currentProjectId));

                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());
            }
        }
        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 Generate()
        {
            mReport1 master = (mReport1)this.Master;

            // Get Data
            DateTime startDate = DateTime.Parse(tkrdpStartDate.SelectedDate.Value.ToShortDateString());
            DateTime endDate = DateTime.Parse(tkrdpEndDate.SelectedDate.Value.ToShortDateString());
            int companyId = Int32.Parse(hdfCompanyId.Value);
            LiquiForce.LFSLive.BL.Projects.Projects.ProductionReport productionReport = new LiquiForce.LFSLive.BL.Projects.Projects.ProductionReport();

            if (ddlCountry.SelectedValue == "(All)")
            {
                if (ddlClient.SelectedValue == "-1")
                {
                    productionReport.LoadByStartDateEndDate(startDate, endDate, companyId);
                }
                else
                {
                    int clientId = int.Parse(ddlClient.SelectedValue);

                    if (ddlProject.SelectedValue == "-1")
                    {
                        productionReport.LoadByClientIdStartDateEndDate(clientId, startDate, endDate, companyId);
                    }
                    else
                    {
                        int projectId = int.Parse(ddlProject.SelectedValue);
                        productionReport.LoadByClientIdProjectIdStartDateEndDate(clientId, projectId, startDate, endDate, companyId);
                    }
                }
            }
            else
            {
                int country = Int32.Parse(ddlCountry.SelectedValue);

                if (ddlClient.SelectedValue == "-1")
                {
                    productionReport.LoadByCountryIdStartDateEndDate(country, startDate, endDate, companyId);
                }
                else
                {
                    int clientId = int.Parse(ddlClient.SelectedValue);

                    if (ddlProject.SelectedValue == "-1")
                    {
                        productionReport.LoadByCountryIdClientIdStartDateEndDate(country, clientId, startDate, endDate, companyId);
                    }
                    else
                    {
                        int projectId = int.Parse(ddlProject.SelectedValue);
                        productionReport.LoadByCountryIdClientIdProjectIdStartDateEndDate(country, clientId, projectId, startDate, endDate, companyId);
                    }
                }
            }

            LiquiForce.LFSLive.DA.Projects.Projects.ProductionReportGateway productionReportGateway = new LiquiForce.LFSLive.DA.Projects.Projects.ProductionReportGateway(productionReport.Data);

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

            // Get report
            if (productionReportGateway.Table.Rows.Count > 0)
            {
                if (master.Format == "pdf")
                {
                    master.Report = new LiquiForce.LFSLive.WebUI.Projects.Projects.ProductionReport();
                }
                else
                {
                    master.Report = new LiquiForce.LFSLive.WebUI.Projects.Projects.ProductionReportExport();
                }

                // ... set parameters to report
                if (master.Format == "pdf")
                {
                    // ... ...  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());

                    // ... ... country
                    if (ddlCountry.SelectedValue == "2")
                    {
                        master.SetParameter("Country", "USA");
                    }
                    else
                    {
                        if (ddlCountry.SelectedValue == "1")
                        {
                            master.SetParameter("Country", "Canada");
                        }
                        else
                        {
                            master.SetParameter("Country", "All");
                        }
                    }

                    // ... ... 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);
                    }

                    // ... ... Date
                    string startDateParameter = tkrdpStartDate.SelectedDate.Value.ToShortDateString();
                    master.SetParameter("StartDate", startDateParameter);

                    string endDateParameter = tkrdpEndDate.SelectedDate.Value.ToShortDateString();
                    master.SetParameter("EndDate", endDateParameter);

                    // ... ... client
                    if (ddlClient.SelectedValue == "-1")
                    {
                        master.SetParameter("Client", "All");
                    }
                    else
                    {
                        int currentClientId = Int32.Parse(ddlClient.SelectedValue);

                        CompaniesGateway companiesGateway = new CompaniesGateway();
                        companiesGateway.LoadByCompaniesId(currentClientId, companyId);
                        master.SetParameter("Client", companiesGateway.GetName(currentClientId));
                    }
                }
                else
                {
                    // ... ... Date
                    string startDateParameter = tkrdpStartDate.SelectedDate.Value.ToShortDateString();
                    master.SetParameter("StartDate", startDateParameter);

                    string endDateParameter = tkrdpEndDate.SelectedDate.Value.ToShortDateString();
                    master.SetParameter("EndDate", endDateParameter);
                }
            }
        }
        private void Generate()
        {
            mReport1 master = (mReport1)this.Master;
            LiquiForce.LFSLive.BL.CWP.Common.LateralLocationSheetReport lateralLocationSheetReport = new LiquiForce.LFSLive.BL.CWP.Common.LateralLocationSheetReport();
            int companyId = Int32.Parse(hdfCurrentCompanyId.Value);

            // Restore TDS
            JlNavigatorTDS jlNavigatorTDS = (JlNavigatorTDS)Session["jlNavigatorTDS"];

            // Get Data
            lateralLocationSheetReport.LoadByProjectIdJlNavigatorTDS(Int32.Parse(hdfCurrentProjectId.Value), jlNavigatorTDS, companyId);

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

            // Get report
            if (lateralLocationSheetReport.Table.Rows.Count > 0)
            {
                master.Report = new LateralLocationSheetReport();

                // ... for client
                int currentClientId = Int32.Parse(hdfCurrentClientId.Value);
                CompaniesGateway companiesGateway = new CompaniesGateway();
                companiesGateway.LoadByCompaniesId(currentClientId, companyId);
                master.SetParameter("Client", companiesGateway.GetName(currentClientId));

                // ... for project
                int currentProjectId = Int32.Parse(hdfCurrentProjectId.Value);
                ProjectGateway projectGateway = new ProjectGateway();
                projectGateway.LoadByProjectId(currentProjectId);
                string name = projectGateway.GetName(currentProjectId);
                master.SetParameter("Project", projectGateway.GetProjectNumber(currentProjectId));

                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());
            }
        }
        private void Generate()
        {
            mReport1 master = (mReport1)this.Master;

            // Get Data
            LiquiForce.LFSLive.BL.CWP.JunctionLining.JlToBuildReport jlToBuildReport = new LiquiForce.LFSLive.BL.CWP.JunctionLining.JlToBuildReport();

            if (ddlClient.SelectedValue == "-1")
            {
                jlToBuildReport.Load(int.Parse(hdfCompanyId.Value));
            }
            else
            {
                if (ddlProject.SelectedValue == "-1")
                {
                    jlToBuildReport.LoadByCompaniesId(int.Parse(hdfCompanyId.Value), int.Parse(ddlClient.SelectedValue));
                }
                else
                {
                    jlToBuildReport.LoadByCompaniesIdProjectId(int.Parse(hdfCompanyId.Value), int.Parse(ddlClient.SelectedValue), int.Parse(ddlProject.SelectedValue));
                }
            }

            if (cbxAutoFillLinerOrdered.Checked)
            {
                try
                {
                    jlToBuildReport.UpdateForReport();
                }
                catch
                {
                    string url = string.Format("./error_page.aspx?error={0}", "Autofill Liner In Process Failed. Please check your Database");
                    Response.Redirect(url);
                }
            }

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

            // Get report
            if (jlToBuildReport.Table.Rows.Count > 0)
            {
                if (master.Format == "pdf")
                {
                    master.Report = new JlToBuildReport();
                }
                else
                {
                    master.Report = new JlToBuildReportExport();
                }

                // ... set parameters to report
                int companyId = Int32.Parse(hdfCompanyId.Value);
                if (master.Format == "pdf")
                {
                    if (ddlClient.SelectedValue != "-1")
                    {
                        // ... for client
                        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");
                    }

                    if (ddlProject.SelectedValue != "-1")
                    {
                        // ... for project
                        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");
                    }

                    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());
                }
            }
        }
예제 #6
0
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Security check
                if (!(Convert.ToBoolean(Session["sgLFS_CWP_POINTREPAIRS_VIEW"]) && Convert.ToBoolean(Session["sgLFS_CWP_POINTREPAIRS_EDIT"])))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                }

                // Validate query string
                if (((string)Request.QueryString["source_page"] == null) || ((string)Request.QueryString["client_id"] == null) || ((string)Request.QueryString["project_id"] == null) ||  ((string)Request.QueryString["asset_id"] == null) || ((string)Request.QueryString["active_tab"] == null))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in pr_summary.aspx");
                }

                // Tag Page
                TagPage();

                // If coming from
                int companyId = Int32.Parse(hdfCompanyId.Value.Trim());
                int currentProjectId = Int32.Parse(hdfCurrentProjectId.Value.ToString());
                int assetId = Int32.Parse(hdfAssetId.Value.Trim());
                int workId = Int32.Parse(hdfWorkId.Value);

                Session.Remove("pointRepairsRepairsTempDummy");
                Session.Remove("pointRepairsCommentsTempDummy");

                // ... pr_navigator2.aspx
                if (Request.QueryString["source_page"] == "pr_navigator2.aspx")
                {
                    StoreNavigatorState();
                    ViewState["update"] = "no";

                    // ... Set initial tab
                    if ((string)Session["dialogOpenedPr"] != "1")
                    {
                        hdfActiveTab.Value = Request.QueryString["active_tab"];

                        pointRepairsTDS = new PointRepairsTDS();
                        pointRepairsRepairsTemp = new PointRepairsTDS.RepairDetailsDataTable();
                        pointRepairsCommentsTemp = new PointRepairsTDS.CommentDetailsDataTable();

                        PointRepairsSectionDetails pointRepairsSectionDetails = new PointRepairsSectionDetails(pointRepairsTDS);
                        pointRepairsSectionDetails.LoadByWorkId(workId, companyId);

                        PointRepairsWorkDetails pointRepairsWorkDetails = new PointRepairsWorkDetails(pointRepairsTDS);
                        pointRepairsWorkDetails.LoadByWorkIdAssetId(workId, assetId, companyId);

                        PointRepairsRepairDetails pointRepairsRepairDetails = new PointRepairsRepairDetails(pointRepairsTDS);
                        pointRepairsRepairDetails.LoadAllByWorkId(workId, companyId);

                        PointRepairsCommentDetails pointRepairsCommentDetails = new PointRepairsCommentDetails(pointRepairsTDS);
                        pointRepairsCommentDetails.LoadAllByWorkIdWorkType(workId, companyId, "Point Repairs");
                    }
                    else
                    {
                        hdfActiveTab.Value = (string)Session["activeTabPr"];

                        // Restore datasets
                        pointRepairsTDS = (PointRepairsTDS)Session["pointRepairsTDS"];
                        pointRepairsRepairsTemp = (PointRepairsTDS.RepairDetailsDataTable)Session["pointRepairsRepairsTemp"];
                        pointRepairsCommentsTemp = (PointRepairsTDS.CommentDetailsDataTable)Session["pointRepairsCommentsTemp"];
                    }

                    tcPrDetails.ActiveTabIndex = Int32.Parse(hdfActiveTab.Value);

                    Session["filterExpression"] = "Deleted = 0";

                    // Store dataset
                    Session["pointRepairsTDS"] = pointRepairsTDS;
                    Session["pointRepairsRepairsTemp"] = pointRepairsRepairsTemp;
                    Session["pointRepairsCommentsTemp"] = pointRepairsCommentsTemp;
                }

                // ... pr_delete.aspx or pr_edit.aspx
                if ((Request.QueryString["source_page"] == "pr_delete.aspx") || (Request.QueryString["source_page"] == "pr_edit.aspx"))
                {
                    StoreNavigatorState();
                    ViewState["update"] = Request.QueryString["update"];

                    // Restore dataset
                    pointRepairsTDS = (PointRepairsTDS)Session["pointRepairsTDS"];
                    pointRepairsRepairsTemp = (PointRepairsTDS.RepairDetailsDataTable)Session["pointRepairsRepairsTemp"];
                    pointRepairsCommentsTemp = (PointRepairsTDS.CommentDetailsDataTable)Session["pointRepairsCommentsTemp"];

                    // ... Set initial tab
                    if ((string)Session["dialogOpenedPr"] != "1")
                    {
                        hdfActiveTab.Value = Request.QueryString["active_tab"];
                    }
                    else
                    {
                        hdfActiveTab.Value = (string)Session["activeTabPr"];
                    }

                    tcPrDetails.ActiveTabIndex = Int32.Parse(hdfActiveTab.Value);

                    ApplyFilter();

                    switch ((string)Session["filterExpression"])
                    {
                        case "Deleted = 0":
                            ddlFilter.SelectedIndex = 0;
                            break;

                        case "Type='Robotic Reaming' AND Deleted = 0":
                            ddlFilter.SelectedIndex = 1;
                            break;

                        case "Type='Point Lining' AND Deleted = 0":
                            ddlFilter.SelectedIndex = 2;
                            break;

                        case "Type='Grouting' AND Deleted = 0":
                            ddlFilter.SelectedIndex = 3;
                            break;

                        default:
                            ddlFilter.SelectedIndex = 0;
                            break;
                    }
                }

                // Prepare initial data
                // ... for client
                int currentClientId = Int32.Parse(hdfCurrentClientId.Value.ToString());

                CompaniesGateway companiesGateway = new CompaniesGateway();
                companiesGateway.LoadByCompaniesId(currentClientId, companyId);
                lblTitleClientName.Text = "Client: " + companiesGateway.GetName(currentClientId);

                // ... for project
                ProjectGateway projectGateway = new ProjectGateway();
                projectGateway.LoadByProjectId(currentProjectId);
                string name = projectGateway.GetName(currentProjectId);
                if (name.Length > 23) name = name.Substring(0, 20) + "...";
                lblTitleProjectName.Text = " > Project: " + name + " (" + projectGateway.GetProjectNumber(currentProjectId) + ") > Selected Section";

                // ... Data for current point repairs work
                LoadPointRepairsData(currentProjectId, assetId, companyId);
            }
            else
            {
                // Restore datasets
                pointRepairsTDS = (PointRepairsTDS)Session["pointRepairsTDS"];
                pointRepairsRepairsTemp = (PointRepairsTDS.RepairDetailsDataTable)Session["pointRepairsRepairsTemp"];
                pointRepairsCommentsTemp = (PointRepairsTDS.CommentDetailsDataTable)Session["pointRepairsCommentsTemp"];

                // Set initial tab
                int activeTab = Int32.Parse(hdfActiveTab.Value);
                tcPrDetails.ActiveTabIndex = activeTab;

                ApplyFilter();
            }
        }
        private void Generate3()
        {
            mReportForM12 master = (mReportForM12)this.Master;
            string unitType = ddlUnitType.SelectedValue;
            int companyId = Convert.ToInt32(hdfCompanyId.Value);

            FlM1ReportTDS flM1ReportTDS = new FlM1ReportTDS();

            // Get Data
            LiquiForce.LFSLive.BL.CWP.FullLengthLining.FlM1Report flM1Report = new LiquiForce.LFSLive.BL.CWP.FullLengthLining.FlM1Report(flM1ReportTDS);
            LiquiForce.LFSLive.BL.CWP.FullLengthLining.FlM12Report flM2Report = new LiquiForce.LFSLive.BL.CWP.FullLengthLining.FlM12Report(flM1ReportTDS);

            GetM1Data(flM1Report, unitType, companyId);
            GetM2Data(flM2Report, unitType);

            // ... set properties to master page
            //FlM1ReportTDS dataSet = new FlM1ReportTDS();
            //dataSet.M1ReportByClient.Merge(flM1Report, true);
            //dataSet.M2_SECTION.Merge(flM2Report, true);

            master.Data3 = flM1ReportTDS;
            master.Table1 = flM1Report.TableName;
            master.Table2 = flM2Report.TableName;

            // Get report
            if (flM2Report.Table.Rows.Count > 0 || flM1Report.Table.Rows.Count > 0)
            {
                if (master.Format3 == "pdf")
                {
                    master.Report3 = new FlM12Report();

                    if (ddlClient.SelectedValue != "-1")
                    {
                        // ... for client
                        int currentClientId = Int32.Parse(ddlClient.SelectedValue);

                        CompaniesGateway companiesGateway = new CompaniesGateway();
                        companiesGateway.LoadByCompaniesId(currentClientId, companyId);

                        master.SetParameter3("Client", companiesGateway.GetName(currentClientId));
                    }
                    else
                    {
                        master.SetParameter3("Client", "All");
                    }

                    if (ddlProject.SelectedValue != "-1")
                    {
                        // ... for project
                        int currentProjectId = Int32.Parse(ddlProject.SelectedValue);

                        ProjectGateway projectGateway = new ProjectGateway();
                        projectGateway.LoadByProjectId(currentProjectId);

                        string name = projectGateway.GetName(currentProjectId);
                        master.SetParameter3("Project", name);
                    }
                    else
                    {
                        master.SetParameter3("Project", "All");
                    }

                    master.SetParameter3("UnitType", unitType);

                    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.SetParameter3("User", user.Trim());
                }
                else
                {
                    //master.Report2 = new FlM12ReportExport();
                }
            }
        }
        private void Generate()
        {
            mReport1 master = (mReport1)this.Master;

            // Get Data
            string whereClause = "(P.Deleted = 0) AND (P.ProjectType = 'Proposal')";
            if (ddlCountry.SelectedValue != "(All)")
            {
                if (whereClause.Length > 0) whereClause += " AND ";
                whereClause += "(P.CountryID = " + ddlCountry.SelectedValue + ")";
            }

            if (ddlClient.SelectedValue != "-1")
            {
                if (whereClause.Length > 0) whereClause += " AND ";
                whereClause += "(P.ClientID = " + ddlClient.SelectedValue + ")";
            }

            if (ddlState.SelectedValue != "(All)")
            {
                if (whereClause.Length > 0) whereClause += " AND ";
                if (ddlState.SelectedValue == "AwardedBidding")
                {
                    whereClause += "((P.ProjectState = 'Bidding') OR (P.ProjectState = 'Awarded'))";
                }
                else
                {
                    whereClause += "(P.ProjectState = '" + ddlState.SelectedValue + "')";
                }
            }

            whereClause += " AND (P.ProjectType != 'Internal')";

            LiquiForce.LFSLive.BL.Projects.Projects.TotalValueWorkAheadReport totalValueWorkAheadReport = new LiquiForce.LFSLive.BL.Projects.Projects.TotalValueWorkAheadReport();
            totalValueWorkAheadReport.LoadWhere(whereClause, ddlCurrency.SelectedValue, decimal.Parse(tbxExchangeRate.Text));

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

            // Get report
            if (totalValueWorkAheadReport.Table.Rows.Count > 0)
            {
                if (master.Format == "pdf")
                {
                    master.Report = new LiquiForce.LFSLive.WebUI.Projects.Projects.TotalValueWorkAheadReport();
                }
                else
                {
                    master.Report = new LiquiForce.LFSLive.WebUI.Projects.Projects.TotalValueWorkAheadReportExport();
                }

                // ... set parameters to report
                if (master.Format == "pdf")
                {
                    // ... For report
                    master.SetParameter("ExchangeRate", decimal.Parse(tbxExchangeRate.Text.Trim()));
                    master.SetParameter("Total", "Total (" + ddlCurrency.SelectedValue.Trim() + "):");
                    master.SetParameter("GrandTotal", "GRAND TOTAL (" + ddlCurrency.SelectedValue.Trim() + "):");
                    master.SetParameter("Currency", ddlCurrency.SelectedValue.Trim());

                    // ... ...  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
                    {
                        CompaniesGateway companiesGateway = new CompaniesGateway();
                        companiesGateway.LoadByCompaniesId(Int32.Parse(ddlClient.SelectedValue), companyId);
                        string clientName = companiesGateway.GetName(Int32.Parse(ddlClient.SelectedValue));
                        master.SetParameter("Client", clientName);
                    }

                    // ... ... state
                    if (ddlState.SelectedValue == "(All)")
                    {
                        master.SetParameter("State", "All");
                    }
                    else
                    {
                        if (ddlState.SelectedValue == "AwardedBidding")
                        {
                            master.SetParameter("State", "Awarded & Bidding");
                        }
                        else
                        {
                            master.SetParameter("State", ddlState.SelectedValue);
                        }
                    }

                    // ... ... country
                    if (ddlCountry.SelectedValue == "2")
                    {
                        master.SetParameter("Country", "USA");
                    }
                    else
                    {
                        if (ddlCountry.SelectedValue == "1")
                        {
                            master.SetParameter("Country", "Canada");
                        }
                        else
                        {
                            master.SetParameter("Country", "All");
                        }
                    }
                }
                else
                {
                    master.SetParameter("ExchangeRate", decimal.Parse(tbxExchangeRate.Text.Trim()));
                    master.SetParameter("Total", "Total (" + ddlCurrency.SelectedValue.Trim() + "):");
                    master.SetParameter("GrandTotal", "GRAND TOTAL (" + ddlCurrency.SelectedValue.Trim() + "):");
                }
            }
        }
        private void Generate()
        {
            mReport1 master = (mReport1)this.Master;

            DateTime startDate = DateTime.Parse(tkrdpStartDate.SelectedDate.Value.ToShortDateString());
            DateTime endDate = DateTime.Parse(tkrdpEndDate.SelectedDate.Value.ToShortDateString());

            // Get Data
            LiquiForce.LFSLive.BL.CWP.FullLengthLining.FlLiningCompletedReport flLiningCompletedReport = new LiquiForce.LFSLive.BL.CWP.FullLengthLining.FlLiningCompletedReport();
            int companyId = Int32.Parse(hdfCompanyId.Value);

            if (ddlCountry.SelectedValue == "(All)")
            {
                if (ddlClient.SelectedValue == "-1")
                {
                    flLiningCompletedReport.LoadByStartDateEndDate(startDate, endDate, companyId);
                }
                else
                {
                    if (ddlProject.SelectedValue == "-1")
                    {
                        flLiningCompletedReport.LoadByCompaniesIdStartDateEndDate(int.Parse(ddlClient.SelectedValue), startDate, endDate, companyId);
                    }
                    else
                    {
                        flLiningCompletedReport.LoadByCompaniesIdProjectIdStartDateEndDate(int.Parse(ddlClient.SelectedValue), int.Parse(ddlProject.SelectedValue), startDate, endDate, companyId);
                    }
                }
            }
            else
            {
                int countryId = Int32.Parse(ddlCountry.SelectedValue);
                if (ddlClient.SelectedValue == "-1")
                {
                    flLiningCompletedReport.LoadByStartDateEndDateCountryId(startDate, endDate, countryId, companyId);
                }
                else
                {
                    if (ddlProject.SelectedValue == "-1")
                    {
                        flLiningCompletedReport.LoadByCompaniesIdStartDateEndDateCountryId(int.Parse(ddlClient.SelectedValue), startDate, endDate, countryId, companyId);
                    }
                    else
                    {
                        flLiningCompletedReport.LoadByCompaniesIdProjectIdStartDateEndDateCountryId(int.Parse(ddlClient.SelectedValue), int.Parse(ddlProject.SelectedValue), startDate, endDate, countryId, companyId);
                    }
                }
            }

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

            // Get report
            if (flLiningCompletedReport.Table.Rows.Count > 0)
            {
                if (master.Format == "pdf")
                {
                    master.Report = new FlLiningCompletedReport();
                }
                else
                {
                    master.Report = new FlLiningCompletedReportExport();
                }

                // ... 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");
                    }

                    // ... ... 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());

                    // ... ... country
                    if (ddlCountry.SelectedValue == "2")
                    {
                        master.SetParameter("Country", "USA");
                    }
                    else
                    {
                        if (ddlCountry.SelectedValue == "1")
                        {
                            master.SetParameter("Country", "Canada");
                        }
                        else
                        {
                            master.SetParameter("Country", "All");
                        }
                    }
                }
            }
        }
        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 Generate()
        {
            mReport1 master = (mReport1)this.Master;

            // Get Data
            LiquiForce.LFSLive.BL.CWP.PointRepairs.PrOverviewReport prOverviewReport = new LiquiForce.LFSLive.BL.CWP.PointRepairs.PrOverviewReport();
            int companyId = Int32.Parse(hdfCompanyId.Value);

            if (ddlClient.SelectedValue == "-1")
            {
                if (ddlPrType.SelectedValue == "(All)")
                {
                    prOverviewReport.Load(companyId);
                }
                else
                {
                    prOverviewReport.LoadByPrType(ddlPrType.SelectedValue, companyId);
                }
            }
            else
            {
                int clientId = Int32.Parse(ddlClient.SelectedValue);

                if (ddlProject.SelectedValue == "-1")
                {
                    if (ddlPrType.SelectedValue == "(All)")
                    {
                        prOverviewReport.LoadByCompaniesId(companyId, clientId);
                    }
                    else
                    {
                        prOverviewReport.LoadByCompaniesIdPrType(companyId, clientId, ddlPrType.SelectedValue);
                    }
                }
                else
                {
                    int projectId = Int32.Parse(ddlProject.SelectedValue);

                    if (ddlPrType.SelectedValue == "(All)")
                    {
                        prOverviewReport.LoadByCompaniesIdProjectId(companyId, clientId, projectId);
                    }
                    else
                    {
                        prOverviewReport.LoadByCompaniesIdProjectIdPrType(companyId, clientId, projectId, ddlPrType.SelectedValue);
                    }
                }
            }

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

            // Get report
            if (prOverviewReport.Table.Rows.Count > 0)
            {
                if (master.Format == "pdf")
                {
                    if (Convert.ToBoolean(Session["sgLFS_CWP_POINTREPAIRS_ADMIN"]))
                    {
                        master.Report = new PrOverviewReport();
                    }
                }
                else
                {
                    if (Convert.ToBoolean(Session["sgLFS_CWP_POINTREPAIRS_ADMIN"]))
                    {
                        master.Report = new PrOverviewReportExport();
                    }
                }

                // ... set parameters to report
                if (master.Format == "pdf")
                {
                    if (ddlClient.SelectedValue != "-1")
                    {
                        // ... for client
                        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");
                    }

                    if (ddlProject.SelectedValue != "-1")
                    {
                        // ... for project
                        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");
                    }

                    if (ddlPrType.SelectedValue != "(All)")
                    {
                        // ... for point repair type
                        master.SetParameter("Type", ddlPrType.SelectedValue);
                    }
                    else
                    {
                        master.SetParameter("Type", "All");
                    }

                    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());

                    // Report format
                    master.Report.PrintOptions.PaperOrientation = PaperOrientation.Landscape;
                    master.Report.PrintOptions.PaperSize = PaperSize.PaperLegal;
                }
            }
        }
        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 Generate()
        {
            mReport1 master = (mReport1)this.Master;

            // Get Data
            string employeeType = (ddlEmployeeType.SelectedValue == "(All)") ? "%" : ddlEmployeeType.SelectedValue + "%";
            string projectTimeState = "%";
            DateTime startDate = DateTime.Parse(tkrdpStartDate.SelectedDate.Value.ToShortDateString());
            DateTime endDate = DateTime.Parse(tkrdpEndDate.SelectedDate.Value.ToShortDateString());
            int clientId = 0; if (ddlClient.SelectedValue != "-1") clientId = Int32.Parse(ddlClient.SelectedValue);
            int projectId = 0; if (ddlProject.SelectedValue != "-1") projectId = Int32.Parse(ddlProject.SelectedValue);
            string personnelAgencySelected = "%";
            if (pnlPersonnelAgency.Visible)
            {
                if (ddlPersonalAgency.SelectedIndex > 0)
                {
                    personnelAgencySelected = ddlPersonalAgency.SelectedValue + "%";
                }
            }

            PrintHoursForPayrollPeriodGateway printHoursForPayrollPeriodGateway = new PrintHoursForPayrollPeriodGateway();
            printHoursForPayrollPeriodGateway.ClearBeforeFill = false;

            foreach (ListItem lst in cbxlEmployee.Items)
            {
                if (lst.Selected)
                {
                    if (ddlCountry.SelectedValue == "-1")
                    {
                        if (ddlEmployeeType.SelectedValue != "Salaried")
                        {
                            if (ddlClient.SelectedValue == "-1")
                            {
                                printHoursForPayrollPeriodGateway.LoadByEmployeeTypeStartDateEndDateEmployeeIdProjectTimeState(employeeType, startDate, endDate, int.Parse(lst.Value), projectTimeState, false, personnelAgencySelected);
                            }
                            else
                            {
                                if (ddlProject.SelectedValue == "-1")
                                {
                                    printHoursForPayrollPeriodGateway.LoadByEmployeeTypeStartDateEndDateEmployeeIdProjectTimeStateClientId(employeeType, startDate, endDate, int.Parse(lst.Value), projectTimeState, clientId, false, personnelAgencySelected);
                                }
                                else
                                {
                                    printHoursForPayrollPeriodGateway.LoadByEmployeeTypeStartDateEndDateEmployeeIdProjectTimeStateClientIdProjectId(employeeType, startDate, endDate, int.Parse(lst.Value), projectTimeState, clientId, projectId, false, personnelAgencySelected);
                                }
                            }
                        }
                        else
                        {
                            if (ddlClient.SelectedValue == "-1")
                            {
                                printHoursForPayrollPeriodGateway.LoadBySalariedStartDateEndDateEmployeeIdProjectTimeState(startDate, endDate, int.Parse(lst.Value), projectTimeState, false);
                            }
                            else
                            {
                                if (ddlProject.SelectedValue == "-1")
                                {
                                    printHoursForPayrollPeriodGateway.LoadBySalariedStartDateEndDateEmployeeIdProjectTimeStateClientId(startDate, endDate, int.Parse(lst.Value), projectTimeState, clientId, false);
                                }
                                else
                                {
                                    printHoursForPayrollPeriodGateway.LoadBySalariedStartDateEndDateEmployeeIdProjectTimeStateClientIdProjectId(startDate, endDate, int.Parse(lst.Value), projectTimeState, clientId, projectId, false);
                                }
                            }
                        }
                    }
                    else
                    {
                        if (ddlEmployeeType.SelectedValue != "Salaried")
                        {
                            if (ddlClient.SelectedValue == "-1")
                            {
                                printHoursForPayrollPeriodGateway.LoadByEmployeeTypeStartDateEndDateCountryIdEmployeeIdProjectTimeState(employeeType, startDate, endDate, int.Parse(ddlCountry.SelectedValue), int.Parse(lst.Value), projectTimeState, false, personnelAgencySelected);
                            }
                            else
                            {
                                if (ddlProject.SelectedValue == "-1")
                                {
                                    printHoursForPayrollPeriodGateway.LoadByEmployeeTypeStartDateEndDateCountryIdEmployeeIdProjectTimeStateClientId(employeeType, startDate, endDate, int.Parse(ddlCountry.SelectedValue), int.Parse(lst.Value), projectTimeState, clientId, false, personnelAgencySelected);
                                }
                                else
                                {
                                    printHoursForPayrollPeriodGateway.LoadByEmployeeTypeStartDateEndDateCountryIdEmployeeIdProjectTimeStateClientIdProjectId(employeeType, startDate, endDate, int.Parse(ddlCountry.SelectedValue), int.Parse(lst.Value), projectTimeState, clientId, projectId, false, personnelAgencySelected);
                                }
                            }
                        }
                        else
                        {
                            if (ddlClient.SelectedValue == "-1")
                            {
                                printHoursForPayrollPeriodGateway.LoadBySalariedStartDateEndDateCountryIdEmployeeIdProjectTimeState(startDate, endDate, int.Parse(ddlCountry.SelectedValue), int.Parse(lst.Value), projectTimeState, false);
                            }
                            else
                            {
                                if (ddlProject.SelectedValue == "-1")
                                {
                                    printHoursForPayrollPeriodGateway.LoadBySalariedStartDateEndDateCountryIdEmployeeIdProjectTimeStateClientId(startDate, endDate, int.Parse(ddlCountry.SelectedValue), int.Parse(lst.Value), projectTimeState, clientId, false);
                                }
                                else
                                {
                                    printHoursForPayrollPeriodGateway.LoadBySalariedStartDateEndDateCountryIdEmployeeIdProjectTimeStateClientIdProjectId(startDate, endDate, int.Parse(ddlCountry.SelectedValue), int.Parse(lst.Value), projectTimeState, clientId, projectId, false);
                                }
                            }
                        }
                    }
                }
            }

            printHoursForPayrollPeriodGateway.ClearBeforeFill = true;

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

            // Get report
            if (printHoursForPayrollPeriodGateway.Table.Rows.Count > 0)
            {
                if (master.Format == "pdf")
                {
                    master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ProjectTime.PrintHoursForPayrollPeriodReportOld();
                }
                else
                {
                    master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ProjectTime.PrintHoursForPayrollPeriodReportExportOld();
                }

                // ... set parameters to report
                if (master.Format == "pdf")
                {
                    // ... For report
                    // ... ... country
                    if (ddlCountry.SelectedValue == "2")
                    {
                        master.SetParameter("Country", "USA");
                    }
                    else
                    {
                        if (ddlCountry.SelectedValue == "1")
                        {
                            master.SetParameter("Country", "Canada");
                        }
                        else
                        {
                            master.SetParameter("Country", "All");
                        }
                    }

                    // ... ... team member
                    if (IsAllEmployeesSelected())
                    {
                        master.SetParameter("teamMember", "All");
                    }
                    else
                    {
                        string fullName = GetEmployeesSelected();

                        master.SetParameter("teamMember", fullName);
                    }

                    // ... ... team member type
                    if (ddlEmployeeType.SelectedValue == "(All)")
                    {
                        master.SetParameter("teamMemberType", "All");
                    }
                    else
                    {
                        if (ddlEmployeeType.SelectedValue == "LFSCA") master.SetParameter("teamMemberType", "LFS Canada");
                        if (ddlEmployeeType.SelectedValue == "LFSUS") master.SetParameter("teamMemberType", "LFS USA");
                        if (ddlEmployeeType.SelectedValue == "LFS") master.SetParameter("teamMemberType", "All LFS");
                        if (ddlEmployeeType.SelectedValue == "PAGCA") master.SetParameter("teamMemberType", "PAG Canada");
                        if (ddlEmployeeType.SelectedValue == "PAGUS") master.SetParameter("teamMemberType", "PAG USA");
                        if (ddlEmployeeType.SelectedValue == "PAG") master.SetParameter("teamMemberType", "All PAG");
                        if (ddlEmployeeType.SelectedValue == "SOTA") master.SetParameter("teamMemberType", "SOTA");
                        if (ddlEmployeeType.SelectedValue == "Salaried") master.SetParameter("teamMemberType", "Salaried");
                        if (ddlEmployeeType.SelectedValue == "Subcontractor") master.SetParameter("teamMemberType", "Subcontractor");
                    }

                    // ... ...  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
                    {
                        int currentClientId = Int32.Parse(ddlClient.SelectedValue);
                        CompaniesGateway companiesGateway = new CompaniesGateway();
                        companiesGateway.LoadByCompaniesId(currentClientId, companyId);
                        master.SetParameter("Client", companiesGateway.GetName(currentClientId));
                    }

                    // ... ... 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);
                    }

                    master.SetParameter("dateFrom", tkrdpStartDate.SelectedDate.Value.ToShortDateString());
                    master.SetParameter("dateTo", tkrdpEndDate.SelectedDate.Value.ToShortDateString());
                }
                else
                {
                    master.SetParameter("dateFrom", tkrdpStartDate.SelectedDate.Value.ToShortDateString());
                    master.SetParameter("dateTo", tkrdpEndDate.SelectedDate.Value.ToShortDateString());
                }
            }
        }
        private void Generate()
        {
            mReport1 master = (mReport1)this.Master;

            // Get Data
            LiquiForce.LFSLive.BL.CWP.Jliner.JlinerOverviewReport jlinerOverviewReport = new LiquiForce.LFSLive.BL.CWP.Jliner.JlinerOverviewReport();
            int companyId = Convert.ToInt32(Session["companyID"]);

            if (ddlSelectAClient.SelectedValue == "-1")
            {
                jlinerOverviewReport.Load(companyId);
                jlinerOverviewReport.UpdateCommentsForReport();
            }
            else
            {
                jlinerOverviewReport.LoadByCompaniesID(Int32.Parse(ddlSelectAClient.SelectedValue), companyId);
                jlinerOverviewReport.UpdateCommentsForReport();
            }

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

            // Get report
            if (jlinerOverviewReport.Table.Rows.Count > 0)
            {
                if (master.Format == "pdf")
                {
                    if (Convert.ToBoolean(Session["sgLFS_APP_ADMIN"]))
                    {
                        master.Report = new rJlinerOverviewReport();
                    }
                    else
                    {
                        master.Report = new rJLinerOverviewReportSimple();
                    }
                }
                else
                {
                    if (Convert.ToBoolean(Session["sgLFS_APP_ADMIN"]))
                    {
                        master.Report = new rJlinerOverviewReportExport();
                    }
                    else
                    {
                        master.Report = new rJlinerOverviewReportSimpleExport();
                    }
                }

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

                    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());

                    // Report format
                    master.Report.PrintOptions.PaperOrientation = PaperOrientation.Landscape;
                    master.Report.PrintOptions.PaperSize = PaperSize.PaperLegal;
                }
            }
        }
        private void Generate()
        {
            mReport1 master = (mReport1)this.Master;
            LiquiForce.LFSLive.BL.CWP.ManholeRehabilitation.MrSummaryReport mrSummaryReport = new LiquiForce.LFSLive.BL.CWP.ManholeRehabilitation.MrSummaryReport();
            int companyId = Int32.Parse(hdfCompanyId.Value);

            Page.Validate();
            if (Page.IsValid)
            {
                // Get Data
                // For all clients
                if (ddlClient.SelectedValue == "-1")
                {
                    // validate checkboxes
                    if (cbxMhId.Checked)
                    {
                        ArrayList assetId = new ArrayList();
                        foreach (ListItem lst in cbxlMhId.Items)
                        {
                            if (lst.Selected)
                            {
                                assetId.Add(lst.Value);
                            }
                        }

                        mrSummaryReport.LoadByAssetId(companyId, assetId);
                    }
                }

                // For specific client
                else
                {
                    // For all projects
                    if (ddlProject.SelectedValue == "-1")
                    {
                        if (cbxMhId.Checked)
                        {
                            ArrayList assetId = new ArrayList();
                            foreach (ListItem lst in cbxlMhId.Items)
                            {
                                if (lst.Selected)
                                {
                                    assetId.Add(lst.Value);
                                }
                            }

                            mrSummaryReport.LoadByCompaniesIdAssetId(companyId, int.Parse(ddlClient.SelectedValue), assetId);
                        }
                    }
                    // For specific project
                    else
                    {
                        if (cbxMhId.Checked)
                        {
                            ArrayList assetId = new ArrayList();
                            foreach (ListItem lst in cbxlMhId.Items)
                            {
                                if (lst.Selected)
                                {
                                    assetId.Add(lst.Value);
                                }
                            }

                            mrSummaryReport.LoadByCompaniesIdProjectIdAssetId(companyId, int.Parse(ddlClient.SelectedValue), int.Parse(ddlProject.SelectedValue), assetId);
                        }
                    }
                }
            }

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

            // Get report
            if (mrSummaryReport.Table.Rows.Count > 0)
            {
                if (master.Format == "pdf")
                {
                    master.Report = new MrSummaryReport();
                }
                else
                {
                    master.Report = new MrSummaryReportExport();
                }

                // ... set parameters to report
                if (master.Format == "pdf")
                {
                    if (ddlClient.SelectedValue != "-1")
                    {
                        // ... for client
                        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");
                    }

                    if (ddlProject.SelectedValue != "-1")
                    {
                        // ... for project
                        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");
                    }

                    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());
                }
            }
        }
        private void Generate()
        {
            Page.Validate();

            if (Page.IsValid)
            {
                mReport1 master = (mReport1)this.Master;

                // Get Data
                string employeeType = (ddlEmployeeType.SelectedValue == "(All)") ? "%" : ddlEmployeeType.SelectedValue + "%";
                string projectTimeState = (ddlProjectTimeState.SelectedValue == "(All)") ? "%" : ddlProjectTimeState.SelectedValue;
                DateTime startDate = DateTime.Parse(tkrdpStartDate.SelectedDate.Value.ToShortDateString());
                DateTime endDate = DateTime.Parse(tkrdpEndDate.SelectedDate.Value.ToShortDateString());
                int clientId = 0; if (ddlClient.SelectedValue != "-1") clientId = Int32.Parse(ddlClient.SelectedValue);
                int projectId = 0; if (ddlProject.SelectedValue != "-1") projectId = Int32.Parse(ddlProject.SelectedValue);
                bool includeAllHours = cbxIncludeAllHours.Checked;
                string personnelAgencySelected = "null";
                if (pnlPersonnelAgency.Visible)
                {
                    if (ddlPersonalAgency.SelectedIndex > 0)
                    {
                        personnelAgencySelected = ddlPersonalAgency.SelectedValue + "%";
                    }
                }

                PrintHoursForPayrollPeriodGateway printHoursForPayrollPeriodGateway = new PrintHoursForPayrollPeriodGateway();
                printHoursForPayrollPeriodGateway.ClearBeforeFill = false;

                foreach (ListItem lst in cbxlEmployee.Items)
                {
                    if (lst.Selected)
                    {
                        if (ddlCountry.SelectedValue == "-1")
                        {
                            if (ddlEmployeeType.SelectedValue != "Salaried")
                            {
                                if (ddlClient.SelectedValue == "-1")
                                {
                                    printHoursForPayrollPeriodGateway.LoadByEmployeeTypeStartDateEndDateEmployeeIdProjectTimeState(employeeType, startDate, endDate, int.Parse(lst.Value), projectTimeState, true, personnelAgencySelected);
                                }
                                else
                                {
                                    if (ddlProject.SelectedValue == "-1")
                                    {
                                        printHoursForPayrollPeriodGateway.LoadByEmployeeTypeStartDateEndDateEmployeeIdProjectTimeStateClientId(employeeType, startDate, endDate, int.Parse(lst.Value), projectTimeState, clientId, true, personnelAgencySelected);
                                    }
                                    else
                                    {
                                        if (!includeAllHours)
                                        {
                                            printHoursForPayrollPeriodGateway.LoadByEmployeeTypeStartDateEndDateEmployeeIdProjectTimeStateClientIdProjectId(employeeType, startDate, endDate, int.Parse(lst.Value), projectTimeState, clientId, projectId, true, personnelAgencySelected);
                                        }
                                        else
                                        {
                                            printHoursForPayrollPeriodGateway.LoadByEmployeeTypeStartDateEndDateEmployeeIdProjectTimeStateClientIdProjectIdIncludeAllHours(employeeType, startDate, endDate, int.Parse(lst.Value), projectTimeState, clientId, projectId, true);

                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (ddlClient.SelectedValue == "-1")
                                {
                                    printHoursForPayrollPeriodGateway.LoadBySalariedStartDateEndDateEmployeeIdProjectTimeState(startDate, endDate, int.Parse(lst.Value), projectTimeState, true);
                                }
                                else
                                {
                                    if (ddlProject.SelectedValue == "-1")
                                    {
                                        printHoursForPayrollPeriodGateway.LoadBySalariedStartDateEndDateEmployeeIdProjectTimeStateClientId(startDate, endDate, int.Parse(lst.Value), projectTimeState, clientId, true);
                                    }
                                    else
                                    {
                                        if (!includeAllHours)
                                        {
                                            printHoursForPayrollPeriodGateway.LoadBySalariedStartDateEndDateEmployeeIdProjectTimeStateClientIdProjectId(startDate, endDate, int.Parse(lst.Value), projectTimeState, clientId, projectId, true);
                                        }
                                        else
                                        {
                                            printHoursForPayrollPeriodGateway.LoadBySalariedStartDateEndDateEmployeeIdProjectTimeStateClientIdProjectIdIncludeAllHours(startDate, endDate, int.Parse(lst.Value), projectTimeState, clientId, projectId, true);

                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (ddlEmployeeType.SelectedValue != "Salaried")
                            {
                                if (ddlClient.SelectedValue == "-1")
                                {
                                    printHoursForPayrollPeriodGateway.LoadByEmployeeTypeStartDateEndDateCountryIdEmployeeIdProjectTimeState(employeeType, startDate, endDate, int.Parse(ddlCountry.SelectedValue), int.Parse(lst.Value), projectTimeState, true, personnelAgencySelected);
                                }
                                else
                                {
                                    if (ddlProject.SelectedValue == "-1")
                                    {
                                        printHoursForPayrollPeriodGateway.LoadByEmployeeTypeStartDateEndDateCountryIdEmployeeIdProjectTimeStateClientId(employeeType, startDate, endDate, int.Parse(ddlCountry.SelectedValue), int.Parse(lst.Value), projectTimeState, clientId, true, personnelAgencySelected);
                                    }
                                    else
                                    {
                                        if (!includeAllHours)
                                        {
                                            printHoursForPayrollPeriodGateway.LoadByEmployeeTypeStartDateEndDateCountryIdEmployeeIdProjectTimeStateClientIdProjectId(employeeType, startDate, endDate, int.Parse(ddlCountry.SelectedValue), int.Parse(lst.Value), projectTimeState, clientId, projectId, true, personnelAgencySelected);
                                        }
                                        else
                                        {
                                            printHoursForPayrollPeriodGateway.LoadByEmployeeTypeStartDateEndDateCountryIdEmployeeIdProjectTimeStateClientIdProjectIdIncludeAllHours(employeeType, startDate, endDate, int.Parse(ddlCountry.SelectedValue), int.Parse(lst.Value), projectTimeState, clientId, projectId, true);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (ddlClient.SelectedValue == "-1")
                                {
                                    printHoursForPayrollPeriodGateway.LoadBySalariedStartDateEndDateCountryIdEmployeeIdProjectTimeState(startDate, endDate, int.Parse(ddlCountry.SelectedValue), int.Parse(lst.Value), projectTimeState, true);
                                }
                                else
                                {
                                    if (ddlProject.SelectedValue == "-1")
                                    {
                                        printHoursForPayrollPeriodGateway.LoadBySalariedStartDateEndDateCountryIdEmployeeIdProjectTimeStateClientId(startDate, endDate, int.Parse(ddlCountry.SelectedValue), int.Parse(lst.Value), projectTimeState, clientId, true);
                                    }
                                    else
                                    {
                                        if (!includeAllHours)
                                        {
                                            printHoursForPayrollPeriodGateway.LoadBySalariedStartDateEndDateCountryIdEmployeeIdProjectTimeStateClientIdProjectId(startDate, endDate, int.Parse(ddlCountry.SelectedValue), int.Parse(lst.Value), projectTimeState, clientId, projectId, true);
                                        }
                                        else
                                        {
                                            printHoursForPayrollPeriodGateway.LoadBySalariedStartDateEndDateCountryIdEmployeeIdProjectTimeStateClientIdProjectIdIncludeAllHours(startDate, endDate, int.Parse(ddlCountry.SelectedValue), int.Parse(lst.Value), projectTimeState, clientId, projectId, true);

                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                printHoursForPayrollPeriodGateway.ClearBeforeFill = true;

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

                // Get report
                if (printHoursForPayrollPeriodGateway.Table.Rows.Count > 0)
                {
                    if (master.Format == "pdf")
                    {
                        if (ddlCountry.SelectedValue == "1")
                        {
                            master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ProjectTime.PrintHoursForPayrollPeriodWithApprovalReport();
                        }
                        else
                        {
                            master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ProjectTime.PrintHoursForPayrollPeriodWithApprovalUSAReport();
                        }
                    }
                    else
                    {
                        if (ddlCountry.SelectedValue == "1")
                        {
                            master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ProjectTime.PrintHoursForPayrollPeriodWithApprovalReportExport();
                        }
                        else
                        {
                            master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ProjectTime.PrintHoursForPayrollPeriodWithApprovalUSAReportExport();
                        }
                    }

                    // ... set parameters to report
                    if (master.Format == "pdf")
                    {
                        // ... For report
                        // ... ... country
                        if (ddlCountry.SelectedValue == "2")
                        {
                            master.SetParameter("Country", "USA");
                        }
                        else
                        {
                            if (ddlCountry.SelectedValue == "1")
                            {
                                master.SetParameter("Country", "Canada");
                            }
                            else
                            {
                                master.SetParameter("Country", "All");
                            }
                        }

                        // ... ... project time state
                        if (ddlProjectTimeState.SelectedValue == "(All)")
                        {
                            master.SetParameter("ProjectTimeState", "All");
                        }
                        else
                        {
                            master.SetParameter("ProjectTimeState", ddlProjectTimeState.SelectedItem.Text);
                        }

                        // ... ... team member
                        if (IsAllEmployeesSelected())
                        {
                            master.SetParameter("teamMember", "All");
                        }
                        else
                        {
                            string fullName = GetEmployeesSelected();

                            master.SetParameter("teamMember", fullName);
                        }

                        // ... ... team member type
                        if (ddlEmployeeType.SelectedValue == "(All)")
                        {
                            master.SetParameter("teamMemberType", "All");
                        }
                        else
                        {
                            if (ddlEmployeeType.SelectedValue == "LFSCA") master.SetParameter("teamMemberType", "LFS Canada");
                            if (ddlEmployeeType.SelectedValue == "LFSUS") master.SetParameter("teamMemberType", "LFS USA");
                            if (ddlEmployeeType.SelectedValue == "LFS") master.SetParameter("teamMemberType", "All LFS");
                            if (ddlEmployeeType.SelectedValue == "PAGCA")
                            {
                                master.SetParameter("teamMemberType", "PAG Canada");
                            }
                            if (ddlEmployeeType.SelectedValue == "PAGUS")
                            {
                                master.SetParameter("teamMemberType", "PAG USA");
                            }
                            if (ddlEmployeeType.SelectedValue == "PAG")
                            {
                                master.SetParameter("teamMemberType", "All PAG");
                            }
                            if (ddlEmployeeType.SelectedValue == "SOTA") master.SetParameter("teamMemberType", "SOTA");
                            if (ddlEmployeeType.SelectedValue == "Salaried") master.SetParameter("teamMemberType", "Salaried");
                            if (ddlEmployeeType.SelectedValue == "Subcontractor") master.SetParameter("teamMemberType", "Subcontractor");
                        }

                        string employeeTypeSelected = ddlEmployeeType.SelectedValue;
                        string employeeTypeSelectedFull = ddlEmployeeType.SelectedItem.Text;
                        string country = "";
                        if (ddlCountry.SelectedValue == "1")
                        {
                            country = "CANADA";
                        }
                        else
                        {
                            country = "USA";
                        }

                        if (employeeTypeSelected == "PAGCA" || employeeTypeSelected == "PAGUS" || employeeTypeSelected == "PAG")
                        {
                            master.SetParameter("name", "TEAM MEMBER HOURS FOR PAYROLL PERIOD - " + country + " - " + employeeTypeSelectedFull.ToUpper() + " -  (New Version With Approval)");
                        }
                        else
                        {
                            master.SetParameter("name", "TEAM MEMBER HOURS FOR PAYROLL PERIOD - " + country + " -  (New Version With Approval)");
                        }

                        // ... ...  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
                        {
                            int currentClientId = Int32.Parse(ddlClient.SelectedValue);

                            CompaniesGateway companiesGateway = new CompaniesGateway();
                            companiesGateway.LoadByCompaniesId(currentClientId, companyId);
                            master.SetParameter("Client", companiesGateway.GetName(currentClientId));
                        }

                        // ... ... 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);
                        }

                        master.SetParameter("dateFrom", tkrdpStartDate.SelectedDate.Value.ToShortDateString());
                        master.SetParameter("dateTo", tkrdpEndDate.SelectedDate.Value.ToShortDateString());

                        if (ddlPersonalAgency.SelectedIndex > 0)
                        {
                            master.SetParameter("personnelAgency", ddlPersonalAgency.SelectedItem.Text);
                        }
                        else
                        {
                            master.SetParameter("personnelAgency", "All");
                        }

                        // Report format
                        master.Report.PrintOptions.PaperOrientation = PaperOrientation.Landscape;
                        master.Report.PrintOptions.PaperSize = PaperSize.PaperLetter;
                    }
                }
            }
            else
            {
                PrintHoursForPayrollPeriodGateway printHoursForPayrollPeriodGateway = new PrintHoursForPayrollPeriodGateway();

                mReport1 master = (mReport1)this.Master;
                master.Data = printHoursForPayrollPeriodGateway.Data;
                master.Table = printHoursForPayrollPeriodGateway.TableName;
            }
        }
        private void Generate()
        {
            mReport1 master = (mReport1)this.Master;
            int companyId = Convert.ToInt32(Session["companyID"]);
            string type = Request.QueryString["type"].ToString();
            int costingSheetId = 0;
            int projectId = 0;

            ProjectCostingSheetInformationBasicInformation projectCostingSheetInformationBasicInformation = new ProjectCostingSheetInformationBasicInformation();

            if (ddlCostingSheets.SelectedValue != "-1")
            {
                // Get Data
                costingSheetId = Convert.ToInt32(ddlCostingSheets.SelectedValue);
                projectCostingSheetInformationBasicInformation.LoadByCostingSheetIdForPreviewReport(costingSheetId, companyId);
                ProjectCostingSheetInformationBasicInformationGateway projectCostingSheetInformationBasicInformationGateway = new ProjectCostingSheetInformationBasicInformationGateway(projectCostingSheetInformationBasicInformation.Data);
                projectId = projectCostingSheetInformationBasicInformationGateway.GetProjectID(costingSheetId);

                // ... set properties to master page
                master.Data = projectCostingSheetInformationBasicInformation.Data;
                master.Table = projectCostingSheetInformationBasicInformation.TableName;
                master.Report = new ProjectCostingSheetsPreview();

                // Get report
                if (projectCostingSheetInformationBasicInformation.Table.Rows.Count > 0)
                {
                    ProjectGateway projectGateway = new ProjectGateway();
                    projectGateway.LoadByProjectId(projectId);
                    int clientId = projectGateway.GetClientID(projectId);

                    CompaniesGateway companiesGateway = new CompaniesGateway();
                    companiesGateway.LoadByCompaniesId(clientId, companyId);
                    master.SetParameter("Client", companiesGateway.GetName(clientId));

                    string name = projectGateway.GetName(projectId);
                    master.SetParameter("Project", name);

                    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());

                    master.SetParameter("CostingSheet", projectCostingSheetInformationBasicInformationGateway.GetName(costingSheetId));

                    if (type == "resume")
                    {
                        ((Section)master.Report.ReportDefinition.Sections["detailsLabourHours"]).SectionFormat.EnableSuppress = true;
                        ((Section)master.Report.ReportDefinition.Sections["detailsLabourHours2"]).SectionFormat.EnableSuppress = true;
                        ((Section)master.Report.ReportDefinition.Sections["detailsUnits"]).SectionFormat.EnableSuppress = true;
                        ((Section)master.Report.ReportDefinition.Sections["detailsUnits2"]).SectionFormat.EnableSuppress = true;
                        ((Section)master.Report.ReportDefinition.Sections["detailsMaterials"]).SectionFormat.EnableSuppress = true;
                        ((Section)master.Report.ReportDefinition.Sections["detailsMaterials2"]).SectionFormat.EnableSuppress = true;
                        ((Section)master.Report.ReportDefinition.Sections["detailsOtherCosts"]).SectionFormat.EnableSuppress = true;
                        ((Section)master.Report.ReportDefinition.Sections["detailsOtherCosts2"]).SectionFormat.EnableSuppress = true;
                        ((Section)master.Report.ReportDefinition.Sections["detailsSubcontractors"]).SectionFormat.EnableSuppress = true;
                        //((Section)master.Report.ReportDefinition.Sections["detailsSubcontractors2"]).SectionFormat.EnableSuppress = true;
                    }
                    else
                    {
                        ((Section)master.Report.ReportDefinition.Sections["detailsLabourHours"]).SectionFormat.EnableSuppress = false;
                        ((Section)master.Report.ReportDefinition.Sections["detailsLabourHours2"]).SectionFormat.EnableSuppress = false;
                        ((Section)master.Report.ReportDefinition.Sections["detailsUnits"]).SectionFormat.EnableSuppress = false;
                        ((Section)master.Report.ReportDefinition.Sections["detailsUnits2"]).SectionFormat.EnableSuppress = false;
                        ((Section)master.Report.ReportDefinition.Sections["detailsMaterials"]).SectionFormat.EnableSuppress = false;
                        ((Section)master.Report.ReportDefinition.Sections["detailsMaterials2"]).SectionFormat.EnableSuppress = false;
                        ((Section)master.Report.ReportDefinition.Sections["detailsOtherCosts"]).SectionFormat.EnableSuppress = false;
                        ((Section)master.Report.ReportDefinition.Sections["detailsOtherCosts2"]).SectionFormat.EnableSuppress = false;
                        ((Section)master.Report.ReportDefinition.Sections["detailsSubcontractors"]).SectionFormat.EnableSuppress = false;
                        //((Section)master.Report.ReportDefinition.Sections["detailsSubcontractors2"]).SectionFormat.EnableSuppress = false;
                    }

                    if (projectGateway.GetCountryID(projectId) == 1)//Canada
                    {
                        // General
                        ((Section)master.Report.ReportDefinition.Sections["GroupHeaderSection1"]).ReportObjects["Text32"].ObjectFormat.EnableSuppress = true;
                        ((Section)master.Report.ReportDefinition.Sections["GroupHeaderSection1"]).ReportObjects["Text34"].ObjectFormat.EnableSuppress = true;
                        ((Section)master.Report.ReportDefinition.Sections["GroupHeaderSection1"]).ReportObjects["Text36"].ObjectFormat.EnableSuppress = true;
                        ((Section)master.Report.ReportDefinition.Sections["GroupHeaderSection1"]).ReportObjects["Text38"].ObjectFormat.EnableSuppress = true;
                        ((Section)master.Report.ReportDefinition.Sections["GroupHeaderSection1"]).ReportObjects["Text2"].ObjectFormat.EnableSuppress = true;
                        ((Section)master.Report.ReportDefinition.Sections["GroupHeaderSection1"]).ReportObjects["headerTotalSubcontractorsUsd"].ObjectFormat.EnableSuppress = true;

                        ((Section)master.Report.ReportDefinition.Sections["Section3"]).ReportObjects["TotalLabourHoursUsd1"].ObjectFormat.EnableSuppress = true;
                        ((Section)master.Report.ReportDefinition.Sections["Section3"]).ReportObjects["TotalUnitsUsd1"].ObjectFormat.EnableSuppress = true;
                        ((Section)master.Report.ReportDefinition.Sections["Section3"]).ReportObjects["TotalMaterialsUsd1"].ObjectFormat.EnableSuppress = true;
                        ((Section)master.Report.ReportDefinition.Sections["Section3"]).ReportObjects["TotalOtherCostsUsd1"].ObjectFormat.EnableSuppress = true;
                        ((Section)master.Report.ReportDefinition.Sections["Section3"]).ReportObjects["GrandTotalUsd1"].ObjectFormat.EnableSuppress = true;
                        ((Section)master.Report.ReportDefinition.Sections["Section3"]).ReportObjects["TotalSubcontractorsUsd1"].ObjectFormat.EnableSuppress = true;

                        ((Section)master.Report.ReportDefinition.Sections["GroupFooterSection1"]).ReportObjects["Text5"].ObjectFormat.EnableSuppress = true;
                        ((Section)master.Report.ReportDefinition.Sections["GroupFooterSection1"]).ReportObjects["GrandTotalUsd2"].ObjectFormat.EnableSuppress = true;

                        // Labour Hours
                        ReportDocument rpLabourHoursDetails = master.Report.OpenSubreport("LabourHoursDetails");
                        ReportDocument rpLabourHoursResume = master.Report.OpenSubreport("LabourHoursResume");

                        ((Section)rpLabourHoursDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text5"].ObjectFormat.EnableSuppress = true;
                        ((Section)rpLabourHoursDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text2"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpLabourHoursDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["LHCostUsd1"].ObjectFormat.EnableSuppress = true;
                        ((Section)rpLabourHoursDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["TotalCostUsd1"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpLabourHoursDetails.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostUsd2"].ObjectFormat.EnableSuppress = true;
                        //
                        ((Section)rpLabourHoursResume.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text2"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpLabourHoursResume.ReportDefinition.Sections["GroupFooterSection1"]).ReportObjects["SumofTotalCostUsd1"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpLabourHoursResume.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostUsd2"].ObjectFormat.EnableSuppress = true;

                        // Units
                        ReportDocument rpUnitsDetails = master.Report.OpenSubreport("UnitsDetails");
                        ReportDocument rpUnitsResume = master.Report.OpenSubreport("UnitsResume");

                        ((Section)rpUnitsDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text3"].ObjectFormat.EnableSuppress = true;
                        ((Section)rpUnitsDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text2"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpUnitsDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["CostUsd1"].ObjectFormat.EnableSuppress = true;
                        ((Section)rpUnitsDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["TotalCostUsd1"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpUnitsDetails.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostUsd2"].ObjectFormat.EnableSuppress = true;
                        //
                        ((Section)rpUnitsResume.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text6"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpUnitsResume.ReportDefinition.Sections["GroupFooterSection1"]).ReportObjects["SumofTotalCostUsd1"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpUnitsResume.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostUsd2"].ObjectFormat.EnableSuppress = true;

                        // Materials
                        ReportDocument rpMaterialsDetails = master.Report.OpenSubreport("MaterialsDetails");
                        ReportDocument rpMaterialsResune = master.Report.OpenSubreport("MaterialsResume");

                        ((Section)rpMaterialsDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text3"].ObjectFormat.EnableSuppress = true;
                        ((Section)rpMaterialsDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text2"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpMaterialsDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["CostUsd1"].ObjectFormat.EnableSuppress = true;
                        ((Section)rpMaterialsDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["TotalCostUsd1"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpMaterialsDetails.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostUsd2"].ObjectFormat.EnableSuppress = true;

                        ///
                        ((Section)rpMaterialsResune.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text6"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpMaterialsResune.ReportDefinition.Sections["GroupFooterSection1"]).ReportObjects["SumofTotalCostUsd1"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpMaterialsResune.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostUsd2"].ObjectFormat.EnableSuppress = true;

                        // Subcontractors
                        ReportDocument rpSubcontractorsDetails = master.Report.OpenSubreport("SubcontractorsDetails");
                        //ReportDocument rpSubcontractorsResune = master.Report.OpenSubreport("SubcontractorsResume");

                        ((Section)rpSubcontractorsDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text3"].ObjectFormat.EnableSuppress = true;
                        ((Section)rpSubcontractorsDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text2"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpSubcontractorsDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["CostUsd1"].ObjectFormat.EnableSuppress = true;
                        ((Section)rpSubcontractorsDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["TotalCostUsd1"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpSubcontractorsDetails.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostUsd1"].ObjectFormat.EnableSuppress = true;

                        ///
                        //((Section)rpSubcontractorsResune.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text6"].ObjectFormat.EnableSuppress = true;

                        //((Section)rpSubcontractorsResune.ReportDefinition.Sections["GroupFooterSection1"]).ReportObjects["SumofTotalCostUsd1"].ObjectFormat.EnableSuppress = true;

                        //((Section)rpSubcontractorsResune.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostUsd2"].ObjectFormat.EnableSuppress = true;

                        // Other Costs
                        ReportDocument rpOtherCostsDetails = master.Report.OpenSubreport("OtherCostsDetails");
                        ReportDocument rpOtherCostsResume = master.Report.OpenSubreport("OtherCostsResume");

                        ((Section)rpOtherCostsDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text3"].ObjectFormat.EnableSuppress = true;
                        ((Section)rpOtherCostsDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text2"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpOtherCostsDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["CostUsd1"].ObjectFormat.EnableSuppress = true;
                        ((Section)rpOtherCostsDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["TotalCostUsd1"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpOtherCostsDetails.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostUsd2"].ObjectFormat.EnableSuppress = true;

                        ///
                        ((Section)rpOtherCostsResume.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text6"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpOtherCostsResume.ReportDefinition.Sections["GroupFooterSection1"]).ReportObjects["SumofTotalCostUsd1"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpOtherCostsResume.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostUsd2"].ObjectFormat.EnableSuppress = true;
                    }
                    else//USA
                    {
                        // General
                        ((Section)master.Report.ReportDefinition.Sections["GroupHeaderSection1"]).ReportObjects["Text31"].ObjectFormat.EnableSuppress = true;
                        ((Section)master.Report.ReportDefinition.Sections["GroupHeaderSection1"]).ReportObjects["Text33"].ObjectFormat.EnableSuppress = true;
                        ((Section)master.Report.ReportDefinition.Sections["GroupHeaderSection1"]).ReportObjects["Text35"].ObjectFormat.EnableSuppress = true;
                        ((Section)master.Report.ReportDefinition.Sections["GroupHeaderSection1"]).ReportObjects["Text37"].ObjectFormat.EnableSuppress = true;
                        ((Section)master.Report.ReportDefinition.Sections["GroupHeaderSection1"]).ReportObjects["Text1"].ObjectFormat.EnableSuppress = true;
                        ((Section)master.Report.ReportDefinition.Sections["GroupHeaderSection1"]).ReportObjects["headerTotalSubcontractorsCad"].ObjectFormat.EnableSuppress = true;

                        ((Section)master.Report.ReportDefinition.Sections["Section3"]).ReportObjects["TotalLabourHoursCad1"].ObjectFormat.EnableSuppress = true;
                        ((Section)master.Report.ReportDefinition.Sections["Section3"]).ReportObjects["TotalUnitsCad1"].ObjectFormat.EnableSuppress = true;
                        ((Section)master.Report.ReportDefinition.Sections["Section3"]).ReportObjects["TotalMaterialsCad1"].ObjectFormat.EnableSuppress = true;
                        ((Section)master.Report.ReportDefinition.Sections["Section3"]).ReportObjects["TotalOtherCostsCad1"].ObjectFormat.EnableSuppress = true;
                        ((Section)master.Report.ReportDefinition.Sections["Section3"]).ReportObjects["GrandTotalCad1"].ObjectFormat.EnableSuppress = true;
                        ((Section)master.Report.ReportDefinition.Sections["Section3"]).ReportObjects["TotalSubcontractorsCad1"].ObjectFormat.EnableSuppress = true;

                        ((Section)master.Report.ReportDefinition.Sections["GroupFooterSection1"]).ReportObjects["Text4"].ObjectFormat.EnableSuppress = true;
                        ((Section)master.Report.ReportDefinition.Sections["GroupFooterSection1"]).ReportObjects["GrandTotalCad2"].ObjectFormat.EnableSuppress = true;

                        // Labour Hours
                        ReportDocument rpLabourHoursDetails = master.Report.OpenSubreport("LabourHoursDetails");
                        ReportDocument rpLabourHoursResume = master.Report.OpenSubreport("LabourHoursResume");

                        ((Section)rpLabourHoursDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text9"].ObjectFormat.EnableSuppress = true;
                        ((Section)rpLabourHoursDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text6"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpLabourHoursDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["LHCostCad1"].ObjectFormat.EnableSuppress = true;
                        ((Section)rpLabourHoursDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["TotalCostCad1"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpLabourHoursDetails.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostCad2"].ObjectFormat.EnableSuppress = true;

                        //
                        ((Section)rpLabourHoursResume.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text4"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpLabourHoursResume.ReportDefinition.Sections["GroupFooterSection1"]).ReportObjects["SumofTotalCostCad1"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpLabourHoursResume.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostCad2"].ObjectFormat.EnableSuppress = true;

                        // Units
                        ReportDocument rpUnitsDetails = master.Report.OpenSubreport("UnitsDetails");
                        ReportDocument rpUnitsResume = master.Report.OpenSubreport("UnitsResume");

                        ((Section)rpUnitsDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text5"].ObjectFormat.EnableSuppress = true;
                        ((Section)rpUnitsDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text4"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpUnitsDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["CostCad1"].ObjectFormat.EnableSuppress = true;
                        ((Section)rpUnitsDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["TotalCostCad1"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpUnitsDetails.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostCad2"].ObjectFormat.EnableSuppress = true;

                        //
                        ((Section)rpUnitsResume.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text4"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpUnitsResume.ReportDefinition.Sections["GroupFooterSection1"]).ReportObjects["SumofTotalCostCad1"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpUnitsResume.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostCad2"].ObjectFormat.EnableSuppress = true;

                        // Materials
                        ReportDocument rpMaterialsDetails = master.Report.OpenSubreport("MaterialsDetails");
                        ReportDocument rpMaterialsResune = master.Report.OpenSubreport("MaterialsResume");

                        ((Section)rpMaterialsDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text5"].ObjectFormat.EnableSuppress = true;
                        ((Section)rpMaterialsDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text4"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpMaterialsDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["CostCad1"].ObjectFormat.EnableSuppress = true;
                        ((Section)rpMaterialsDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["TotalCostCad1"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpMaterialsDetails.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostCad2"].ObjectFormat.EnableSuppress = true;

                        ///
                        ((Section)rpMaterialsResune.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text4"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpMaterialsResune.ReportDefinition.Sections["GroupFooterSection1"]).ReportObjects["SumofTotalCostCad1"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpMaterialsResune.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostCad2"].ObjectFormat.EnableSuppress = true;

                        // Subcontractors
                        ReportDocument rpSubcontractorsDetails = master.Report.OpenSubreport("SubcontractorsDetails");

                        ((Section)rpSubcontractorsDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text5"].ObjectFormat.EnableSuppress = true;
                        ((Section)rpSubcontractorsDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text4"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpSubcontractorsDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["CostCad1"].ObjectFormat.EnableSuppress = true;
                        ((Section)rpSubcontractorsDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["TotalCostCad1"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpSubcontractorsDetails.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostCad1"].ObjectFormat.EnableSuppress = true;

                        // Other Costs
                        ReportDocument rpOtherCostsDetails = master.Report.OpenSubreport("OtherCostsDetails");
                        ReportDocument rpOtherCostsResume = master.Report.OpenSubreport("OtherCostsResume");

                        ((Section)rpOtherCostsDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text5"].ObjectFormat.EnableSuppress = true;
                        ((Section)rpOtherCostsDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text4"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpOtherCostsDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["CostCad1"].ObjectFormat.EnableSuppress = true;
                        ((Section)rpOtherCostsDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["TotalCostCad1"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpOtherCostsDetails.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostCad2"].ObjectFormat.EnableSuppress = true;

                        ///
                        ((Section)rpOtherCostsResume.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text4"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpOtherCostsResume.ReportDefinition.Sections["GroupFooterSection1"]).ReportObjects["SumofTotalCostCad1"].ObjectFormat.EnableSuppress = true;

                        ((Section)rpOtherCostsResume.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostCad2"].ObjectFormat.EnableSuppress = true;
                    }
                }
            }
        }
        private void Generate()
        {
            mReport1 master = (mReport1)this.Master;

            // Get Data
            string projectTimeState = (ddlProjectTimeState.SelectedValue == "(All)") ? "%" : ddlProjectTimeState.SelectedValue;
            DateTime startDate = DateTime.Parse(tkrdpStartDate.SelectedDate.Value.ToShortDateString());
            DateTime endDate = DateTime.Parse(tkrdpEndDate.SelectedDate.Value.ToShortDateString());
            int companyId = Int32.Parse(hdfCompanyId.Value);

            PrintHoursForProjectGateway printHoursForProjectGateway = new PrintHoursForProjectGateway();
            if (ddlEmployeeType.SelectedValue == "(All)")
            {
                if (ddlClient.SelectedValue == "-1")
                {
                    printHoursForProjectGateway.LoadByStartDateEndDateProjectTimeState(startDate, endDate, projectTimeState, companyId);
                }
                else
                {
                    if (ddlProject.SelectedValue == "-1")
                    {
                        printHoursForProjectGateway.LoadByCompaniesIdStartDateEndDateProjectTimeState(int.Parse(ddlClient.SelectedValue), startDate, endDate, projectTimeState, companyId);
                    }
                    else
                    {
                        printHoursForProjectGateway.LoadByCompaniesIdProjectIdStartDateEndDateProjectTimeState(int.Parse(ddlClient.SelectedValue), int.Parse(ddlProject.SelectedValue), startDate, endDate, projectTimeState, companyId);
                    }
                }
            }
            else
            {
                string teamMemberType = ddlEmployeeType.SelectedValue;
                if (ddlClient.SelectedValue == "-1")
                {
                    printHoursForProjectGateway.LoadByStartDateEndDateProjectTimeStateTeamMemberType(startDate, endDate, projectTimeState, teamMemberType, companyId);
                }
                else
                {
                    if (ddlProject.SelectedValue == "-1")
                    {
                        printHoursForProjectGateway.LoadByCompaniesIdStartDateEndDateProjectTimeStateTeamMemberType(Int32.Parse(ddlClient.SelectedValue), startDate, endDate, projectTimeState, teamMemberType, companyId);
                    }
                    else
                    {
                        printHoursForProjectGateway.LoadByCompaniesIdProjectIdStartDateEndDateProjectTimeStateTeamMemberType(Int32.Parse(ddlClient.SelectedValue), int.Parse(ddlProject.SelectedValue), startDate, endDate, projectTimeState, teamMemberType, companyId);
                    }
                }
            }

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

            // Get report
            if (printHoursForProjectGateway.Table.Rows.Count > 0)
            {
                if (master.Format == "pdf")
                {
                    master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ProjectTime.PrintHoursForProjectReport();
                }
                else
                {
                    master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ProjectTime.PrintHoursForProjectReportExport();
                }

                // ... 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);
                    }

                    // ... ... team member type
                    if (ddlEmployeeType.SelectedValue == "(All)")
                    {
                        master.SetParameter("teamMemberType", "All");
                    }
                    else
                    {
                        if (ddlEmployeeType.SelectedValue == "LFSCA") master.SetParameter("teamMemberType", "LFS Canada");
                        if (ddlEmployeeType.SelectedValue == "LFSUS") master.SetParameter("teamMemberType", "LFS USA");
                        if (ddlEmployeeType.SelectedValue == "LFS") master.SetParameter("teamMemberType", "All LFS");
                        if (ddlEmployeeType.SelectedValue == "PAGCA") master.SetParameter("teamMemberType", "PAG Canada");
                        if (ddlEmployeeType.SelectedValue == "PAGUS") master.SetParameter("teamMemberType", "PAG USA");
                        if (ddlEmployeeType.SelectedValue == "PAG") master.SetParameter("teamMemberType", "All PAG");
                        if (ddlEmployeeType.SelectedValue == "SOTA") master.SetParameter("teamMemberType", "SOTA");
                        if (ddlEmployeeType.SelectedValue == "Salaried") master.SetParameter("teamMemberType", "Salaried");
                        if (ddlEmployeeType.SelectedValue == "Subcontractor") master.SetParameter("teamMemberType", "Subcontractor");
                    }

                    // ... ...  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
                    {
                        int currentClientId = Int32.Parse(ddlClient.SelectedValue);
                        CompaniesGateway companiesGateway = new CompaniesGateway();
                        companiesGateway.LoadByCompaniesId(currentClientId, companyId);
                        master.SetParameter("Client", companiesGateway.GetName(currentClientId));
                    }

                    // ... ... 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);
                    }

                    master.SetParameter("dateFrom", tkrdpStartDate.SelectedDate.Value.ToShortDateString());
                    master.SetParameter("dateTo", tkrdpEndDate.SelectedDate.Value.ToShortDateString());
                }
                else
                {
                    master.SetParameter("startDate", tkrdpStartDate.SelectedDate.Value.ToShortDateString());
                    master.SetParameter("endDate", tkrdpEndDate.SelectedDate.Value.ToShortDateString());
                }
            }
        }
        private void Generate2()
        {
            mReportForM12 master = (mReportForM12)this.Master;
            string unitType = ddlUnitType.SelectedValue;

            // Get Data
            LiquiForce.LFSLive.BL.CWP.FullLengthLining.FlM2Report flM2Report = new LiquiForce.LFSLive.BL.CWP.FullLengthLining.FlM2Report();

            if (ddlClient.SelectedValue == "-1")
            {
                if (cbxSectionId.Checked)
                {
                    ArrayList sectionsId = new ArrayList();
                    foreach (ListItem lst in cbxlSectionId.Items)
                    {
                        if (lst.Selected)
                        {
                            sectionsId.Add(lst.Value);
                        }
                    }

                    flM2Report.LoadBySectionId(int.Parse(hdfCompanyId.Value), sectionsId, unitType);
                }
                else
                {
                    if (cbxDate.Checked)
                    {
                        DateTime m1Date = DateTime.Parse(tkrdpDate.SelectedDate.Value.ToShortDateString());
                        flM2Report.LoadByDate(int.Parse(hdfCompanyId.Value), m1Date.ToShortDateString(), unitType);
                    }
                    else
                    {
                        if (cbxStreet.Checked)
                        {
                            flM2Report.LoadByStreet(int.Parse(hdfCompanyId.Value), tbxStreet.Text.Trim(), unitType);
                        }
                        else
                        {
                            if (cbxSubArea.Checked)
                            {
                                flM2Report.LoadBySubArea(int.Parse(hdfCompanyId.Value), tbxSubArea.Text.Trim(), unitType);
                            }
                            else
                            {
                                flM2Report.Load(int.Parse(hdfCompanyId.Value), unitType);
                            }
                        }
                    }
                }
            }
            else
            {
                if (ddlProject.SelectedValue == "-1")
                {
                    if (cbxSectionId.Checked)
                    {
                        ArrayList sectionsId = new ArrayList();
                        foreach (ListItem lst in cbxlSectionId.Items)
                        {
                            if (lst.Selected)
                            {
                                sectionsId.Add(lst.Value);
                            }
                        }

                        flM2Report.LoadByCompaniesIdSectionId(int.Parse(hdfCompanyId.Value), int.Parse(ddlClient.SelectedValue), unitType, sectionsId);
                    }
                    else
                    {
                        if (cbxDate.Checked)
                        {
                            DateTime m1Date = DateTime.Parse(tkrdpDate.SelectedDate.Value.ToShortDateString());
                            flM2Report.LoadByCompaniesIdDate(int.Parse(hdfCompanyId.Value), int.Parse(ddlClient.SelectedValue), unitType, m1Date.ToShortDateString());
                        }
                        else
                        {
                            if (cbxStreet.Checked)
                            {
                                flM2Report.LoadByCompaniesIdStreet(int.Parse(hdfCompanyId.Value), int.Parse(ddlClient.SelectedValue), unitType, tbxStreet.Text.Trim());
                            }
                            else
                            {
                                if (cbxSubArea.Checked)
                                {
                                    flM2Report.LoadByCompaniesIdSubArea(int.Parse(hdfCompanyId.Value), int.Parse(ddlClient.SelectedValue), unitType, tbxSubArea.Text.Trim());
                                }
                                else
                                {
                                    flM2Report.LoadByCompaniesId(int.Parse(hdfCompanyId.Value), int.Parse(ddlClient.SelectedValue), unitType);
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (cbxSectionId.Checked)
                    {
                        ArrayList sectionsId = new ArrayList();
                        foreach (ListItem lst in cbxlSectionId.Items)
                        {
                            if (lst.Selected)
                            {
                                sectionsId.Add(lst.Value);
                            }
                        }

                        flM2Report.LoadByCompaniesIdProjectIdSectionId(int.Parse(hdfCompanyId.Value), int.Parse(ddlClient.SelectedValue), int.Parse(ddlProject.SelectedValue), unitType, sectionsId);
                    }
                    else
                    {
                        if (cbxDate.Checked)
                        {
                            DateTime m1Date = DateTime.Parse(tkrdpDate.SelectedDate.Value.ToShortDateString());
                            flM2Report.LoadByCompaniesIdProjectIdDate(int.Parse(hdfCompanyId.Value), int.Parse(ddlClient.SelectedValue), int.Parse(ddlProject.SelectedValue), unitType, m1Date.ToShortDateString());
                        }
                        else
                        {
                            if (cbxStreet.Checked)
                            {
                                flM2Report.LoadByCompaniesIdProjectIdStreet(int.Parse(hdfCompanyId.Value), int.Parse(ddlClient.SelectedValue), int.Parse(ddlProject.SelectedValue), unitType, tbxStreet.Text.Trim());
                            }
                            else
                            {
                                if (cbxSubArea.Checked)
                                {
                                    flM2Report.LoadByCompaniesIdProjectIdSubArea(int.Parse(hdfCompanyId.Value), int.Parse(ddlClient.SelectedValue), int.Parse(ddlProject.SelectedValue), unitType, tbxSubArea.Text.Trim());
                                }
                                else
                                {
                                    flM2Report.LoadByCompaniesIdProjectId(int.Parse(hdfCompanyId.Value), int.Parse(ddlClient.SelectedValue), int.Parse(ddlProject.SelectedValue), unitType);
                                }
                            }
                        }
                    }
                }
            }

            // ... set properties to master page
            master.Data2 = flM2Report.Data;
            master.Table2 = flM2Report.TableName;

            // Get report
            if (flM2Report.Table.Rows.Count > 0)
            {
                if (master.Format2 == "pdf")
                {
                    master.Report2 = new FlM2Report();
                }
                else
                {
                    master.Report2 = new FlM2ReportExport();
                }

                // ... set parameters to report
                int companyId = Convert.ToInt32(Session["companyID"]);
                if (master.Format2 == "pdf")
                {
                    if (ddlClient.SelectedValue != "-1")
                    {
                        // ... for client
                        int currentCompanyId = Int32.Parse(ddlClient.SelectedValue);
                        CompaniesGateway companiesGateway = new CompaniesGateway();
                        companiesGateway.LoadByCompaniesId(currentCompanyId, companyId);
                        master.SetParameter2("Client", companiesGateway.GetName(currentCompanyId));
                    }
                    else
                    {
                        master.SetParameter2("Client", "All");
                    }

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

                    master.SetParameter2("UnitType", unitType);

                    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.SetParameter2("User", user.Trim());
                }
            }
        }
        private void Generate()
        {
            mReport1 master = (mReport1)this.Master;

            // Get Data
            LinningPlanTDS linningPlanTDS = (LinningPlanTDS)Session["linningPlanTDS"];
            LiquiForce.LFSLive.BL.CWP.Jliner.LinningPlan linningPlan = new LiquiForce.LFSLive.BL.CWP.Jliner.LinningPlan();
            linningPlan.ProcessForReport(linningPlanTDS);

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

            // Get report
            int companyId = Convert.ToInt32(Session["companyID"]);
            if (linningPlan.Table.Rows.Count > 0)
            {
                master.Report = new LinningPlan();

                // ... for client
                int currentClientId = Int32.Parse(hdfCurrentClientId.Value);
                CompaniesGateway companiesGateway = new CompaniesGateway();
                companiesGateway.LoadByCompaniesId(currentClientId, companyId);
                master.SetParameter("Client", companiesGateway.GetName(currentClientId));

                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());
            }
        }
        private void Generate()
        {
            mReport1 master = (mReport1)this.Master;
            int companyId = Convert.ToInt32(Session["companyID"]);

            ProjectCostingSheetInformationReportInformation projectCostingSheetInformationReportInformation = new ProjectCostingSheetInformationReportInformation();

            if (ddlClient.SelectedValue == "-1")
            {
                projectCostingSheetInformationReportInformation.Load(companyId);
            }
            else
            {
                if (ddlProject.SelectedValue == "-1")
                {
                    projectCostingSheetInformationReportInformation.LoadByCompaniesId(Int32.Parse(ddlClient.SelectedValue), companyId);
                }
                else
                {
                    projectCostingSheetInformationReportInformation.LoadByCompaniesIdProjectId(Int32.Parse(ddlClient.SelectedValue), Int32.Parse(ddlProject.SelectedValue), companyId);
                }
            }

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

            // Get report
            if (projectCostingSheetInformationReportInformation.Table.Rows.Count > 0)
            {
                if (master.Format == "pdf")
                {
                    master.Report = new ConsolidatedCostingSheetReport();
                    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());

                    // For process code
                    ProjectCostingSheetInformationReportInformationGateway projectCostingSheetInformationReportInformationGateway = new ProjectCostingSheetInformationReportInformationGateway(projectCostingSheetInformationReportInformation.Data);

                    // ... ... client
                    if (ddlClient.SelectedValue == "-1")
                    {
                        master.SetParameter("client", "All");
                    }
                    else
                    {
                        CompaniesGateway companiesGateway = new CompaniesGateway();
                        companiesGateway.LoadByCompaniesId(Int32.Parse(ddlClient.SelectedValue), Int32.Parse(hdfCompanyId.Value));
                        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);
                    }
                }
                else
                {
                    master.Report = new ConsolidatedCostingSheetPreviewReport();
                }
            }
        }
        private void Generate()
        {
            mReport1 master = (mReport1)this.Master;

            // Get Data
            string orderBy = ddlOrderBy.SelectedValue;
            string whereClause = "(P.Deleted = 0) AND (P.ProjectType = 'Ballpark') AND (P.ProjectState = 'Active')";

            if (ddlCountry.SelectedValue != "(All)")
            {
                if (whereClause.Length > 0) whereClause += " AND ";
                whereClause += "(P.CountryID = " + ddlCountry.SelectedValue + ")";
            }

            if (ddlClient.SelectedValue != "-1")
            {
                if (whereClause.Length > 0) whereClause += " AND ";
                whereClause += "(P.ClientID = " + ddlClient.SelectedValue + ")";
            }

            if (ddlSalesman.SelectedValue != "-1")
            {
                if (whereClause.Length > 0) whereClause += " AND ";
                whereClause += "(P.SalesmanID = " + ddlSalesman.SelectedValue + ")";
            }

            LiquiForce.LFSLive.BL.Projects.Projects.BallparkSummaryReport ballparkSummayReport = new LiquiForce.LFSLive.BL.Projects.Projects.BallparkSummaryReport();
            ballparkSummayReport.LoadWhereOrderBy(whereClause, orderBy, ddlCurrency.SelectedValue, decimal.Parse(tbxExchangeRate.Text));

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

            // Get report
            if (ballparkSummayReport.Table.Rows.Count > 0)
            {
                if (master.Format == "pdf")
                {
                    master.Report = new LiquiForce.LFSLive.WebUI.Projects.Projects.BallparkSummaryReport();
                }
                else
                {
                    master.Report = new LiquiForce.LFSLive.WebUI.Projects.Projects.BallparkSummaryReportExport();
                }

                // ... set parameters to report
                if (master.Format == "pdf")
                {
                    // ... For report
                    master.SetParameter("ExchangeRate", decimal.Parse(tbxExchangeRate.Text.Trim()));
                    master.SetParameter("Total", "Total (" + ddlCurrency.SelectedValue.Trim() + "):");
                    master.SetParameter("Currency", ddlCurrency.SelectedValue.Trim());

                    // ... ...  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
                    {
                        CompaniesGateway companiesGateway = new CompaniesGateway();
                        companiesGateway.LoadByCompaniesId(Int32.Parse(ddlClient.SelectedValue), companyId);
                        string clientName = companiesGateway.GetName(Int32.Parse(ddlClient.SelectedValue));
                        master.SetParameter("Client", clientName);
                    }

                    // ... ... salesman
                    if (ddlSalesman.SelectedValue == "-1")
                    {
                        master.SetParameter("Salesman", "All");
                    }
                    else
                    {
                        EmployeeGateway employeeGateway = new EmployeeGateway();
                        employeeGateway.LoadByEmployeeId(Int32.Parse(ddlSalesman.SelectedValue));
                        string salesman = employeeGateway.GetFullName(Int32.Parse(ddlSalesman.SelectedValue));
                        master.SetParameter("Salesman", salesman);
                    }

                    // ... ... country
                    if (ddlCountry.SelectedValue == "2")
                    {
                        master.SetParameter("Country", "USA");
                    }
                    else
                    {
                        if (ddlCountry.SelectedValue == "1")
                        {
                            master.SetParameter("Country", "Canada");
                        }
                        else
                        {
                            master.SetParameter("Country", "All");
                        }
                    }

                    // ... ... order by
                    if (ddlOrderBy.SelectedValue == "P.CountryID")
                    {
                        master.SetParameter("OrderBy", "Country");
                    }
                    else
                    {
                        if (ddlOrderBy.SelectedValue == "P.ProjectNumber")
                        {
                            master.SetParameter("OrderBy", "Project Number");
                        }
                        else
                        {
                            if (ddlOrderBy.SelectedValue == "P.Name")
                            {
                                master.SetParameter("OrderBy", "Project Name");
                            }
                            else
                            {
                                if (ddlOrderBy.SelectedValue == "C.Name")
                                {
                                    master.SetParameter("OrderBy", "Client");
                                }
                                else
                                {
                                    master.SetParameter("OrderBy", "Salesman");
                                }
                            }
                        }
                    }
                }
                else
                {
                    master.SetParameter("ExchangeRate", decimal.Parse(tbxExchangeRate.Text.Trim()));
                    master.SetParameter("Total", "Total (" + ddlCurrency.SelectedValue.Trim() + "):");
                }
            }
        }
        private void Generate()
        {
            mReport1 master = (mReport1)this.Master;

            // Get Data
            LiquiForce.LFSLive.BL.CWP.FullLengthLining.FlOutstandingInvestigationIssuesReport flOutstandingInvestigationIssuesReport = new LiquiForce.LFSLive.BL.CWP.FullLengthLining.FlOutstandingInvestigationIssuesReport();

            if (ddlClient.SelectedValue == "-1")
            {
                flOutstandingInvestigationIssuesReport.Load(int.Parse(hdfCompanyId.Value));
            }
            else
            {
                if (ddlProject.SelectedValue == "-1")
                {
                    flOutstandingInvestigationIssuesReport.LoadByCompaniesId(int.Parse(hdfCompanyId.Value), int.Parse(ddlClient.SelectedValue));
                }
                else
                {
                    flOutstandingInvestigationIssuesReport.LoadByCompaniesIdProjectId(int.Parse(hdfCompanyId.Value), int.Parse(ddlClient.SelectedValue), int.Parse(ddlProject.SelectedValue));
                }
            }

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

            // Get report
            if (flOutstandingInvestigationIssuesReport.Table.Rows.Count > 0)
            {
                if (master.Format == "pdf")
                {
                    master.Report = new FlOutstandingInvestigationIssuesReport();
                }
                else
                {
                    master.Report = new FlOutstandingInvestigationIssuesReportExport();
                }

                // ... set parameters to report
                int companyId = Convert.ToInt32(Session["companyID"]);
                if (master.Format == "pdf")
                {
                    if (ddlClient.SelectedValue != "-1")
                    {
                        // ... for client
                        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");
                    }

                    if (ddlProject.SelectedValue != "-1")
                    {
                        // ... for project
                        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");
                    }

                    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());
                }
            }
        }
        private void Generate()
        {
            mReport1 master = (mReport1)this.Master;

            // Get Data
            string projectTimeState = (ddlProjectTimeState.SelectedValue == "(All)") ? "%" : ddlProjectTimeState.SelectedValue;
            DateTime startDate = DateTime.Parse(tkrdpStartDate.SelectedDate.Value.ToShortDateString());
            DateTime endDate = DateTime.Parse(tkrdpEndDate.SelectedDate.Value.ToShortDateString());
            string work_ = "all"; if (ddlTypeOfWork.SelectedValue != "(All)") work_ = ddlTypeOfWork.SelectedValue;
            string function_ = "all"; if (ddlFunction.SelectedValue != "(All)") function_ = ddlFunction.SelectedValue;
            int companyId = Int32.Parse(hdfCompanyId.Value);

            LiquiForce.LFSLive.BL.LabourHours.ProjectTime.PrintProjectCosting printProjectCosting = new LiquiForce.LFSLive.BL.LabourHours.ProjectTime.PrintProjectCosting();

            if (ddlClient.SelectedValue == "-1")
            {
                if (ddlTypeOfWork.SelectedValue == "(All)")
                {
                    // ... ... For all types of work and all functions
                    printProjectCosting.LoadByStartDateEndDateProjectTimeState(startDate, endDate, projectTimeState, companyId);
                }
                else
                {
                    if (ddlFunction.SelectedValue == "(All)")
                    {
                        // ... ... For specific type of work and all functions
                        printProjectCosting.LoadByStartDateEndDateProjectTimeStateWork(startDate, endDate, projectTimeState, work_, companyId);
                    }
                    else
                    {
                        // ... ... For specific type of work and specific function
                        printProjectCosting.LoadByStartDateEndDateProjectTimeStateWorkFunction(startDate, endDate, projectTimeState, work_, function_, companyId);
                    }
                }
            }
            else
            {
                if (ddlProject.SelectedValue == "-1")
                {
                    if (ddlTypeOfWork.SelectedValue == "(All)")
                    {
                        // ... ... For all types of work and all functions
                        printProjectCosting.LoadByCompaniesIdStartDateEndDateProjectTimeState(int.Parse(ddlClient.SelectedValue), startDate, endDate, projectTimeState, companyId);
                    }
                    else
                    {
                        if (ddlFunction.SelectedValue == "(All)")
                        {
                            // ... ... For specific type of work and all functions
                            printProjectCosting.LoadByCompaniesIdStartDateEndDateProjectTimeStateWork(int.Parse(ddlClient.SelectedValue), startDate, endDate, projectTimeState, work_, companyId);
                        }
                        else
                        {
                            // ... ... For specific type of work and specific function
                            printProjectCosting.LoadByCompaniesIdStartDateEndDateProjectTimeStateWorkFunction(int.Parse(ddlClient.SelectedValue), startDate, endDate, projectTimeState, work_, function_, companyId);
                        }
                    }
                }
                else
                {
                    if (ddlTypeOfWork.SelectedValue == "(All)")
                    {
                        // ... ... For all types of work and all functions
                        printProjectCosting.LoadByCompaniesIdProjectIdStartDateEndDateProjectTimeState(int.Parse(ddlClient.SelectedValue), int.Parse(ddlProject.SelectedValue), startDate, endDate, projectTimeState, companyId);
                    }
                    else
                    {
                        if (ddlFunction.SelectedValue == "(All)")
                        {
                            // ... ... For specific type of work and all functions
                            printProjectCosting.LoadByCompaniesIdProjectIdStartDateEndDateProjectTimeStateWork(int.Parse(ddlClient.SelectedValue), int.Parse(ddlProject.SelectedValue), startDate, endDate, projectTimeState, work_, companyId);
                        }
                        else
                        {
                            // ... ... For specific type of work and specific function
                            printProjectCosting.LoadByCompaniesIdProjectIdStartDateEndDateProjectTimeStateWorkFunction(int.Parse(ddlClient.SelectedValue), int.Parse(ddlProject.SelectedValue), startDate, endDate, projectTimeState, work_, function_, companyId);
                        }
                    }
                }
            }

            LiquiForce.LFSLive.DA.LabourHours.ProjectTime.PrintProjectCostingGateway printProjectCostingGateway = new LiquiForce.LFSLive.DA.LabourHours.ProjectTime.PrintProjectCostingGateway(printProjectCosting.Data);

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

            // Get report
            if (printProjectCostingGateway.Table.Rows.Count > 0)
            {
                if (master.Format == "pdf")
                {
                    master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ProjectTime.PrintProjectCostingReport();
                }
                else
                {
                    master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ProjectTime.PrintProjectCostingReportExport();
                }

                // ... 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
                    {
                        int currentClientId = Int32.Parse(ddlClient.SelectedValue);
                        CompaniesGateway companiesGateway = new CompaniesGateway();
                        companiesGateway.LoadByCompaniesId(currentClientId, companyId);
                        master.SetParameter("Client", companiesGateway.GetName(currentClientId));
                    }

                    // ... ... 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);
                    }

                    // ... ... type of work
                    if (ddlTypeOfWork.SelectedValue == "(All)")
                    {
                        master.SetParameter("typeOfWork", "All");
                    }
                    else
                    {
                        master.SetParameter("typeOfWork", ddlTypeOfWork.SelectedValue);
                    }

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

                    // ... ... Date
                    master.SetParameter("dateFrom", tkrdpStartDate.SelectedDate.Value.ToShortDateString());
                    master.SetParameter("dateTo", tkrdpEndDate.SelectedDate.Value.ToShortDateString());
                }
                else
                {
                    // ... ... Date
                    master.SetParameter("startDate", tkrdpStartDate.SelectedDate.Value.ToShortDateString());
                    master.SetParameter("endDate", tkrdpEndDate.SelectedDate.Value.ToShortDateString());
                }
            }
        }