예제 #1
0
        protected void uclAdminList_OnDeptClick(decimal deptID)
        {
            BUSINESS_ORG busOrg = (BUSINESS_ORG)SessionManager.EffLocation.BusinessOrg;
            DEPARTMENT   dept   = SQMModelMgr.LookupDepartment(entities, SessionManager.EffLocation.Company.COMPANY_ID, busOrg.BUS_ORG_ID, 0, deptID, "", false);

            uclSubLists.ToggleVisible(null);
            pnlAdminEdit.Visible = true;
            uclAdminEdit.BindDeptartment(dept);
            LocalOrg().EditObject = dept;
        }
        protected void uclAdminList_OnDeptClick(decimal deptID)
        {
            PLANT      plant = (PLANT)SessionManager.EffLocation.Plant;
            DEPARTMENT dept  = SQMModelMgr.LookupDepartment(entities, (decimal)plant.COMPANY_ID, (decimal)plant.BUS_ORG_ID, (decimal)plant.PLANT_ID, deptID, "", false);

            uclSubLists.ToggleVisible(null);
            pnlAdminEdit.Visible = true;
            uclAdminEdit.BindDeptartment(dept);
            LocalOrg().EditObject = dept;
        }
        protected void SaveDept()
        {
            bool success;

            if (uclAdminEdit.IsNew)
            {
                PLANT      plant   = (PLANT)SessionManager.EffLocation.Plant;
                DEPARTMENT deptNew = new DEPARTMENT();
                deptNew = uclAdminEdit.ReadDepartment(deptNew);
                LocalOrg().DeptList.Add(SQMModelMgr.CreateDepartment(entities, plant, deptNew, SessionManager.UserContext.UserName()));
            }
            else
            {
                DEPARTMENT dept = (DEPARTMENT)LocalOrg().EditObject;
                dept = SQMModelMgr.LookupDepartment(entities, (decimal)dept.COMPANY_ID, (decimal)dept.BUS_ORG_ID, (decimal)dept.PLANT_ID, (decimal)dept.DEPT_ID, "", false);
                dept = uclAdminEdit.ReadDepartment(dept);
                SQMModelMgr.UpdateDepartment(entities, dept, SessionManager.UserContext.UserName());
                LocalOrg().DeptList[LocalOrg().DeptList.FindIndex(d => (d.DEPT_ID == dept.DEPT_ID))] = dept;
            }

            LocalOrg().EditObject = null;
            DoDeptList();
            pnlAdminEdit.Visible = false;
        }
예제 #4
0
        AlertData PopulateByIncidentId(decimal iid)
        {
            AlertData d        = new AlertData();
            var       entities = new PSsqmEntities();

            d.incident = EHSIncidentMgr.SelectIncidentById(entities, iid);

            if (d.incident != null)
            {
                try
                {
                    string plantName = EHSIncidentMgr.SelectPlantNameById((decimal)d.incident.DETECT_PLANT_ID);
                    d.incidentLocation = plantName;
                    d.incidentNumber   = WebSiteCommon.FormatID(iid, 6);

                    string  incidentType   = EHSIncidentMgr.SelectIncidentTypeByIncidentId(iid);
                    decimal incidentTypeId = EHSIncidentMgr.SelectIncidentTypeIdByIncidentId(iid);
                    decimal companyId      = d.incident.DETECT_COMPANY_ID;
                    var     questions      = EHSIncidentMgr.SelectIncidentQuestionList(incidentTypeId, companyId, 0);
                    questions.AddRange(EHSIncidentMgr.SelectIncidentQuestionList(incidentTypeId, companyId, 1));

                    d.answerList = EHSIncidentMgr.GetIncidentAnswerList(d.incident.INCIDENT_ID);
                    INCIDENT_ANSWER answer = null;

                    // Date/Time

                    d.incidentDate = d.incident.INCIDENT_DT.ToShortDateString();
                    if ((answer = d.answerList.Where(a => a.INCIDENT_QUESTION_ID == (decimal)EHSQuestionId.TimeOfDay).SingleOrDefault()) != null)
                    {
                        if (!string.IsNullOrEmpty(answer.ANSWER_VALUE))
                        {
                            d.incidentTime = Convert.ToDateTime(answer.ANSWER_VALUE).ToShortTimeString();
                        }
                    }

                    if ((answer = d.answerList.Where(a => a.INCIDENT_QUESTION_ID == (decimal)EHSQuestionId.Shift).SingleOrDefault()) != null)
                    {
                        if (!string.IsNullOrEmpty(SQMBasePage.GetXLAT(reportXLAT, "SHIFT", answer.ANSWER_VALUE).DESCRIPTION))
                        {
                            answer.ANSWER_VALUE = SQMBasePage.GetXLAT(reportXLAT, "SHIFT", answer.ANSWER_VALUE).DESCRIPTION;
                        }
                    }

                    if ((answer = d.answerList.Where(a => a.INCIDENT_QUESTION_ID == (decimal)EHSQuestionId.Department).SingleOrDefault()) != null)
                    {
                        d.incidentDept = answer.ANSWER_VALUE;
                        decimal deptID = 0;
                        if (decimal.TryParse(answer.ANSWER_VALUE, out deptID))
                        {
                            DEPARTMENT dept = SQMModelMgr.LookupDepartment(entities, deptID);
                            if (dept != null)
                            {
                                d.incidentDept = dept.DEPT_NAME;
                            }
                        }
                    }

                    // Incident Type

                    d.incidentType = incidentType;

                    // Description

                    d.incidentDescription = d.incident.DESCRIPTION;

                    d.detectPerson = SQMModelMgr.LookupPerson(entities, (decimal)d.incident.CREATE_PERSON, "", false);
                    if (d.detectPerson != null)
                    {
                        d.supervisorPerson = SQMModelMgr.LookupPersonByEmpID(entities, d.detectPerson.SUPV_EMP_ID);
                    }

                    if (d.incident.ISSUE_TYPE_ID == (decimal)EHSIncidentTypeId.InjuryIllness)
                    {
                        if (d.incident.INCFORM_INJURYILLNESS.INVOLVED_PERSON_ID.HasValue)
                        {
                            d.involvedPerson = SQMModelMgr.LookupPerson(entities, (decimal)d.incident.INCFORM_INJURYILLNESS.INVOLVED_PERSON_ID, "", false);
                            if (d.involvedPerson != null)
                            {
                                if (d.incident.INCFORM_INJURYILLNESS.SUPERVISOR_PERSON_ID.HasValue)                                             // supervisor was known
                                {
                                    d.supervisorPerson = SQMModelMgr.LookupPerson(entities, (decimal)d.incident.INCFORM_INJURYILLNESS.SUPERVISOR_PERSON_ID, "", false);
                                }
                                else
                                {
                                    // get current supervisor
                                    d.supervisorPerson = SQMModelMgr.LookupPersonByEmpID(entities, d.involvedPerson.SUPV_EMP_ID);
                                }
                            }
                        }
                        else
                        {
                            d.involvedPerson            = new PERSON();
                            d.involvedPerson.FIRST_NAME = d.incident.INCFORM_INJURYILLNESS.INVOLVED_PERSON_NAME;
                        }

                        if (d.incident.INCFORM_INJURYILLNESS.DEPT_ID.HasValue)
                        {
                            DEPARTMENT dept = SQMModelMgr.LookupDepartment(entities, (decimal)d.incident.INCFORM_INJURYILLNESS.DEPT_ID);
                            if (dept != null)
                            {
                                d.incidentDept = dept.DEPT_NAME;
                            }
                        }
                        else
                        {
                            d.incidentDept = d.incident.INCFORM_INJURYILLNESS.DEPARTMENT;
                        }
                    }

                    // Containment
                    foreach (INCFORM_CONTAIN cc in EHSIncidentMgr.GetContainmentList(iid, null, false))
                    {
                        if (cc.ASSIGNED_PERSON_ID.HasValue)
                        {
                            cc.ASSIGNED_PERSON = SQMModelMgr.FormatPersonListItem(SQMModelMgr.LookupPerson((decimal)cc.ASSIGNED_PERSON_ID, ""));
                        }
                        d.containList.Add(cc);
                    }

                    // Root Cause(s)
                    d.root5YList = EHSIncidentMgr.GetRootCauseList(iid).Where(l => !string.IsNullOrEmpty(l.ITEM_DESCRIPTION)).ToList();
                    if (d.root5YList != null && d.root5YList.Count > 0)
                    {
                        d.incident.INCFORM_CAUSATION.Load();
                        if (d.incident.INCFORM_CAUSATION != null && d.incident.INCFORM_CAUSATION.Count > 0)
                        {
                            d.causation = d.incident.INCFORM_CAUSATION.ElementAt(0);
                        }
                    }

                    // Corrective Actions
                    foreach (TASK_STATUS ac in EHSIncidentMgr.GetCorrectiveActionList(iid, null, false))
                    {
                        if (ac.RESPONSIBLE_ID.HasValue)
                        {
                            ac.COMMENTS = SQMModelMgr.FormatPersonListItem(SQMModelMgr.LookupPerson((decimal)ac.RESPONSIBLE_ID, ""));
                        }
                        d.actionList.Add(ac);
                    }

                    var files = (from a in entities.ATTACHMENT
                                 where
                                 (a.RECORD_ID == iid && a.RECORD_TYPE == 40 && a.DISPLAY_TYPE > 0) &&
                                 (a.FILE_NAME.ToLower().Contains(".jpg") || a.FILE_NAME.ToLower().Contains(".jpeg") ||
                                  a.FILE_NAME.ToLower().Contains(".gif") || a.FILE_NAME.ToLower().Contains(".png") ||
                                  a.FILE_NAME.ToLower().Contains(".bmp"))
                                 orderby a.RECORD_TYPE, a.FILE_NAME
                                 select new
                    {
                        Data = (from f in entities.ATTACHMENT_FILE where f.ATTACHMENT_ID == a.ATTACHMENT_ID select f.ATTACHMENT_DATA).FirstOrDefault(),
                        Description = (string.IsNullOrEmpty(a.FILE_DESC)) ? "" : a.FILE_DESC,
                    }).ToList();


                    d.approvalList = EHSIncidentMgr.GetApprovalList(entities, (decimal)d.incident.ISSUE_TYPE_ID, 10.0m, iid, null, 0);

                    if (files.Count > 0)
                    {
                        d.photoData     = new List <byte[]>();
                        d.photoCaptions = new List <string>();

                        foreach (var f in files)
                        {
                            d.photoData.Add(f.Data);
                            d.photoCaptions.Add(f.Description);
                        }
                    }
                }
                catch
                {
                }
            }

            return(d);
        }
        AuditData PopulateByAuditId(decimal aid)
        {
            AuditData d        = new AuditData();
            var       entities = new PSsqmEntities();

            d.audit = EHSAuditMgr.SelectAuditById(entities, aid);

            if (d.audit != null)
            {
                try
                {
                    string plantName = EHSAuditMgr.SelectPlantNameById((decimal)d.audit.DETECT_PLANT_ID);
                    d.auditLocation = plantName;
                    d.auditNumber   = aid.ToString();

                    AUDIT_TYPE auditType = EHSAuditMgr.SelectAuditTypeById(entities, d.audit.AUDIT_TYPE_ID);
                    d.auditType = auditType.TITLE;                     // do I need this?
                    decimal auditTypeId = d.audit.AUDIT_TYPE_ID;       // if I have all this, why am I redefining it?
                    decimal companyId   = d.audit.DETECT_COMPANY_ID;
                    if (d.audit.DEPT_ID != null)
                    {
                        if (d.audit.DEPT_ID == 0)
                        {
                            d.auditDepartment = "Plant Wide";
                        }
                        else
                        {
                            DEPARTMENT dept = SQMModelMgr.LookupDepartment(entities, (decimal)d.audit.DEPT_ID);
                            d.auditDepartment = dept.DEPT_NAME;
                        }
                    }

                    var questions = EHSAuditMgr.SelectAuditQuestionList(auditTypeId, 0, aid);
                    d.questionList = questions;

                    List <AUDIT_TOPIC> topics          = new List <AUDIT_TOPIC>();
                    AUDIT_TOPIC        topic           = new AUDIT_TOPIC();
                    decimal            previousTopicId = 0;
                    foreach (EHSAuditQuestion question in questions)
                    {
                        if (question.TopicId != previousTopicId)
                        {
                            topic = new AUDIT_TOPIC();
                            topic.AUDIT_TOPIC_ID = question.TopicId;
                            topic.TITLE          = question.TopicTitle;
                            topics.Add(topic);
                            previousTopicId = question.TopicId;
                        }
                    }
                    d.topicList = topics;

                    // Date/Time

                    d.auditDate = d.audit.AUDIT_DT.ToShortDateString();
                    DateTime closeDate = d.audit.AUDIT_DT.AddDays(auditType.DAYS_TO_COMPLETE);
                    d.auditCloseDate = closeDate.ToShortDateString();

                    // Description

                    d.auditDescription = d.audit.DESCRIPTION;

                    d.auditPerson = SQMModelMgr.LookupPerson(entities, (decimal)d.audit.AUDIT_PERSON, "", false);

                    // Audit Exception Actions

                    foreach (TASK_STATUS ac in EHSAuditMgr.GetAuditActionList(aid, 0))
                    {
                        //if (ac.RESPONSIBLE_ID.HasValue)
                        //{
                        //	ac.COMMENTS = SQMModelMgr.FormatPersonListItem(SQMModelMgr.LookupPerson((decimal)ac.RESPONSIBLE_ID, ""));
                        //}
                        d.actionList.Add(ac);
                    }

                    // not showing the attachments at this point, but not deleting code... just in case
                    //var files = (from a in entities.ATTACHMENT
                    //			 where
                    //				(a.RECORD_ID == aid && a.RECORD_TYPE == 40 && a.DISPLAY_TYPE > 0) &&
                    //				(a.FILE_NAME.ToLower().Contains(".jpg") || a.FILE_NAME.ToLower().Contains(".jpeg") ||
                    //				a.FILE_NAME.ToLower().Contains(".gif") || a.FILE_NAME.ToLower().Contains(".png") ||
                    //				a.FILE_NAME.ToLower().Contains(".bmp"))
                    //			 orderby a.RECORD_TYPE, a.FILE_NAME
                    //			 select new
                    //			 {
                    //				 Data = (from f in entities.ATTACHMENT_FILE where f.ATTACHMENT_ID == a.ATTACHMENT_ID select f.ATTACHMENT_DATA).FirstOrDefault(),
                    //				 Description = (string.IsNullOrEmpty(a.FILE_DESC)) ? "" : a.FILE_DESC,
                    //			 }).ToList();


                    //if (files.Count > 0)
                    //{
                    //	d.photoData = new List<byte[]>();
                    //	d.photoCaptions = new List<string>();

                    //	foreach (var f in files)
                    //	{
                    //		d.photoData.Add(f.Data);
                    //		d.photoCaptions.Add(f.Description);
                    //	}
                    //}
                }
                catch
                {
                }
            }

            return(d);
        }