public static List <PERSON> SelectIncidentPersonList(decimal incidentId) { var personSelectList = new List <PERSON>(); var entities = new PSsqmEntities(); INCIDENT incident = SelectIncidentById(entities, incidentId); decimal companyId = 0; if (incident.DETECT_COMPANY_ID != null) { companyId = incident.DETECT_COMPANY_ID; } // start with all data originators for the company List <PERSON> personList = SQMModelMgr.SelectPersonList(companyId, 0, true, false).Where(l => l.ROLE <= 300).OrderBy(p => p.LAST_NAME).ToList(); personList = SQMModelMgr.FilterPersonListByAppContext(personList, "EHS"); // limit the list to those people having access to the plant where the incident (if defined) occurred if (incident != null) { foreach (PERSON person in personList) { if (SQMModelMgr.PersonPlantAccess(person, (decimal)incident.DETECT_PLANT_ID) || (incident.RESP_PLANT_ID.HasValue && SQMModelMgr.PersonPlantAccess(person, (decimal)incident.RESP_PLANT_ID))) { personSelectList.Add(person); } } } personSelectList = personSelectList.OrderBy(p => p.FIRST_NAME).ToList(); personSelectList = personSelectList.OrderBy(p => p.LAST_NAME).ToList(); return(personSelectList); }
public void PopulateInitialForm() { PSsqmEntities entities = new PSsqmEntities(); decimal typeId = (IsEditContext) ? EditIncidentTypeId : SelectedTypeId; if (IncidentId > 0) { try { LocalIncident = (from i in entities.INCIDENT where i.INCIDENT_ID == IncidentId select i).SingleOrDefault(); PLANT plant = SQMModelMgr.LookupPlant(entities, (decimal)LocalIncident.DETECT_PLANT_ID, ""); if (plant != null) { IncidentLocationTZ = plant.LOCAL_TIMEZONE; } if (PageMode == PageUseMode.ViewOnly) { divTitle.Visible = true; lblFormTitle.Text = Resources.LocalizedText.RootCause; } pnlRoot5Y.Enabled = PageMode == PageUseMode.ViewOnly ? false : EHSIncidentMgr.CanUpdateIncident(LocalIncident, IsEditContext, SysPriv.originate, LocalIncident.INCFORM_LAST_STEP_COMPLETED); } catch { } } InitializeForm(); }
public static void TryClosePrevention(decimal incidentId, decimal personId) { var entities = new PSsqmEntities(); INCIDENT incident = SelectIncidentById(entities, incidentId); bool shouldUpdateAuditPerson = true; if (ShouldPreventionClose(incident)) { incident.CLOSE_DATE = DateTime.Now; incident.CLOSE_PERSON = personId; SetTaskComplete(incidentId, 45); shouldUpdateAuditPerson = false; } else { incident.CLOSE_DATE = null; } if (ShouldPreventionCloseAudited(incident)) { incident.CLOSE_DATE_DATA_COMPLETE = DateTime.Now; if (shouldUpdateAuditPerson == true) { incident.AUDIT_PERSON = personId; } } else { incident.CLOSE_DATE_DATA_COMPLETE = null; } entities.SaveChanges(); }
public static bool ShouldPreventionCloseAudited(INCIDENT incident) { bool shouldClose = false; var entities = new PSsqmEntities(); var questionList = SelectIncidentQuestionList((decimal)incident.ISSUE_TYPE_ID, incident.DETECT_COMPANY_ID, 1); foreach (var q in questionList) { string answer = (from a in entities.INCIDENT_ANSWER where a.INCIDENT_ID == incident.INCIDENT_ID && a.INCIDENT_QUESTION_ID == q.QuestionId select a.ANSWER_VALUE).FirstOrDefault(); if (q.QuestionId == (decimal)EHSQuestionId.FinalAuditStepResolved && !string.IsNullOrEmpty(answer)) { if (answer.ToLower() == "yes" || answer.ToLower().Contains("funding")) { shouldClose = true; } } } return(shouldClose); }
public BusinessLocation ProblemBusinessLocation() { BusinessLocation problemLocation = new BusinessLocation(); if (this.IncidentList != null && this.IncidentList.Count > 0) { INCIDENT incident = this.IncidentList[0]; if (incident.INCIDENT_TYPE == "QI") { problemLocation.Company = SQMModelMgr.LookupCompany((decimal)incident.RESP_COMPANY_ID); problemLocation.BusinessOrg = SQMModelMgr.LookupBusOrg((decimal)incident.RESP_BUS_ORG_ID); problemLocation.Plant = SQMModelMgr.LookupPlant((decimal)incident.RESP_PLANT_ID); } else { problemLocation.Company = SQMModelMgr.LookupCompany((decimal)incident.DETECT_COMPANY_ID); problemLocation.BusinessOrg = SQMModelMgr.LookupBusOrg((decimal)incident.DETECT_BUS_ORG_ID); problemLocation.Plant = SQMModelMgr.LookupPlant((decimal)incident.DETECT_PLANT_ID); } } else { problemLocation.Company = this.ProbCase.COMPANY; } return(problemLocation); }
public static bool ShouldIncidentReportClose(INCIDENT incident) { var entities = new PSsqmEntities(); int incidentClosedScore = 0; var questionList = SelectIncidentQuestionList((decimal)incident.ISSUE_TYPE_ID, incident.DETECT_COMPANY_ID, 1); foreach (var q in questionList) { string answer = (from a in entities.INCIDENT_ANSWER where a.INCIDENT_ID == incident.INCIDENT_ID && a.INCIDENT_QUESTION_ID == q.QuestionId select a.ANSWER_VALUE).FirstOrDefault(); if (q.QuestionId == (decimal)EHSQuestionId.CompletionDate && !string.IsNullOrEmpty(answer)) { incidentClosedScore++; } if (q.QuestionId == (decimal)EHSQuestionId.CompletedBy && !string.IsNullOrEmpty(answer)) { incidentClosedScore++; } } return(incidentClosedScore >= 2); }
public static void TryCloseIncident(decimal incidentId) { var entities = new PSsqmEntities(); INCIDENT incident = SelectIncidentById(entities, incidentId); if (ShouldIncidentReportClose(incident)) { incident.CLOSE_DATE = DateTime.Now; SetTaskComplete(incidentId, 40); } else { incident.CLOSE_DATE = null; } if (ShouldIncidentCloseDataComplete(incident)) { incident.CLOSE_DATE_DATA_COMPLETE = DateTime.Now; } else { incident.CLOSE_DATE_DATA_COMPLETE = null; } entities.SaveChanges(); }
private decimal GetTaskLocation(TASK_STATUS task) { decimal plantID = SessionManager.UserContext.HRLocation.Plant.PLANT_ID; switch ((TaskRecordType)task.RECORD_TYPE) { case TaskRecordType.HealthSafetyIncident: case TaskRecordType.PreventativeAction: INCIDENT incident = EHSIncidentMgr.SelectIncidentById(new PSsqmEntities(), task.RECORD_ID); if (incident != null && incident.DETECT_PLANT_ID.HasValue) { plantID = (decimal)incident.DETECT_PLANT_ID; } break; case TaskRecordType.Audit: AUDIT audit = EHSAuditMgr.SelectAuditById(new PSsqmEntities(), task.RECORD_ID); if (audit != null && audit.DETECT_PLANT_ID.HasValue) { plantID = (decimal)audit.DETECT_PLANT_ID; } break; } return(plantID); }
public static void NotifyOnCreate(decimal incidentId, decimal plantId) { var entities = new PSsqmEntities(); decimal companyId = SessionManager.UserContext.HRLocation.Company.COMPANY_ID; decimal busOrgId = SessionManager.UserContext.HRLocation.BusinessOrg.BUS_ORG_ID; var emailIds = new HashSet <decimal>(); INCIDENT incident = EHSIncidentMgr.SelectIncidentById(entities, incidentId); string incidentLocation = EHSIncidentMgr.SelectIncidentLocationNameByIncidentId(incidentId); string incidentType = EHSIncidentMgr.SelectIncidentTypeByIncidentId(incidentId); List <ATTACHMENT> attachList = SQM.Website.Classes.SQMDocumentMgr.SelectAttachmentListByRecord(40, incidentId, "", ""); List <NOTIFY> notifications = SQMModelMgr.SelectNotifyHierarchy(companyId, busOrgId, plantId, 0, TaskRecordType.HealthSafetyIncident); foreach (NOTIFY n in notifications) { if (n.NOTIFY_PERSON1 != null) { emailIds.Add((decimal)n.NOTIFY_PERSON1); } if (n.NOTIFY_PERSON2 != null) { emailIds.Add((decimal)n.NOTIFY_PERSON2); } } if (emailIds.Count > 0) { string appUrl = SQMSettings.SelectSettingByCode(entities, "MAIL", "TASK", "MailURL").VALUE; if (string.IsNullOrEmpty(appUrl)) { appUrl = "the website"; } string emailSubject = "Incident Created: " + incidentType + " (" + incidentLocation + ")"; string emailBody = "A new incident has been created:<br/>" + "<br/>" + incidentLocation + "<br/>" + incidentType + "<br/>" + "<br/>" + incident.DESCRIPTION + "<br/>" + "<br/>" + "Please log in to " + appUrl + " to view the incident."; foreach (decimal eid in emailIds) { string emailAddress = (from p in entities.PERSON where p.PERSON_ID == eid select p.EMAIL).FirstOrDefault(); Thread thread = new Thread(() => WebSiteCommon.SendEmail(emailAddress, emailSubject, emailBody, "", "web", attachList)); thread.IsBackground = true; thread.Start(); //WebSiteCommon.SendEmail(emailAddress, emailSubject, emailBody, ""); } } }
protected void UpdateDisplayState(DisplayState state, decimal incidentID) { try { switch (state) { case DisplayState.IncidentList: SearchIncidents(); SessionManager.ClearReturns(); break; case DisplayState.IncidentNotificationNew: SessionManager.ClearReturns(); if (rddlNewActionType.SelectedItem != null) { INCIDENT newIncident = new INCIDENT(); newIncident.DETECT_PLANT_ID = Convert.ToDecimal(ddlActionLocation.SelectedValue); newIncident.ISSUE_TYPE_ID = (decimal)EHSIncidentTypeId.PreventativeAction; newIncident.ISSUE_TYPE = rddlNewActionType.SelectedValue; if (newIncident.DETECT_PLANT_ID < 1 || newIncident.ISSUE_TYPE_ID < 1) { ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Error creating new PrevAction');", true); } else { SessionManager.ReturnObject = newIncident; SessionManager.ReturnStatus = true; Response.Redirect("/EHS/EHS_PrevActionForm.aspx"); } } break; case DisplayState.IncidentNotificationEdit: SessionManager.ClearReturns(); INCIDENT theIncident = EHSIncidentMgr.SelectIncidentById(entities, incidentID); if (theIncident != null) { SessionManager.ReturnObject = theIncident; SessionManager.ReturnStatus = true; string stepCmd = ""; if (!string.IsNullOrEmpty(Request.QueryString["s"])) // from inbox/calendar assume this is a task assignment. direct to corrective actions page { stepCmd = ("?s=" + Request.QueryString["s"]); } Response.Redirect("/EHS/EHS_PrevActionForm.aspx" + stepCmd); } break; default: SessionManager.ClearReturns(); break; } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Error updating PrevAction display state:'" + ex.Message + ");", true); } }
protected void OnIssue_Click(string issueID) { List <INCIDENT> incidentList = new List <INCIDENT>(); INCIDENT incident = new INCIDENT(); incident.INCIDENT_ID = Convert.ToDecimal(issueID); incidentList.Add(incident); SessionManager.ReturnObject = incidentList; SessionManager.ReturnStatus = true; CloseWindow(); }
public static string SelectIncidentAnswer(INCIDENT incident, decimal questionId) { string answerText = null; var entities = new PSsqmEntities(); answerText = (from a in entities.INCIDENT_ANSWER where a.INCIDENT_ID == incident.INCIDENT_ID && a.INCIDENT_QUESTION_ID == questionId select a.ANSWER_VALUE).FirstOrDefault(); return(answerText); }
protected void Page_Load(object sender, EventArgs e) { PSsqmEntities entities = new PSsqmEntities(); companyId = SessionManager.UserContext.WorkingLocation.Company.COMPANY_ID; if (IsPostBack) { // Since IsPostBack is always TRUE for every invocation of this user control we need some way // to determine whether or not to refresh its page controls, or just data bind instead. // Here we are using the "__EVENTTARGET" form event property to see if this user control is loading // because of certain page control events that are supposed to be fired off as actual postbacks. IsFullPagePostback = false; var targetID = Request.Form["__EVENTTARGET"]; if (!string.IsNullOrEmpty(targetID)) { var targetControl = this.Page.FindControl(targetID); if (targetControl != null) { if ((this.Page.FindControl(targetID).ID == "rddlWorkStatus") || (this.Page.FindControl(targetID).ID == "btnSubnavSave") || (this.Page.FindControl(targetID).ID == "btnAddFinal")) { IsFullPagePostback = true; } } } else { // The postback is coming from btnSubnavSave IsFullPagePostback = true; } } if (IncidentId != null) { INCIDENT incident = (from i in entities.INCIDENT where i.INCIDENT_ID == IncidentId select i).FirstOrDefault(); //if (incident != null) //if (incident.CLOSE_DATE != null && incident.CLOSE_DATE_DATA_COMPLETE != null) //btnClose.Text = "Reopen Power Outage Incident"; } if (!IsFullPagePostback) { PopulateInitialForm(); } }
public void AddIncident(decimal incidentID) { INCIDENT incident = LookupIncident(incidentID); if (incident != null) { this.IncidentList.Add(incident); PROB_OCCUR occur = new PROB_OCCUR(); occur.INCIDENT_ID = incidentID; occur.STATUS = "A"; this.ProbCase.PROB_OCCUR.Add(occur); LoadIncidentIssueInfo(incidentID); SetAliasID(); } return; }
public static List <PERSON> InvolvedPersonList(INCIDENT incident) { List <PERSON> involvedList = new List <PERSON>(); if (incident.ISSUE_TYPE_ID == (int)EHSIncidentTypeId.InjuryIllness) { PSsqmEntities ctx = new PSsqmEntities(); INCFORM_INJURYILLNESS iiDetail = EHSIncidentMgr.SelectInjuryIllnessDetailsById(ctx, incident.INCIDENT_ID); if (iiDetail != null && iiDetail.INVOLVED_PERSON_ID.HasValue) { involvedList = SQMModelMgr.GetSupvHierarchy(ctx, SQMModelMgr.LookupPerson(ctx, (decimal)iiDetail.INVOLVED_PERSON_ID, "", false), 2, true); } } return(involvedList); }
protected void Page_Load(object sender, EventArgs e) { PSsqmEntities entities = new PSsqmEntities(); if (IncidentId != null) { INCIDENT incident = (from i in entities.INCIDENT where i.INCIDENT_ID == IncidentId select i).FirstOrDefault(); if (incident != null) { if (incident.CLOSE_DATE != null && incident.CLOSE_DATE_DATA_COMPLETE != null) { btnClose.Text = "Reopen Incident Verification"; } } } }
protected void Page_PreRender(object sender, EventArgs e) { if (!IsPostBack) { uclIncidentForm.Mode = IncidentMode.Incident; Ucl_DocMgr ucl = (Ucl_DocMgr)this.Master.FindControl("uclDocSelect"); if (ucl != null) { ucl.BindDocumentSelect("EHS", 2, true, true, ""); } try { if (SessionManager.ReturnStatus == true && SessionManager.ReturnObject is INCIDENT) { INCIDENT incident = SessionManager.ReturnObject as INCIDENT; string context = SessionManager.ReturnContext; SessionManager.ClearReturns(); SessionManager.SetIncidentLocation((decimal)incident.DETECT_PLANT_ID); if (incident.INCIDENT_ID > 0) { // edit existing incident if (context == "a") { uclIncidentForm.BindIncidentAlert(incident.INCIDENT_ID); } else { uclIncidentForm.BindIncident(incident.INCIDENT_ID); } } else { // create new uclIncidentForm.InitNewIncident((decimal)incident.ISSUE_TYPE_ID, (decimal)incident.DETECT_PLANT_ID); } uclIncidentForm.Visible = true; } } catch { } } }
protected void Page_PreRender(object sender, EventArgs e) { if (!IsPostBack) { Ucl_DocMgr ucl = (Ucl_DocMgr)this.Master.FindControl("uclDocSelect"); if (ucl != null) { ucl.BindDocumentSelect("EHS", 2, true, true, ""); } try { if (SessionManager.ReturnStatus == true && SessionManager.ReturnObject is INCIDENT) { INCIDENT incident = SessionManager.ReturnObject as INCIDENT; SessionManager.ClearReturns(); SessionManager.SetIncidentLocation((decimal)incident.DETECT_PLANT_ID); if (incident.INCIDENT_ID > 0) { // edit existing incident int step = 0; string returnOverride = ""; if (!string.IsNullOrEmpty(Request.QueryString["s"])) // from inbox/calendar assume this is a task assignment. direct to corrective actions page { int.TryParse(Request.QueryString["s"], out step); returnOverride = "/Home/Calendar.aspx"; } uclActionForm.BindIncident(incident.INCIDENT_ID, step, returnOverride); } else { // create new uclActionForm.InitNewIncident((decimal)incident.ISSUE_TYPE_ID, incident.ISSUE_TYPE, (decimal)incident.DETECT_PLANT_ID); } uclActionForm.Visible = true; } } catch { } } }
protected void Page_Load(object sender, EventArgs e) { companyId = SessionManager.UserContext.WorkingLocation.Company.COMPANY_ID; if (Request.QueryString["inid"] != null && Request.QueryString["peid"] != null && Request.QueryString["plid"] != null) { incidentId = Convert.ToDecimal(Request.QueryString["inid"]); personId = Convert.ToDecimal(Request.QueryString["peid"]); plantId = Convert.ToDecimal(Request.QueryString["plid"]); if (personId == SessionManager.UserContext.Person.PERSON_ID) { INCIDENT incident = (from v in entities.INCIDENT_VERIFICATION where v.INCIDENT_ID == incidentId && v.PERSON_ID == personId && v.PLANT_ID == plantId select(from i in entities.INCIDENT where i.INCIDENT_ID == incidentId select i).FirstOrDefault() ).FirstOrDefault(); PLANT plant = (from p in entities.PLANT where p.PLANT_ID == plantId select p).FirstOrDefault(); lblPlantLocation.Text = plant.DISP_PLANT_NAME; lblIncidentDate.Text = incident.INCIDENT_DT.ToShortDateString(); lblIncidentInstructions.Text = incident.DESCRIPTION; decimal probCaseId = (decimal)incident.VERIFY_PROBCASE_ID; PopulateComments(); lblFullName.Text = SessionManager.UserContext.Person.FIRST_NAME + " " + SessionManager.UserContext.Person.LAST_NAME; ltrDownloadReport.Text = BuildReport(probCaseId); CheckSubmitDisabled(); } else { lblPageInstructions.Text = "INVALID ACCESS LEVEL."; divPageBody.Visible = false; } } }
public List <PERSON> LoadPersonSelectList(bool anyLocation, string appContext) { this.PersonSelectList = new List <PERSON>(); // limit the list to those people having access to the plant where the incident (if defined) occurred INCIDENT incident = this.IncidentList.FirstOrDefault(); if (incident != null) { List <BusinessLocation> locationList = new List <BusinessLocation>(); locationList.Add(new BusinessLocation().Initialize((decimal)incident.DETECT_PLANT_ID)); if (incident.RESP_PLANT_ID.HasValue) { locationList.Add(new BusinessLocation().Initialize((decimal)incident.RESP_PLANT_ID)); } this.PersonSelectList = SQMModelMgr.SelectPlantPersonList(locationList, appContext == "SQM" ? "211,212" : "312", AccessMode.Update); } return(this.PersonSelectList); }
public static INCIDENT LookupIncident(decimal incidentID) { INCIDENT incident = null; using (PSsqmEntities entities = new PSsqmEntities()) { try { incident = (from i in entities.INCIDENT where (i.INCIDENT_ID == incidentID) select i).Single(); } catch (Exception e) { // SQMLogger.LogException(e); } } return(incident); }
public static int NotifyIncidentTaskAssigment(INCIDENT incident, TASK_STATUS theTask, string scopeAction) { int status = 0; PLANT plant = SQMModelMgr.LookupPlant((decimal)incident.DETECT_PLANT_ID); PERSON person = SQMModelMgr.LookupPerson((decimal)theTask.RESPONSIBLE_ID, ""); if (person != null && !string.IsNullOrEmpty(person.EMAIL)) { List <XLAT> XLATList = SQMBasePage.SelectXLATList(new string[3] { "NOTIFY_SCOPE", "NOTIFY_SCOPE_TASK", "NOTIFY_TASK_STATUS" }); string appUrl = SQMSettings.SelectSettingByCode(new PSsqmEntities(), "MAIL", "TASK", "MailURL").VALUE; if (string.IsNullOrEmpty(appUrl)) { appUrl = "the website"; } string emailTo = person.EMAIL; string actionText = XLATList.Where(x => x.XLAT_GROUP == "NOTIFY_SCOPE_TASK" && x.XLAT_CODE == scopeAction).FirstOrDefault().DESCRIPTION; string emailSubject = "Health/Safety Incident " + actionText + ": " + incident.ISSUE_TYPE + " (" + plant.PLANT_NAME + ")"; string emailBody = "You have been assigned to one or more tasks regarding the following Incident: <br/>" + "<br/>" + "Incident ID: " + WebSiteCommon.FormatID(incident.INCIDENT_ID, 6) + "<br/>" + plant.PLANT_NAME + "<br/>" + incident.ISSUE_TYPE + "<br/>" + "<br/>" + incident.DESCRIPTION + "<br/>" + "<br/>" + theTask.DESCRIPTION + "<br/>" + "<br/>" + "Due : " + theTask.DUE_DT.ToString() + "<br/>" + "<br/>" + "Please log in to " + (appUrl + incidentPath) + " to view this incident."; Thread thread = new Thread(() => WebSiteCommon.SendEmail(emailTo, emailSubject, emailBody, "", "web", null)); thread.IsBackground = true; thread.Start(); } return(status); }
public AlertData() { incidentDate = "N/A"; incidentTime = "N/A"; incidentLocation = "N/A"; locationNLS = "en"; incidentDept = "N/A"; incidentNumber = "N/A"; incidentType = "N/A"; incidentDescription = "N/A"; detectPerson = null; involvedPerson = null; supervisorPerson = null; incident = null; answerList = new List <INCIDENT_ANSWER>(); containList = new List <INCFORM_CONTAIN>(); root5YList = new List <INCFORM_ROOT5Y>(); causation = null; actionList = new List <TASK_STATUS>(); approvalList = new List <EHSIncidentApproval>(); }
public void PopulateForm() { PSsqmEntities entities = new PSsqmEntities(); if (IsEditContext == true) { INCIDENT incident = (from i in entities.INCIDENT where i.INCIDENT_ID == IncidentId select i).FirstOrDefault(); if (incident != null) { if (incident.VERIFY_PROBCASE_ID != null && rcbCases.Items.Count > 0) { if (rcbCases.Items.Count > 0) { if (rcbCases.Items.FindItemByValue(incident.VERIFY_PROBCASE_ID.ToString()) != null) { rcbCases.SelectedValue = incident.VERIFY_PROBCASE_ID.ToString(); } } tbInstructions.Text = incident.DESCRIPTION; rdpDueDate.SelectedDate = incident.INCIDENT_DT; btnSubmit.Text = "Save Incident"; btnClose.Visible = true; } } } else { tbInstructions.Text = ""; rdpDueDate.Clear(); btnSubmit.Text = "Add Incident and Send Notifications"; } plantList = SQMModelMgr.SelectPlantList(entities, SessionManager.UserContext.HRLocation.Company.COMPANY_ID, 0); pnlSelect.Visible = true; gvPreventLocationsList.DataSource = plantList; gvPreventLocationsList.DataBind(); }
public static List <ProblemCase> QualifyCaseList(List <PROB_CASE> problemCaseList, decimal[] plantIDS) { var qualCaseList = new List <ProblemCase>(); PLANT plant = null; using (PSsqmEntities entities = new PSsqmEntities()) { try { foreach (PROB_CASE probCase in problemCaseList) { INCIDENT incident = ProblemCase.LookupProbIncidentList(entities, probCase).FirstOrDefault(); if (incident != null && ((incident.DETECT_PLANT_ID.HasValue && plantIDS.Contains((decimal)incident.DETECT_PLANT_ID)) || (incident.RESP_PLANT_ID.HasValue && plantIDS.Contains((decimal)incident.RESP_PLANT_ID)))) { if (plant == null || plant.PLANT_ID != incident.DETECT_PLANT_ID) { plant = SQMModelMgr.LookupPlant((decimal)incident.DETECT_PLANT_ID); } ProblemCase problemCase = new ProblemCase(); problemCase.IncidentList = new List <INCIDENT>(); problemCase.ProbCase = probCase; problemCase.IncidentList.Add(incident); problemCase.Plant = plant; if (incident.INCIDENT_TYPE == "QI") { ; // todo get qi_occur and part number } qualCaseList.Add(problemCase); } } } catch (Exception ex) { // SQMLogger.LogException(ex); } } return(qualCaseList); }
public int PopulateInitialForm(PSsqmEntities ctx) { int status = 0; INCIDENT incident = EHSIncidentMgr.SelectIncidentById(ctx, IncidentId, true); //if incident is not null populate the form if (incident != null) { PLANT plant = SQMModelMgr.LookupPlant(ctx, (decimal)incident.DETECT_PLANT_ID, ""); if (plant != null) { IncidentLocationTZ = plant.LOCAL_TIMEZONE; } BindCausation(incident); pnlCausation.Enabled = PageMode == PageUseMode.ViewOnly ? false : EHSIncidentMgr.CanUpdateIncident(incident, IsEditContext, SysPriv.originate, incident.INCFORM_LAST_STEP_COMPLETED); } return(status); }
public static bool ShouldIncidentCloseDataComplete(INCIDENT incident) { var entities = new PSsqmEntities(); var questionList = SelectIncidentQuestionList((decimal)incident.ISSUE_TYPE_ID, incident.DETECT_COMPANY_ID, 0); var requiredQuestionIds = (from q in questionList where q.IsRequiredClose == true select q.QuestionId).ToList(); // Remove lost time date questions from required questions if not a lost time case if (incident.ISSUE_TYPE_ID == (decimal)EHSIncidentTypeId.InjuryIllness) { var lostTimeQuestion = (from q in questionList where q.QuestionId == (decimal)EHSQuestionId.LostTimeCase select q).FirstOrDefault(); if (lostTimeQuestion != null) { var answerText = SelectIncidentAnswer(incident, (decimal)EHSQuestionId.LostTimeCase); if (answerText != "Yes") { requiredQuestionIds.Remove((decimal)EHSQuestionId.ExpectedReturnDate); requiredQuestionIds.Remove((decimal)EHSQuestionId.ActualReturnDate); } } } var answers = (from a in entities.INCIDENT_ANSWER where a.INCIDENT_ID == incident.INCIDENT_ID && requiredQuestionIds.Contains(a.INCIDENT_QUESTION_ID) select a.ANSWER_VALUE).ToList(); bool shouldClose = true; foreach (var a in answers) { if (string.IsNullOrEmpty(a)) { shouldClose = false; break; } } return(shouldClose); }
public void PopulateInitialForm(string context) { lblStatusMsg.Visible = false; PSsqmEntities entities = new PSsqmEntities(); hfContext.Value = context; IncidentId = (IsEditContext) ? IncidentId : NewIncidentId; companyId = SessionManager.UserContext.WorkingLocation.Company.COMPANY_ID; if (IncidentId > 0) { try { WorkStatusIncident = (from i in entities.INCIDENT where i.INCIDENT_ID == IncidentId select i).Single(); PLANT plant = SQMModelMgr.LookupPlant(entities, (decimal)WorkStatusIncident.DETECT_PLANT_ID, ""); if (plant != null) { IncidentLocationTZ = plant.LOCAL_TIMEZONE; } } catch { return; } } else { WorkStatusIncident = new INCIDENT(); WorkStatusIncident.INCFORM_LAST_STEP_COMPLETED = 100; } decimal typeId = (IsEditContext) ? EditIncidentTypeId : SelectedTypeId; // what the f**k does this do ? //formSteps = EHSIncidentMgr.GetStepsForincidentTypeId(typeId); //totalFormSteps = formSteps.Count(); InitializeForm(); }
protected void btnClose_Click(object sender, EventArgs e) { PSsqmEntities entities = new PSsqmEntities(); if (IncidentId != null) { INCIDENT incident = (from i in entities.INCIDENT where i.INCIDENT_ID == IncidentId select i).FirstOrDefault(); if (incident.CLOSE_DATE == null || incident.CLOSE_DATE_DATA_COMPLETE == null) { incident.CLOSE_DATE = DateTime.Now; incident.CLOSE_DATE_DATA_COMPLETE = DateTime.Now; } else { incident.CLOSE_DATE = null; // Reopen incident.CLOSE_DATE_DATA_COMPLETE = null; } entities.SaveChanges(); } Response.Redirect("EHS_Incidents.aspx"); }
public void BindIncidentListHeader(INCIDENT incident, TaskItem taskItem) { pnlIncidentTaskHdr.Visible = true; lblCaseDescription.Visible = lblIncidentDescription.Visible = lblActionDescription.Visible = false; if (incident.ISSUE_TYPE_ID == 13) // preventative action { lblActionDescription.Visible = true; } else { lblIncidentDescription.Visible = true; } if (taskItem.Plant != null) { lblCasePlant_out.Text = taskItem.Plant.PLANT_NAME; } lblResponsible_out.Text = SQMModelMgr.FormatPersonListItem(taskItem.Person); lblCase2ID_out.Text = WebSiteCommon.FormatID(incident.INCIDENT_ID, 6); // lblCase2Desc_out.Text = incident.ISSUE_TYPE; lblCase2Desc_out.Text = taskItem.Task.DESCRIPTION; }