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(); }
// //////////////////////////////////////////////////////////////////////// // 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 wucItemsAboutToExpire.ascx"); } // Tag page hdfCompanyId.Value = Session["companyID"].ToString(); // Prepare initial data HttpContext.Current.Session.Remove("dashboardItemsAboutToExpireDummy"); ArrayList arrayListWidgetData = (ArrayList)HttpContext.Current.Session["itemsAboutToExpireWidget"]; // 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); string period = "0 days"; // ... For ddl working location companyLevelsItemsAboutToExpiredTDS = new CompanyLevelsTDS(); CompanyLevel companyLevel = new CompanyLevel(companyLevelsItemsAboutToExpiredTDS); companyLevel.LoadNodes(companyId); GetNodeForCompanyLevel(1); ddlWorkingLocation.Items.Insert(0, new ListItem("(All)", "0")); if (HttpContext.Current.Session["itemsAboutToExpireWidget"] != null) { ddlWorkingLocation.SelectedIndex = Convert.ToInt32(arrayListWidgetData[0].ToString()); ddlType.SelectedIndex = Convert.ToInt32(arrayListWidgetData[1].ToString()); ddlPeriod.SelectedIndex = Convert.ToInt32(arrayListWidgetData[3].ToString()); companyLevelId = Convert.ToInt32(ddlWorkingLocation.SelectedValue); period = ddlPeriod.SelectedValue; } else { ddlWorkingLocation.SelectedValue = companyLevelId.ToString(); ddlPeriod.SelectedValue = period; } dashboardItemsAboutToExpireTDS = new DashboardTDS(); DashboardItemsAboutToExpire model = new DashboardItemsAboutToExpire(dashboardItemsAboutToExpireTDS); // ... Load for admin 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); // ... Store datasets HttpContext.Current.Session.Add("dashboardItemsAboutToExpireTDS", dashboardItemsAboutToExpireTDS); HttpContext.Current.Session.Add("companyLevelsItemsAboutToExpiredTDS", companyLevelsItemsAboutToExpiredTDS); } } else { // Prepare initial data HttpContext.Current.Session.Remove("dashboardItemsAboutToExpireDummy"); // Restore dataset dashboardItemsAboutToExpireTDS = (DashboardTDS)HttpContext.Current.Session["dashboardItemsAboutToExpireTDS"]; companyLevelsItemsAboutToExpiredTDS = (CompanyLevelsTDS)HttpContext.Current.Session["companyLevelsItemsAboutToExpiredTDS"]; } }