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

            dashboardMyServiceRequestsTDS = (DashboardTDS)HttpContext.Current.Session["dashboardMyServiceRequestsTDS"];
            DashboardMyServiceRequests model = new DashboardMyServiceRequests(dashboardMyServiceRequestsTDS);

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

            if (companyLevelId == 0)
            {
                if (ddlType.SelectedValue != "(All)")
                {
                    model.LoadMyServicesByAssignTeamMemberIDUnitType(employeeId, companyId, ddlType.SelectedValue);
                }
                else
                {
                    model.LoadMyServicesByAssignTeamMemberID(employeeId, companyId);
                }
            }
            else
            {
                if (ddlType.SelectedValue != "(All)")
                {
                    model.LoadMyServicesByAssignTeamMemberIDCompanyLevelIdUnitType(employeeId, companyId, companyLevelId, ddlType.SelectedValue);
                }
                else
                {
                    model.LoadMyServicesByAssignTeamMemberIDCompanyLevelId(employeeId, companyId, companyLevelId);
                }
            }

            model.UpdateForDashboard(companyId);

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

            Page.DataBind();
        }
        private void PostPageChanges()
        {
            DashboardMyServiceRequests dashboardMyServiceRequests = new DashboardMyServiceRequests(dashboardMyServiceRequestsTDS);

            // Update grdMyServiceRequests rows
            foreach (GridViewRow row in grdMyServiceRequests.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);

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

            dashboardMyServiceRequests.Data.AcceptChanges();

            // Store datasets
            Session["dashboardMyServiceRequestsTDS"] = dashboardMyServiceRequestsTDS;
        }
        // ////////////////////////////////////////////////////////////////////////
        // 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 wucMyServiceRequest.ascx");
                }

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

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

                // 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
                    companyLevelsForMySRTDS = new CompanyLevelsTDS();

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

                    GetNodeForCompanyLevel(1);

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

                    if (HttpContext.Current.Session["mySRWidget"] != 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();
                    }

                    dashboardMyServiceRequestsTDS = new DashboardTDS();
                    DashboardMyServiceRequests model = new DashboardMyServiceRequests(dashboardMyServiceRequestsTDS);

                    if (companyLevelId == 0)
                    {
                        if (ddlType.SelectedValue != "(All)")
                        {
                            model.LoadMyServicesByAssignTeamMemberIDUnitType(employeeId, companyId, ddlType.SelectedValue);
                        }
                        else
                        {
                            // ... Load
                            model.LoadMyServicesByAssignTeamMemberID(employeeId, companyId);
                        }
                    }
                    else
                    {
                        if (ddlType.SelectedValue != "(All)")
                        {
                            model.LoadMyServicesByAssignTeamMemberIDCompanyLevelIdUnitType(employeeId, companyId, companyLevelId, ddlType.SelectedValue);
                        }
                        else
                        {
                            model.LoadMyServicesByAssignTeamMemberIDCompanyLevelId(employeeId, companyId, companyLevelId);
                        }
                    }

                    model.UpdateForDashboard(companyId);

                    // ... Store datasets
                    HttpContext.Current.Session.Add("dashboardMyServiceRequestsTDS", dashboardMyServiceRequestsTDS);
                    HttpContext.Current.Session.Add("companyLevelsForMySRTDS", companyLevelsForMySRTDS);
                }
            }
            else
            {
                // Prepare initial data
                HttpContext.Current.Session.Remove("dashboardMyServiceRequestsDummy");

                dashboardMyServiceRequestsTDS = (DashboardTDS)HttpContext.Current.Session["dashboardMyServiceRequestsTDS"];
                companyLevelsForMySRTDS = (CompanyLevelsTDS)HttpContext.Current.Session["companyLevelsForMySRTDS"];
            }
        }