private void mRemove_Click(object sender, EventArgs e) { if (_CurrentCategory.IsCategory == false) { //Obtengo el padre _ParentFwkCategory = _CategoryTreeList.Where(p => p.Id.Equals(_CurrentCategory.ParentId)).FirstOrDefault <CategoryTree>(); _ParentFwkCategory.RemoveRule(_CurrentCategory.Name); _CategoryTreeList.RemoveItem(_CurrentCategory.Id);//No es necesario ya que se ejecurara luego --> PopulateAsync try { FwkMembership.CreateRuleInCategory(_ParentFwkCategory.FwkCategory, frmAdmin.Provider.Name); MessageViewInfo.Show("Rule was successfully removed from category"); PopulateAsync(); } catch (Exception ex) { throw ex; } } else { DialogResult r = MessageBox.Show("Will have to delete the category and recursively all its subcategories", "Rules mannager", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (r == DialogResult.Yes) { try { FwkMembership.RemoveCategory(_CurrentCategory.FwkCategory.CategoryId, frmAdmin.Provider.Name); MessageViewInfo.Show("Category was successfully removed "); PopulateAsync(); } catch (Exception ex) { throw ex; } } } }
public bool AceptChanges() { if (string.IsNullOrEmpty(txtRuleName.Text)) { errorProvider1.SetError(txtRuleName, "Rule name must not be empty"); return(false); } try { if (_CurrentRule == null) { _CurrentRule = new FwkAuthorizationRule(); } _CurrentRule.Expression = txtRuleExpression.Text; if (base.State == Bases.EntityUpdateEnum.NEW) { _CurrentRule.Name = txtRuleName.Text; if (FwkMembership.ExistRule(txtRuleName.Text.Trim(), frmAdmin.Provider.Name)) { MessageViewInfo.Show(String.Format("The rule {0} exist", txtRuleName.Text)); txtRuleName.Focus(); return(false); } FwkMembership.CreateRule(_CurrentRule, frmAdmin.Provider.Name); MessageViewInfo.Show(String.Format(Properties.Resources.RuleCreatedMessage, txtRuleName.Text)); this.btnCreateRule.Enabled = false; } if (base.State == Bases.EntityUpdateEnum.UPDATED) { //Si Cambio el nombre if (_CurrentRule.Name.Trim().CompareTo(txtRuleName.Text.Trim()) != 0) { FwkMembership.UpdateRuleAndRuleName(_CurrentRule, txtRuleName.Text.Trim(), frmAdmin.Provider.Name); } else { FwkMembership.UpdateRule(_CurrentRule, frmAdmin.Provider.Name); } MessageViewInfo.Show(String.Format(Properties.Resources.RuleUpdatedMessage, txtRuleName.Text)); } NewSecurityInfoCreatedHandler(); } catch (Exception ex) { MessageViewInfo.Show(ex); return(false); } return(true); }
private void button1_Click(object sender, EventArgs e) { if (FwkMembership.ValidateUser(txtUserName.Text, txtPassword.Text, frmAdmin.Provider.Name)) { MessageViewInfo.Show("Log sussefully"); } else { MessageViewInfo.Show("Log not sussefully"); } }
private void btnUnlock_Click(object sender, EventArgs e) { if (usersGrid1.CurrentUser == null) { return; } FwkMembership.UnlockUser(usersGrid1.CurrentUser.UserName, frmAdmin.Provider.Name); MessageViewInfo.Show(string.Format("User {0} was successfully unlocked", usersGrid1.CurrentUser.UserName)); usersGrid1.Initialize(); }
private void btnchangePwd_Click(object sender, EventArgs e) { if (usersGrid1.CurrentUser == null) { return; } using (frmChangePwd frm = new frmChangePwd(usersGrid1.CurrentUser)) { if (frm.ShowDialog() == DialogResult.OK) { MessageViewInfo.Show("User password was successfully updated"); } } }
private void btnApprove_Click(object sender, EventArgs e) { if (usersGrid1.CurrentUser == null) { return; } if (usersGrid1.CurrentUser.IsApproved) { FwkMembership.UnApproveUser(usersGrid1.CurrentUser.UserName, frmAdmin.Provider.Name); MessageViewInfo.Show(string.Concat("User password was successfully ", "disapproved")); } else { FwkMembership.ApproveUser(usersGrid1.CurrentUser.UserName, frmAdmin.Provider.Name); MessageViewInfo.Show(string.Concat("User password was successfully ", "approved")); } usersGrid1.Initialize(); }
private void RemoveItem() { MessageViewInfo.MessageBoxButtons = MessageBoxButtons.YesNo; MessageViewInfo.MessageBoxIcon = Fwk.Bases.FrontEnd.Controls.MessageBoxIcon.Question; if (MessageViewInfo.Show("Are you sure to remove selected users from current role : " + selectedRol.RolName) == DialogResult.Yes) { UserList removedUsersList = new UserList(); foreach (DataGridViewRow row in grdUsers.SelectedRows) { removedUsersList.Remove(((User)row.DataBoundItem)); } FwkMembership.RemoveUsersFromRole(removedUsersList.GetArraNames(), selectedRol.RolName, frmAdmin.Provider.Name); grdUsers.DataSource = FwkMembership.GetUsersDetailedInRole(selectedRol.RolName, frmAdmin.Provider.Name); grdUsers.Refresh(); } SetMessageViewToDefault(); }
private void btnUpdate_Click(object sender, EventArgs e) { User wUser = usersGrid1.CurrentUser; User wpdatedUser = new User(txtUserName.Text); wpdatedUser.Email = txtEmail.Text; wpdatedUser.Comment = txtComments.Text; wpdatedUser.IsApproved = chkApproved.Checked; wpdatedUser.AnswerPassword = txtAnsw.Text; wpdatedUser.QuestionPassword = txtQuest.Text; FwkMembership.UpdateUser(wpdatedUser, wUser.UserName, frmAdmin.Provider.Name); MessageViewInfo.Show("User was successfully updated"); usersGrid1.Initialize(); }
private void mAddNewCategory_Click(object sender, EventArgs e) { using (frmAddName frm = new frmAddName()) { if (frm.ShowDialog() == DialogResult.OK) { if (!string.IsNullOrEmpty(frm.Tag.ToString()) && _CurrentCategory != null) { if (FwkMembership.ExistCategory(frm.Tag.ToString().Trim(), Convert.ToInt32(_CurrentCategory.Id), frmAdmin.Provider.Name)) { MessageViewInfo.Show(string.Format("Category {0} already exist", frm.Tag.ToString())); return; } else { Create_Categoty(frm.Tag.ToString()); } } } } }
private void addRootcategoryToolStripMenuItem_Click(object sender, EventArgs e) { using (frmAddName frm = new frmAddName()) { if (frm.ShowDialog() == DialogResult.OK) { if (!string.IsNullOrEmpty(frm.Tag.ToString())) { if (FwkMembership.ExistCategory(frm.Tag.ToString().Trim(), 0, frmAdmin.Provider.Name)) { MessageViewInfo.Show(string.Format("Category {0} already exist", frm.Tag.ToString())); return; } else { _CurrentCategory = null; Create_Categoty(frm.Tag.ToString()); } } } } }
void Create_Categoty(string name) { FwkCategory wFwkCategory = new FwkCategory(); wFwkCategory.Name = name; if (_CurrentCategory != null) { wFwkCategory.ParentId = Convert.ToInt32(_CurrentCategory.Id); } else { wFwkCategory.ParentId = 0; } try { FwkMembership.CreateCategory(wFwkCategory, frmAdmin.Provider.Name); MessageViewInfo.Show("Category was successfully created"); PopulateAsync(); } catch (Exception ex) { throw ex; } }
private void btnRemove_Click(object sender, EventArgs e) { if (usersGrid1.CurrentUser == null) { btnRemove.Enabled = false; btnUpdate.Enabled = false; return; } String wUserName = usersGrid1.CurrentUser.UserName; FwkMembership.DeleteUser(wUserName, frmAdmin.Provider.Name); MessageViewInfo.Show("User was successfully removed"); lblRolesByUser.Text = string.Empty; txtEmail.Text = String.Empty; txtUserName.Text = String.Empty; btnRemove.Enabled = false; btnUpdate.Enabled = false; usersGrid1.Initialize(); }
private void btnCreateUser_Click(object sender, EventArgs e) { if (!ValidateControls()) { return; } string wMessage = string.Empty; using (new WaitCursorHelper(this)) { try { MembershipCreateStatus wStatus = MembershipCreateStatus.Success; if (string.IsNullOrEmpty(txtAnsw.Text) && string.IsNullOrEmpty(txtQuest.Text)) { FwkMembership.CreateUser(txtUserName.Text, txtPassword.Text, txtEmail.Text, frmAdmin.Provider.Name); } else { FwkMembership.CreateUser(txtUserName.Text, txtPassword.Text, txtEmail.Text, txtQuest.Text, txtAnsw.Text, chkApproved.Checked, out wStatus, frmAdmin.Provider.Name); } if (wStatus == MembershipCreateStatus.Success) { wMessage = String.Format(Properties.Resources.UserCreatedMessage, txtUserName.Text); } MessageViewInfo.Show(wMessage); this.Initialize(); OnNewSecurityInfoCreated(); } catch (Exception ex) { MessageViewInfo.Show(ex); } } }