private void SavePrivItem()
        {
            PSsqmEntities ctx      = new PSsqmEntities();
            PRIVLIST      privList = null;
            bool          isNew    = false;

            // should we always check to see if the privgroup is there??? because we don't want to add a duplicate...
            if (string.IsNullOrEmpty(hfPrivPrivGroupID.Value))              // add new item
            {
                //privList = new PRIVLIST();

                isNew = true;
            }
            //else
            //{
            privList = SQMModelMgr.LookupPrivList(hfPrivPrivGroupID.Value.ToString(), Convert.ToInt16(ddlPriviledge.SelectedValue.ToString().Trim()), ddlScope.SelectedValue.ToString().Trim(), true);
            //}

            privList.PRIV_GROUP = hfPrivPrivGroupID.Value.ToString().Trim();
            privList.PRIV       = Convert.ToInt16(ddlPriviledge.SelectedValue.ToString().Trim());
            privList.SCOPE      = ddlScope.SelectedValue.ToString().Trim();

            if ((privList = SQMModelMgr.UpdatePrivList(ctx, privList)) != null)
            {
                //if (isNew) // they are all new for now... no updates, just deletes
                //{
                if (OnPrivGroupCommand != null)
                {
                    OnPrivGroupCommand("add");
                }
                //}
                //else
                //{
                //foreach (GridDataItem item in rgPrivList.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;
                //	}
                //}
                //}
            }
        }
        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;
                        }
                    }
                }
            }
        }