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

            if (!IsPostBack)
            {
                // Security check
                if (!(Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_ACTUAL_COSTS_ADMIN"])))
                {
                    // Security check
                    if (!(Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_ACTUAL_COSTS_VIEW"]) && Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_ACTUAL_COSTS_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["project_id"] == null) || ((string)Request.QueryString["ref_id"] == null) || ((string)Request.QueryString["category"] == null))
                    {
                        Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in actual_costs_delete.aspx");
                    }
                }

                // Tag page
                hdfCompanyId.Value = Session["companyID"].ToString();
                hdfCurrentProjectId.Value = Request.QueryString["project_id"];
                hdfCurrentRefId.Value = Request.QueryString["ref_id"];
                hdfCategory.Value = Request.QueryString["category"];

                // ... for titles
                int companyId = Int32.Parse(hdfCompanyId.Value.Trim());
                int currentProjectId = int.Parse(hdfCurrentProjectId.Value);
                int currentRefId = int.Parse(hdfCurrentRefId.Value);
                string category = hdfCategory.Value;

                if (category == "Subcontractors")
                {
                    lblDelete.Text = "Are you sure you want to delete this subcontractor cost?";
                    ActualCostsInformationSubcontractorBasicInformationGateway actualCostsInformationSubcontractorBasicInformationGatewayForTitle = new ActualCostsInformationSubcontractorBasicInformationGateway();
                    actualCostsInformationSubcontractorBasicInformationGatewayForTitle.LoadByProjectIdRefId(currentProjectId, currentRefId, companyId);
                    lblTitle.Text = "Subcontractor: " + actualCostsInformationSubcontractorBasicInformationGatewayForTitle.GetSubcontractor(currentProjectId, currentRefId);
                }
                else
                {
                    if (category == "Hotels")
                    {
                        lblDelete.Text = "Are you sure you want to delete this hotel cost?";
                        ActualCostsInformationHotelCostsBasicInformationGateway actualCostsInformationHotelCostsBasicInformationGateway = new ActualCostsInformationHotelCostsBasicInformationGateway();
                        actualCostsInformationHotelCostsBasicInformationGateway.LoadByProjectIdRefId(currentProjectId, currentRefId, companyId);
                        lblTitle.Text = "Hotel: " + actualCostsInformationHotelCostsBasicInformationGateway.GetHotel(currentProjectId, currentRefId);
                    }
                    else
                    {
                        if (category == "Insurance")
                        {
                            lblDelete.Text = "Are you sure you want to delete this insurance company cost?";
                            ActualCostsInformationInsuranceCostsBasicInformationGateway actualCostsInformationInsuranceCostsBasicInformationGateway = new ActualCostsInformationInsuranceCostsBasicInformationGateway();
                            actualCostsInformationInsuranceCostsBasicInformationGateway.LoadByProjectIdRefId(currentProjectId, currentRefId, companyId);
                            lblTitle.Text = "Insurance Company:  " + actualCostsInformationInsuranceCostsBasicInformationGateway.GetInsurance(currentProjectId, currentRefId);
                        }
                        else
                        {
                            if (category == "Bonding")
                            {
                                lblDelete.Text = "Are you sure you want to delete this bonding company cost?";
                                ActualCostsInformationBondingCostsBasicInformationGateway actualCostsInformationBondingCostsBasicInformationGateway = new ActualCostsInformationBondingCostsBasicInformationGateway();
                                actualCostsInformationBondingCostsBasicInformationGateway.LoadByProjectIdRefId(currentProjectId, currentRefId, companyId);
                                lblTitle.Text = "Bonding Company: " + actualCostsInformationBondingCostsBasicInformationGateway.GetBonding(currentProjectId, currentRefId);
                            }
                            else
                            {
                                // for other categories
                                lblDelete.Text = "Are you sure you want to delete this insurance other cost?";
                                ActualCostsInformationOtherCostsBasicInformationGateway actualCostsInformationOtherCostsBasicInformationGateway = new ActualCostsInformationOtherCostsBasicInformationGateway();
                                actualCostsInformationOtherCostsBasicInformationGateway.LoadByProjectIdRefId(currentProjectId, currentRefId, companyId);
                                lblTitle.Text = "Category: " + actualCostsInformationOtherCostsBasicInformationGateway.GetCategory(currentProjectId, currentRefId);
                            }
                        }
                    }
                }

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

                    actualCostsInformationTDS = new ActualCostsInformationTDS();

                    if (category == "Subcontractors")
                    {
                        ActualCostsInformationSubcontractorBasicInformationGateway actualCostsInformationSubcontractorBasicInformationGateway = new ActualCostsInformationSubcontractorBasicInformationGateway(actualCostsInformationTDS);
                        actualCostsInformationSubcontractorBasicInformationGateway.LoadByProjectIdRefId(currentProjectId, currentRefId, companyId);
                    }
                    else
                    {
                        if (category == "Hotels")
                        {
                            ActualCostsInformationHotelCostsBasicInformationGateway actualCostsInformationHotelCostsBasicInformationGateway = new ActualCostsInformationHotelCostsBasicInformationGateway(actualCostsInformationTDS);
                            actualCostsInformationHotelCostsBasicInformationGateway.LoadByProjectIdRefId(currentProjectId, currentRefId, companyId);
                        }
                        else
                        {
                            if (category == "Insurance")
                            {
                                ActualCostsInformationInsuranceCostsBasicInformationGateway actualCostsInformationInsuranceCostsBasicInformationGateway = new ActualCostsInformationInsuranceCostsBasicInformationGateway(actualCostsInformationTDS);
                                actualCostsInformationInsuranceCostsBasicInformationGateway.LoadByProjectIdRefId(currentProjectId, currentRefId, companyId);
                            }
                            else
                            {
                                if (category == "Bonding")
                                {
                                    ActualCostsInformationBondingCostsBasicInformationGateway actualCostsInformationBondingCostsBasicInformationGateway = new ActualCostsInformationBondingCostsBasicInformationGateway(actualCostsInformationTDS);
                                    actualCostsInformationBondingCostsBasicInformationGateway.LoadByProjectIdRefId(currentProjectId, currentRefId, companyId);
                                }
                                else
                                {
                                    // other categories
                                    ActualCostsInformationOtherCostsBasicInformationGateway actualCostsInformationOtherCostsBasicInformationGateway = new ActualCostsInformationOtherCostsBasicInformationGateway(actualCostsInformationTDS);
                                    actualCostsInformationOtherCostsBasicInformationGateway.LoadByProjectIdRefId(currentProjectId, currentRefId, companyId);

                                }
                            }
                        }
                    }

                    // ... Store dataset
                    Session["actualCostsInformationTDS"] = actualCostsInformationTDS;
                }

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

                    // Restore dataset
                    actualCostsInformationTDS = (ActualCostsInformationTDS)Session["actualCostsInformationTDS"];
                }

            }
            else
            {
                // Restore dataset
                actualCostsInformationTDS = (ActualCostsInformationTDS)Session["actualCostsInformationTDS"];
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {                if (!(Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_ACTUAL_COSTS_ADMIN"])))
                {
                    // Security check
                    if (!(Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_ACTUAL_COSTS_VIEW"]) && Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_ACTUAL_COSTS_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["project_id"] == null) || ((string)Request.QueryString["ref_id"] == null))
                    {
                        Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in actual_costs_edit.aspx");
                    }
                }

                // Initialize  variables
                hdfProjectId.Value = Request.QueryString["project_id"].ToString();
                hdfRefId.Value = Request.QueryString["ref_id"].ToString();
                hdfCompanyId.Value = Session["companyID"].ToString();
                hdfCategory.Value = Request.QueryString["category"].ToString();

                // If coming from
                int currentRefId = Int32.Parse(hdfRefId.Value);
                int currentProjectId = Int32.Parse(hdfProjectId.Value);
                int companyId = Int32.Parse(hdfCompanyId.Value);
                string category = hdfCategory.Value;

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

                    actualCostsInformationTDS = new ActualCostsInformationTDS();

                    if (category == "Subcontractors")
                    {
                        lblTitle.Text = "Subcontractor Costs";
                        lblCategoryName.Text = "Subcontractor";
                        ActualCostsInformationSubcontractorBasicInformation actualCostsInformationSubcontractorBasicInformation = new ActualCostsInformationSubcontractorBasicInformation(actualCostsInformationTDS);
                        actualCostsInformationSubcontractorBasicInformation.LoadByProjectIdRefId(currentProjectId, currentRefId, companyId);
                    }
                    else
                    {
                        if (category == "Hotels")
                        {
                            lblTitle.Text = "Hotel Costs";
                            lblCategoryName.Text = "Hotels";
                            tbxState.Visible = false;
                            ActualCostsInformationHotelCostsBasicInformation actualCostsInformationHotelCostsBasicInformation = new ActualCostsInformationHotelCostsBasicInformation(actualCostsInformationTDS);
                            actualCostsInformationHotelCostsBasicInformation.LoadByProjectIdRefId(currentProjectId, currentRefId, companyId);
                        }
                        else
                        {
                            if (category == "Insurance")
                            {
                                lblTitle.Text = "Insurance Company Costs";
                                lblCategoryName.Text = "Insurance Company";
                                tbxState.Visible = false;
                                ActualCostsInformationInsuranceCostsBasicInformation actualCostsInformationInsuranceCostsBasicInformation = new ActualCostsInformationInsuranceCostsBasicInformation(actualCostsInformationTDS);
                                actualCostsInformationInsuranceCostsBasicInformation.LoadByProjectIdRefId(currentProjectId, currentRefId, companyId);
                            }
                            else
                            {
                                if (category == "Bonding")
                                {
                                    lblTitle.Text = "Bonding Company Costs";
                                    lblCategoryName.Text = "Bonding Company";
                                    tbxState.Visible = false;
                                    ActualCostsInformationBondingCostsBasicInformation actualCostsInformationBondingCostsBasicInformation = new ActualCostsInformationBondingCostsBasicInformation(actualCostsInformationTDS);
                                    actualCostsInformationBondingCostsBasicInformation.LoadByProjectIdRefId(currentProjectId, currentRefId, companyId);
                                }
                                else
                                {
                                    // other categories
                                    lblTitle.Text = "Other Costs";
                                    lblCategoryName.Text = "Category";
                                    tbxState.Visible = false;
                                    ActualCostsInformationOtherCostsBasicInformation actualCostsInformationOtherCostsBasicInformation = new ActualCostsInformationOtherCostsBasicInformation(actualCostsInformationTDS);
                                    actualCostsInformationOtherCostsBasicInformation.LoadByProjectIdRefId(currentProjectId, currentRefId, companyId);
                                }
                            }
                        }
                    }

                    // ... Store dataset
                    Session["actualCostsInformationTDS"] = actualCostsInformationTDS;
                }

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

                    // ... Restore dataset
                    actualCostsInformationTDS = (ActualCostsInformationTDS)Session["actualCostsInformationTDS"];
                }

                // ... Data for current employee
                LoadData(currentProjectId, currentRefId);
            }
            else
            {
                // Restore datasets
                actualCostsInformationTDS = (ActualCostsInformationTDS)Session["actualCostsInformationTDS"];
            }
        }