/// <summary>
 /// InitData
 /// </summary>
 protected override void InitData()
 {
     _data = new ProjectCostingSheetAddTDS();
 }
        // ////////////////////////////////////////////////////////////////////////
        // INITIAL EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Security check
                if (!Convert.ToBoolean(Session["sgLFS_PROJECTS_COSTINGSHEETS_ADMIN"]))
                {
                    if (!(Convert.ToBoolean(Session["sgLFS_PROJECTS_COSTINGSHEETS_VIEW"]) && Convert.ToBoolean(Session["sgLFS_PROJECTS_COSTINGSHEETS_ADD"])))
                    {
                        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))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in project_combined_costing_sheets_add.aspx");
                }

                if ((string)Request.QueryString["project_id"] == "0")
                {
                    if (Session["projectsSelected"] != null)
                    {
                        projectsSelected = (ArrayList)Session["projectsSelected"];
                    }
                    else
                    {
                        Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in project_combined_costing_sheets_add.aspx");
                    }
                }
                else
                {
                    projectsSelected = new ArrayList();
                    projectsSelected.Add(int.Parse((string)Request.QueryString["project_id"]));
                    Session["projectsSelected"] = projectsSelected;
                }

                // Tag Page
                TagPage();

                // Initialize viewstate variables
                ViewState["StepFrom"] = "Out";
                Session.Remove("labourHoursInformationDummy");
                Session.Remove("labourHoursInformation");
                Session.Remove("unitsInformationDummy");
                Session.Remove("unitsInformation");
                Session.Remove("subcontractorsInformationDummy");
                Session.Remove("subcontractorsInformation");
                Session.Remove("materialsInformationDummy");
                Session.Remove("materialsInformation");
                Session.Remove("otherCostsInformationDummy");
                Session.Remove("otherCostsInformation");
                Session.Remove("revenueInformationDummy");
                Session.Remove("revenueInformation");
                Session.Remove("templateInformationDummy");
                Session.Remove("templateInformation");

                // ... Initialize tables
                projectCostingSheetAddTDS = new ProjectCostingSheetAddTDS();
                labourHoursInformation = new ProjectCostingSheetAddTDS.CombinedLabourHoursInformationDataTable();
                unitsInformation = new ProjectCostingSheetAddTDS.CombinedUnitsInformationDataTable();
                subcontractorsInformation = new ProjectCostingSheetAddTDS.CombinedSubcontractorsInformationDataTable();
                materialsInformation = new ProjectCostingSheetAddTDS.CombinedMaterialsInformationDataTable();
                otherCostsInformation = new ProjectCostingSheetAddTDS.CombinedOtherCostsInformationDataTable();
                revenueInformation = new ProjectCostingSheetAddTDS.CombinedRevenueInformationDataTable();
                templateInformation = new ProjectCostingSheetAddTDS.TemplateInformationDataTable();

                tbxTeamMembersTotalCostCAD.Text = "0";
                tbxTeamMembersTotalCostUSD.Text = "0";
                tbxUnitsTotalCostsCAD.Text = "0";
                tbxUnitsTotalCostsUSD.Text = "0";
                tbxSubcontractorsTotalCostsCAD.Text = "0";
                tbxSubcontractorsTotalCostsUSD.Text = "0";
                tbxMaterialsTotalCostsCAD.Text = "0";
                tbxMaterialsTotalCostsUSD.Text = "0";
                tbxOtherCostsTotalCostsCAD.Text = "0";
                tbxOtherCostsTotalCostsUSD.Text = "0";
                tbxRevenueTotal.Text = "0";
                tbxGradRevenue.Text = "0";
                tbxGrandProfit.Text = "0";
                tbxGrandGrossMargin.Text = "0";

                // ... Store tables
                Session["projectCostingSheetAddTDS"] = projectCostingSheetAddTDS;
                Session["labourHoursInformation"] = labourHoursInformation;
                Session["unitsInformation"] = unitsInformation;
                Session["subcontractorsInformation"] = subcontractorsInformation;
                Session["materialsInformation"] = materialsInformation;
                Session["otherCostsInformation"] = otherCostsInformation;
                Session["revenueInformation"] = revenueInformation;
                Session["templateInformation"] = templateInformation;

                // StepGeneralInformation
                wzProjectCostinsSheetsAdd.ActiveStepIndex = 0;
            }
            else
            {
                // Restore tables
                projectCostingSheetAddTDS = (ProjectCostingSheetAddTDS)Session["projectCostingSheetAddTDS"];
                labourHoursInformation = (ProjectCostingSheetAddTDS.CombinedLabourHoursInformationDataTable)Session["labourHoursInformation"];
                unitsInformation = (ProjectCostingSheetAddTDS.CombinedUnitsInformationDataTable)Session["unitsInformation"];
                subcontractorsInformation = (ProjectCostingSheetAddTDS.CombinedSubcontractorsInformationDataTable)Session["subcontractorsInformation"];
                materialsInformation = (ProjectCostingSheetAddTDS.CombinedMaterialsInformationDataTable)Session["materialsInformation"];
                otherCostsInformation = (ProjectCostingSheetAddTDS.CombinedOtherCostsInformationDataTable)Session["otherCostsInformation"];
                revenueInformation = (ProjectCostingSheetAddTDS.CombinedRevenueInformationDataTable)Session["revenueInformation"];
                templateInformation = (ProjectCostingSheetAddTDS.TemplateInformationDataTable)Session["templateInformation"];
                projectsSelected = (ArrayList)Session["projectsSelected"];

                foreach (int projectIdSelected in projectsSelected)
                {
                    ProjectGateway projectGateway = new ProjectGateway();
                    projectGateway.LoadByProjectId(projectIdSelected);

                    string name = projectGateway.GetName(projectIdSelected);

                    projectList.Add(new ListItem(name, projectIdSelected.ToString()));
                }
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // INITIAL EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Security check
                if (!Convert.ToBoolean(Session["sgLFS_PROJECTS_COSTINGSHEETS_ADMIN"]))
                {
                    if (!(Convert.ToBoolean(Session["sgLFS_PROJECTS_COSTINGSHEETS_VIEW"]) && Convert.ToBoolean(Session["sgLFS_PROJECTS_COSTINGSHEETS_ADD"])))
                    {
                        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["project_id"] == null))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in project_costing_sheets_add.aspx");
                }

                // Tag Page
                TagPage();

                // Initialize viewstate variables
                ViewState["StepFrom"] = "Out";
                Session.Remove("labourHoursInformationDummy");
                Session.Remove("labourHoursInformation");
                Session.Remove("unitsInformationDummy");
                Session.Remove("unitsInformation");
                Session.Remove("subcontractorsInformationDummy");
                Session.Remove("subcontractorsInformation");
                Session.Remove("materialsInformationDummy");
                Session.Remove("materialsInformation");
                Session.Remove("otherCostsInformationDummy");
                Session.Remove("otherCostsInformation");
                Session.Remove("revenueInformationDummy");
                Session.Remove("revenueInformation");
                Session.Remove("templateInformationDummy");
                Session.Remove("templateInformation");

                Session.Remove("hotelsInformationDummy");
                Session.Remove("hotelsInformation");

                Session.Remove("bondingsInformationDummy");
                Session.Remove("bondingsInformation");

                Session.Remove("insurancesInformationDummy");
                Session.Remove("insurancesInformation");

                Session.Remove("otherCategoryInformationDummy");
                Session.Remove("otherCategoryInformation");

                // ... Initialize tables
                projectCostingSheetAddTDS = new ProjectCostingSheetAddTDS();
                labourHoursInformation = new ProjectCostingSheetAddTDS.LabourHoursInformationDataTable();
                unitsInformation = new ProjectCostingSheetAddTDS.UnitsInformationDataTable();
                subcontractorsInformation = new ProjectCostingSheetAddTDS.SubcontractorsInformationDataTable();
                materialsInformation = new ProjectCostingSheetAddTDS.MaterialsInformationDataTable();
                otherCostsInformation = new ProjectCostingSheetAddTDS.OtherCostsInformationDataTable();
                revenueInformation = new ProjectCostingSheetAddTDS.RevenueInformationDataTable();
                templateInformation = new ProjectCostingSheetAddTDS.TemplateInformationDataTable();
                hotelsInformation = new ProjectCostingSheetAddTDS.HotelsInformationDataTable();
                bondingsInformation = new ProjectCostingSheetAddTDS.BondingsInformationDataTable();
                insurancesInformation = new ProjectCostingSheetAddTDS.InsurancesInformationDataTable();
                otherCategoryInformation = new ProjectCostingSheetAddTDS.OtherCategoryInformationDataTable();

                tbxTeamMembersTotalCostCAD.Text = "0";
                tbxTeamMembersTotalCostUSD.Text = "0";
                tbxUnitsTotalCostsCAD.Text = "0";
                tbxUnitsTotalCostsUSD.Text = "0";
                tbxSubcontractorsTotalCostsCAD.Text = "0";
                tbxSubcontractorsTotalCostsUSD.Text = "0";
                tbxMaterialsTotalCostsCAD.Text = "0";
                tbxMaterialsTotalCostsUSD.Text = "0";
                tbxOtherCostsTotalCostsCAD.Text = "0";
                tbxOtherCostsTotalCostsUSD.Text = "0";
                tbxRevenueTotal.Text = "0";
                tbxGradRevenue.Text = "0";
                tbxGrandProfit.Text = "0";
                tbxGrandGrossMargin.Text = "0";

                tbxHotelsTotalCostsCAD.Text = "0";
                tbxHotelsTotalCostsUSD.Text = "0";

                tbxBondingsTotalCostsCAD.Text = "0";
                tbxBondingsTotalCostsUSD.Text = "0";

                tbxInsurancesTotalCostsCAD.Text = "0";
                tbxInsurancesTotalCostsUSD.Text = "0";

                tbxOtherCategoryTotalCostsCAD.Text = "0";
                tbxOtherCategoryTotalCostsUSD.Text = "0";

                // ... Store tables
                Session["projectCostingSheetAddTDS"] = projectCostingSheetAddTDS;
                Session["labourHoursInformation"] = labourHoursInformation;
                Session["unitsInformation"] = unitsInformation;
                Session["subcontractorsInformation"] = subcontractorsInformation;
                Session["materialsInformation"] = materialsInformation;
                Session["otherCostsInformation"] = otherCostsInformation;
                Session["revenueInformation"] = revenueInformation;
                Session["templateInformation"] = templateInformation;

                Session["hotelsInformation"] = hotelsInformation;
                Session["bondingsInformation"] = bondingsInformation;
                Session["insurancesInformation"] = insurancesInformation;
                Session["otherCategoryInformation"] = otherCategoryInformation;

                // StepGeneralInformation
                wzProjectCostinsSheetsAdd.ActiveStepIndex = 0;
            }
            else
            {
                // Restore tables
                projectCostingSheetAddTDS = (ProjectCostingSheetAddTDS)Session["projectCostingSheetAddTDS"];
                labourHoursInformation = (ProjectCostingSheetAddTDS.LabourHoursInformationDataTable)Session["labourHoursInformation"];
                unitsInformation = (ProjectCostingSheetAddTDS.UnitsInformationDataTable)Session["unitsInformation"];
                subcontractorsInformation = (ProjectCostingSheetAddTDS.SubcontractorsInformationDataTable)Session["subcontractorsInformation"];
                materialsInformation = (ProjectCostingSheetAddTDS.MaterialsInformationDataTable)Session["materialsInformation"];
                otherCostsInformation = (ProjectCostingSheetAddTDS.OtherCostsInformationDataTable)Session["otherCostsInformation"];
                revenueInformation = (ProjectCostingSheetAddTDS.RevenueInformationDataTable)Session["revenueInformation"];
                templateInformation = (ProjectCostingSheetAddTDS.TemplateInformationDataTable)Session["templateInformation"];

                hotelsInformation = (ProjectCostingSheetAddTDS.HotelsInformationDataTable)Session["hotelsInformation"];
                bondingsInformation = (ProjectCostingSheetAddTDS.BondingsInformationDataTable)Session["bondingsInformation"];
                insurancesInformation = (ProjectCostingSheetAddTDS.InsurancesInformationDataTable)Session["insurancesInformation"];
                otherCategoryInformation = (ProjectCostingSheetAddTDS.OtherCategoryInformationDataTable)Session["otherCategoryInformation"];
            }
        }
        /// <summary>
        /// GetUnitData
        /// </summary>
        /// <param name="startDate">startDate</param>
        /// <param name="endDate">endDate</param>
        /// <param name="unitId">unitId</param>
        /// <param name="work_">work_</param>
        /// <param name="newRow">newRow</param>
        /// <param name="isTowedUnitId">isTowedUnitId</param>
        private void GetUnitData(DateTime startDate, DateTime endDate, int unitId, string work_, ProjectCostingSheetAddTDS.UnitsInformationRow newRow, bool isTowedUnitId)
        {
            ProjectCostingSheetAddUnitListGateway projectCostingSheetAddUnitListGateway = new ProjectCostingSheetAddUnitListGateway();
            projectCostingSheetAddUnitListGateway.LoadByStartDateEndDateUnitIdWork_(startDate, endDate, unitId, work_);

            if (projectCostingSheetAddUnitListGateway.Table.Rows.Count <= 0)
            {
                projectCostingSheetAddUnitListGateway.LoadByStartDateEndDateUnitId(startDate, endDate, unitId);
                if (projectCostingSheetAddUnitListGateway.Table.Rows.Count <= 0)
                {
                    projectCostingSheetAddUnitListGateway.LoadByStartDateUnitIdWork_(startDate, unitId, work_);
                    if (projectCostingSheetAddUnitListGateway.Table.Rows.Count <= 0)
                    {
                        projectCostingSheetAddUnitListGateway.LoadByStartDateUnitId(startDate, unitId);
                        if (projectCostingSheetAddUnitListGateway.Table.Rows.Count <= 0)
                        {
                            projectCostingSheetAddUnitListGateway.LoadByUnitId(unitId);
                        }
                    }
                }
            }

            DataRow unitRow = projectCostingSheetAddUnitListGateway.GetRow(unitId);

            if (isTowedUnitId)
            {
                try
                {
                    newRow.CostCad = (decimal)unitRow["CostCad"] / 2;
                    newRow.CostUsd = (decimal)unitRow["CostUsd"] / 2;
                }
                catch
                {
                    newRow.CostCad = 0;
                    newRow.CostUsd = 0;
                }
            }
            else
            {
                newRow.CostCad = (decimal)unitRow["CostCad"];
                newRow.CostUsd = (decimal)unitRow["CostUsd"];
            }
        }
        /// <summary>
        /// GetMaterialData
        /// </summary>
        /// <param name="startDate">startDate</param>
        /// <param name="endDate">endDate</param>
        /// <param name="materialId">v</param>
        /// <param name="work_">work_</param>
        /// <param name="newRow">newRow</param>
        private void GetMaterialData(DateTime startDate, DateTime endDate, int materialId, string work_, ProjectCostingSheetAddTDS.MaterialsInformationRow newRow)
        {
            ProjectCostingSheetAddMaterialListGateway projectCostingSheetAddMaterialListGateway = new ProjectCostingSheetAddMaterialListGateway();
            projectCostingSheetAddMaterialListGateway.LoadByStartDateEndDateMaterialIdWork_(startDate, endDate, materialId, work_);

            if (projectCostingSheetAddMaterialListGateway.Table.Rows.Count <= 0)
            {
                projectCostingSheetAddMaterialListGateway.LoadByStartDateEndDateMaterialId(startDate, endDate, materialId);
                if (projectCostingSheetAddMaterialListGateway.Table.Rows.Count <= 0)
                {
                    projectCostingSheetAddMaterialListGateway.LoadByStartDateMaterialIdWork_(startDate, materialId, work_);
                    if (projectCostingSheetAddMaterialListGateway.Table.Rows.Count <= 0)
                    {
                        projectCostingSheetAddMaterialListGateway.LoadByStartDateMaterialId(startDate, materialId);
                        if (projectCostingSheetAddMaterialListGateway.Table.Rows.Count <= 0)
                        {
                            projectCostingSheetAddMaterialListGateway.LoadByMaterialId(materialId);
                        }
                    }
                }
            }

            DataRow materialRow = projectCostingSheetAddMaterialListGateway.GetRow(materialId);
            newRow.CostUsd = (decimal)materialRow["CostUsd"];
            newRow.CostCad = (decimal)materialRow["CostCad"];
        }
        /// <summary>
        /// GetEmployeeDataOvertime
        /// </summary>
        /// <param name="startDate">startDate</param>
        /// <param name="endDate">endDate</param>
        /// <param name="employeeId">employeeId</param>
        /// <param name="work_">work_</param>
        /// <param name="newRow">newRow</param>
        private void GetEmployeeDataOvertime(DateTime startDate, DateTime endDate, int employeeId, string work_, ProjectCostingSheetAddTDS.LabourHoursInformationRow newRow)
        {
            ProjectCostingSheetAddEmployeeListGateway projectCostingSheetAddEmployeeListGateway = new ProjectCostingSheetAddEmployeeListGateway();
            projectCostingSheetAddEmployeeListGateway.LoadByStartDateEndDateEmployeeIdWork_(startDate, endDate, employeeId, work_);

            if (projectCostingSheetAddEmployeeListGateway.Table.Rows.Count <= 0)
            {
                projectCostingSheetAddEmployeeListGateway.LoadByStartDateEndDateEmployeeId(startDate, endDate, employeeId);
                if (projectCostingSheetAddEmployeeListGateway.Table.Rows.Count <= 0)
                {
                    projectCostingSheetAddEmployeeListGateway.LoadByStartDateEmployeeIdWork_(startDate, employeeId, work_);
                    if (projectCostingSheetAddEmployeeListGateway.Table.Rows.Count <= 0)
                    {
                        projectCostingSheetAddEmployeeListGateway.LoadByStartDateEmployeeId(startDate, employeeId);
                        if (projectCostingSheetAddEmployeeListGateway.Table.Rows.Count <= 0)
                        {
                            projectCostingSheetAddEmployeeListGateway.LoadByEmployeeId(employeeId);
                        }
                    }
                }
            }

            DataRow employeeRow = projectCostingSheetAddEmployeeListGateway.GetRow(employeeId);
            newRow.LHUnitOfMeasurement = (string)employeeRow["UnitOfMeasurement"];

            newRow.LHCostCad = ((decimal)employeeRow["CostCad"] * 1.5M) + (decimal)employeeRow["BenefitFactorCad"];//employeeRow["CostCad"] == PayRateCad + BurdenRateCad
            newRow.LHCostUsd = ((decimal)employeeRow["CostUsd"] * 1.5M) + (decimal)employeeRow["BenefitFactorUsd"];//employeeRow["CostUsd"] == PayRateUsd + BurdenRateUsd

            if ((decimal)employeeRow["CostCad"] > 0)
            {
                newRow.LHCostUsd = (decimal)employeeRow["CostCad"] + (decimal)employeeRow["BenefitFactorCad"];//employeeRow["CostUsd"] == PayRateUsd + BurdenRateUsd
            }
        }
        /// <summary>
        /// GetEmployeeDataFairWageOvertime
        /// </summary>
        /// <param name="startDate">startDate</param>
        /// <param name="endDate">endDate</param>
        /// <param name="employeeId">employeeId</param>
        /// <param name="work_">work_</param>
        /// <param name="newRow">newRow</param>
        /// <param name="contryId">contryId</param>
        /// <param name="fringeRate">fringeRate</param>
        /// <param name="fairWageRate">fairWageRate</param>
        private void GetEmployeeDataFairWageOvertime(DateTime startDate, DateTime endDate, int employeeId, string work_, ProjectCostingSheetAddTDS.LabourHoursInformationRow newRow, int contryId, decimal fringeRate, decimal fairWageRate)
        {
            ProjectCostingSheetAddEmployeeListGateway projectCostingSheetAddEmployeeListGateway = new ProjectCostingSheetAddEmployeeListGateway();
            projectCostingSheetAddEmployeeListGateway.LoadByStartDateEndDateEmployeeIdWork_FairWage(startDate, endDate, employeeId, work_);

            if (projectCostingSheetAddEmployeeListGateway.Table.Rows.Count <= 0)
            {
                projectCostingSheetAddEmployeeListGateway.LoadByStartDateEndDateEmployeeIdFairWage(startDate, endDate, employeeId);
                if (projectCostingSheetAddEmployeeListGateway.Table.Rows.Count <= 0)
                {
                    projectCostingSheetAddEmployeeListGateway.LoadByStartDateEmployeeIdWork_FairWage(startDate, employeeId, work_);
                    if (projectCostingSheetAddEmployeeListGateway.Table.Rows.Count <= 0)
                    {
                        projectCostingSheetAddEmployeeListGateway.LoadByStartDateEmployeeIdFairWage(startDate, employeeId);
                        if (projectCostingSheetAddEmployeeListGateway.Table.Rows.Count <= 0)
                        {
                            projectCostingSheetAddEmployeeListGateway.LoadByEmployeeId(employeeId);
                        }
                    }
                }
            }

            DataRow employeeRow = projectCostingSheetAddEmployeeListGateway.GetRow(employeeId);
            newRow.LHUnitOfMeasurement = (string)employeeRow["UnitOfMeasurement"];

            if (contryId == 1)
            {
                //Canada
                decimal regularRate = 0; if (!employeeRow.IsNull("PayRateCad")) { regularRate = (decimal)employeeRow["PayRateCad"]; }

                decimal rate = fairWageRate * 1.5M;
                decimal burdenRate = 0;

                if (fairWageRate < regularRate)
                {
                    rate = regularRate * 1.5M;
                }

                if (!employeeRow.IsNull("BourdenFactor"))
                {
                    decimal burdenFactor = (decimal)employeeRow["BourdenFactor"] / 100;
                    burdenRate = rate * burdenFactor;
                }

                newRow.LHCostCad = rate + fringeRate + burdenRate;
                newRow.LHCostUsd = rate + fringeRate + burdenRate;
            }
            else
            {
                //USA
                decimal regularRate = 0; if (!employeeRow.IsNull("PayRateUsd")) { regularRate = (decimal)employeeRow["PayRateUsd"]; }
                decimal benefitFactorUsd = 0; if (!employeeRow.IsNull("HealthBenefitUsd")) { benefitFactorUsd = (decimal)employeeRow["BenefitFactorUsd"]; }

                decimal healtBenefitFactor = 0;
                if (!employeeRow.IsNull("HealthBenefitUsd"))
                {
                    decimal usHealthBenefitFactor = (decimal)employeeRow["HealthBenefitUsd"] / 100;
                    healtBenefitFactor = benefitFactorUsd + (benefitFactorUsd * usHealthBenefitFactor);
                }
                else
                {
                    healtBenefitFactor = benefitFactorUsd;
                }

                decimal burdenRate = 0;
                decimal fringeDeficiency = fringeRate - benefitFactorUsd;
                decimal rate = fairWageRate * 1.5M;

                if (fairWageRate < regularRate)
                {
                    rate = regularRate * 1.5M;
                }

                if (!employeeRow.IsNull("BourdenFactor"))
                {
                    decimal burdenFactor = (decimal)employeeRow["BourdenFactor"] / 100;
                    burdenRate = (rate + fringeDeficiency) * burdenFactor;
                }

                newRow.LHCostUsd = rate + fringeDeficiency + burdenRate + healtBenefitFactor;
                newRow.LHCostCad = rate + fringeDeficiency + burdenRate + healtBenefitFactor;
            }
        }
        private void Generate()
        {
            Page.Validate();

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

                ProjectCostingSheetAddTDS projectCostingSheetAddTDS = new ProjectCostingSheetAddTDS();
                LiquiForce.LFSLive.BL.Projects.Projects.PrintSummaryCostingSheetByMonthDummyInformation printSummaryCostingSheetByMonthDummyInformation = new LiquiForce.LFSLive.BL.Projects.Projects.PrintSummaryCostingSheetByMonthDummyInformation(projectCostingSheetAddTDS);

                int rows = 0;
                // Get Data
                string year = ddlYear.SelectedItem.Value;
                string month = "";

                foreach (ListItem lst in cbxlMonth.Items)
                {
                    if (lst.Selected)
                    {
                        DateTime startDate = new DateTime(int.Parse(year), int.Parse(lst.Value), 1);
                        DateTime endDate = (startDate.AddMonths(1)).AddDays(-1);

                        rows = rows + printSummaryCostingSheetByMonthDummyInformation.LoadAll(startDate, endDate, 3, lst.Text);
                        if (lst.Text == "(All)")
                        {
                            month = "(All)";
                        }
                        else
                        {
                            month = month + ", " + lst.Text;
                        }
                    }
                }

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

                // Get report
                if (rows > 0)
                {
                    if (master.Format == "pdf")
                    {
                        master.Report = new PrintSummaryCostingSheetByMonthReport();

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

                        // ... for start date
                        master.SetParameter("Year", year);

                        // ... for end date
                        master.SetParameter("Month", month);
                    }
                    else
                    {
                        master.Report = new PrintSummaryCostingSheetByMonthReport();

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

                        // ... for start date
                        master.SetParameter("Year", year);

                        // ... for end date
                        master.SetParameter("Month", month);
                    }
                }
            }
        }