Esempio n. 1
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            bool createAuditAccess = SessionManager.CheckUserPrivilege(SysPriv.config, SysScope.audit);

            rbNew.Visible = createAuditAccess;


            if (IsPostBack)
            {
                //if (!uclAuditForm.IsEditContext)
                RadPersistenceManager1.StorageProviderKey = SessionManager.UserContext.Person.PERSON_ID.ToString();
                RadPersistenceManager1.SaveState();

                if (SessionManager.ReturnStatus == true)
                {
                    if (SessionManager.ReturnObject is string)
                    {
                        string type = SessionManager.ReturnObject as string;
                        switch (type)
                        {
                        case "DisplayAudits":
                            UpdateDisplayState(DisplayState.AuditList);
                            break;

                        case "Notification":
                            //UpdateDisplayState(DisplayState.AuditNotificationEdit);
                            //UpdateDisplayState(DisplayState.AuditReportEdit);
                            uclAuditForm.EditAuditId = SessionManager.ReturnRecordID;
                            // need to determine if the Audit is past due and force it into display mode (probelm when coming from Calendar)
                            string auditStatus = EHSAuditMgr.SelectAuditStatus(SessionManager.ReturnRecordID);
                            if (auditStatus == "C")
                            {
                                UpdateDisplayState(DisplayState.AuditNotificationDisplay);
                            }
                            else
                            {
                                UpdateDisplayState(DisplayState.AuditNotificationEdit);
                            }
                            if (isDirected)
                            {
                                rbNew.Visible = false;
                                uclAuditForm.EnableReturnButton(false);
                            }
                            break;

                        case "Closed":
                            uclAuditForm.EditAuditId = SessionManager.ReturnRecordID;
                            UpdateDisplayState(DisplayState.AuditNotificationClosed);
                            if (isDirected)
                            {
                                rbNew.Visible = false;
                                uclAuditForm.EnableReturnButton(false);
                            }
                            break;

                        case "DisplayOnly":
                            uclAuditForm.EditAuditId = SessionManager.ReturnRecordID;
                            UpdateDisplayState(DisplayState.AuditNotificationDisplay);
                            if (isDirected)
                            {
                                rbNew.Visible = false;
                                uclAuditForm.EnableReturnButton(false);
                            }
                            break;
                        }
                    }
                    SessionManager.ClearReturns();
                }
            }
            else
            {
                Ucl_DocMgr ucl = (Ucl_DocMgr)this.Master.FindControl("uclDocSelect");
                if (ucl != null)
                {
                    ucl.BindDocumentSelect("EHS", 2, true, true, "");
                }

                if (SessionManager.ReturnStatus == true && SessionManager.ReturnObject is string)
                {
                    try
                    {
                        // from inbox
                        DisplayNonPostback();
                        SessionManager.ReturnRecordID = Convert.ToDecimal(SessionManager.ReturnObject.ToString());
                        SessionManager.ReturnObject   = "Notification";
                        SessionManager.ReturnStatus   = true;
                        isDirected = true;

                        StringBuilder       sbScript = new StringBuilder();
                        ClientScriptManager cs       = Page.ClientScript;

                        sbScript.Append("<script language='JavaScript' type='text/javascript'>\n");
                        sbScript.Append("<!--\n");
                        sbScript.Append(cs.GetPostBackEventReference(this, "PBArg") + ";\n");
                        sbScript.Append("// -->\n");
                        sbScript.Append("</script>\n");

                        cs.RegisterStartupScript(this.GetType(), "AutoPostBackScript", sbScript.ToString());
                    }
                    catch
                    {
                        // not a number, parse as type
                        DisplayNonPostback();
                    }
                }
                else
                {
                    DisplayNonPostback();
                }
            }
            // for now, we will only let 'admin' create audits
            //if (!SessionManager.UserContext.Person.SSO_ID.ToLower().Equals("admin"))
            //	rbNew.Visible = false;
        }