protected int SaveRootCauses(decimal incidentId, List <INCFORM_ROOT5Y> itemList) { PSsqmEntities entities = new PSsqmEntities(); int status = 0; using (var ctx = new PSsqmEntities()) { ctx.ExecuteStoreCommand("DELETE FROM INCFORM_ROOT5Y WHERE INCIDENT_ID = {0}", incidentId); } int seq = 0; foreach (INCFORM_ROOT5Y item in itemList) { var newItem = new INCFORM_ROOT5Y(); if (!string.IsNullOrEmpty(item.ITEM_DESCRIPTION)) { seq = seq + 1; newItem.INCIDENT_ID = incidentId; newItem.ITEM_SEQ = seq; newItem.ITEM_DESCRIPTION = item.ITEM_DESCRIPTION; newItem.LAST_UPD_BY = SessionManager.UserContext.Person.FIRST_NAME + " " + SessionManager.UserContext.Person.LAST_NAME; newItem.LAST_UPD_DT = DateTime.Now; entities.AddToINCFORM_ROOT5Y(newItem); status = entities.SaveChanges(); } } return(status); }
public int AddUpdateINCFORM_ROOT5Y(decimal incidentId) { var itemList = new List <INCFORM_ROOT5Y>(); int seqnumber = 0; int status = 0; foreach (RepeaterItem rootcauseitem in rptRootCause.Items) { var item = new INCFORM_ROOT5Y(); TextBox tb = (TextBox)rootcauseitem.FindControl("tbRootCause"); HiddenField hfSeq = (HiddenField)rootcauseitem.FindControl("hfItemSeq"); HiddenField hf = (HiddenField)rootcauseitem.FindControl("hfItemType"); CheckBox cb = (CheckBox)rootcauseitem.FindControl("cbIsRootCause"); if (!String.IsNullOrEmpty(tb.Text)) { item.ITEM_TYPE = Convert.ToInt32(hf.Value); hf = (HiddenField)rootcauseitem.FindControl("hfProblemSeries"); item.PROBLEM_SERIES = Convert.ToInt32(hf.Value); item.IS_ROOTCAUSE = cb.Checked; seqnumber = seqnumber + 1; item.ITEM_DESCRIPTION = tb.Text; item.ITEM_SEQ = seqnumber; itemList.Add(item); } } status = SaveRootCauses(incidentId, itemList); return(status); }
public int AddUpdateINCFORM_ROOT5Y(decimal incidentId) { var itemList = new List <INCFORM_ROOT5Y>(); int seqnumber = 0; int status = 0; foreach (RepeaterItem rootcauseitem in rptRootCause.Items) { var item = new INCFORM_ROOT5Y(); TextBox tb = (TextBox)rootcauseitem.FindControl("tbRootCause"); Label lb = (Label)rootcauseitem.FindControl("lbItemSeq"); if (!String.IsNullOrEmpty(tb.Text)) { seqnumber = seqnumber + 1; item.ITEM_DESCRIPTION = tb.Text; item.ITEM_SEQ = seqnumber; itemList.Add(item); } } status = SaveRootCauses(incidentId, itemList); return(status); }
public void rptRootCause_OnItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { try { INCFORM_ROOT5Y rootCause = (INCFORM_ROOT5Y)e.Item.DataItem; Label lbPrompt = (Label)e.Item.FindControl("lbWhyPrompt"); Label lbSeq = (Label)e.Item.FindControl("lbItemSeq"); Label lbCause = (Label)e.Item.FindControl("lblRootCause"); if (rootCause.ITEM_TYPE == 1) { lbPrompt.Text = Resources.LocalizedText.ProblemStatement; lbSeq.Visible = false; lbCause.CssClass = "refText"; System.Web.UI.HtmlControls.HtmlGenericControl div = (System.Web.UI.HtmlControls.HtmlGenericControl)e.Item.FindControl("divPrompt"); //div.Style.Add("BACKGROUND-COLOR", "#FFFFE0"); div = (System.Web.UI.HtmlControls.HtmlGenericControl)e.Item.FindControl("divRootCause"); div.Style.Add("BACKGROUND-COLOR", "#FFFFE0"); Image img = (Image)e.Item.FindControl("imgProblem"); img.ImageUrl = "~/images/defaulticon/16x16/alert-alt.png"; //img.Visible = true; } else { if (currentProblemSeries != rootCause.PROBLEM_SERIES) { currentProblemSeries = rootCause.PROBLEM_SERIES.HasValue ? (int)rootCause.PROBLEM_SERIES : 0; currentItemSeq = 0; } lbSeq.Text = (++currentItemSeq).ToString(); if (rootCause.IS_ROOTCAUSE.HasValue && (bool)rootCause.IS_ROOTCAUSE == true) { Label lbIsRoot = (Label)e.Item.FindControl("lblIsRootCause"); lbIsRoot.Text = Resources.LocalizedText.RootCause; Image img = (Image)e.Item.FindControl("imgIsRootCause"); img.Visible = true; } } lbCause.Text = rootCause.ITEM_DESCRIPTION; } catch { } } }
protected int SaveRootCauses(decimal incidentId, List <INCFORM_ROOT5Y> itemList) { PSsqmEntities entities = new PSsqmEntities(); int status = 0; using (var ctx = new PSsqmEntities()) { ctx.ExecuteStoreCommand("DELETE FROM INCFORM_ROOT5Y WHERE INCIDENT_ID = {0}", incidentId); } int seq = 0; foreach (INCFORM_ROOT5Y item in itemList) { var newItem = new INCFORM_ROOT5Y(); if (!string.IsNullOrEmpty(item.ITEM_DESCRIPTION)) { seq = seq + 1; newItem.INCIDENT_ID = incidentId; newItem.ITEM_SEQ = seq; newItem.ITEM_TYPE = item.ITEM_TYPE; newItem.PROBLEM_SERIES = item.PROBLEM_SERIES; newItem.ITEM_DESCRIPTION = item.ITEM_DESCRIPTION; newItem.IS_ROOTCAUSE = item.IS_ROOTCAUSE; newItem.LAST_UPD_BY = SessionManager.UserContext.Person.FIRST_NAME + " " + SessionManager.UserContext.Person.LAST_NAME; newItem.LAST_UPD_DT = WebSiteCommon.LocalTime(DateTime.UtcNow, IncidentLocationTZ); entities.AddToINCFORM_ROOT5Y(newItem); status = entities.SaveChanges(); } } if (seq > 0) { EHSIncidentMgr.UpdateIncidentStatus(incidentId, IncidentStepStatus.rootcause, WebSiteCommon.LocalTime(DateTime.UtcNow, IncidentLocationTZ)); } return(status); }
public void rptRootCause_OnItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { int minRowsToValidate = 1; try { INCFORM_ROOT5Y rootCause = (INCFORM_ROOT5Y)e.Item.DataItem; TextBox tb = (TextBox)e.Item.FindControl("tbRootCause"); Label lb = (Label)e.Item.FindControl("lbItemSeq"); RadButton itmdel = (RadButton)e.Item.FindControl("btnItemDelete"); RequiredFieldValidator rvf = (RequiredFieldValidator)e.Item.FindControl("rfvRootCause"); rvf.ValidationGroup = ValidationGroup; lb.Text = rootCause.ITEM_SEQ.ToString(); tb.Text = rootCause.ITEM_DESCRIPTION; // Set user access: tb.Enabled = ActionAccess; itmdel.Visible = ActionAccess; rvf.Enabled = ActionAccess; if (rootCause.ITEM_SEQ > minRowsToValidate) { rvf.Enabled = false; } } catch { } } if (e.Item.ItemType == ListItemType.Footer) { Button addanother = (Button)e.Item.FindControl("btnAddRootCause"); addanother.Visible = ActionAccess; } }
protected void rptRootCause_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandArgument == "AddAnother") { var itemList = new List <INCFORM_ROOT5Y>(); int seqnumber = 0; foreach (RepeaterItem rootcauseitem in rptRootCause.Items) { var item = new INCFORM_ROOT5Y(); TextBox tb = (TextBox)rootcauseitem.FindControl("tbRootCause"); Label lb = (Label)rootcauseitem.FindControl("lbItemSeq"); seqnumber = Convert.ToInt32(lb.Text); item.ITEM_DESCRIPTION = tb.Text; item.ITEM_SEQ = seqnumber; itemList.Add(item); } var emptyItem = new INCFORM_ROOT5Y(); emptyItem.ITEM_DESCRIPTION = ""; emptyItem.ITEM_SEQ = seqnumber + 1; itemList.Add(emptyItem); rptRootCause.DataSource = itemList; rptRootCause.DataBind(); } else if (e.CommandArgument.ToString() == "Delete") { int delId = e.Item.ItemIndex; var itemList = new List <INCFORM_ROOT5Y>(); int seqnumber = 0; foreach (RepeaterItem rootcauseitem in rptRootCause.Items) { var item = new INCFORM_ROOT5Y(); TextBox tb = (TextBox)rootcauseitem.FindControl("tbRootCause"); Label lb = (Label)rootcauseitem.FindControl("lbItemSeq"); if (Convert.ToInt32(lb.Text) != delId + 1) { seqnumber = seqnumber + 1; item.ITEM_DESCRIPTION = tb.Text; item.ITEM_SEQ = seqnumber; itemList.Add(item); } } rptRootCause.DataSource = itemList; rptRootCause.DataBind(); decimal incidentId = (IsEditContext) ? EditIncidentId : NewIncidentId; int status = SaveRootCauses(incidentId, itemList); } }
protected void btnConversion_Click(object sender, EventArgs e) { int status = 0; INCIDENT_ANSWER answer = null; List <XLAT> xlatList = SQMBasePage.SelectXLATList(new string[6] { "SHIFT", "INJURY_CAUSE", "INJURY_TYPE", "INJURY_PART", "INJURY_TENURE", "IQ_10" }); foreach (EHSIncidentData eda in HSCalcs().ehsCtl.IncidentHst.Where(i => i.Incident.INCFORM_LAST_STEP_COMPLETED < 1 && i.Incident.INCIDENT_ID > 0)) { INCIDENT incident = (from i in entities.INCIDENT where i.INCIDENT_ID == eda.Incident.INCIDENT_ID select i).SingleOrDefault(); incident.INCIDENT_ANSWER.Load(); // clear any prior conversion reecords string delCmd = " = " + incident.INCIDENT_ID.ToString(); status = entities.ExecuteStoreCommand("DELETE FROM TASK_STATUS WHERE RECORD_TYPE = 40 AND RECORD_ID" + delCmd); status = entities.ExecuteStoreCommand("DELETE FROM INCFORM_LOSTTIME_HIST WHERE INCIDENT_ID" + delCmd); status = entities.ExecuteStoreCommand("DELETE FROM INCFORM_CONTAIN WHERE INCIDENT_ID" + delCmd); status = entities.ExecuteStoreCommand("DELETE FROM INCFORM_ACTION WHERE INCIDENT_ID" + delCmd); status = entities.ExecuteStoreCommand("DELETE FROM INCFORM_ROOT5Y WHERE INCIDENT_ID" + delCmd); status = entities.ExecuteStoreCommand("DELETE FROM INCFORM_CAUSATION WHERE INCIDENT_ID" + delCmd); status = entities.ExecuteStoreCommand("DELETE FROM INCFORM_APPROVAL WHERE INCIDENT_ID" + delCmd); status = entities.ExecuteStoreCommand("DELETE FROM INCFORM_WITNESS WHERE INCIDENT_ID" + delCmd); status = entities.ExecuteStoreCommand("DELETE FROM INCFORM_INJURYILLNESS WHERE INCIDENT_ID" + delCmd); EHSIncidentTypeId issueType = (EHSIncidentTypeId)incident.ISSUE_TYPE_ID; try { switch (issueType) { case EHSIncidentTypeId.PropertyDamage: case EHSIncidentTypeId.PowerOutage: case EHSIncidentTypeId.Fire: case EHSIncidentTypeId.Explosion: case EHSIncidentTypeId.ImsAudit: case EHSIncidentTypeId.RegulatoryContact: case EHSIncidentTypeId.FireSystemImpairment: case EHSIncidentTypeId.SpillRelease: case EHSIncidentTypeId.EhsWalk: case EHSIncidentTypeId.NearMiss: case EHSIncidentTypeId.InjuryIllness: incident.INCFORM_LAST_STEP_COMPLETED = 100; // assume new status answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 69).FirstOrDefault(); // containment if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE)) { incident.INCFORM_LAST_STEP_COMPLETED = 110; // containment INCFORM_CONTAIN contain = new INCFORM_CONTAIN(); contain.INCIDENT_ID = incident.INCIDENT_ID; contain.ITEM_SEQ = 1; contain.ITEM_DESCRIPTION = answer.ANSWER_VALUE; contain.ASSIGNED_PERSON_ID = incident.CREATE_PERSON; contain.START_DATE = contain.COMPLETION_DATE = incident.CREATE_DT; contain.IsCompleted = true; contain.LAST_UPD_BY = SessionManager.UserContext.UserName(); contain.LAST_UPD_DT = DateTime.UtcNow; entities.AddToINCFORM_CONTAIN(contain); } answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 24).FirstOrDefault(); // root cause if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE)) { incident.INCFORM_LAST_STEP_COMPLETED = 120; // root cause INCFORM_ROOT5Y rootc = new INCFORM_ROOT5Y(); rootc.INCIDENT_ID = incident.INCIDENT_ID; rootc.ITEM_SEQ = 1; rootc.ITEM_DESCRIPTION = answer.ANSWER_VALUE; rootc.LAST_UPD_BY = SessionManager.UserContext.UserName(); rootc.LAST_UPD_DT = DateTime.UtcNow; entities.AddToINCFORM_ROOT5Y(rootc); } answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 78).FirstOrDefault(); // causation if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE)) { incident.INCFORM_LAST_STEP_COMPLETED = 125; // causation INCFORM_CAUSATION cause = new INCFORM_CAUSATION(); cause.INCIDENT_ID = incident.INCIDENT_ID; cause.CAUSEATION_CD = xlatList.Where(l => l.XLAT_GROUP == "INJURY_CAUSE" && l.DESCRIPTION == answer.ANSWER_VALUE).FirstOrDefault() == null ? "1000" : xlatList.Where(l => l.XLAT_GROUP == "INJURY_CAUSE" && l.DESCRIPTION == answer.ANSWER_VALUE).FirstOrDefault().XLAT_CODE; cause.LAST_UPD_BY = SessionManager.UserContext.UserName(); cause.LAST_UPD_DT = DateTime.UtcNow; entities.AddToINCFORM_CAUSATION(cause); } answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 27).FirstOrDefault(); // corrective action if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE)) { incident.INCFORM_LAST_STEP_COMPLETED = 130; // corrective action TASK_STATUS action = new TASK_STATUS(); action.RECORD_TYPE = (int)TaskRecordType.HealthSafetyIncident; action.RECORD_ID = incident.INCIDENT_ID; action.TASK_STEP = ((int)SysPriv.action).ToString(); action.TASK_SEQ = 0; action.RECORD_SUBID = 0; action.TASK_TYPE = "T"; action.TASK_SEQ = 0; action.DESCRIPTION = answer.ANSWER_VALUE; action.DETAIL = incident.DESCRIPTION; action.STATUS = "1"; action.CREATE_ID = action.RESPONSIBLE_ID = action.COMPLETE_ID = incident.CREATE_PERSON; // default action values action.CREATE_DT = action.DUE_DT = action.COMPLETE_DT = incident.CREATE_DT; answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 79).FirstOrDefault(); // responsible if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE)) { action.RESPONSIBLE_ID = action.COMPLETE_ID = decimal.Parse(answer.ANSWER_VALUE); } answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 65).FirstOrDefault(); // action due date if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE)) { action.DUE_DT = DateTime.ParseExact(answer.ANSWER_VALUE, "M/d/yyyy hh:mm:ss tt", null); } answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 66).FirstOrDefault(); // action complete date if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE)) { action.COMPLETE_DT = DateTime.ParseExact(answer.ANSWER_VALUE, "M/d/yyyy hh:mm:ss tt", null); } answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 70).FirstOrDefault(); // verification ? if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE)) { action.COMMENTS = answer.ANSWER_VALUE; } entities.AddToTASK_STATUS(action); } if (incident.CLOSE_DATE_DATA_COMPLETE.HasValue || incident.CLOSE_DATE.HasValue) { incident.INCFORM_LAST_STEP_COMPLETED = 151; // signoff INCFORM_APPROVAL approval = new INCFORM_APPROVAL(); approval.INCIDENT_ID = incident.INCIDENT_ID; approval.ITEM_SEQ = (int)SysPriv.approve1; approval.APPROVAL_DATE = incident.CLOSE_DATE.HasValue ? incident.CLOSE_DATE : incident.CLOSE_DATE_DATA_COMPLETE; approval.IsAccepted = true; approval.APPROVER_PERSON_ID = incident.CLOSE_PERSON.HasValue ? incident.CLOSE_PERSON : incident.CREATE_PERSON; PERSON person = (from p in entities.PERSON where p.PERSON_ID == approval.APPROVER_PERSON_ID select p).FirstOrDefault(); approval.APPROVAL_MESSAGE = approval.APPROVER_PERSON = (person.FIRST_NAME + " " + person.LAST_NAME); answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 67).FirstOrDefault(); // completed by if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE)) { approval.APPROVAL_MESSAGE = approval.APPROVER_PERSON = answer.ANSWER_VALUE; string[] names = answer.ANSWER_VALUE.ToLower().Split(' '); if (names.Length > 1) { string firstName = names[0]; string lastnamne = names[1]; person = (from p in entities.PERSON where p.FIRST_NAME.ToLower() == firstName && p.LAST_NAME.ToLower() == lastnamne select p).FirstOrDefault(); } } if (person != null) { approval.APPROVER_PERSON_ID = person.PERSON_ID; approval.APPROVER_TITLE = person.JOB_TITLE; } entities.AddToINCFORM_APPROVAL(approval); } if (issueType == EHSIncidentTypeId.InjuryIllness) { INCFORM_INJURYILLNESS inRec = new INCFORM_INJURYILLNESS(); INCFORM_WITNESS witness = new INCFORM_WITNESS(); INCFORM_LOSTTIME_HIST hist = new INCFORM_LOSTTIME_HIST(); inRec.INCIDENT_ID = incident.INCIDENT_ID; answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 6).FirstOrDefault(); // shift inRec.SHIFT = GetXLATCode(xlatList, "SHIFT", answer.ANSWER_VALUE); answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 7).FirstOrDefault(); // department if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE)) { inRec.DEPARTMENT = answer.ANSWER_VALUE; DEPARTMENT dept = (from d in entities.DEPARTMENT where d.DEPT_NAME.ToLower() == answer.ANSWER_VALUE.ToLower() select d).SingleOrDefault(); if (dept != null) { inRec.DEPT_ID = dept.DEPT_ID; } } answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 8).FirstOrDefault(); // involved person if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE)) { inRec.INVOLVED_PERSON_NAME = answer.ANSWER_VALUE; } answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 4).FirstOrDefault(); // supervisor inform date if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE)) { inRec.SUPERVISOR_INFORMED_DT = DateTime.ParseExact(answer.ANSWER_VALUE, "M/d/yyyy hh:mm:ss tt", null); } answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 5).FirstOrDefault(); // time of incident if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE)) { inRec.INCIDENT_TIME = TimeSpan.Parse(answer.ANSWER_VALUE); } answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 9).FirstOrDefault(); // witness if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE) && answer.ANSWER_VALUE.Split(' ').Length > 1) { witness.INCIDENT_ID = incident.INCIDENT_ID; witness.WITNESS_NO = 1; witness.WITNESS_NAME = answer.ANSWER_VALUE; witness.LAST_UPD_BY = SessionManager.UserContext.UserName(); witness.LAST_UPD_DT = DateTime.UtcNow; entities.AddToINCFORM_WITNESS(witness); } answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 10).FirstOrDefault(); // inside/outside if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE)) { inRec.INSIDE_OUTSIDE_BLDNG = GetXLATCode(xlatList, "IQ_10", answer.ANSWER_VALUE); } answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 11).FirstOrDefault(); // weather if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE)) { ; // NO FIELD } answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 12).FirstOrDefault(); // injury type if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE)) { inRec.INJURY_TYPE = GetXLATCode(xlatList, "INJURY_TYPE", answer.ANSWER_VALUE); } answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 13).FirstOrDefault(); // body part if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE)) { inRec.INJURY_BODY_PART = GetXLATCode(xlatList, "INJURY_PART", answer.ANSWER_VALUE); } answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 15).FirstOrDefault(); // reocurrance if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE)) { inRec.REOCCUR = answer.ANSWER_VALUE.ToLower() == "yes" ? true : false; } answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 16).FirstOrDefault(); // first aid case if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE)) { inRec.FIRST_AID = answer.ANSWER_VALUE.ToLower() == "yes" ? true : false; } answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 37).FirstOrDefault(); // employee if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE)) { inRec.COMPANY_SUPERVISED = answer.ANSWER_VALUE.ToLower() == "yes" ? true : false; } answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 58).FirstOrDefault(); // specific description if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE)) { inRec.DESCRIPTION_LOCAL = answer.ANSWER_VALUE; } answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 62).FirstOrDefault(); // recordable if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE)) { inRec.RECORDABLE = answer.ANSWER_VALUE.ToLower() == "yes" ? true : false; } answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 63).FirstOrDefault(); // lost time case if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE)) { inRec.LOST_TIME = answer.ANSWER_VALUE.ToLower() == "yes" ? true : false; if (inRec.LOST_TIME) { hist.INCIDENT_ID = incident.INCIDENT_ID; hist.WORK_STATUS = "03"; hist.ITEM_DESCRIPTION = "Lost Time"; hist.BEGIN_DT = incident.INCIDENT_DT; answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 3).FirstOrDefault(); // expected return date if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE)) { hist.RETURN_EXPECTED_DT = DateTime.ParseExact(answer.ANSWER_VALUE, "M/d/yyyy hh:mm:ss tt", null); } answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 55).FirstOrDefault(); // actual return date if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE)) { hist.RETURN_TOWORK_DT = DateTime.ParseExact(answer.ANSWER_VALUE, "M/d/yyyy hh:mm:ss tt", null); } hist.LAST_UPD_BY = SessionManager.UserContext.UserName(); hist.LAST_UPD_DT = DateTime.UtcNow; entities.AddToINCFORM_LOSTTIME_HIST(hist); } } answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 74).FirstOrDefault(); // occupational event ? if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE)) { inRec.STD_PROCS_FOLLOWED = answer.ANSWER_VALUE.ToLower() == "yes" ? true : false; // map to std procedures ? } entities.AddToINCFORM_INJURYILLNESS(inRec); } status = entities.SaveChanges(); break; case EHSIncidentTypeId.PreventativeAction: break; default: break; } } catch { decimal id; id = incident.INCIDENT_ID; } } }
protected void rptRootCause_ItemCommand(object source, RepeaterCommandEventArgs e) { int itemId = e.Item.ItemIndex; if (e.CommandArgument == "AddAnother" || e.CommandArgument == "AddStatement") { var itemList = new List <INCFORM_ROOT5Y>(); int seqnumber = 0; int maxProblemSeries = -1; int problemSeries = -1; string defaultProblemStatement = ""; foreach (RepeaterItem rootcauseitem in rptRootCause.Items) { INCFORM_ROOT5Y item = new INCFORM_ROOT5Y(); TextBox tb = (TextBox)rootcauseitem.FindControl("tbRootCause"); HiddenField hfSeq = (HiddenField)rootcauseitem.FindControl("hfItemSeq"); HiddenField hf = (HiddenField)rootcauseitem.FindControl("hfItemType"); CheckBox cb = (CheckBox)rootcauseitem.FindControl("cbIsRootCause"); item.ITEM_TYPE = Convert.ToInt32(hf.Value); hf = (HiddenField)rootcauseitem.FindControl("hfProblemSeries"); item.PROBLEM_SERIES = Convert.ToInt32(hf.Value); seqnumber = Convert.ToInt32(hfSeq.Value); item.ITEM_DESCRIPTION = tb.Text; item.ITEM_SEQ = seqnumber; item.IS_ROOTCAUSE = cb.Checked; itemList.Add(item); // add problem series maxProblemSeries = Math.Max(maxProblemSeries, (int)item.PROBLEM_SERIES); if (seqnumber == itemId + 1) { // insert into problem series problemSeries = (int)item.PROBLEM_SERIES; } if (item.ITEM_TYPE == 0) { defaultProblemStatement = item.ITEM_DESCRIPTION; } } INCFORM_ROOT5Y emptyItem = new INCFORM_ROOT5Y(); if (e.CommandArgument == "AddStatement") { emptyItem.ITEM_SEQ = seqnumber + 1; emptyItem.ITEM_DESCRIPTION = defaultProblemStatement; emptyItem.ITEM_TYPE = 1; emptyItem.PROBLEM_SERIES = (problemSeries = ++maxProblemSeries); emptyItem.IS_ROOTCAUSE = false; itemList.Add(emptyItem); } emptyItem = new INCFORM_ROOT5Y(); emptyItem.ITEM_SEQ = seqnumber + 1; emptyItem.ITEM_DESCRIPTION = ""; emptyItem.ITEM_TYPE = 0; emptyItem.IS_ROOTCAUSE = false; emptyItem.PROBLEM_SERIES = Math.Max(problemSeries, 0); itemList.Add(emptyItem); rptRootCause.DataSource = itemList.OrderBy(l => l.PROBLEM_SERIES).ThenBy(l => l.ITEM_SEQ).ToList(); rptRootCause.DataBind(); } else if (e.CommandArgument.ToString() == "Delete") { var itemList = new List <INCFORM_ROOT5Y>(); int seqnumber = 0; int problemSeries = -1; bool shouldDelete = false; foreach (RepeaterItem rootcauseitem in rptRootCause.Items) { var item = new INCFORM_ROOT5Y(); TextBox tb = (TextBox)rootcauseitem.FindControl("tbRootCause"); HiddenField hfSeq = (HiddenField)rootcauseitem.FindControl("hfItemSeq"); HiddenField hfType = (HiddenField)rootcauseitem.FindControl("hfItemType"); HiddenField hfSeries = (HiddenField)rootcauseitem.FindControl("hfProblemSeries"); CheckBox cb = (CheckBox)rootcauseitem.FindControl("cbIsRootCause"); if (Convert.ToInt32(hfSeries.Value) != problemSeries) { shouldDelete = false; } problemSeries = Convert.ToInt32(hfSeries.Value); if (Convert.ToInt32(hfSeq.Value) == itemId + 1 || shouldDelete) { if (hfType.Value == "1") // deleting an entire problem series { shouldDelete = true; } } else { shouldDelete = false; seqnumber = seqnumber + 1; item.ITEM_DESCRIPTION = tb.Text; item.ITEM_SEQ = seqnumber; item.ITEM_TYPE = Convert.ToInt32(hfType.Value); item.IS_ROOTCAUSE = cb.Checked; item.PROBLEM_SERIES = problemSeries; itemList.Add(item); } } rptRootCause.DataSource = itemList.OrderBy(l => l.PROBLEM_SERIES).ThenBy(l => l.ITEM_SEQ).ToList(); rptRootCause.DataBind(); int status = SaveRootCauses(IncidentId, itemList); } }
public void rptRootCause_OnItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { try { INCFORM_ROOT5Y rootCause = (INCFORM_ROOT5Y)e.Item.DataItem; RadButton itmdel = (RadButton)e.Item.FindControl("btnItemDelete"); TextBox tb = (TextBox)e.Item.FindControl("tbRootCause"); Label lp = (Label)e.Item.FindControl("lblProblemStatement"); tb.Text = lp.Text = rootCause.ITEM_DESCRIPTION; HiddenField hfSeq = (HiddenField)e.Item.FindControl("hfItemSeq"); hfSeq.Value = rootCause.ITEM_SEQ.ToString(); HiddenField hf = (HiddenField)e.Item.FindControl("hfItemType"); hf.Value = rootCause.ITEM_TYPE.HasValue ? rootCause.ITEM_TYPE.ToString() : "0"; hf = (HiddenField)e.Item.FindControl("hfProblemSeries"); hf.Value = rootCause.PROBLEM_SERIES.HasValue ? rootCause.PROBLEM_SERIES.ToString() : "0"; Label lb = (Label)e.Item.FindControl("lbWhyPrompt"); if (rootCause.ITEM_TYPE == 1) // problem statement { tb.Visible = true; lp.Visible = false; lb.Text = Resources.LocalizedText.ProblemStatement; Image img = (Image)e.Item.FindControl("imgProblem"); img.ImageUrl = "~/images/defaulticon/16x16/alert-alt.png"; //img.Visible = true; Panel pnl = (Panel)e.Item.FindControl("pnlIsRootCause"); pnl.Visible = false; System.Web.UI.HtmlControls.HtmlGenericControl div = (System.Web.UI.HtmlControls.HtmlGenericControl)e.Item.FindControl("divPrompt"); //div.Style.Add("BACKGROUND-COLOR", "#FFFFE0"); div = (System.Web.UI.HtmlControls.HtmlGenericControl)e.Item.FindControl("divRootCause"); tb.Style.Add("BACKGROUND-COLOR", "#FFFFE0"); if (rootCause.PROBLEM_SERIES < 1) { itmdel.Visible = false; // don't allow deleting 1st problem series } Button btn = (Button)e.Item.FindControl("btnAddRootCause"); if (PageMode == PageUseMode.ViewOnly) { btn.Visible = false; } } else { tb.Visible = true; // 'why' cause lp.Visible = false; lb = (Label)e.Item.FindControl("lbItemSeq"); if (currentProblemSeries != rootCause.PROBLEM_SERIES) { currentProblemSeries = rootCause.PROBLEM_SERIES.HasValue ? (int)rootCause.PROBLEM_SERIES : 0; currentItemSeq = 0; } lb.Text = (++currentItemSeq).ToString(); Button btn = (Button)e.Item.FindControl("btnAddRootCause"); btn.Visible = false; if (rootCause.IS_ROOTCAUSE.HasValue && (bool)rootCause.IS_ROOTCAUSE == true) { CheckBox cb = (CheckBox)e.Item.FindControl("cbIsRootCause"); cb.Checked = true; } } if (itmdel.Visible) { itmdel.Visible = PageMode == PageUseMode.ViewOnly ? false : EHSIncidentMgr.CanUpdateIncident(LocalIncident, IsEditContext, SysPriv.action, LocalIncident.INCFORM_LAST_STEP_COMPLETED); } } catch { } } if (e.Item.ItemType == ListItemType.Footer) { Button btnAdd = (Button)e.Item.FindControl("btnAddStatement"); RadButton btnSave = (RadButton)e.Item.FindControl("btnSave"); //Save button is visible when localincident is not null if (LocalIncident != null) { btnSave.Visible = btnAdd.Visible = PageMode == PageUseMode.ViewOnly ? false : EHSIncidentMgr.CanUpdateIncident(LocalIncident, IsEditContext, SysPriv.action, LocalIncident.INCFORM_LAST_STEP_COMPLETED); if (RootCauseLevels() < 2) { btnAdd.Visible = false; } } else { btnAdd.Visible = false; btnSave.Visible = false; } } if (e.Item.ItemType == ListItemType.Header) { Label lp = (Label)e.Item.FindControl("lblProblemDesc"); // Get Description if incident is not null if (LocalIncident != null) { lp.Text = LocalIncident.DESCRIPTION; } } }