void PopulateByProblemCaseId(decimal problemCaseId) { PROB_CASE probCase = ProblemCase.LookupCase(entities, problemCaseId); if (probCase != null) { List <INCIDENT> incidentList = ProblemCase.LookupProbIncidentList(entities, probCase); ltrDate.Text = probCase.CREATE_DT.ToString(); if (incidentList.Count > 0) { var incident = incidentList[0]; string plantName = EHSIncidentMgr.SelectPlantNameById((decimal)incident.DETECT_PLANT_ID); lblPlantName.Text = String.Format("Location: {0}", plantName); lblIncidentId.Text = String.Format("Incident ID: {0}", incident.INCIDENT_ID); //lblCaseId.Text = String.Format("Problem Case ID: {0}", probCase.PROBCASE_ID); string incidentType = EHSIncidentMgr.SelectIncidentTypeByIncidentId(incident.INCIDENT_ID); decimal incidentTypeId = EHSIncidentMgr.SelectIncidentTypeIdByIncidentId(incident.INCIDENT_ID); decimal companyId = incident.DETECT_COMPANY_ID; var questions = EHSIncidentMgr.SelectIncidentQuestionList(incidentTypeId, companyId, 0); questions.AddRange(EHSIncidentMgr.SelectIncidentQuestionList(incidentTypeId, companyId, 1)); // Date/Time ltrDate.Text = incidentList[0].INCIDENT_DT.ToLongDateString(); var timeQuestion = questions.FirstOrDefault(q => q.QuestionId == 5); if (timeQuestion != null) { string timeAnswer = (from a in entities.INCIDENT_ANSWER where a.INCIDENT_ID == incident.INCIDENT_ID && a.INCIDENT_QUESTION_ID == 5 select a.ANSWER_VALUE).FirstOrDefault(); if (!string.IsNullOrEmpty(timeAnswer)) { ltrTime.Text = Convert.ToDateTime(timeAnswer).ToShortTimeString(); } } // Incident Type ltrIncidentType.Text = incidentType; // Description ltrDescription.Text = "<div style=\"width: 600px; word-wrap: break-word;\">" + Server.HtmlEncode(probCase.DESC_LONG) + "</div>"; // Root Cause(s) List <PROB_CAUSE_STEP> probCauses = (from i in entities.PROB_CAUSE_STEP where i.PROBCASE_ID == problemCaseId && i.IS_ROOTCAUSE == true select i).ToList(); if (probCauses.Count > 0) { ltrRootCause.Text = "<ul>"; foreach (var pc in probCauses) { ltrRootCause.Text += "<li>" + Server.HtmlEncode(pc.WHY_OCCUR) + "</li>"; } ltrRootCause.Text += "</ul>"; } // Containment var containment = (from i in entities.PROB_CONTAIN where i.PROBCASE_ID == problemCaseId select new { Disposition = i.INITIAL_DISPOSITION, Action = i.INITIAL_ACTION, Results = i.INITIAL_RESULTS }).FirstOrDefault(); if (containment != null) { ltrContainment.Text = "<ul><li>Initial Disposition: " + Server.HtmlEncode(containment.Disposition) + "</li>" + "<li>Action: " + Server.HtmlEncode(containment.Action) + "</li>" + "<li>Results: " + Server.HtmlEncode(containment.Results) + "</li>" + "</ul>"; } // Corrective Actions var correctiveActions = (from i in entities.PROB_CAUSE_ACTION where i.PROBCASE_ID == problemCaseId select i.ACTION_DESC).ToList(); if (correctiveActions.Count > 0) { ltrCorrectiveActions.Text = "<ul>"; foreach (var caDesc in correctiveActions) { ltrCorrectiveActions.Text += "<li>" + Server.HtmlEncode(caDesc) + "</li>"; } ltrCorrectiveActions.Text += "</ul>"; } // Photos BindAttachmentsProbCase(incident.INCIDENT_ID, probCase.PROBCASE_ID); } else { pnlContent.Visible = false; pnlError.Visible = true; } } }
void PopulateByIncidentId(decimal incidentId) { var entities = new PSsqmEntities(); var incident = EHSIncidentMgr.SelectIncidentById(entities, incidentId); string plantName = EHSIncidentMgr.SelectPlantNameById((decimal)incident.DETECT_PLANT_ID); lblPlantName.Text = String.Format("Location: {0}", plantName); lblIncidentId.Text = String.Format("Incident ID: {0}", incidentId); //lblCaseId.Text = String.Format("Incident ID: {0}", incidentId); string incidentType = EHSIncidentMgr.SelectIncidentTypeByIncidentId(incidentId); decimal incidentTypeId = EHSIncidentMgr.SelectIncidentTypeIdByIncidentId(incidentId); decimal companyId = incident.DETECT_COMPANY_ID; var questions = EHSIncidentMgr.SelectIncidentQuestionList(incidentTypeId, companyId, 0); questions.AddRange(EHSIncidentMgr.SelectIncidentQuestionList(incidentTypeId, companyId, 1)); // Date/Time ltrDate.Text = incident.INCIDENT_DT.ToLongDateString(); var timeQuestion = questions.FirstOrDefault(q => q.QuestionId == (decimal)EHSQuestionId.TimeOfDay); if (timeQuestion != null) { string timeAnswer = (from a in entities.INCIDENT_ANSWER where a.INCIDENT_ID == incident.INCIDENT_ID && a.INCIDENT_QUESTION_ID == (decimal)EHSQuestionId.TimeOfDay select a.ANSWER_VALUE).FirstOrDefault(); if (!string.IsNullOrEmpty(timeAnswer)) { ltrTime.Text = Convert.ToDateTime(timeAnswer).ToShortTimeString(); } } // Incident Type ltrIncidentType.Text = incidentType; // Description ltrDescription.Text = "<div style=\"width: 600px; word-wrap: break-word;\">" + Server.HtmlEncode(incident.DESCRIPTION) + "</div>"; // Root Cause(s) var rootCauseQuestion = questions.FirstOrDefault(q => q.QuestionId == (decimal)EHSQuestionId.RootCause); if (rootCauseQuestion != null) { string rootCauseAnswer = (from a in entities.INCIDENT_ANSWER where a.INCIDENT_ID == incidentId && a.INCIDENT_QUESTION_ID == (decimal)EHSQuestionId.RootCause select a.ANSWER_VALUE).FirstOrDefault(); if (!string.IsNullOrEmpty(rootCauseAnswer)) { ltrRootCause.Text = "<div style=\"width: 600px; word-wrap: break-word;\">" + Server.HtmlEncode(rootCauseAnswer) + "</div>"; } } // Containment var containmentQuestion = questions.FirstOrDefault(q => q.QuestionId == (decimal)EHSQuestionId.Containment); if (containmentQuestion != null) { string containmentAnswer = (from a in entities.INCIDENT_ANSWER where a.INCIDENT_ID == incidentId && a.INCIDENT_QUESTION_ID == (decimal)EHSQuestionId.Containment select a.ANSWER_VALUE).FirstOrDefault(); if (!string.IsNullOrEmpty(containmentAnswer)) { ltrContainment.Text = "<div style=\"width: 600px; word-wrap: break-word;\">" + Server.HtmlEncode(containmentAnswer) + "</div>"; } } // Corrective Actions var correctiveQuestion = questions.FirstOrDefault(q => q.QuestionId == (decimal)EHSQuestionId.CorrectiveActions); if (correctiveQuestion != null) { string correctiveAnswer = (from a in entities.INCIDENT_ANSWER where a.INCIDENT_ID == incidentId && a.INCIDENT_QUESTION_ID == (decimal)EHSQuestionId.CorrectiveActions select a.ANSWER_VALUE).FirstOrDefault(); if (!string.IsNullOrEmpty(correctiveAnswer)) { ltrCorrectiveActions.Text = "<div style=\"width: 600px; word-wrap: break-word;\">" + Server.HtmlEncode(correctiveAnswer) + "</div>"; } } // Photos BindAttachmentsIncident(incident.INCIDENT_ID); }