/// <summary>
        /// LoadByCostingSheetIdForPreviewReport
        /// </summary>
        /// <param name="costingSheetId">costingSheetId</param>
        /// <param name="companyId">companyId</param>
        public void LoadByCostingSheetIdForPreviewReport(int costingSheetId, int companyId)
        {
            ProjectCostingSheetInformationBasicInformationGateway projectCostingSheetInformationBasicInformationGateway = new ProjectCostingSheetInformationBasicInformationGateway(Data);
            projectCostingSheetInformationBasicInformationGateway.LoadByCostingSheetId(costingSheetId, companyId);

            UpdateForReport();
        }
        // ////////////////////////////////////////////////////////////////////////
        // 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_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["costing_sheet_id"] == null)  || ((string)Request.QueryString["costing_sheet_state"] == null))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in project_costing_sheets_state.aspx");
                }

                // Tag Page
                hdfCostingSheetId.Value = Request.QueryString["costing_sheet_id"].ToString();
                hdfCostingSheetState.Value = Request.QueryString["costing_sheet_state"].ToString();
                hdfCompanyId.Value = Session["companyID"].ToString();
                hdfProjectId.Value = Request.QueryString["project_id"];
                hdfDataChanged.Value = Request.QueryString["data_changed"];
                hdfDataChangedMessage.Value = "Changes made to this project will not be saved.";
                ViewState["state"] = Request.QueryString["state"];
                ViewState["active_tab"] = Request.QueryString["active_tab"];
                ViewState["origin"] = Request.QueryString["origin"];
                ViewState["update"] = Request.QueryString["update"];
                int projectId = Int32.Parse(hdfProjectId.Value);

                projectTDS = (ProjectTDS)Session["lfsProjectTDS"];

                // If coming from project_costing_sheets_summary.aspx
                if ((string)Request.QueryString["source_page"] == "project_costing_sheets_summary.aspx")
                {
                    ViewState["update"] = Request.QueryString["update"];

                    int companyId = Int32.Parse(hdfCompanyId.Value.Trim());
                    int costingSheetId = Int32.Parse(hdfCostingSheetId.Value.Trim());

                    projectCostingSheetInformationTDS = (ProjectCostingSheetInformationTDS)Session["projectCostingSheetInformationTDS"];
                    ProjectCostingSheetInformationBasicInformationGateway projectCostingSheetInformationBasicInformationGateway = new ProjectCostingSheetInformationBasicInformationGateway(projectCostingSheetInformationTDS);
                    projectCostingSheetInformationBasicInformationGateway.LoadByCostingSheetId(costingSheetId, companyId);

                    // Store dataset
                    Session["projectCostingSheetInformationTDS"] = projectCostingSheetInformationTDS;
                }

                // Restore dataset
                projectCostingSheetInformationTDS = (ProjectCostingSheetInformationTDS)Session["projectCostingSheetInformationTDS"];

                // Costing Sheet state check
                ProjectCostingSheetInformationBasicInformationGateway projectCostingSheetInformationBasicInformationGatewayToValidate = new ProjectCostingSheetInformationBasicInformationGateway(projectCostingSheetInformationTDS);

                DateTime startDate = projectCostingSheetInformationBasicInformationGatewayToValidate.GetStartDate(Int32.Parse(hdfCostingSheetId.Value));
                DateTime endDate = projectCostingSheetInformationBasicInformationGatewayToValidate.GetEndDate(Int32.Parse(hdfCostingSheetId.Value));

                ProjectCostingSheetGateway projectCostingSheetGateway = new ProjectCostingSheetGateway();
                if (projectCostingSheetGateway.ExistCostingSheetApproved(projectId, startDate, endDate))
                {
                    string msg = "You cannot approve this costing sheet. There are other costing sheets already approved on the same date range. There is an overlaping issue between yours costing sheets.";
                    Response.Redirect("./../../error_page.aspx?error=" + msg);
                }
            }
            else
            {
                // Restore dataset
                projectTDS = (ProjectTDS)Session["lfsProjectTDS"];
                projectCostingSheetInformationTDS = (ProjectCostingSheetInformationTDS)Session["projectCostingSheetInformationTDS"];
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

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

                // Tag Page
                hdfCostingSheetId.Value = Request.QueryString["costing_sheet_id"].ToString();
                hdfCompanyId.Value = Session["companyID"].ToString();
                hdfProjectId.Value = Request.QueryString["project_id"];
                hdfDataChanged.Value = Request.QueryString["data_changed"];
                hdfDataChangedMessage.Value = "Changes made to this project will not be saved.";
                ViewState["state"] = Request.QueryString["state"];
                ViewState["active_tab"] = Request.QueryString["active_tab"];
                ViewState["origin"] = Request.QueryString["origin"];
                ViewState["update"] = Request.QueryString["update"];

                projectTDS = (ProjectTDS)Session["lfsProjectTDS"];

                // If coming from
                // ... project_costing_sheets_navigator2.aspx
                if (Request.QueryString["source_page"] == "project_costing_sheets_navigator.aspx")
                {
                    StoreNavigatorState();
                    ViewState["update"] = "no";

                    projectCostingSheetInformationTDS = new ProjectCostingSheetInformationTDS();

                    int costingSheetId = Int32.Parse(hdfCostingSheetId.Value);
                    int companyId = Int32.Parse(hdfCompanyId.Value);

                    ProjectCostingSheetInformationBasicInformationGateway projectCostingSheetInformationBasicInformationGateway = new ProjectCostingSheetInformationBasicInformationGateway(projectCostingSheetInformationTDS);
                    projectCostingSheetInformationBasicInformationGateway.LoadByCostingSheetId(costingSheetId, companyId);

                    if (!Convert.ToBoolean(Session["sgLFS_PROJECTS_COSTINGSHEETS_ADMIN"]))
                    {
                        string state = projectCostingSheetInformationBasicInformationGateway.GetState(costingSheetId);
                        if (state == "Approved")
                        {
                            Response.Redirect("./../../error_page.aspx?error=" + "This costing sheet is approved, you can not delete it.");
                        }
                    }

                    // Store dataset
                    Session["projectCostingSheetInformationTDS"] = projectCostingSheetInformationTDS;
                }

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

                    // Restore dataset
                    projectCostingSheetInformationTDS = (ProjectCostingSheetInformationTDS)Session["projectCostingSheetInformationTDS"];

                    if (!Convert.ToBoolean(Session["sgLFS_PROJECTS_COSTINGSHEETS_ADMIN"]))
                    {
                        // Costing Sheet state check
                        ProjectCostingSheetInformationBasicInformationGateway projectCostingSheetInformationBasicInformationGatewayForValidate = new ProjectCostingSheetInformationBasicInformationGateway(projectCostingSheetInformationTDS);
                        string state = projectCostingSheetInformationBasicInformationGatewayForValidate.GetState(Int32.Parse(hdfCostingSheetId.Value));
                        if (state == "Approved")
                        {
                            Response.Redirect("./../../error_page.aspx?error=" + "This costing sheet is approved, you can not delete it.");
                        }
                    }
                }
            }
            else
            {
                // Restore datasets
                projectTDS = (ProjectTDS)Session["lfsProjectTDS"];
                projectCostingSheetInformationTDS = (ProjectCostingSheetInformationTDS)Session["projectCostingSheetInformationTDS"];
            }
        }