protected void rgCSTIssueList_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem item = (GridDataItem)e.Item;
                HiddenField  hf;
                Label        lbl;

                try
                {
                    QualityIncidentData data = (QualityIncidentData)e.Item.DataItem;

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

                    Image img = (Image)e.Item.FindControl("imgRespLocation");
                    if (data.PlantResponsible.PLANT_ID != data.Plant.PLANT_ID)
                    {
                        img.Visible = true;
                    }
                    else
                    {
                        img.Visible = false;
                    }

                    if (!string.IsNullOrEmpty(data.QIIssue.SEVERITY))
                    {
                        lbl      = (Label)e.Item.FindControl("lblSeverity");
                        lbl.Text = WebSiteCommon.GetXlatValue("incidentSeverity", data.QIIssue.SEVERITY);
                    }

                    if (rgCSTIssueList.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", 1);
                    }
                }

                catch { }
            }
        }
Пример #2
0
        public void rptResponseList_OnItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                try
                {
                    ResponseItem response = (ResponseItem)e.Item.DataItem;

                    Label lbl = (Label)e.Item.FindControl("lblPersonName_out");
                    lbl.Text = SQMModelMgr.FormatPersonListItem(SQMModelMgr.LookupPerson(response.Response.PERSON_ID, ""));
                    if (!string.IsNullOrEmpty(response.Response.REFERENCE_DATA))
                    {
                        Control parent = lbl.Parent;
                        int     idx    = parent.Controls.IndexOf(lbl) + 1;
                        lbl          = new Label();
                        lbl.Text     = response.Response.REFERENCE_DATA;
                        lbl.CssClass = "refText";
                        parent.Controls.AddAt(idx, new LiteralControl("<br />"));
                        parent.Controls.AddAt(idx + 1, lbl);
                    }
                    lbl      = (Label)e.Item.FindControl("lblResponseDate_out");
                    lbl.Text = SQMBasePage.FormatDate(WebSiteCommon.LocalTime(response.Response.RESPONSE_DT, SessionManager.UserContext.TimeZoneID), "g", true);
                    RadTextBox rt = (RadTextBox)e.Item.FindControl("rtResponseText_out");
                    rt.Text = response.Response.RESPONSE_TEXT;

                    if (response.AttachmentList != null && response.AttachmentList.Count > 0)
                    {
                        Ucl_Attach attch = (Ucl_Attach)Page.LoadControl("/Include/Ucl_Attach.ascx");
                        // rt.Parent.Controls.AddAt(rt.Parent.Controls.IndexOf(rt),new LiteralControl("<br/>"));
                        rt.Parent.Controls.AddAt(rt.Parent.Controls.IndexOf(rt) + 1, attch);
                        attch.BindListAttachment(response.AttachmentList, "1", 0, false);
                    }
                }
                catch
                {
                }
            }
        }
        protected void rgPreventativeList_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                HiddenField hf;
                Label       lbl;
                string      val = "";

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

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

                lbl      = (Label)e.Item.FindControl("lblDescription");
                lbl.Text = StringHtmlExtensions.TruncateHtml(data.Incident.DESCRIPTION, 100, "...");
                lbl.Text = lbl.Text.Replace("<a href", "<a target=\"blank\" href");

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

                lbl      = (Label)e.Item.FindControl("lblCategory");
                lbl.Text = EHSIncidentMgr.SelectIncidentAnswer(data.Incident, (decimal)EHSQuestionId.InspectionCategory) + "<br/>" +
                           EHSIncidentMgr.SelectIncidentAnswer(data.Incident, (decimal)EHSQuestionId.RecommendationType);

                lbl = (Label)e.Item.FindControl("lblIncStatus");
                try
                {
                    if (data.Status == "U")
                    {
                        lbl.Text = "Audited " + SQMBasePage.FormatDate((DateTime)data.Incident.CLOSE_DATE_DATA_COMPLETE, "d", false) + "<br/>(" + data.DaysToClose.ToString() + ")";
                    }
                    else if (data.Status == "F")
                    {
                        lbl.Text = "Awaiting Funding " + SQMBasePage.FormatDate((DateTime)data.Incident.CLOSE_DATE_DATA_COMPLETE, "d", false) + "<br/>(" + data.DaysToClose.ToString() + ")";
                    }
                    else if (data.Status == "C")
                    {
                        lbl.Text = "Closed  " + SQMBasePage.FormatDate((DateTime)data.Incident.CLOSE_DATE, "d", false) + "<br/><strong>Not Audited</strong>";
                    }
                    else
                    {
                        lbl.Text = WebSiteCommon.GetXlatValue("incidentStatus", data.Status) + "<br/>(" + data.DaysOpen + ")";
                    }
                }
                catch
                {
                    ;
                }

                LinkButton lbEditReport = (LinkButton)e.Item.FindControl("lbEditReport");
                lbEditReport.Visible = true;

                try
                {
                    lbl      = (Label)e.Item.FindControl("lblIncidentDT");
                    lbl.Text = SQMBasePage.FormatDate(data.Incident.INCIDENT_DT, "d", false);
                    if ((val = data.EntryList.Where(l => l.INCIDENT_QUESTION_ID == 80).Select(l => l.ANSWER_VALUE).FirstOrDefault()) != null && !string.IsNullOrEmpty(val))
                    {
                        val = val.Substring(0, val.IndexOf(' '));
                        DateTime parseDate;
                        if (DateTime.TryParse(val, CultureInfo.GetCultureInfo("en-US"), DateTimeStyles.AssumeLocal, out parseDate))
                        {
                            lbl.Text = parseDate.ToShortDateString();
                        }
                    }
                }
                catch {}
                try {
                    if ((val = data.EntryList.Where(l => l.INCIDENT_QUESTION_ID == 92).Select(l => l.ANSWER_VALUE).FirstOrDefault()) != null && !string.IsNullOrEmpty(val))
                    {
                        val = val.Substring(0, val.IndexOf(' '));
                        DateTime parseDate;
                        if (DateTime.TryParse(val, CultureInfo.GetCultureInfo("en-US"), DateTimeStyles.AssumeLocal, out parseDate))
                        {
                            lbl      = (Label)e.Item.FindControl("lblDueDT");
                            lbl.Text = parseDate.ToShortDateString();
                        }
                    }
                }
                catch  {; }

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

                if (rgPreventativeList.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", 1);
                }
            }
        }
        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");
                lb8d.Visible = lbEditReport.Visible = false;                  // mt - for AAM

                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;
                }

                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);
                }
            }
        }