Example #1
0
        public static List <PERSON> SelectAuditPersonList(decimal auditId)
        {
            var personSelectList = new List <PERSON>();
            var entities         = new PSsqmEntities();

            AUDIT   audit     = SelectAuditById(entities, auditId);
            decimal companyId = 0;

            if (audit.DETECT_COMPANY_ID != null)
            {
                companyId = audit.DETECT_COMPANY_ID;
            }

            // start with all data originators for the company
            List <PERSON> personList = SQMModelMgr.SelectPersonList(companyId, 0, true, false).Where(l => l.ROLE <= 300).OrderBy(p => p.LAST_NAME).ToList();

            personList = SQMModelMgr.FilterPersonListByAppContext(personList, "EHS");
            // limit the list to those people having access to the plant where the audit (if defined) occurred
            if (audit != null)
            {
                foreach (PERSON person in personList)
                {
                    if (SQMModelMgr.PersonPlantAccess(person, (decimal)audit.DETECT_PLANT_ID))
                    {
                        personSelectList.Add(person);
                    }
                }
            }

            personSelectList = personSelectList.OrderBy(p => p.FIRST_NAME).ToList();
            personSelectList = personSelectList.OrderBy(p => p.LAST_NAME).ToList();

            return(personSelectList);
        }
        private void OnLocationSelect(decimal plantID)
        {
            PLANT plant = SQMModelMgr.LookupPlant(plantID);

            if (plant == null)
            {
                DisplayProfileMessage(lblProfileNotExist);
            }
            else
            {
                List <BusinessLocation> locationList = new List <BusinessLocation>();
                locationList.Add(new BusinessLocation().Initialize(plantID));
                List <PERSON> responsibleList = SQMModelMgr.SelectPlantPersonList(locationList, "311", AccessMode.Update);

                SQMBasePage.SetPersonList(ddlMetricResponsible, responsibleList, "");
                SQMBasePage.SetPersonList(ddlFinalApprover, responsibleList.Where(l => l.ROLE < SessionManager.AccessModeRoleXREF(AccessMode.Update)).ToList(), "");

                LoadPlantProfile(plant);

                if (LocalProfile() != null && (LocalProfile().Profile.EHS_PROFILE_MEASURE == null || LocalProfile().Profile.EHS_PROFILE_MEASURE.Count == 0))
                {
                    if (UserContext.RoleAccess() > AccessMode.Plant)
                    {
                        List <EHS_PROFILE> profileList = EHSModel.SelectPlantProfileList(SessionManager.UserContext.HRLocation.Company.COMPANY_ID);
                        SQMBasePage.SetLocationList(ddlCopyProfile, SQMModelMgr.SelectBusinessLocationList(SessionManager.UserContext.HRLocation.Company.COMPANY_ID, 0, true).Where(l => profileList.Select(p => p.PLANT_ID).ToArray().Contains(l.Plant.PLANT_ID)).ToList(), 0);
                        ddlCopyProfile.Items.Insert(0, new Telerik.Web.UI.RadComboBoxItem("", ""));
                        responsibleList = SQMModelMgr.SelectPersonList((decimal)plant.COMPANY_ID, (decimal)plant.BUS_ORG_ID, true, false).Where(p => p.ROLE >= SessionManager.AccessModeRoleXREF(AccessMode.Admin) && p.ROLE < SessionManager.AccessModeRoleXREF(AccessMode.View)).OrderBy(l => l.LAST_NAME).ToList();
                        ddlDefaultResponsible.Items.Clear();
                        foreach (PERSON person in responsibleList)
                        {
                            if (SQMModelMgr.PersonPlantAccess(person, plant.PLANT_ID))
                            {
                                ddlDefaultResponsible.Items.Add(new Telerik.Web.UI.RadComboBoxItem(SQMModelMgr.FormatPersonListItem(person), person.PERSON_ID.ToString()));
                            }
                        }
                        ddlDefaultResponsible.Items.Insert(0, new Telerik.Web.UI.RadComboBoxItem("", ""));
                        pnlCopyProfile.Visible = true;
                    }
                }

                pnlProfileEdit.Style.Add("display", "none");
            }
        }
        public void gvPlantList_OnRowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
        {
            if ((!e.Row.RowType.ToString().Trim().Equals(System.Web.UI.WebControls.ListItemType.Header.ToString())) & (!e.Row.RowType.ToString().Trim().Equals(System.Web.UI.WebControls.ListItemType.Footer.ToString())))
            {
                System.Web.UI.WebControls.Label       lbl     = new Label();
                System.Web.UI.WebControls.HiddenField hfField = new HiddenField();

                try
                {
                    lbl      = (Label)e.Row.Cells[0].FindControl("lblLocationType_out");
                    hfField  = (HiddenField)e.Row.Cells[0].FindControl("hfLocationType");
                    lbl.Text = WebSiteCommon.GetXlatValue("locationType", hfField.Value);

                    lbl      = (Label)e.Row.Cells[0].FindControl("lblStatus_out");
                    hfField  = (HiddenField)e.Row.Cells[0].FindControl("hfStatus_out");
                    lbl.Text = WebSiteCommon.GetStatusString(hfField.Value);

                    SETTINGS sets = SQMSettings.GetSetting("COMPANY", "PLANTUSER");
                    if (sets == null || sets.VALUE.ToUpper() != "N")
                    {
                        LinkButton  lnk     = (LinkButton)e.Row.Cells[0].FindControl("lnkView_out");
                        decimal     plantID = Convert.ToDecimal(lnk.CommandArgument);
                        HiddenField hf      = (HiddenField)e.Row.Cells[0].FindControl("hfPlantCompanyID");
                        lnk.ToolTip = "";
                        foreach (PERSON person in UserList())
                        {
                            if (person.ROLE > 1 && SQMModelMgr.PersonPlantAccess(person, plantID))
                            {
                                lnk.ToolTip += (" " + person.FIRST_NAME + " " + person.LAST_NAME + ",");
                            }
                        }
                        lnk.ToolTip = lnk.ToolTip.TrimEnd(',');
                    }
                }
                catch
                {
                }
            }
        }