/// <summary>
 /// InitData. Create a PrintManhoursPerPhaseTDS dataset
 /// </summary>
 protected override void InitData()
 {
     _data = new PrintManhoursPerPhaseTDS();
 }
        private void GenerateAll()
        {
            // Get Data
            string accessType = (ddlAccessType.SelectedValue == "(All)") ? "%" : ddlAccessType.SelectedValue;
            DateTime startDate = DateTime.Parse(tkrdpStartDate.SelectedDate.Value.ToShortDateString());
            DateTime endDate = DateTime.Parse(tkrdpEndDate.SelectedDate.Value.ToShortDateString());
            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;
            string projectTimeState = (ddlProjectTimeState.SelectedValue == "(All)") ? "%" : ddlProjectTimeState.SelectedItem.Text;
            int companyId = Int32.Parse(hdfCompanyId.Value);
            string confirmedSize1 = (ddlConfirmedSize.SelectedValue == "(All)") ? "%" : ddlConfirmedSize.SelectedValue;
            string confirmedSize2 = "%"; //By default
            switch (confirmedSize1)
            {
                case "8":
                    confirmedSize1 = "8%";
                    confirmedSize2 = "200%";
                    break;
                case "10":
                    confirmedSize1 = "10%";
                    confirmedSize2 = "250%";
                    break;
                case "12":
                    confirmedSize1 = "12%";
                    confirmedSize2 = "300%";
                    break;
                case "15":
                    confirmedSize1 = "15%";
                    confirmedSize2 = "375%";
                    break;
                case "18":
                    confirmedSize1 = "18%";
                    confirmedSize2 = "450%";
                    break;
                case "21":
                    confirmedSize1 = "21%";
                    confirmedSize2 = "525%";
                    break;
                case "24":
                    confirmedSize1 = "24%";
                    confirmedSize2 = "600%";
                    break;
                case "27":
                    confirmedSize1 = "27%";
                    confirmedSize2 = "675%";
                    break;
                case "30":
                    confirmedSize1 = "30%";
                    confirmedSize2 = "750%";
                    break;
            }
            //string work_ = "";
            //string function_ = "";

            int? countryId = null;

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

            mReport1 master = (mReport1)this.Master;
            PrintManhoursPerPhaseTDS printManhoursPerPhaseTDS = new PrintManhoursPerPhaseTDS();

            bool existData = true;

            // Get report
            if (existData)
            {
                LiquiForce.LFSLive.BL.LabourHours.ProjectTime.PrintManhoursPerPhaseGeneral printManhoursPerPhaseGeneral = new LiquiForce.LFSLive.BL.LabourHours.ProjectTime.PrintManhoursPerPhaseGeneral(printManhoursPerPhaseTDS);

                if (ddlClient.SelectedIndex == 0)
                {
                    if (ddlCountry.SelectedIndex == 0)
                    {
                        printManhoursPerPhaseGeneral.Load(companyId, startDate, endDate, projectTimeState, confirmedSize1, confirmedSize2, accessType, shape, conditionRating, location, material, crew);
                    }
                    else
                    {
                        printManhoursPerPhaseGeneral.LoadByCountryId(companyId, countryId.Value, startDate, endDate, projectTimeState, confirmedSize1, confirmedSize2, accessType, shape, conditionRating, location, material, crew);
                    }
                }
                else
                {
                    if (ddlProject.SelectedIndex == 0)
                    {
                        printManhoursPerPhaseGeneral.LoadByClientId(companyId, Convert.ToInt32(ddlClient.SelectedValue), startDate, endDate, projectTimeState, confirmedSize1, confirmedSize2, accessType, shape, conditionRating, location, material, crew);
                    }
                    else
                    {
                        printManhoursPerPhaseGeneral.LoadByProjectId(companyId, Convert.ToInt32(ddlProject.SelectedValue), startDate, endDate, projectTimeState, confirmedSize1, confirmedSize2, accessType, shape, conditionRating, location, material, crew);
                    }
                }

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

                if (master.Format == "pdf")
                {
                    master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ProjectTime.PrintManhoursPerPhaseGeneralReport();

                    // ... 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
                    {
                        string clientName = ddlClient.SelectedItem.Text;
                        master.SetParameter("client", clientName);
                    }

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

                    // ... ... phase / function
                    master.SetParameter("phase", ddlPhase.SelectedItem.Text);

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

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

                    // ... ... Condition Rating
                    if (ddlConditioningRating.SelectedValue == "(All)")
                    {
                        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);
                    }

                    // ... ... Confirmed Size
                    if (ddlConfirmedSize.SelectedValue == "(All)")
                    {
                        master.SetParameter("ConfirmedSize", "All");
                    }
                    else
                    {
                        master.SetParameter("ConfirmedSize", ddlConfirmedSize.SelectedValue);
                    }

                    // ... ... Access Type
                    if (ddlAccessType.SelectedValue == "(All)")
                    {
                        master.SetParameter("AccessType", "All");
                    }
                    else
                    {
                        master.SetParameter("AccessType", ddlAccessType.SelectedValue);
                    }
                }
                else
                {
                    master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ProjectTime.PrintManhoursPerPhaseGeneralReport();
                }
            }
        }