public void BindProblemCaseHeader(ProblemCase problemCase, bool showAll)
 {
     pnlProbCaseHdr.Visible = true;
     if (problemCase.ProbCase.PROBCASE_TYPE == "EHS")
     {
         lblCaseID.Text = hfLblCaseIDEHS.Value;
     }
     lblCaseID_out.Text   = problemCase.CaseID;
     lblCaseType_out.Text = WebSiteCommon.GetXlatValue("incidentType", problemCase.ProbCase.PROBCASE_TYPE);
     lblCaseDesc_out.Text = problemCase.ProbCase.DESC_SHORT;
     // trProbCaseHdrRow2.Visible = showAll;
     if (showAll)
     {
         int progress = problemCase.CheckCaseStatus();
         lblCreateDate_out.Text = SQMBasePage.FormatDate((DateTime)problemCase.ProbCase.CREATE_DT, "d", false);
         lblUpdateDate_out.Text = SQMBasePage.FormatDate((DateTime)problemCase.ProbCase.LAST_UPD_DT, "d", false);
         //lblCaseProgress_out.Text = progress.ToString();
         if (problemCase.ProbCase.CLOSE_DT.HasValue)
         {
             lblCaseStatus_out.Text = WebSiteCommon.GetXlatValue("recordStatus", "C") + ": " + SQMBasePage.FormatDate((DateTime)problemCase.ProbCase.CLOSE_DT, "d", false);
         }
         else
         {
             lblCaseStatus_out.Text = WebSiteCommon.GetXlatValue("caseStep", (Math.Max((decimal)problemCase.ProbCase.PROGRESS, 1) - 1).ToString());
             if (problemCase.ProbCase.STATUS == "I")
             {
                 imgCaseStatus.ImageUrl = "/images/defaulticon/16x16/no.png";
                 imgCaseStatus.Visible  = true;
             }
         }
     }
 }
Ejemplo n.º 2
0
        public static ProblemCase UpdateProblemCase(ProblemCase theCase)
        {
            ProblemCase retCase = null;

            try
            {
                theCase.ProbCase = (PROB_CASE)SQMModelMgr.SetObjectTimestamp((object)theCase.ProbCase, SessionManager.UserContext.UserName(), CaseState(theCase));
                if (theCase.ProbCase.EntityState == System.Data.EntityState.Added || theCase.ProbCase.EntityState == System.Data.EntityState.Detached)
                {
                    theCase.Entities.AddToPROB_CASE(theCase.ProbCase);
                }
                if (!string.IsNullOrEmpty(theCase.StepComplete))
                {
                    theCase.TeamTask.SetTaskComplete(theCase.StepComplete, "C", 0, true);
                    if (theCase.StepComplete == "8" && theCase.ProbCase.CLOSE_DT.HasValue == false)
                    {
                        DateTime closeDate = DateTime.UtcNow;
                        theCase.ProbCase.PROB_CLOSE.NOTIFY_DT = theCase.ProbCase.CLOSE_DT = closeDate;
                        theCase.ProbCase.PROB_CLOSE.STATUS    = "C";
                        foreach (PROB_OCCUR occur in theCase.ProbCase.PROB_OCCUR)
                        {
                            theCase.Entities.ExecuteStoreCommand("UPDATE INCIDENT SET CLOSE_DATE_8D = {0} WHERE INCIDENT_ID = " + occur.INCIDENT_ID, closeDate);
                        }
                    }
                }
                int progress;

                if (theCase.ProbCase.PROB_CONTAIN != null)
                {
                    for (int n = 0; n < theCase.ProbCase.PROB_CONTAIN.PROB_CONTAIN_ACTION.Count; n++)
                    {
                        PROB_CONTAIN_ACTION contain = theCase.ProbCase.PROB_CONTAIN.PROB_CONTAIN_ACTION.ElementAt(n);
                        if (contain.STATUS == "D")
                        {
                            theCase.Entities.DeleteObject(contain);
                        }
                    }
                }
                if (theCase.ProbCase.PROB_CAUSE_ACTION != null)
                {
                    for (int n = 0; n < theCase.ProbCase.PROB_CAUSE_ACTION.Count; n++)
                    {
                        PROB_CAUSE_ACTION action = theCase.ProbCase.PROB_CAUSE_ACTION.ElementAt(n);
                        if (action.STATUS == "D")
                        {
                            theCase.Entities.DeleteObject(action);
                        }
                    }
                }
                if (theCase.ProbCase.PROB_PREVENT != null)
                {
                    for (int n = 0; n < theCase.ProbCase.PROB_PREVENT_LIST.Count; n++)
                    {
                        PROB_PREVENT_LIST prevent = theCase.ProbCase.PROB_PREVENT_LIST.ElementAt(n);
                        if (prevent.CONFIRM_STATUS == "D")
                        {
                            theCase.Entities.DeleteObject(prevent);
                        }
                    }
                }

                theCase.ProbCase.PROGRESS = theCase.CheckCaseStatus(); // theCase.CheckCaseNextStep();

                theCase.Entities.SaveChanges();

                if (theCase.IsNew)
                {
                    if (SessionManager.DocumentContext == null)
                    {
                        SessionManager.DocumentContext = new SQM.Shared.DocumentScope().CreateNew(SessionManager.UserContext.WorkingLocation.Company.COMPANY_ID, "BLI", 0, "", SessionManager.UserContext.WorkingLocation.Plant.PLANT_ID, "", 0);
                    }
                    SQM.Website.Classes.SQMDocumentMgr.UpdateAttachmentRecordID(theCase.Entities, 21, SessionManager.DocumentContext.SessionID, theCase.ProbCase.PROBCASE_ID);
                }

                theCase.TeamTask.UpdateTaskList(theCase.ProbCase.PROBCASE_ID);

                theCase.UpdateStatus = CaseUpdateStatus.Success;
                retCase              = theCase;
                retCase.IsNew        = false;
                theCase.StepComplete = "";
            }
            catch (Exception e)
            {
                theCase.UpdateStatus = CaseUpdateStatus.SaveError;
                retCase = theCase;
                // SQMLogger.LogException(e);
            }
            return(retCase);
        }