Example #1
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                uclSearchBar.PageTitle.Text = lblProbCaseTitle.Text;
                CaseCtl().isDirected        = false;

                Ucl_DocMgr ucl = (Ucl_DocMgr)this.Master.FindControl("uclDocSelect");
                if (ucl != null)
                {
                    ucl.BindDocumentSelect(CaseCtl().Context == "EHS" ? CaseCtl().Context : "SQM", 0, true);
                }

                if (ddlPlantSelect.Items.Count < 1)
                {
                    List <PLANT> plantList = SQMModelMgr.SelectPlantList(entities, SQMModelMgr.LookupPrimaryCompany(entities).COMPANY_ID, 0);
                    ddlPlantSelect.Items.Clear();
                    foreach (PLANT plant in plantList)
                    {
                        if (SessionManager.PlantAccess(plant.PLANT_ID))
                        {
                            RadComboBoxItem item = new RadComboBoxItem(plant.PLANT_NAME, plant.PLANT_ID.ToString());
                            item.CssClass = "prompt";
                            item.Checked  = true;
                            ddlPlantSelect.Items.Add(item);
                        }
                    }
                    ddlStatusSelect.SelectedValue = "A";
                }

                // create new case from quality issue
                if ((bool)SessionManager.ReturnStatus)
                {
                    if (SessionManager.ReturnObject is QI_OCCUR)
                    {
                        QI_OCCUR qiIssue = (QI_OCCUR)SessionManager.ReturnObject;
                        CaseCtl().CreateNew("QI", SessionManager.PrimaryCompany().COMPANY_ID, SessionManager.UserContext.Person);
                        CaseCtl().isAutoCreated = true;
                        CaseCtl().problemCase.ProbCase.DESC_LONG = qiIssue.INCIDENT.DESCRIPTION;
                        CaseCtl().problemCase.AddIncident(qiIssue.INCIDENT_ID);
                        uclCaseEdit.BindIncidentList(CaseCtl().problemCase.IncidentList);
                        uclCaseEdit.BindPartIssueItemList(CaseCtl().problemCase.PartIssueItemList);
                    }
                    else if (SessionManager.ReturnObject is TASK_STATUS)
                    {
                        // from inbox
                        CaseCtl().isDirected           = true;
                        uclSearchBar.ReturnButton.Text = lblReturnInbox.Text;
                        TASK_STATUS task = (TASK_STATUS)SessionManager.ReturnObject;
                        uclCaseList_Click(task.RECORD_ID);
                        if (CaseCtl().problemCase.CheckCaseNextStep() >= Convert.ToInt32(task.TASK_STEP))
                        {
                            PageTabClicked("lbTab" + task.TASK_STEP, task.TASK_STEP);
                        }
                        else
                        {
                            PageTabClicked("lbTab0", "0");
                        }
                    }
                    else if (SessionManager.ReturnObject is decimal)
                    {
                        // from console list
                        uclCaseList_Click((decimal)SessionManager.ReturnObject);
                        PageTabClicked("lbTab0", "0");
                    }
                    else if (SessionManager.ReturnObject is INCIDENT)
                    {
                        // Problem case from EHS Incident
                        INCIDENT incident   = (INCIDENT)SessionManager.ReturnObject;
                        decimal  locationId = EHSIncidentMgr.SelectIncidentLocationIdByIncidentId(incident.INCIDENT_ID);
                        CaseCtl().CreateNew("EHS", SessionManager.PrimaryCompany().COMPANY_ID, SessionManager.UserContext.Person);
                        CaseCtl().problemCase.ProbCase.DESC_SHORT    = incident.ISSUE_TYPE;
                        CaseCtl().problemCase.ProbCase.DESC_LONG     = incident.DESCRIPTION;
                        CaseCtl().problemCase.ProbCase.PROBCASE_TYPE = "EHS";
                        CaseCtl().problemCase.AddIncident(incident.INCIDENT_ID);
                        uclCaseEdit.BindIncidentList(CaseCtl().problemCase.IncidentList);
                        if (CaseCtl().problemCase.ProbCase.PROB_DEFINE == null)
                        {
                            CaseCtl().problemCase.CreateProblemDefinition();
                        }
                        CaseCtl().isAutoCreated = true;
                    }
                    else
                    {
                        uclSearchBar_OnSearchClick();
                    }
                }
                else
                {
                    uclSearchBar_OnSearchClick();
                }
            }
            else
            {
                /* add incidents from qi issue popup list */
                if ((bool)SessionManager.ReturnStatus)
                {
                    if (SessionManager.ReturnObject.GetType().ToString().ToUpper().Contains("INCIDENT"))
                    {
                        List <INCIDENT> incidentList = (List <INCIDENT>)SessionManager.ReturnObject;
                        foreach (INCIDENT incident in incidentList)
                        {
                            CaseCtl().problemCase.AddIncident(incident.INCIDENT_ID);
                        }
                        uclCaseEdit.BindIncidentList(CaseCtl().problemCase.IncidentList);
                        uclCaseEdit.BindPartIssueItemList(CaseCtl().problemCase.PartIssueItemList);
                        PageTabClicked("lbTab0", "0");
                    }

                    else if (SessionManager.ReturnObject == "DisplayCases")
                    {
                        uclSearchBar_OnSearchClick();
                        SessionManager.ClearReturns();
                    }
                }
            }
            SessionManager.ClearReturns();

            if (CaseCtl().isAutoCreated)
            {
                CaseCtl().Update();
                SetupPage();
                PageTabClicked("lbTab0", "0");
            }
        }