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 rgPrivList_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridDataItem) { if (defaultPrivs == null) { defaultPrivs = SQMSettings.SelectSettingsGroup("DEFAULT_PRIVS", ""); } GridDataItem item = (GridDataItem)e.Item; Label lbl; LinkButton lnk; PRIVLIST data = (PRIVLIST)item.DataItem; if (data.PRIV_GROUP != null) { lbl = (Label)item.FindControl("lblPrivDesc"); lbl.Text = XLATList.Where(x => x.XLAT_GROUP == "PRIV_PRIV" && x.XLAT_CODE == data.PRIV.ToString()).FirstOrDefault().DESCRIPTION_SHORT; lbl = (Label)item.FindControl("lblScope"); lbl.Text = XLATList.Where(x => x.XLAT_GROUP == "PRIV_SCOPE" && x.XLAT_CODE == data.SCOPE.ToString()).FirstOrDefault().DESCRIPTION_SHORT; lnk = (LinkButton)item.FindControl("lnkDeletePriv"); lnk.CommandArgument = data.PRIV_GROUP.ToString() + "~" + data.PRIV.ToString() + "~" + data.SCOPE.ToString(); // hide the link for the default privs that can't be removed 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++) { if (data.PRIV == Convert.ToInt16(setting.SETTING_CD.Trim()) && data.SCOPE == scopes[i].Trim()) { lnk.Visible = false; } } } catch { } } } } } }
public void BindPrivGroups(List <PRIVGROUP> privGroupList, BusinessLocation businessLocation, string context) { hfPrivGroupContext.Value = context; if (ddlPrivGroupStatus.Items.Count == 0) { XLATList = SQMBasePage.SelectXLATList(new string[3] { "ACTIVE_STATUS", "PRIV_PRIV", "PRIV_SCOPE" }); ddlPrivGroupStatus.DataSource = XLATList.Where(x => x.XLAT_GROUP == "ACTIVE_STATUS").ToList(); ddlPrivGroupStatus.DataValueField = "XLAT_CODE"; ddlPrivGroupStatus.DataTextField = "DESCRIPTION"; ddlPrivGroupStatus.DataBind(); } if (ddlScope.Items.Count == 0) { ddlScope.DataSource = XLATList.Where(x => x.XLAT_GROUP == "PRIV_SCOPE").ToList(); ddlScope.DataValueField = "XLAT_CODE"; ddlScope.DataTextField = "DESCRIPTION"; ddlScope.DataBind(); } if (ddlPriviledge.Items.Count == 0) { ddlPriviledge.DataSource = XLATList.Where(x => x.XLAT_GROUP == "PRIV_PRIV").ToList(); ddlPriviledge.DataValueField = "XLAT_CODE"; ddlPriviledge.DataTextField = "DESCRIPTION"; ddlPriviledge.DataBind(); RadComboBoxItem item = new RadComboBoxItem("", "select a priviledge level"); ddlPriviledge.Items.Insert(0, item); try { item = ddlPriviledge.FindItemByValue("100"); item.Enabled = false; } catch { } } defaultPrivs = SQMSettings.SelectSettingsGroup("DEFAULT_PRIVS", ""); pnlPrivGroups.Visible = true; rgPrivGroup.DataSource = privGroupList; rgPrivGroup.DataBind(); }
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; } } } } }