private void lvUsers_DragDrop(object sender, DragEventArgs e) { var ddo = getDragDropObject(e); AdminProxy.AddUsersToGroup(ID, ddo.IDList); RefreshData(); }
private void popupAddUser() { if (ID < 1) { if (DialogResult.Yes == MessageBox.Show(this, getDisplayMember("popupAddUser{prompt_body}", "You must save the group before adding users to it.\nDo you want to save it now?"), getDisplayMember("popupAddUser{prompt_title}", "Save Group?"), MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { save(false); } else { return; } } var fu = new frmUsers(); foreach (ListViewItem lvi in lvUsers.Items) { fu.AssignedIDs.Add(Toolkit.ToInt32(lvi.Tag, -1)); } if (DialogResult.OK == MainFormPopupForm(fu, this, true)) { // add selected permission to user, refresh AdminProxy.AddUsersToGroup(ID, fu.SelectedIDs); RefreshData(); } }
private void lvGroups_DragDrop(object sender, DragEventArgs e) { var ddo = getDragDropObject(e); AdminProxy.AddUsersToGroup(ddo.IDList[0], new List <int>(new int[] { ID })); RefreshData(); MainFormUpdateStatus(getDisplayMember("groupsDragDrop{addeduser}", "Added user to group"), true); }
private void popupAddToGroup() { var fg = new frmGroups(); //foreach (ListViewItem lvi in lvGroups.Items) { // fg.AssignedIDs.Add(Toolkit.ToInt32(lvi.Tag, -1)); //} if (DialogResult.OK == MainFormPopupForm(fg, this, false)) { // add selected permission to user, refresh var ids = new List <int>(); ids.Add(ID); foreach (int groupID in fg.SelectedIDs) { AdminProxy.AddUsersToGroup(groupID, ids); } refreshData(false, true, true); MainFormUpdateStatus(getDisplayMember("popupAddToGroup{done}", "Added user to group(s)"), true); } }
private bool save() { if (txtUserName.Text.Trim().Length == 0) { tcUser.SelectedTab = tpGeneral; Application.DoEvents(); MessageBox.Show(getDisplayMember("save{usernamerequired}", "You must set a username for this user before saving.")); txtUserName.Focus(); return(false); } if (String.IsNullOrEmpty(_password) && ID == -1) { tcUser.SelectedTab = tpGeneral; Application.DoEvents(); MessageBox.Show(getDisplayMember("save{passwordrequired}", "You must set a password for this user before saving.")); btnChangePassword.Focus(); return(false); } if (_cooperatorID < 1 && (txtFirstName.Text.Trim().Length == 0 || txtLastName.Text.Trim().Length == 0)) { tcUser.SelectedTab = tpGeneral; tcCooperator.SelectedTab = tpCoopGeneral; Application.DoEvents(); MessageBox.Show(getDisplayMember("save{cooperatorrequired}", "You must select a cooperator or enter a new one for this user before saving.\nA new cooperator must have its First Name and Last Name specified.")); txtFirstName.Focus(); return(false); } if (_geographyID < 1) { tcUser.SelectedTab = tpGeneral; tcCooperator.SelectedTab = tpCoopGeographic; Application.DoEvents(); MessageBox.Show(getDisplayMember("save{geographyrequired}", "You must specify a geographic location for this user before saving.")); btnGeography.Focus(); return(false); } var discCode = getSelectedValue(ddlDisciplineCode) + string.Empty; var catCode = getSelectedValue(ddlCategoryCode) + string.Empty; var orgRegionCode = getSelectedValue(ddlOrganizationRegionCode) + string.Empty; //.SelectedValue == null ? null : ((DataRowView)ddlOrganizationRegionCode.SelectedValue).Row[ddlOrganizationRegionCode.ValueMember] + string.Empty; var newID = -1; try { newID = AdminProxy.SaveUser(ID, txtUserName.Text, chkEnabled.Checked, _cooperatorID, _currentCooperatorID, _webCooperatorID, txtTitle.Text, txtFirstName.Text, //txtInitials.Text, txtLastName.Text, // txtFullName.Text, txtJob.Text, discCode, txtOrganization.Text, txtOrganizationAbbreviation.Text, Toolkit.ToInt32(ddlLanguage.SelectedValue, -1), chkIsActive.Checked, txtAddressLine1.Text, txtAddressLine2.Text, txtAddressLine3.Text, txtCity.Text, txtPostalIndex.Text, txtEmail.Text, txtPrimaryPhone.Text, txtSecondaryPhone.Text, txtFax.Text, Toolkit.ToInt32(ddlSiteCode.SelectedValue, -1), orgRegionCode, catCode, // txtRegionCode.Text, // txtCategoryCode.Text, _geographyID, // Toolkit.ToInt32(ddlGeography.SelectedValue, 0), txtNote.Text ); } catch (InvalidOperationException ioe) { if (ioe.Message.Contains("duplicate")) { MessageBox.Show(this, getDisplayMember("save{duplicateuser_body}", "A user with that user name already exists.\r\nYou must choose a different one."), getDisplayMember("save{duplicateuser_title}", "User Name Taken")); } else { throw; } } if (newID != ID) { // every user is added to the all users group. always. var groups = AdminProxy.ListGroups(-1).Tables["list_groups"]; var groupID = -1; foreach (DataRow dr in groups.Rows) { if (dr["group_tag"].ToString().ToLower() == "allusers") { groupID = Toolkit.ToInt32(dr["sys_group_id"], -1); break; } } if (groupID > -1) { var userIDs = new List <int>(); userIDs.Add(newID); AdminProxy.AddUsersToGroup(groupID, userIDs); } } ID = newID; if (!String.IsNullOrEmpty(_password)) { AdminProxy.ChangePassword(ID, _password); _password = null; } return(true); }