private void refreshData(bool generalTab, bool permissionsTab, bool groupsTab) { this.Text = "User " + MainFormCurrentNodeText("") + " - " + this.AdminProxy.Connection.ServerName + (Toolkit.IsProcessElevated() ? " - Administrator " : ""); var ds = AdminProxy.GetUserInfo(ID); if (generalTab) { // fill general user tab (includes Web Login tab too!) var dt = ds.Tables["user_info"]; var enableSave = true; if (dt.Rows.Count > 0) { var dr = dt.Rows[0]; _password = null; // header info for user txtUserName.Text = dr["user_name"].ToString(); chkEnabled.Checked = dr["is_enabled"].ToString().ToUpper() == "Y"; lblUserIsDisabled.Visible = !chkEnabled.Checked; enableSave = dr["password_is_set"].ToString().ToUpper() != "Y"; lblPasswordNotSet.Visible = enableSave; _webCooperatorID = Toolkit.ToInt32(dr["web_cooperator_id"], -1); txtWebUserName.Text = dr["web_user_name"].ToString(); fillCooperatorGUI(dr); } else { ddlLanguage.SelectedIndex = getSelectedIndex(ddlLanguage, AdminProxy.LanguageID.ToString()); } var enabled = lblCurrentCooperator.Text.Replace("Current Cooperator is ", "").Trim() != ""; toggleCooperatorControls(enabled); btnSave.Enabled = enableSave; btnChangePassword.Enabled = txtUserName.Text.Length > 0; } if (permissionsTab) { // fill permissions tab lvPermissions.Items.Clear(); foreach (DataRow dr in ds.Tables["user_perm_info"].Rows) { var lvi = new ListViewItem(dr["group_name"].ToString()); lvi.Tag = dr["sys_permission_id"]; lvi.UseItemStyleForSubItems = false; lvi.SubItems.Add(dr["title"].ToString()); string dv = dr["dataview_name"].ToString(); string tbl = dr["table_name"].ToString(); if (String.IsNullOrEmpty(dv) && String.IsNullOrEmpty(tbl)) { lvi.SubItems.Add("-- any resource --"); } else { if (!String.IsNullOrEmpty(dv)) { lvi.SubItems.Add(dv + " (dataview)"); } else { lvi.SubItems.Add(tbl); } } addPermItem(lvi, dr["create_permission_text"].ToString()); addPermItem(lvi, dr["read_permission_text"].ToString()); addPermItem(lvi, dr["update_permission_text"].ToString()); addPermItem(lvi, dr["delete_permission_text"].ToString()); // get restriction info... var drFields = ds.Tables["user_perm_field_info"].Select("sys_permission_id = " + dr["sys_permission_id"]); if (drFields == null || drFields.Length == 0) { lvi.SubItems.Add("-"); } else { // pull perm field info into english-like display... var sb = new StringBuilder(); foreach (var drField in drFields) { if (sb.Length > 0) { sb.Append(" and "); } if (drField["compare_mode"].ToString() == "parent") { sb.Append(drField["parent_table_name"] + "." + drField["parent_table_field_name"] + " " + drField["parent_compare_operator"] + " " + drField["parent_compare_value"] + " (for all children)"); } else { if (Toolkit.ToInt32(drField["sys_dataview_field_id"], -1) > -1) { sb.Append(drField["dataview_name"] + "." + drField["dataview_field_name"] + " " + drField["compare_operator"] + " " + drField["compare_value"] + " (dataview)"); } else if (Toolkit.ToInt32(drField["sys_table_field_id"], -1) > -1) { sb.Append(drField["table_name"] + "." + drField["table_field_name"] + " " + drField["compare_operator"] + " " + drField["compare_value"] + " "); } else { sb.Append("INVALID -- must map a field from either Data View or Table!!!"); } } } lvi.SubItems.Add(sb.ToString()); } if (!String.IsNullOrEmpty(dr["group_name"].ToString())) { for (var i = 0; i < lvi.SubItems.Count; i++) { lvi.SubItems[i].BackColor = Color.LightGray; } } lvPermissions.Items.Add(lvi); } refreshEffectivePermissions(); } if (groupsTab) { lvGroups.Items.Clear(); foreach (DataRow dr in ds.Tables["groups_by_user"].Rows) { var lvi = new ListViewItem(dr["group_name"].ToString()); lvi.Tag = Toolkit.ToInt32(dr["sys_group_id"], -1); lvi.SubItems.Add(dr["description"].ToString()); lvi.Tag = dr["sys_group_id"]; lvGroups.Items.Add(lvi); } } MarkClean(); }