Ejemplo n.º 1
0
        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, "en");
                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);
            }
        }
        string BuildReport(decimal problemCaseId)
        {
            var sb = new StringBuilder();

            sb.AppendFormat("<a href=\"/Reports/EHS_5Phase.aspx?pcid={0}\" target=\"_blank\" style=\"border: none;\">", EncryptionManager.Encrypt(problemCaseId.ToString()));
            sb.Append("<img src=\"/images/ico-download-100x125.png\" alt=\"download\" style=\"border: none;\" /><br /><br />");
            sb.Append("<strong>View Incident Details</strong><br />");
            sb.Append("(Printable page, opens in new window)");
            sb.Append("</a>");
            return(sb.ToString());
        }
        protected void rgIncidentList_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem item = (GridDataItem)e.Item;
                HiddenField  hf;
                Label        lbl;

                EHSIncidentData data = (EHSIncidentData)e.Item.DataItem;

                lbl      = (Label)e.Item.FindControl("lblIncidentId");
                lbl.Text = WebSiteCommon.FormatID(data.Incident.INCIDENT_ID, 6);

                if (data.Incident.DESCRIPTION.Length > 120)
                {
                    lbl      = (Label)e.Item.FindControl("lblDescription");
                    lbl.Text = data.Incident.DESCRIPTION.Substring(0, 117) + "...";
                }

                lbl      = (Label)e.Item.FindControl("lblDescription");
                lbl.Text = HttpUtility.HtmlEncode(lbl.Text);

                if (data.Person != null)
                {
                    lbl      = (Label)e.Item.FindControl("lblReportedBy");
                    lbl.Text = SQMModelMgr.FormatPersonListItem(data.Person);
                }

                lbl = (Label)e.Item.FindControl("lblIncStatus");
                if (data.Status == "C")
                {
                    lbl.Text = WebSiteCommon.GetXlatValue("incidentStatus", "C") + " " + SQMBasePage.FormatDate((DateTime)data.Incident.CLOSE_DATE, "d", false) + "<br/>(" + data.DaysToClose.ToString() + ")";
                }
                else if (data.Status == "C8")
                {
                    lbl.Text = WebSiteCommon.GetXlatValue("incidentStatus", "C8") + " " + SQMBasePage.FormatDate((DateTime)data.Incident.CLOSE_DATE_8D, "d", false) + "<br/>(" + data.DaysToClose.ToString() + ")";
                }
                else if (data.Status == "N")
                {
                    lbl.Text = "<strong>" + WebSiteCommon.GetXlatValue("incidentStatus", "N") + "</strong>";
                }
                else
                {
                    lbl.Text = WebSiteCommon.GetXlatValue("incidentStatus", "A") + "<br/>(" + data.DaysOpen + ")";
                }

                LinkButton lb8d         = (LinkButton)e.Item.FindControl("lb8d");
                LinkButton lbEditReport = (LinkButton)e.Item.FindControl("lbEditReport");

                HyperLink hlReport = (HyperLink)e.Item.FindControl("hlReport");
                hlReport.Visible = true;

                INCIDENT_ANSWER entry = data.Incident.INCIDENT_ANSWER.Where(l => l.INCIDENT_QUESTION_ID == (decimal)EHSQuestionId.Create8D).FirstOrDefault();
                if (entry != null && entry.ANSWER_VALUE == "Yes")
                {
                    if (UserContext.RoleAccess() > AccessMode.View)
                    {
                        lb8d.Visible = true;
                    }
                    else
                    {
                        lb8d.Visible = false;
                    }

                    lbEditReport.Visible = false;

                    var problemCaseId = EHSIncidentMgr.SelectProblemCaseIdByIncidentId(data.Incident.INCIDENT_ID);
                    if (problemCaseId > 0)
                    {
                        hlReport.NavigateUrl = "/EHS/EHS_Alert_PDF.aspx?pcid=" + EncryptionManager.Encrypt(problemCaseId.ToString());

                        LinkButton lbReport = (LinkButton)e.Item.FindControl("lbReport");
                        lbReport.Visible         = true;
                        lbReport.CommandArgument = problemCaseId.ToString();
                        lbReport.Attributes.Add("CaseType", data.Incident.INCIDENT_TYPE);
                    }
                }
                else
                {
                    lb8d.Visible         = false;
                    lbEditReport.Visible = true;

                    hlReport.NavigateUrl = "/EHS/EHS_Alert_PDF.aspx?iid=" + EncryptionManager.Encrypt(data.Incident.INCIDENT_ID.ToString());
                }

                if (data.Incident.ISSUE_TYPE_ID == 10)                 // Prevention Verification
                {
                    lbEditReport.Visible = false;
                    //HtmlImage imgEditReport = (HtmlImage)e.Item.FindControl("imgEditReport");
                    //imgEditReport.Visible = false;
                }

                if (rgIncidentList.MasterTableView.GetColumn("Attach").Visible&& data.AttachList != null)
                {
                    lbl = (Label)e.Item.FindControl("lblAttach");
                    Ucl_Attach attch = (Ucl_Attach)Page.LoadControl("/Include/Ucl_Attach.ascx");
                    lbl.Parent.Controls.AddAt(lbl.Parent.Controls.IndexOf(lbl), attch);
                    attch.BindListAttachment(data.AttachList, "", 1);
                }
            }
        }