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");
            }
        }
Beispiel #2
0
        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.SelectPrivGroupPersonList(SysPriv.approve, SysScope.envdata, plant.PLANT_ID);
                responsibleList.AddRange(SQMModelMgr.SelectPrivGroupPersonList(SysPriv.admin, SysScope.system, 0));                  // append any system administrators to the approval list
                SQMBasePage.SetPersonList(ddlFinalApprover, responsibleList, "", true);
                SQMBasePage.SetPersonList(ddlMetricResponsible, SQMModelMgr.SelectPrivGroupPersonList(SysPriv.originate, SysScope.envdata, plant.PLANT_ID), "", true);

                LoadPlantProfile(plant);

                if (LocalProfile() != null && (LocalProfile().Profile.EHS_PROFILE_MEASURE == null || LocalProfile().Profile.EHS_PROFILE_MEASURE.Count == 0))
                {
                    if (UserContext.GetMaxScopePrivilege(SysScope.envdata) <= SysPriv.config)
                    {
                        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.SelectPrivGroupPersonList(SysPriv.originate, SysScope.envdata, plant.PLANT_ID);
                        SQMBasePage.SetPersonList(ddlDefaultResponsible, responsibleList, "");
                        ddlDefaultResponsible.Items.Insert(0, new Telerik.Web.UI.RadComboBoxItem("", ""));
                        pnlCopyProfile.Visible = true;
                    }
                }

                pnlProfileEdit.Style.Add("display", "none");
            }
        }
Beispiel #3
0
        public void LoadProfileSelectHdr(decimal companyID, decimal busOrgID, bool indicateUndefined, bool showExpanded)
        {
            ToggleVisible(pnlProfileSelectHdr);

            List <BusinessLocation> locationList = SQMModelMgr.SelectBusinessLocationList(companyID, busOrgID, true).Where(l => l.Plant.TRACK_EW_DATA == true).ToList();

            locationList = UserContext.FilterPlantAccessList(locationList);

            int maxdesc = locationList.Select(l => l.Plant.PLANT_NAME.Length).Max();

            if (showExpanded && locationList.Select(l => l.Plant.BUS_ORG_ID).Distinct().Count() > 1 && maxdesc < 41)
            {
                ddlBusLocSelect.Visible = false;
                mnuBusLocSelect.Visible = true;
                SQMBasePage.SetLocationList(mnuBusLocSelect, locationList, 0, "select a location ...", "TOP", false);
                if (indicateUndefined)
                {
                    int           undefinedCount = 0;
                    List <string> profileList    = EHSModel.SelectPlantProfileList(companyID).Select(l => l.PLANT_ID.ToString()).ToList();
                    RadMenuItem   miTop          = mnuBusLocSelect.Items[0];
                    foreach (RadMenuItem miBU in miTop.Items)
                    {
                        foreach (RadMenuItem miLoc in miBU.Items)
                        {
                            if (!profileList.Contains(miLoc.Value))
                            {
                                ++undefinedCount;
                                // miLoc.ImageUrl = "~/images/defaulticon/16x16/grid-dot.png";
                                miLoc.CssClass = "rcbItemEmphasis";
                            }
                            else
                            {
                                miLoc.ImageUrl = "~/images/defaulticon/16x16/document.png";
                            }
                        }
                    }
                }
            }
            else
            {
                ddlBusLocSelect.Visible = true;
                mnuBusLocSelect.Visible = false;
                SQMBasePage.SetLocationList(ddlBusLocSelect, locationList, 0);
                if (indicateUndefined)
                {
                    int           undefinedCount = 0;
                    List <string> profileList    = EHSModel.SelectPlantProfileList(companyID).Select(l => l.PLANT_ID.ToString()).ToList();
                    foreach (RadComboBoxItem item in ddlBusLocSelect.Items)
                    {
                        if (!item.IsSeparator)
                        {
                            if (!profileList.Contains(item.Value))
                            {
                                ++undefinedCount;
                                item.ImageUrl = "~/images/defaulticon/16x16/blank.png";
                                item.CssClass = "rcbItemEmphasis";
                                item.ToolTip  = "Metrics not defined";
                            }
                            else
                            {
                                item.ImageUrl = "~/images/defaulticon/16x16/document.png";
                            }
                        }
                    }
                    if (undefinedCount > 0)
                    {
                        ddlBusLocSelect.ToolTip += hfBusLocProfileUndefined.Value;
                    }
                }
                ddlBusLocSelect.Items.Insert(0, new RadComboBoxItem("", ""));
            }
        }
Beispiel #4
0
        public void LoadProfileInputHdr(bool loadPlants, DateTime dateFrom, DateTime dateTo, decimal defaultPlantID, bool hideUndefined, bool showExpanded)
        {
            ToggleVisible(pnlProfileInputHdr);

            if (loadPlants && ddlPlantSelect.Items.Count == 0)
            {
                List <BusinessLocation> locationList = SQMModelMgr.SelectBusinessLocationList(SessionManager.UserContext.HRLocation.Company.COMPANY_ID, 0, true).Where(l => l.Plant.TRACK_EW_DATA == true).ToList();
                locationList = UserContext.FilterPlantAccessList(locationList);

                int maxdesc = locationList.Select(l => l.Plant.PLANT_NAME.Length).Max();

                if (locationList.Count > 1 && showExpanded && locationList.Select(l => l.Plant.BUS_ORG_ID).Distinct().Count() > 1 && maxdesc < 41)
                {
                    ddlPlantSelect.Visible = false;
                    tdLocation.Visible     = false;
                    mnuPlantSelect.Visible = true;
                    SQMBasePage.SetLocationList(mnuPlantSelect, locationList, 0, "select a location...", "TOP", false);

                    int           undefinedCount = 0;
                    List <string> profileList    = EHSModel.SelectPlantProfileList(SessionManager.UserContext.HRLocation.Company.COMPANY_ID).Select(l => l.PLANT_ID.ToString()).ToList();
                    RadMenuItem   miTop          = mnuPlantSelect.Items[0];
                    foreach (RadMenuItem miBU in miTop.Items)
                    {
                        foreach (RadMenuItem miLoc in miBU.Items)
                        {
                            if (!profileList.Contains(miLoc.Value))
                            {
                                ++undefinedCount;
                                miLoc.ImageUrl = "~/images/defaulticon/16x16/grid-dot.png";
                                miLoc.CssClass = "rcbItemEmphasis";
                                if (hideUndefined)
                                {
                                    miLoc.Visible = false;
                                }
                            }
                        }
                    }
                    if (mnuPlantSelect.FindItemByValue(defaultPlantID.ToString()) != null)
                    {
                        mnuPlantSelect.FindItemByValue(defaultPlantID.ToString()).Selected = true;
                        LocationSelect_Click(mnuPlantSelect, null);
                    }
                }
                else
                {
                    ddlPlantSelect.Visible = true;
                    mnuPlantSelect.Visible = false;
                    SQMBasePage.SetLocationList(ddlPlantSelect, locationList, 0);
                    if (ddlPlantSelect.Items.Count == 1)
                    {
                        tdLocationSelect.Visible = false;
                        tdLocation.Visible       = true;
                        lblPlantName_out.Text    = ddlPlantSelect.SelectedItem.Text;
                        LocationSelect_Click(ddlPlantSelect, null);
                    }
                    else
                    {
                        List <string> profileList    = EHSModel.SelectPlantProfileList(SessionManager.UserContext.HRLocation.Company.COMPANY_ID).Select(l => l.PLANT_ID.ToString()).ToList();
                        int           undefinedCount = 0;
                        foreach (RadComboBoxItem item in ddlPlantSelect.Items)
                        {
                            if (!item.IsSeparator && !profileList.Contains(item.Value))
                            {
                                ++undefinedCount;
                                //item.ImageUrl = "~/images/defaulticon/16x16/grid-dot.png";
                                item.CssClass = "rcbItemEmphasis";
                                item.ToolTip  = "Metrics not defined";
                                if (hideUndefined)
                                {
                                    item.Visible = false;
                                }
                                else
                                {
                                    item.Enabled = false;
                                }
                            }
                        }
                        if (undefinedCount > 0 && !hideUndefined)
                        {
                            ddlPlantSelect.ToolTip += hfPlantProfileUndefined.Value;
                        }

                        tdLocationSelect.Visible = true;
                        tdLocation.Visible       = false;
                        if (ddlPlantSelect.FindItemByValue(defaultPlantID.ToString()) != null)
                        {
                            ddlPlantSelect.SelectedValue = defaultPlantID.ToString();
                            LocationSelect_Click(ddlPlantSelect, null);
                        }
                        else
                        {
                            LocationSelect_Click(ddlPlantSelect, null);
                        }
                    }
                }
            }

            if (dateFrom > DateTime.MinValue)
            {
                radPeriodSelect.Visible = true;
                // radPeriodSelect.Culture = System.Threading.Thread.CurrentThread.CurrentUICulture;
                radPeriodSelect.MinDate          = dateFrom;
                radPeriodSelect.MaxDate          = dateTo;
                radPeriodSelect.ShowPopupOnFocus = true;
                if (dateFrom == dateTo)
                {
                    radPeriodSelect.SelectedDate = dateFrom;
                    radPeriodSelect.Enabled      = false;
                }
                else
                {
                    radPeriodSelect.SelectedDate = DateTime.Now;
                }

                radPeriodSelect.Culture = System.Threading.Thread.CurrentThread.CurrentUICulture;
                tdPeriod.Visible        = false;
                tdPeriodSelect.Visible  = true;
            }
        }