protected void Page_Load(object sender, EventArgs e)
        {
            entities   = new PSsqmEntities();
            baseAppUrl = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + ResolveUrl("~/");

            decimal id = 0;

            string customerLogo = "";

            customerLogo = System.Configuration.ConfigurationManager.AppSettings["CustomerLogo"].ToString();

            string imageUrl = "";

            if (!string.IsNullOrEmpty(customerLogo))
            {
                imageUrl = baseAppUrl + "images/company/" + customerLogo;
            }
            else
            {
                imageUrl = baseAppUrl + "images/company/MetricsoftLogo.png";
            }

            imgLogo.ImageUrl = "data:image/jpg;base64," + ImageUrlToBase64String(imageUrl);

            try
            {
                ltrCaseName.Text = "EH&S Incident Alert";

                if (Request.QueryString["pcid"] != null)
                {
                    string query = Request.QueryString["pcid"];
                    query = query.Replace(" ", "+");
                    string pcid = EncryptionManager.Decrypt(query);
                    id = Convert.ToInt32(pcid);
                    PopulateByProblemCaseId(id);
                }
                else if (Request.QueryString["iid"] != null)
                {
                    string query = Request.QueryString["iid"];
                    query = query.Replace(" ", "+");
                    string pcid = EncryptionManager.Decrypt(query);
                    id = Convert.ToInt32(pcid);
                    PopulateByIncidentId(id);
                }



                pnlContent.Visible = true;
                pnlError.Visible   = false;
            }
            catch
            {
                pnlContent.Visible = false;
                pnlError.Visible   = true;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            decimal issueID = 0;

            if (!Page.IsPostBack)
            {
                //string appContext;
                if (!string.IsNullOrEmpty(Request.QueryString["c"]))
                {
                    appContext = Request.QueryString["c"];
                }
                else
                {
                    appContext = "RCV";
                }

                if (!string.IsNullOrEmpty(Request.QueryString["i"]))
                {
                    try
                    {
                        issueID = Convert.ToDecimal(EncryptionManager.Decrypt(Request.QueryString["i"]));
                    }
                    catch { }
                }

                SetIssueCtl(new QualityIssueCtl().Initialize(null, appContext));

                if (SessionManager.EffLocation.BusinessOrg == null)
                {
                    SessionManager.EffLocation = SessionManager.UserContext.WorkingLocation;
                }
                if (uclIssueSearch.DDLPlantSelect.Items.Count == 0)
                {
                    List <BusinessLocation> locationList = SQMModelMgr.SelectBusinessLocationList(SessionManager.UserContext.HRLocation.Company.COMPANY_ID, 0, true);
                    SQMBasePage.SetLocationList(uclIssueSearch.DDLPlantSelect, UserContext.FilterPlantAccessList(locationList), -1);
                }

                PERSPECTIVE_VIEW view = ViewModel.LookupView(entities, appContext, appContext, 0);
                if (view != null)
                {
                    ddlChartType.Items.Clear();
                    ddlChartType.Items.Add(new RadComboBoxItem("", ""));
                    foreach (PERSPECTIVE_VIEW_ITEM vi in view.PERSPECTIVE_VIEW_ITEM.Where(l => l.STATUS != "I").OrderBy(l => l.ITEM_SEQ).ToList())
                    {
                        RadComboBoxItem item = new RadComboBoxItem();
                        item.Text     = vi.TITLE;
                        item.Value    = vi.ITEM_SEQ.ToString();
                        item.ImageUrl = ViewModel.GetViewItemImageURL(vi);
                        ddlChartType.Items.Add(item);
                    }
                }

                pnlChartSection.Style.Add("display", "none");
                lblChartType.Visible = ddlChartType.Visible = false;

                uclSearchBar_OnListClick();  // display list options upon page entry
            }

            switch (IssueCtl().Context)
            {
            case "CST":
                uclSearchBar1.PageTitle.Text    = lblQICSTTitle.Text;
                uclSearchBar1.NewButton.ToolTip = "Create a new " + lblQICSTTitle.Text;
                foreach (RadComboBoxItem ci in ddlChartType.Items)
                {
                    if (ci.Value.Contains("RCV"))
                    {
                        ci.Visible = false;
                    }
                }
                break;

            case "RCV":
                uclSearchBar1.PageTitle.Text    = lblQIRCVTitle.Text;
                uclSearchBar1.NewButton.ToolTip = "Create a new " + lblQIRCVTitle.Text;
                foreach (RadComboBoxItem ci in ddlChartType.Items)
                {
                    if (ci.Value.Contains("CST"))
                    {
                        ci.Visible = false;
                    }
                }
                break;

            default:
                uclSearchBar1.PageTitle.Text = lblQIPRQTitle.Text;
                break;
            }

            if (issueID > 0)
            {
                OnIssue_Click(issueID);
            }
        }