public override void RefreshData() { //lvPerms.MultiSelect = !Modal; this.Text = "Code Groups - " + this.AdminProxy.Connection.ServerName + (Toolkit.IsProcessElevated() ? " - Administrator " : ""); var tags = rememberSelectedTags(lvGroups); // this form has multiple uses, as does the underlying ListPermissions method. // it can: // List all permissions (0,[0]) // List permission info for a single permission (37,[0]) // List permissions that are NOT in a list (0, [2,3,4,5,6]) var dt = AdminProxy.ListCodeGroups(null).Tables["list_code_groups"]; initHooksForMdiParent(dt, "group_name", "group_name"); lvGroups.Items.Clear(); foreach (DataRow dr in dt.Rows) { var lvi = new ListViewItem(dr["group_name"].ToString(), 0); lvi.ImageIndex = 0; lvi.SubItems.Add(dr["reference_count"].ToString()); lvi.SubItems.Add(dr["value_count"].ToString()); lvi.SubItems.Add((Toolkit.ToDateTime(dr["last_touched"], DateTime.MinValue)).ToLocalTime().ToString()); lvi.Tag = dr["group_name"].ToString(); lvGroups.Items.Add(lvi); } selectRememberedTags(lvGroups, tags); MainFormUpdateStatus(getDisplayMember("RefreshData{refreshed}", "Refreshed Code Groups"), false); }
private bool save() { // if name changed, tell user it might bust something... if (IsControlDirty(txtName)) { if (lvReferencedBy.Items.Count > 0) { if (DialogResult.No == MessageBox.Show(this, getDisplayMember("save{referenced_body}", "This group is referenced by {0} tables and dataviews.\r\nChanging the name will update those references as well.\r\nDo you want to continue?", lvReferencedBy.Items.Count.ToString()), getDisplayMember("save{referenced_title}", "Update Group References?"), MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation)) { return(false); } } var dt = AdminProxy.ListCodeGroups(null).Tables["list_code_groups"]; var drs = dt.Select("group_name = '" + txtName.Text.Replace("'", "''") + "'"); if (drs.Length > 0) { MessageBox.Show(this, getDisplayMember("save{uniquegroup_body}", "The code group name must be unique. {0} already exists.\r\nPlease specify a different one.", txtName.Text), getDisplayMember("save{uniquegroup_title}", "Group Name Exists"), MessageBoxButtons.OK, MessageBoxIcon.Information); txtName.Focus(); txtName.SelectAll(); return(false); } } if (lvValues.Items.Count == 0) { if (DialogResult.No == MessageBox.Show(this, getDisplayMember("save{onevalueminimum_body}", "A code group must contain at least one value.\r\nWould you like to add one now?"), getDisplayMember("save{onevalueminimum_title}", "Value Required"), MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { return(false); } else { var f = new frmCodeValue(); f.GroupName = txtName.Text; if (DialogResult.Cancel == MainFormPopupForm(f, this, false)) { RefreshData(); return(true); } } } if (String.IsNullOrEmpty(_originalGroupName)) { this.Close(); MainFormRefreshData(); MainFormUpdateStatus(getDisplayMember("save{added}", "Added code group '{0}'", txtName.Text), true); } else { // if deleted row(s), check existing data for orphaned values... AdminProxy.RenameCodeGroup(_originalGroupName, txtName.Text); var nd = MainFormCurrentNode(); nd.Tag = txtName.Text; nd.Text = txtName.Text; RefreshData(); MainFormUpdateStatus(getDisplayMember("save{renamed}", "Renamed group to '{0}'", txtName.Text), true); } return(true); }