Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        // ////////////////////////////////////////////////////////////////////////
        // 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 wucAlarms.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("dashboardChecklistAlarmsDummy");

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

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

                    // ... For ddl working location
                    companyLevelsForAlarmsTDS = new CompanyLevelsTDS();
                    CompanyLevel companyLevel = new CompanyLevel(companyLevelsForAlarmsTDS);
                    companyLevel.LoadNodes(companyId);
                    GetNodeForCompanyLevel(1);
                    ddlWorkingLocation.Items.Insert(0, new ListItem("(All)", "0"));
                    ddlWorkingLocation.SelectedValue = companyLevelId.ToString();

                    dashboardChecklistAlarmsTDS = new DashboardTDS();
                    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);
                        }
                    }

                    // ... Store datasets
                    HttpContext.Current.Session.Add("dashboardChecklistAlarmsTDS", dashboardChecklistAlarmsTDS);
                    HttpContext.Current.Session.Add("companyLevelsForAlarmsTDS", companyLevelsForAlarmsTDS);
                }
            }
            else
            {
                // Prepare initial data
                HttpContext.Current.Session.Remove("dashboardChecklistAlarmsDummy");

                // Restore datasets
                dashboardChecklistAlarmsTDS = (DashboardTDS)HttpContext.Current.Session["dashboardChecklistAlarmsTDS"];
                companyLevelsForAlarmsTDS = (CompanyLevelsTDS)HttpContext.Current.Session["companyLevelsForAlarmsTDS"];
            }
        }