protected void rgPrivGroup_ItemDataBound(object sender, GridItemEventArgs e) { // is there anything that we need to do here? if (e.Item is GridDataItem) { try { GridDataItem item = (GridDataItem)e.Item; PRIVGROUP privGroup = (PRIVGROUP)e.Item.DataItem; Label lbl; LinkButton lnk = (LinkButton)item.FindControl("lnkPrivGroupItem"); lbl = (Label)item.FindControl("lblGroupStatus"); lbl.Text = XLATList.Where(x => x.XLAT_GROUP == "ACTIVE_STATUS" && x.XLAT_CODE == privGroup.STATUS).FirstOrDefault().DESCRIPTION_SHORT; lnk = (LinkButton)e.Item.FindControl("lnkAddPriv"); lnk.CommandArgument = privGroup.PRIV_GROUP.ToString(); } catch { } } }
protected void lnklPrivGroupItem_Click(object sender, EventArgs e) { LinkButton lnk = (LinkButton)sender; try { PRIVGROUP privGroup = SQMModelMgr.LookupPrivGroup(new PSsqmEntities(), lnk.CommandArgument.ToString(), false); if (privGroup != null) { hfPrivGroupID.Value = privGroup.PRIV_GROUP; tbEditPrivGroup.Text = privGroup.PRIV_GROUP; tbEditPrivGroup.Enabled = false; tbEditDescription.Text = privGroup.DESCRIPTION; if (ddlPrivGroupStatus.FindItemByValue(privGroup.STATUS) != null) { ddlPrivGroupStatus.SelectedValue = privGroup.STATUS; } ddlEdit_OnIndexChanged(null, null); //btnDelete.Visible = true; } string script = "function f(){OpenPrivGroupEditWindow(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);"; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true); } catch { } }
protected void LoadInformation() { // set up for adding the header info List <PRIVGROUP> pl = SQMModelMgr.SelectPrivGroupList(new SysPriv[1] { SysPriv.originate }, SysScope.audit, ""); // SQMModelMgr.SelectPrivGroupJobcodeList(SysPriv.originate, SysScope.audit); DropDownListItem item = new DropDownListItem(); UpdateAuditTypes(); if (rddlAuditJobcodes.Items.Count == 0) { rddlAuditJobcodes.DataSource = pl; rddlAuditJobcodes.DataTextField = "DESCRIPTION"; rddlAuditJobcodes.DataValueField = "PRIV_GROUP"; rddlAuditJobcodes.DataBind(); item = new DropDownListItem("[Select a Group]", ""); rddlAuditJobcodes.Items.Insert(0, item); } if (rddlDayOfWeek.Items.Count == 0) { rddlDayOfWeek.Items.Clear(); rddlDayOfWeek.DataSource = EHS_Audit_Scheduler.GetAll <DayOfWeek>(); rddlDayOfWeek.DataTextField = "Value"; rddlDayOfWeek.DataValueField = "Key"; rddlDayOfWeek.DataBind(); item = new DropDownListItem("[Select a Day]", ""); rddlDayOfWeek.Items.Insert(0, item); } if (IsEditContext || CurrentStep > 0) { // in edit mode, load the header field values and make all fields display only AUDIT_SCHEDULER scheduler = EHSAuditMgr.SelectAuditSchedulerById(entities, EditAuditScheduleId); BusinessLocation location = new BusinessLocation().Initialize((decimal)scheduler.PLANT_ID); rddlAuditType.SelectedValue = scheduler.AUDIT_TYPE_ID.ToString(); rddlAuditType.Enabled = false; rddlAuditType.Visible = false; lblScheduleAuditType.Visible = true; lblScheduleAuditType.Text = rddlAuditType.SelectedText.ToString(); hdnAuditLocation.Value = location.Plant.PLANT_ID.ToString(); lblAuditLocation.Text = location.Plant.PLANT_NAME + " " + location.BusinessOrg.ORG_NAME; lblAuditLocation.Visible = true; ddlAuditLocation.Visible = false; mnuAuditLocation.Visible = false; rddlDayOfWeek.SelectedValue = scheduler.DAY_OF_WEEK.ToString(); cbInactive.Checked = scheduler.INACTIVE; // build the audit jobcode list PRIVGROUP pv = pl.Where(i => i.PRIV_GROUP.ToString() == scheduler.JOBCODE_CD).FirstOrDefault(); lblAuditJobcode.Text = pv.DESCRIPTION; lblAuditJobcode.Visible = true; rddlAuditJobcodes.SelectedValue = scheduler.JOBCODE_CD.ToString(); rddlAuditJobcodes.Visible = false; } else { if (UserContext.GetMaxScopePrivilege(SysScope.audit) <= SysPriv.config) { List <BusinessLocation> locationList = SessionManager.PlantList; locationList = UserContext.FilterPlantAccessList(locationList); if (locationList.Select(l => l.Plant.BUS_ORG_ID).Distinct().Count() > 1 && SessionManager.IsUserAgentType("ipad,iphone") == false) { if (mnuAuditLocation.Items.Count == 0) { mnuAuditLocation.Items.Clear(); ddlAuditLocation.Visible = false; mnuAuditLocation.Visible = true; mnuAuditLocation.Enabled = true; SQMBasePage.SetLocationList(mnuAuditLocation, locationList, 0, "Select a Location", "", true); } } else { if (ddlAuditLocation.Items.Count == 0) { ddlAuditLocation.Items.Clear(); ddlAuditLocation.Visible = true; ddlAuditLocation.Enabled = true; mnuAuditLocation.Visible = false; SQMBasePage.SetLocationList(ddlAuditLocation, locationList, 0, true); ddlAuditLocation.Items[0].ImageUrl = "~/images/defaulticon/16x16/user-alt-2.png"; } } } // set defaults for add mode rddlAuditType.Enabled = true; rddlAuditType.Visible = true; lblAuditLocation.Visible = false; rddlAuditJobcodes.Enabled = true; rddlAuditJobcodes.Visible = true; lblAuditJobcode.Visible = false; lblScheduleAuditType.Visible = false; } }
private void SavePrivGroupItem() { PSsqmEntities ctx = new PSsqmEntities(); PRIVGROUP privGroup = null; bool isNew = false; if (string.IsNullOrEmpty(hfPrivGroupID.Value)) // add new item { privGroup = new PRIVGROUP(); isNew = true; } else { privGroup = SQMModelMgr.LookupPrivGroup(ctx, hfPrivGroupID.Value.ToString(), false); } privGroup.PRIV_GROUP = tbEditPrivGroup.Text.ToString().Trim(); privGroup.DESCRIPTION = tbEditDescription.Text.ToString().Trim(); privGroup.STATUS = ddlPrivGroupStatus.SelectedValue.ToString().Trim(); if ((privGroup = SQMModelMgr.UpdatePrivGroup(ctx, privGroup)) != null) { if (isNew) { // We need to add the default privs PRIVLIST privList = null; if (defaultPrivs == null) { defaultPrivs = SQMSettings.SelectSettingsGroup("DEFAULT_PRIVS", ""); } if (defaultPrivs.Count > 0) { foreach (SETTINGS setting in defaultPrivs) { try { priv = Convert.ToInt16(setting.SETTING_CD.ToString()); scopes = setting.VALUE.ToString().Split(','); for (int i = 0; i < scopes.Count(); i++) { privList = SQMModelMgr.LookupPrivList(privGroup.PRIV_GROUP, priv, scopes[i], true); privList.PRIV_GROUP = privGroup.PRIV_GROUP; privList.PRIV = priv; privList.SCOPE = scopes[i].Trim(); privList = SQMModelMgr.UpdatePrivList(ctx, privList); } } catch { } } } else { // if there are no defult settings, we are going to force dashboard, inbox and incident } if (OnPrivGroupCommand != null) { OnPrivGroupCommand("add"); } } else { foreach (GridDataItem item in rgPrivGroup.Items) { LinkButton lnk = (LinkButton)item.FindControl("lnkPrivGroupItem"); if (lnk.CommandArgument == hfPrivGroupID.Value) { // update the list item without doing a complete refresh of the list Label lbl = new Label(); lbl = (Label)item.FindControl("lblDescription"); lbl.Text = privGroup.DESCRIPTION; lbl = (Label)item.FindControl("lblGroupStatus"); lbl.Text = XLATList.Where(x => x.XLAT_GROUP == "ACTIVE_STATUS" && x.XLAT_CODE == privGroup.STATUS.ToString()).FirstOrDefault().DESCRIPTION_SHORT; } } } } }