private void UnassignedServiceRequestsProcessGrid()
        {
            dashboardUnassignedServiceRequestsTDS = (DashboardTDS)HttpContext.Current.Session["dashboardUnassignedServiceRequestsTDS"];
            DashboardUnassignedServiceRequests model = new DashboardUnassignedServiceRequests(dashboardUnassignedServiceRequestsTDS);

            // update rows
            if (Session["dashboardUnassignedServiceRequestsDummy"] == null)
            {
                foreach (GridViewRow row in grdUnassignedServiceRequests.Rows)
                {
                    int serviceId = int.Parse(grdUnassignedServiceRequests.DataKeys[row.RowIndex].Values["ServiceID"].ToString());
                    bool selected = ((CheckBox)row.FindControl("cbxSelected")).Checked;

                    model.Update( serviceId, int.Parse(hdfCompanyId.Value), selected);
                }

                model.Table.AcceptChanges();

                dashboardUnassignedServiceRequests = (DashboardTDS.DashboardUnassignedServiceRequestsDataTable)model.Table;
                Session["dashboardUnassignedServiceRequests"] = dashboardUnassignedServiceRequests;

                HttpContext.Current.Session.Add("dashboardUnassignedServiceRequestsTDS", dashboardUnassignedServiceRequestsTDS);
            }
        }
        protected void Page_PreRender(object sender, EventArgs e)
        {
            // Initialize links for service request tools
            lkbtnAddServiceRequest.Attributes.Add("onclick", string.Format("return LkbtnAddServiceRequestClik();"));

            if (Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_SERVICES_ADMIN"]))
            {
                lkbtnServiceRequestManager.Visible = true;
            }
            else
            {
                lkbtnServiceRequestManager.Visible = false;
            }

            // Initialize reminder links
            int companyId = Int32.Parse(hdfCompanyId.Value);
            int employeeId = Convert.ToInt32(hdfEmployeeId.Value);
            int companyLevelId = Int32.Parse(ddlWorkingLocation.SelectedValue);

            dashboardUnassignedServiceRequestsTDS = (DashboardTDS)HttpContext.Current.Session["dashboardUnassignedServiceRequestsTDS"];
            DashboardUnassignedServiceRequestsGateway dashboardUnassignedServiceRequestsGateway = new DashboardUnassignedServiceRequestsGateway(dashboardUnassignedServiceRequestsTDS);

            if (Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_SERVICES_ADMIN"]))
            {
                if (companyLevelId == 0)
                {
                    if (ddlType.SelectedValue != "(All)")
                    {
                        // ... For unassigned service requests
                        int countUnassignedSR = dashboardUnassignedServiceRequestsGateway.CountUnassignedServiceRequestsByUnitType(companyId, ddlType.SelectedValue);
                        lkbtnUnassignedServiceRequests.Text = countUnassignedSR.ToString() + " Unassigned Services Requests";

                        // ... For rejected service requests
                        int countRejectedSR = dashboardUnassignedServiceRequestsGateway.CountRejectedServiceRequestsByUnitType(companyId, ddlType.SelectedValue);
                        lkbtnRejectedServiceRequests.Text = countRejectedSR.ToString() + " Rejected Services Requests";
                    }
                    else
                    {
                        // ... For unassigned service requests
                        int countUnassignedSR = dashboardUnassignedServiceRequestsGateway.CountUnassignedServiceRequests(companyId);
                        lkbtnUnassignedServiceRequests.Text = countUnassignedSR.ToString() + " Unassigned Services Requests";

                        // ... For rejected service requests
                        int countRejectedSR = dashboardUnassignedServiceRequestsGateway.CountRejectedServiceRequests(companyId);
                        lkbtnRejectedServiceRequests.Text = countRejectedSR.ToString() + " Rejected Services Requests";
                    }
                }
                else
                {
                    if (ddlType.SelectedValue != "(All)")
                    {
                        // ... For unassigned service requests
                        int countUnassignedSR = dashboardUnassignedServiceRequestsGateway.CountUnassignedServiceRequestsByCompanyLevelIdUnitType(companyId, companyLevelId, ddlType.SelectedValue);
                        lkbtnUnassignedServiceRequests.Text = countUnassignedSR.ToString() + " Unassigned Services Requests";

                        // ... For rejected service requests
                        int countRejectedSR = dashboardUnassignedServiceRequestsGateway.CountRejectedServiceRequestsByCompanyLevelIdUnitType(companyId, companyLevelId, ddlType.SelectedValue);
                        lkbtnRejectedServiceRequests.Text = countRejectedSR.ToString() + " Rejected Services Requests";
                    }
                    else
                    {
                        // ... For unassigned service requests
                        int countUnassignedSR = dashboardUnassignedServiceRequestsGateway.CountUnassignedServiceRequestsByCompanyLevelId(companyId, companyLevelId);
                        lkbtnUnassignedServiceRequests.Text = countUnassignedSR.ToString() + " Unassigned Services Requests";

                        // ... For rejected service requests
                        int countRejectedSR = dashboardUnassignedServiceRequestsGateway.CountRejectedServiceRequestsByCompanyLevelId(companyId, companyLevelId);
                        lkbtnRejectedServiceRequests.Text = countRejectedSR.ToString() + " Rejected Services Requests";
                    }
                }
            }
            else
            {
                if (companyLevelId == 0)
                {
                    if (ddlType.SelectedValue != "(All)")
                    {
                        // ... For unassigned service requests
                        int countUnassignedSR = dashboardUnassignedServiceRequestsGateway.CountUnassignedServiceRequestsByAssignTeamMemberIDUnitType(employeeId, companyId, ddlType.SelectedValue);
                        lkbtnUnassignedServiceRequests.Text = countUnassignedSR.ToString() + " Unassigned Services Requests";

                        // ... For rejected service requests
                        int countRejectedSR = dashboardUnassignedServiceRequestsGateway.CountRejectedServiceRequestsByAssignTeamMemberIDUnitType(employeeId, companyId, ddlType.SelectedValue);
                        lkbtnRejectedServiceRequests.Text = countRejectedSR.ToString() + " Rejected Services Requests";
                    }
                    else
                    {
                        // ... For unassigned service requests
                        int countUnassignedSR = dashboardUnassignedServiceRequestsGateway.CountUnassignedServiceRequestsByAssignTeamMemberID(employeeId, companyId);
                        lkbtnUnassignedServiceRequests.Text = countUnassignedSR.ToString() + " Unassigned Services Requests";

                        // ... For rejected service requests
                        int countRejectedSR = dashboardUnassignedServiceRequestsGateway.CountRejectedServiceRequestsByAssignTeamMemberID(employeeId, companyId);
                        lkbtnRejectedServiceRequests.Text = countRejectedSR.ToString() + " Rejected Services Requests";
                    }
                }
                else
                {
                    if (ddlType.SelectedValue != "(All)")
                    {
                        // ... For unassigned service requests
                        int countUnassignedSR = dashboardUnassignedServiceRequestsGateway.CountUnassignedServiceRequestsByAssignTeamMemberIDCompanyLevelIdUnitType(employeeId, companyId, companyLevelId, ddlType.SelectedValue);
                        lkbtnUnassignedServiceRequests.Text = countUnassignedSR.ToString() + " Unassigned Services Requests";

                        // ... For rejected service requests
                        int countRejectedSR = dashboardUnassignedServiceRequestsGateway.CountRejectedServiceRequestsByAssignTeamMemberIDCompanyLevelIdUnitType(employeeId, companyId, companyLevelId, ddlType.SelectedValue);
                        lkbtnRejectedServiceRequests.Text = countRejectedSR.ToString() + " Rejected Services Requests";
                    }
                    else
                    {
                        // ... For unassigned service requests
                        int countUnassignedSR = dashboardUnassignedServiceRequestsGateway.CountUnassignedServiceRequestsByAssignTeamMemberIDCompanyLevelId(employeeId, companyId, companyLevelId);
                        lkbtnUnassignedServiceRequests.Text = countUnassignedSR.ToString() + " Unassigned Services Requests";

                        // ... For rejected service requests
                        int countRejectedSR = dashboardUnassignedServiceRequestsGateway.CountRejectedServiceRequestsByAssignTeamMemberIDCompanyLevelId(employeeId, companyId, companyLevelId);
                        lkbtnRejectedServiceRequests.Text = countRejectedSR.ToString() + " Rejected Services Requests";
                    }
                }
            }
        }
        private void LoadData()
        {
            int companyId = Int32.Parse(hdfCompanyId.Value);
            int companyLevelId = Int32.Parse(ddlWorkingLocation.SelectedValue);

            dashboardUnassignedServiceRequestsTDS = (DashboardTDS)HttpContext.Current.Session["dashboardUnassignedServiceRequestsTDS"];
            DashboardUnassignedServiceRequests model = new DashboardUnassignedServiceRequests(dashboardUnassignedServiceRequestsTDS);

            // ... Load for admin
            if (Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_SERVICES_ADMIN"]))
            {
                if (companyLevelId == 0)
                {
                    if (ddlType.SelectedValue != "(All)")
                    {
                        model.LoadAllUnassignedServicesByUnitType(companyId, ddlType.SelectedValue);
                    }
                    else
                    {
                        model.LoadAllUnassignedServices(companyId);
                    }
                }
                else
                {
                    if (ddlType.SelectedValue != "(All)")
                    {
                        model.LoadAllUnassignedServicesByCompanyLevelIdUnitType(companyId, companyLevelId, ddlType.SelectedValue);
                    }
                    else
                    {
                        model.LoadAllUnassignedServicesByCompanyLevelId(companyId, companyLevelId);
                    }
                }
            }
            else
            {
                int employeeId = Convert.ToInt32(hdfEmployeeId.Value);

                if (companyLevelId == 0)
                {
                    if (ddlType.SelectedValue != "(All)")
                    {
                        model.LoadAllUnassignedServicesByAssignTeamMemberIDUnitType(employeeId, companyId, ddlType.SelectedValue);
                    }
                    else
                    {
                        // ... Load for assigned employee
                        model.LoadAllUnassignedServicesByAssignTeamMemberID(employeeId, companyId);
                    }
                }
                else
                {
                    if (ddlType.SelectedValue != "(All)")
                    {
                        model.LoadAllUnassignedServicesByAssignTeamMemberIDCompanyLevelIdUnitType(employeeId, companyId, companyLevelId, ddlType.SelectedValue);
                    }
                    else
                    {
                        // ... Load for assigned employee
                        model.LoadAllUnassignedServicesByAssignTeamMemberIDCompanyLevelId(employeeId, companyId, companyLevelId);
                    }
                }
            }

            model.UpdateForDashboard(companyId);

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

            Page.DataBind();
        }
 /// <summary>
 /// InitData. 
 /// </summary>
 protected override void InitData()
 {
     _data = new DashboardTDS();
 }
        // ////////////////////////////////////////////////////////////////////////
        // 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 wucSRUnassigned.ascx");
                }

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

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

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

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

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

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

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

                    GetNodeForCompanyLevel(1);

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

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

                    dashboardUnassignedServiceRequestsTDS = new DashboardTDS();
                    DashboardUnassignedServiceRequests model = new DashboardUnassignedServiceRequests(dashboardUnassignedServiceRequestsTDS);

                    // ... Load for admin
                    if (Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_SERVICES_ADMIN"]))
                    {
                        if (companyLevelId == 0)
                        {
                            if (ddlType.SelectedValue != "(All)")
                            {
                                model.LoadAllUnassignedServicesByUnitType(companyId, ddlType.SelectedValue);
                            }
                            else
                            {
                                model.LoadAllUnassignedServices(companyId);
                            }
                        }
                        else
                        {
                            if (ddlType.SelectedValue != "(All)")
                            {
                                model.LoadAllUnassignedServicesByCompanyLevelIdUnitType(companyId, companyLevelId, ddlType.SelectedValue);
                            }
                            else
                            {
                                model.LoadAllUnassignedServicesByCompanyLevelId(companyId, companyLevelId);
                            }
                        }
                    }
                    else
                    {
                        if (companyLevelId == 0)
                        {
                            if (ddlType.SelectedValue != "(All)")
                            {
                                model.LoadAllUnassignedServicesByAssignTeamMemberIDUnitType(employeeId, companyId, ddlType.SelectedValue);
                            }
                            else
                            {
                                // ... Load for assigned employee
                                model.LoadAllUnassignedServicesByAssignTeamMemberID(employeeId, companyId);
                            }
                        }
                        else
                        {
                            if (ddlType.SelectedValue != "(All)")
                            {
                                model.LoadAllUnassignedServicesByAssignTeamMemberIDCompanyLevelIdUnitType(employeeId, companyId, companyLevelId, ddlType.SelectedValue);
                            }
                            else
                            {
                                model.LoadAllUnassignedServicesByAssignTeamMemberIDCompanyLevelId(employeeId, companyId, companyLevelId);
                            }
                        }
                    }

                    model.UpdateForDashboard(companyId);

                    // ... Store datasets
                    HttpContext.Current.Session.Add("dashboardUnassignedServiceRequestsTDS", dashboardUnassignedServiceRequestsTDS);
                    HttpContext.Current.Session.Add("companyLevelsForSRUnassignedTDS", companyLevelsForSRUnassignedTDS);
                }
            }
            else
            {
                // Prepare initial data
                HttpContext.Current.Session.Remove("dashboardUnassignedServiceRequestsDummy");

                // Restore datasets
                dashboardUnassignedServiceRequestsTDS = (DashboardTDS)HttpContext.Current.Session["dashboardUnassignedServiceRequestsTDS"];
                companyLevelsForSRUnassignedTDS = (CompanyLevelsTDS)HttpContext.Current.Session["companyLevelsForSRUnassignedTDS"];
            }
        }
        private void LoadData()
        {
            int companyId = Int32.Parse(hdfCompanyId.Value);
            int loginId = Convert.ToInt32(Session["loginID"]);
            EmployeeGateway employeeGateway = new EmployeeGateway(new DataSet());
            int employeeId = employeeGateway.GetEmployeIdByLoginId(loginId);
            string period = ddlPeriod.SelectedItem.Value.ToString();
            int companyLevelId = Int32.Parse(ddlWorkingLocation.SelectedValue);

            dashboardItemsAboutToExpireTDS = (DashboardTDS)HttpContext.Current.Session["dashboardItemsAboutToExpireTDS"];
            DashboardItemsAboutToExpire model = new DashboardItemsAboutToExpire(dashboardItemsAboutToExpireTDS);

            if (Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_SERVICES_ADMIN"]))
            {
                if (companyLevelId == 0)
                {
                    if (ddlType.SelectedValue != "(All)")
                    {
                        model.LoadAllItemsAboutToExpireByUnitType(period, companyId, ddlType.SelectedValue);
                    }
                    else
                    {
                        model.LoadAllItemsAboutToExpire(period, companyId);
                    }
                }
                else
                {
                    if (ddlType.SelectedValue != "(All)")
                    {
                        model.LoadAllItemsAboutToExpireByCompanyLevelIdUnitType(period, companyId, companyLevelId, ddlType.SelectedValue);
                    }
                    else
                    {
                        model.LoadAllItemsAboutToExpireByCompanyLevelId(period, companyId, companyLevelId);
                    }
                }
            }
            else
            {
                if (companyLevelId == 0)
                {
                    if (ddlType.SelectedValue != "(All)")
                    {
                        model.LoadAllItemsAboutToExpireByAssignTeamMemberIDUnitType(period, employeeId, companyId, ddlType.SelectedValue);
                    }
                    else
                    {
                        // ... Load for assigned employee
                        model.LoadAllItemsAboutToExpireByAssignTeamMemberID(period, employeeId, companyId);
                    }
                }
                else
                {
                    if (ddlType.SelectedValue != "(All)")
                    {
                        model.LoadAllItemsAboutToExpireByAssignTeamMemberIDCompanyLevelIdUnitType(period, employeeId, companyId, companyLevelId, ddlType.SelectedValue);
                    }
                    else
                    {
                        model.LoadAllItemsAboutToExpireByAssignTeamMemberIDCompanyLevelId(period, employeeId, companyId, companyLevelId);
                    }
                }
            }

            model.UpdateForDashboard(companyId);

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

            Page.DataBind();
        }
        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 LoadData()
        {
            dashboardMyToDoListTDS = new DashboardTDS();
            DashboardMyToDoList model = new DashboardMyToDoList(dashboardMyToDoListTDS);
            DashboardMyToDoListOnHold modelOnHold = new DashboardMyToDoListOnHold(dashboardMyToDoListTDS);

            EmployeeGateway employeeGateway = new EmployeeGateway(new DataSet());

            int companyId = Int32.Parse(hdfCompanyId.Value);
            int loginId = Convert.ToInt32(Session["loginID"]);
            int employeeId = employeeGateway.GetEmployeIdByLoginId(loginId);
            string state = "%"; if (ddlStateMyToDo.SelectedValue != "(All)") state = ddlStateMyToDo.SelectedValue;

            // ... Load to do list
            // ... ...Load for admin
            if (!Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_TODOLIST_ADMIN"]))
            {
                if (state == "New & In Progress")
                {
                    model.LoadMyNewAndInProgressToDoListByCreated(employeeId, companyId);
                }
                else
                {
                    // ... ... Load for assigned employee
                    model.LoadMyCurrentToDoListByCreatedByIdState(employeeId, state, companyId);
                }

                modelOnHold.LoadMyCurrentToDoListOnHoldByCreatedById(employeeId, companyId);
            }
            else
            {
                if (state == "New & In Progress")
                {
                    model.LoadNewAndInProgressToDoList(companyId);
                }
                else
                {
                    // ... ... Loads all (current)
                    model.LoadCurrentToDoListByState(state, companyId);
                }

                modelOnHold.LoadCurrentToDoListOnHold(companyId);
            }

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

            Page.DataBind();
        }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Security check
                if (!(Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_TODOLIST_VIEW"]) && Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_TODOLIST_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 wucMyToDoList.ascx");
                }

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

                // Prepare initial data
                HttpContext.Current.Session.Remove("dashboardMyToDoListDataTableDummy");
                HttpContext.Current.Session.Remove("dashboardMyToDoListOnHoldDataTableDummy");
                ArrayList arrayListWidgetData = (ArrayList)HttpContext.Current.Session["myToDoListWidget"];
                ArrayList arrayListWidgetDataOnHold = (ArrayList)HttpContext.Current.Session["myToDoListOnHoldWidget"];

                // If coming from
                // ... Out
                if (Request.QueryString["source_page"] == "out")
                {
                    int loginId = Convert.ToInt32(Session["loginID"]);
                    EmployeeGateway employeeGateway = new EmployeeGateway(new DataSet());
                    int employeeId = employeeGateway.GetEmployeIdByLoginId(loginId);
                    string state = "%"; if (ddlStateMyToDo.SelectedValue != "(All)") state = ddlStateMyToDo.SelectedValue;

                    // ... For Grid
                    int companyId = Int32.Parse(hdfCompanyId.Value);

                    dashboardMyToDoListTDS = new DashboardTDS();
                    DashboardMyToDoList model = new DashboardMyToDoList(dashboardMyToDoListTDS);
                    DashboardMyToDoListOnHold modelOnHold = new DashboardMyToDoListOnHold(dashboardMyToDoListTDS);

                    if (HttpContext.Current.Session["myToDoListWidget"] != null)
                    {
                        ddlStateMyToDo.SelectedIndex = Convert.ToInt32(arrayListWidgetData[1].ToString());
                        if (ddlStateMyToDo.SelectedValue != "(All)") state = ddlStateMyToDo.SelectedValue;
                    }

                    // ... Load to do list
                    // ... ...Load for admin
                    if (!Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_TODOLIST_ADMIN"]))
                    {
                        // ... Load for assigned employee
                        model.LoadMyCurrentToDoListByCreatedByIdState(employeeId, state, companyId);
                        modelOnHold.LoadMyCurrentToDoListOnHoldByCreatedById(employeeId, companyId);
                    }
                    else
                    {
                        // ... ... Loads all  (current)
                        model.LoadCurrentToDoListByState(state, companyId);
                        modelOnHold.LoadCurrentToDoListOnHold(companyId);
                    }

                    // ... Store datasets
                    HttpContext.Current.Session.Add("dashboardMyToDoListTDS", dashboardMyToDoListTDS);
                }
            }
            else
            {
                // Prepare initial data
                HttpContext.Current.Session.Remove("dashboardMyToDoListDataTableDummy");
                HttpContext.Current.Session.Remove("dashboardMyToDoListOnHoldDataTableDummy");

                // Restore dataset
                dashboardMyToDoListTDS = (DashboardTDS)HttpContext.Current.Session["dashboardMyToDoListTDS"];
            }
        }
        protected void ddlType_SelectedIndexChanged(object sender, EventArgs e)
        {
            int companyId = Int32.Parse(hdfCompanyId.Value);
            int companyLevelId = Int32.Parse(ddlWorkingLocation.SelectedValue);

            dashboardChecklistAlarmsTDS = (DashboardTDS)HttpContext.Current.Session["dashboardChecklistAlarmsTDS"];
            DashboardChecklistAlarms model = new DashboardChecklistAlarms(dashboardChecklistAlarmsTDS);

            if (companyLevelId == 0)
            {
                if (ddlType.SelectedValue != "(All)")
                {
                    model.LoadAllByAlarmPeriodUnitType(companyId, ddlType.SelectedValue);
                }
                else
                {
                    model.LoadAllByAlarmPeriod(companyId);
                }
            }
            else
            {
                if (ddlType.SelectedValue != "(All)")
                {
                    model.LoadAllByAlarmPeriodCompanyLevelIdUnitType(companyId, companyLevelId, ddlType.SelectedValue);
                }
                else
                {
                    model.LoadAllByAlarmPeriodCompanyLevelId(companyId, companyLevelId);
                }
            }

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

            Page.DataBind();
        }
        private void AlarmsProcessGrid()
        {
            dashboardChecklistAlarmsTDS = (DashboardTDS)HttpContext.Current.Session["dashboardChecklistAlarmsTDS"];
            DashboardChecklistAlarms model = new DashboardChecklistAlarms(dashboardChecklistAlarmsTDS);

            // update rows
            if (Session["dashboardChecklistAlarmsDummy"] == null)
            {
                foreach (GridViewRow row in grdChecklistAlarms.Rows)
                {
                    int unitId = Int32.Parse(grdChecklistAlarms.DataKeys[row.RowIndex].Values["UnitID"].ToString());
                    int ruleId = Int32.Parse(grdChecklistAlarms.DataKeys[row.RowIndex].Values["RuleID"].ToString());
                    bool selected = ((CheckBox)row.FindControl("cbxSelected")).Checked;
                    model.Update(unitId, ruleId, int.Parse(hdfCompanyId.Value), selected);
                }

                model.Table.AcceptChanges();

                dashboardChecklistAlarms = (DashboardTDS.DashboardChecklistAlarmsDataTable)model.Table;
                Session["dashboardChecklistAlarms"] = dashboardChecklistAlarms;

                HttpContext.Current.Session.Add("dashboardChecklistAlarmsTDS", dashboardChecklistAlarmsTDS);
            }
        }
        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();
        }