private void LoadData()
        {
            int companyId = Int32.Parse(hdfCompanyId.Value);
            int companyLevelId = Int32.Parse(ddlWorkingLocation.SelectedValue);

            dashboardInProgressServiceRequestsTDS = (DashboardTDS)HttpContext.Current.Session["dashboardInProgressServiceRequestsTDS"];
            DashboardInProgressServiceRequests model = new DashboardInProgressServiceRequests(dashboardInProgressServiceRequestsTDS);

            if (companyLevelId == 0)
            {
                if (ddlType.SelectedValue != "(All)")
                {
                    model.LoadInProgressServicesByUnitType(companyId, ddlType.SelectedValue);
                }
                else
                {
                    // ... Load
                    model.LoadInProgressServices(companyId);
                }
            }
            else
            {
                if (ddlType.SelectedValue != "(All)")
                {
                    model.LoadInProgressServicesByCompanyLevelIdUnitType(companyId, companyLevelId, ddlType.SelectedValue);
                }
                else
                {
                    model.LoadInProgressServicesByCompanyLevelId(companyId, companyLevelId);
                }
            }

            model.UpdateForDashboard(companyId);

            HttpContext.Current.Session.Add("dashboardInProgressServiceRequestsTDS", dashboardInProgressServiceRequestsTDS);

            Page.DataBind();
        }
        private void PostPageChanges()
        {
            DashboardInProgressServiceRequests dashboardInProgressServiceRequests = new DashboardInProgressServiceRequests(dashboardInProgressServiceRequestsTDS);

            // Update jlinernavigator rows
            foreach (GridViewRow row in grdServiceRequestsInProgress.Rows)
            {
                string serviceIdLabel = ((Label)row.FindControl("lblServiceID")).Text.Trim();
                int serviceId = Int32.Parse(serviceIdLabel.ToString().Trim());
                bool selected = ((CheckBox)row.FindControl("cbxSelected")).Checked;
                int companyId = Int32.Parse(hdfCompanyId.Value);

                dashboardInProgressServiceRequests.Update(serviceId, companyId, selected);
            }

            dashboardInProgressServiceRequests.Data.AcceptChanges();

            // Store datasets
            Session["dashboardInProgressServiceRequestsTDS"] = dashboardInProgressServiceRequestsTDS;
        }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

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

                // Tag page
                hdfCompanyId.Value = Session["companyID"].ToString();

                // Prepare initial data
                HttpContext.Current.Session.Remove("dashboardInProgressServiceRequestsDummy");
                ArrayList arrayListWidgetData = (ArrayList)HttpContext.Current.Session["srInProgressWidget"];

                // If coming from
                // ... Out
                if (Request.QueryString["source_page"] == "out")
                {
                    CompanyLevelsManagersGateway companyLevelsManagersGateway = new CompanyLevelsManagersGateway();

                    int loginId = Convert.ToInt32(Session["loginID"]);
                    EmployeeGateway employeeGateway = new EmployeeGateway(new DataSet());
                    int employeeId = employeeGateway.GetEmployeIdByLoginId(loginId);

                    // ... For Grid
                    int companyId = Int32.Parse(hdfCompanyId.Value);
                    int companyLevelId = companyLevelsManagersGateway.GetCompanyLevelId(employeeId, companyId);

                    // ... For ddl working location
                    companyLevelsForSRInProgressTDS = new CompanyLevelsTDS();

                    CompanyLevel companyLevel = new CompanyLevel(companyLevelsForSRInProgressTDS);
                    companyLevel.LoadNodes(companyId);

                    GetNodeForCompanyLevel(1);

                    ddlWorkingLocation.Items.Insert(0, new ListItem("(All)", "0"));

                    if (HttpContext.Current.Session["srInProgressWidget"] != null)
                    {
                        ddlWorkingLocation.SelectedIndex = Convert.ToInt32(arrayListWidgetData[0].ToString());
                        ddlType.SelectedIndex = Convert.ToInt32(arrayListWidgetData[1].ToString());

                        companyLevelId = Convert.ToInt32(ddlWorkingLocation.SelectedValue);
                    }
                    else
                    {
                        ddlWorkingLocation.SelectedValue = companyLevelId.ToString();
                    }

                    dashboardInProgressServiceRequestsTDS = new DashboardTDS();
                    DashboardInProgressServiceRequests model = new DashboardInProgressServiceRequests(dashboardInProgressServiceRequestsTDS);

                    if (companyLevelId == 0)
                    {
                        if (ddlType.SelectedValue != "(All)")
                        {
                            model.LoadInProgressServicesByUnitType(companyId, ddlType.SelectedValue);
                        }
                        else
                        {
                            // ... Load
                            model.LoadInProgressServices(companyId);
                        }
                    }
                    else
                    {
                        if (ddlType.SelectedValue != "(All)")
                        {
                            model.LoadInProgressServicesByCompanyLevelIdUnitType(companyId, companyLevelId, ddlType.SelectedValue);
                        }
                        else
                        {
                            model.LoadInProgressServicesByCompanyLevelId(companyId, companyLevelId);
                        }
                    }

                    model.UpdateForDashboard(companyId);

                    // ... Store datasets
                    HttpContext.Current.Session.Add("dashboardInProgressServiceRequestsTDS", dashboardInProgressServiceRequestsTDS);
                    HttpContext.Current.Session.Add("companyLevelsForSRInProgressTDS", companyLevelsForSRInProgressTDS);
                }
            }
            else
            {
                // Prepare initial data
                HttpContext.Current.Session.Remove("dashboardInProgressServiceRequestsDummy");

                dashboardInProgressServiceRequestsTDS = (DashboardTDS)HttpContext.Current.Session["dashboardInProgressServiceRequestsTDS"];
                companyLevelsForSRInProgressTDS = (CompanyLevelsTDS)HttpContext.Current.Session["companyLevelsForSRInProgressTDS"];
            }
        }