Exemple #1
0
        private int SaveContainment(decimal incidentId, List <INCFORM_CONTAIN> itemList)
        {
            PSsqmEntities entities = new PSsqmEntities();
            int           status   = 0;

            using (var ctx = new PSsqmEntities())
            {
                ctx.ExecuteStoreCommand("DELETE FROM INCFORM_CONTAIN WHERE INCIDENT_ID = {0}", incidentId);
            }

            int seq = 0;

            foreach (INCFORM_CONTAIN item in itemList)
            {
                var newItem = new INCFORM_CONTAIN();


                if (!string.IsNullOrEmpty(item.ITEM_DESCRIPTION))
                {
                    seq = seq + 1;

                    newItem.INCIDENT_ID        = incidentId;
                    newItem.ITEM_SEQ           = seq;
                    newItem.ITEM_DESCRIPTION   = item.ITEM_DESCRIPTION;
                    newItem.ASSIGNED_PERSON_ID = item.ASSIGNED_PERSON_ID;
                    newItem.START_DATE         = item.START_DATE;
                    newItem.LAST_UPD_BY        = SessionManager.UserContext.Person.FIRST_NAME + " " + SessionManager.UserContext.Person.LAST_NAME;
                    newItem.LAST_UPD_DT        = DateTime.Now;

                    entities.AddToINCFORM_CONTAIN(newItem);
                    status = entities.SaveChanges();
                }
            }
            return(status);
        }
Exemple #2
0
        public int AddUpdateINCFORM_CONTAIN(decimal incidentId)
        {
            var itemList  = new List <INCFORM_CONTAIN>();
            int seqnumber = 0;
            int status    = 0;

            foreach (RepeaterItem containtem in rptContain.Items)
            {
                var item = new INCFORM_CONTAIN();

                TextBox         tbca  = (TextBox)containtem.FindControl("tbContainAction");
                RadDropDownList rddlp = (RadDropDownList)containtem.FindControl("rddlContainPerson");
                Label           lb    = (Label)containtem.FindControl("lbItemSeq");
                RadDatePicker   sd    = (RadDatePicker)containtem.FindControl("rdpStartDate");

                seqnumber = seqnumber + 1;

                item.ITEM_DESCRIPTION   = tbca.Text;
                item.ASSIGNED_PERSON_ID = (String.IsNullOrEmpty(rddlp.SelectedValue)) ? 0 : Convert.ToInt32(rddlp.SelectedValue);
                item.ITEM_SEQ           = seqnumber;
                item.START_DATE         = sd.SelectedDate;

                itemList.Add(item);
            }

            if (itemList.Count > 0)
            {
                status = SaveContainment(incidentId, itemList);
            }

            return(status);
        }
        public int AddUpdateINCFORM_CONTAIN(decimal incidentId)
        {
            lblStatusMsg.Visible = false;
            var  itemList          = new List <INCFORM_CONTAIN>();
            int  seqnumber         = 0;
            int  status            = 0;
            bool allFieldsComplete = true;

            foreach (RepeaterItem containtem in rptContain.Items)
            {
                var item = new INCFORM_CONTAIN();

                TextBox       tbca  = (TextBox)containtem.FindControl("tbContainAction");
                RadComboBox   rddlp = (RadComboBox)containtem.FindControl("rddlContainPerson");
                Label         lb    = (Label)containtem.FindControl("lbItemSeq");
                RadDatePicker sd    = (RadDatePicker)containtem.FindControl("rdpStartDate");

                seqnumber = seqnumber + 1;

                if (string.IsNullOrEmpty(tbca.Text.Trim()) || !sd.SelectedDate.HasValue)
                {
                    allFieldsComplete = false;
                }
                else
                {
                    item.ITEM_DESCRIPTION   = tbca.Text.Trim();
                    item.ASSIGNED_PERSON_ID = (String.IsNullOrEmpty(rddlp.SelectedValue)) ? 0 : Convert.ToInt32(rddlp.SelectedValue);
                    item.ITEM_SEQ           = seqnumber;
                    item.START_DATE         = sd.SelectedDate;

                    if ((tbca = (TextBox)containtem.FindControl("tbComments")) != null)
                    {
                        item.COMMENTS = tbca.Text;
                    }
                }

                itemList.Add(item);
            }

            if (itemList.Count > 0)
            {
                if (allFieldsComplete)
                {
                    status = SaveContainment(incidentId, itemList);
                }
                else
                {
                    lblStatusMsg.Text    = Resources.LocalizedText.ENVProfileRequiredsMsg;
                    lblStatusMsg.Visible = true;
                    status = -1;
                }
            }

            return(status);
        }
        protected void rptContain_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            string cmd = "";

            if (source is Button)
            {
                Button btn = (Button)source;
                cmd = btn.CommandArgument;
            }
            else
            {
                cmd = e.CommandArgument.ToString();
            }

            if (cmd == "AddAnother")
            {
                var itemList  = new List <INCFORM_CONTAIN>();
                int seqnumber = 0;

                foreach (RepeaterItem containitem in rptContain.Items)
                {
                    var item = new INCFORM_CONTAIN();

                    TextBox       tbca  = (TextBox)containitem.FindControl("tbContainAction");
                    RadComboBox   rddlp = (RadComboBox)containitem.FindControl("rddlContainPerson");
                    Label         lb    = (Label)containitem.FindControl("lbItemSeq");
                    RadDatePicker sd    = (RadDatePicker)containitem.FindControl("rdpStartDate");
                    sd = SQMBasePage.SetRadDateCulture(sd, "");

                    rddlp.Items.Add(new RadComboBoxItem("", ""));
                    var personList = new List <PERSON>();
                    personList = SQMModelMgr.SelectPlantPersonList(SessionManager.UserContext.WorkingLocation.Company.COMPANY_ID, (decimal)LocalIncident.DETECT_PLANT_ID);
                    foreach (PERSON p in personList)
                    {
                        if (!String.IsNullOrEmpty(p.EMAIL))
                        {
                            string displayName = string.Format("{0}, {1} ({2})", p.LAST_NAME, p.FIRST_NAME, p.EMAIL);
                            rddlp.Items.Add(new RadComboBoxItem(displayName, Convert.ToString(p.PERSON_ID)));
                        }
                    }

                    if (!string.IsNullOrEmpty(rddlp.SelectedValue) && (rddlp.SelectedValue != ""))
                    {
                        item.ASSIGNED_PERSON_ID = Convert.ToInt32(rddlp.SelectedValue);
                    }

                    seqnumber = Convert.ToInt32(lb.Text);

                    item.ITEM_DESCRIPTION = tbca.Text;
                    item.ITEM_SEQ         = seqnumber;
                    item.START_DATE       = sd.SelectedDate;

                    itemList.Add(item);
                }

                var emptyItem = new INCFORM_CONTAIN();

                emptyItem.ITEM_DESCRIPTION   = "";
                emptyItem.ITEM_SEQ           = seqnumber + 1;
                emptyItem.ASSIGNED_PERSON_ID = null;
                emptyItem.START_DATE         = null;

                itemList.Add(emptyItem);

                rptContain.DataSource = itemList;
                rptContain.DataBind();
            }
            else if (cmd == "Delete")
            {
                int delId     = e.Item.ItemIndex;
                var itemList  = new List <INCFORM_CONTAIN>();
                int seqnumber = 0;

                foreach (RepeaterItem containitem in rptContain.Items)
                {
                    var item = new INCFORM_CONTAIN();

                    TextBox       tbca  = (TextBox)containitem.FindControl("tbContainAction");
                    RadComboBox   rddlp = (RadComboBox)containitem.FindControl("rddlContainPerson");
                    Label         lb    = (Label)containitem.FindControl("lbItemSeq");
                    RadDatePicker sd    = (RadDatePicker)containitem.FindControl("rdpStartDate");
                    sd = SQMBasePage.SetRadDateCulture(sd, "");

                    rddlp.Items.Add(new RadComboBoxItem("", ""));

                    var personList = new List <PERSON>();
                    personList = SQMModelMgr.SelectPlantPersonList(SessionManager.UserContext.WorkingLocation.Company.COMPANY_ID, (decimal)LocalIncident.DETECT_PLANT_ID);
                    foreach (PERSON p in personList)
                    {
                        if (!String.IsNullOrEmpty(p.EMAIL))
                        {
                            string displayName = string.Format("{0}, {1} ({2})", p.LAST_NAME, p.FIRST_NAME, p.EMAIL);
                            rddlp.Items.Add(new RadComboBoxItem(displayName, Convert.ToString(p.PERSON_ID)));
                        }
                    }

                    if (!string.IsNullOrEmpty(rddlp.SelectedValue) && (rddlp.SelectedValue != ""))
                    {
                        item.ASSIGNED_PERSON_ID = Convert.ToInt32(rddlp.SelectedValue);
                    }

                    if (Convert.ToInt32(lb.Text) != delId + 1)
                    {
                        seqnumber             = seqnumber + 1;
                        item.ITEM_DESCRIPTION = tbca.Text;
                        item.ITEM_SEQ         = seqnumber;
                        item.START_DATE       = sd.SelectedDate;
                        itemList.Add(item);
                    }
                }

                rptContain.DataSource = itemList;
                rptContain.DataBind();

                decimal incidentId = (IsEditContext) ? IncidentId : NewIncidentId;
                int     status     = SaveContainment(incidentId, itemList);
            }
        }
        public void rptContain_OnItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                int minRowsToValidate = 1;

                try
                {
                    INCFORM_CONTAIN contain = (INCFORM_CONTAIN)e.Item.DataItem;

                    TextBox       tbca  = (TextBox)e.Item.FindControl("tbContainAction");
                    RadComboBox   rddlp = (RadComboBox)e.Item.FindControl("rddlContainPerson");
                    Label         lb    = (Label)e.Item.FindControl("lbItemSeq");
                    RadDatePicker sd    = (RadDatePicker)e.Item.FindControl("rdpStartDate");
                    sd = SQMBasePage.SetRadDateCulture(sd, "");
                    //RadDatePicker cd = (RadDatePicker)e.Item.FindControl("rdpCompleteDate");
                    //CheckBox ic = (CheckBox)e.Item.FindControl("cbIsComplete");
                    RadButton itmdel = (RadButton)e.Item.FindControl("btnItemDelete");

                    RequiredFieldValidator rvfca = (RequiredFieldValidator)e.Item.FindControl("rfvContainAction");
                    RequiredFieldValidator rvfcp = (RequiredFieldValidator)e.Item.FindControl("rfvContainPerson");
                    RequiredFieldValidator rvfsd = (RequiredFieldValidator)e.Item.FindControl("rvfStartDate");

                    rvfca.ValidationGroup = ValidationGroup;
                    rvfcp.ValidationGroup = ValidationGroup;
                    rvfsd.ValidationGroup = ValidationGroup;

                    rddlp.Items.Add(new RadComboBoxItem("", ""));

                    var personList = new List <PERSON>();
                    personList = SQMModelMgr.SelectPlantPersonList(SessionManager.UserContext.WorkingLocation.Company.COMPANY_ID, (decimal)LocalIncident.DETECT_PLANT_ID);
                    foreach (PERSON p in personList)
                    {
                        if (!String.IsNullOrEmpty(p.EMAIL))
                        {
                            string displayName = string.Format("{0}, {1} ({2})", p.LAST_NAME, p.FIRST_NAME, p.EMAIL);
                            rddlp.Items.Add(new RadComboBoxItem(displayName, Convert.ToString(p.PERSON_ID)));
                        }
                    }

                    if (contain.ASSIGNED_PERSON_ID != null)
                    {
                        rddlp.SelectedValue = contain.ASSIGNED_PERSON_ID.ToString();
                    }
                    lb.Text         = contain.ITEM_SEQ.ToString();
                    tbca.Text       = contain.ITEM_DESCRIPTION;
                    sd.SelectedDate = contain.START_DATE;
                    //cd.SelectedDate = contain.COMPLETION_DATE;
                    //ic.Checked = contain.IsCompleted;

                    if ((tbca = (TextBox)e.Item.FindControl("tbComments")) != null)
                    {
                        tbca.Text = contain.COMMENTS;
                    }

                    // Set user access:
                    tbca.Enabled = rddlp.Enabled = sd.Enabled = itmdel.Visible = SessionManager.CheckUserPrivilege(SysPriv.action, SysScope.incident);

                    rvfca.Enabled = rvfcp.Enabled = rvfsd.Enabled = SessionManager.CheckUserPrivilege(SysPriv.action, SysScope.incident);

                    if (contain.ITEM_SEQ > minRowsToValidate)
                    {
                        rvfca.Enabled = false;
                        rvfcp.Enabled = false;
                        rvfsd.Enabled = false;
                    }

                    itmdel.Visible = PageMode == PageUseMode.ViewOnly ? false : EHSIncidentMgr.CanUpdateIncident(LocalIncident, IsEditContext, SysPriv.originate, LocalIncident.INCFORM_LAST_STEP_COMPLETED);
                }
                catch { }
            }

            btnSave.Visible = btnAddContain.Visible = PageMode == PageUseMode.ViewOnly ? false : EHSIncidentMgr.CanUpdateIncident(LocalIncident, IsEditContext, SysPriv.originate, LocalIncident.INCFORM_LAST_STEP_COMPLETED);
        }
        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;
                }
            }
        }
Exemple #7
0
        public void rptContain_OnItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                int minRowsToValidate = 1;

                try
                {
                    INCFORM_CONTAIN contain = (INCFORM_CONTAIN)e.Item.DataItem;

                    TextBox         tbca  = (TextBox)e.Item.FindControl("tbContainAction");
                    RadDropDownList rddlp = (RadDropDownList)e.Item.FindControl("rddlContainPerson");
                    Label           lb    = (Label)e.Item.FindControl("lbItemSeq");
                    RadDatePicker   sd    = (RadDatePicker)e.Item.FindControl("rdpStartDate");
                    //RadDatePicker cd = (RadDatePicker)e.Item.FindControl("rdpCompleteDate");
                    //CheckBox ic = (CheckBox)e.Item.FindControl("cbIsComplete");
                    RadButton itmdel = (RadButton)e.Item.FindControl("btnItemDelete");

                    RequiredFieldValidator rvfca = (RequiredFieldValidator)e.Item.FindControl("rfvContainAction");
                    RequiredFieldValidator rvfcp = (RequiredFieldValidator)e.Item.FindControl("rfvContainPerson");
                    RequiredFieldValidator rvfsd = (RequiredFieldValidator)e.Item.FindControl("rvfStartDate");

                    rvfca.ValidationGroup = ValidationGroup;
                    rvfcp.ValidationGroup = ValidationGroup;
                    rvfsd.ValidationGroup = ValidationGroup;

                    rddlp.Items.Add(new DropDownListItem("[Select One]", ""));

                    var personList = new List <PERSON>();
                    personList = SQMModelMgr.SelectPlantPersonList(SessionManager.UserContext.WorkingLocation.Company.COMPANY_ID, SessionManager.UserContext.WorkingLocation.Plant.PLANT_ID);
                    foreach (PERSON p in personList)
                    {
                        if (!String.IsNullOrEmpty(p.EMAIL))
                        {
                            string displayName = string.Format("{0}, {1} ({2})", p.LAST_NAME, p.FIRST_NAME, p.EMAIL);
                            rddlp.Items.Add(new DropDownListItem(displayName, Convert.ToString(p.PERSON_ID)));
                        }
                    }

                    if (contain.ASSIGNED_PERSON_ID != null)
                    {
                        rddlp.SelectedValue = contain.ASSIGNED_PERSON_ID.ToString();
                    }
                    lb.Text         = contain.ITEM_SEQ.ToString();
                    tbca.Text       = contain.ITEM_DESCRIPTION;
                    sd.SelectedDate = contain.START_DATE;
                    //cd.SelectedDate = contain.COMPLETION_DATE;
                    //ic.Checked = contain.IsCompleted;

                    // Set user access:
                    tbca.Enabled = rddlp.Enabled = sd.Enabled = itmdel.Visible = SessionManager.CheckUserPrivilege(SysPriv.action, SysScope.incident);

                    rvfca.Enabled = rvfcp.Enabled = rvfsd.Enabled = SessionManager.CheckUserPrivilege(SysPriv.action, SysScope.incident);

                    if (contain.ITEM_SEQ > minRowsToValidate)
                    {
                        rvfca.Enabled = false;
                        rvfcp.Enabled = false;
                        rvfsd.Enabled = false;
                    }
                }
                catch { }
            }

            if (e.Item.ItemType == ListItemType.Footer)
            {
                Button addanother = (Button)e.Item.FindControl("btnAddContain");
                addanother.Visible = SessionManager.CheckUserPrivilege(SysPriv.action, SysScope.incident);
            }
        }