using System; using System.Collections; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; public partial class haldus_Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { pealkiri.InnerText = "Kasutajate loetelu"; if (!Roles.IsUserInRole(User.Identity.Name, "ADMIN")) { gwKasutajad.Columns[8].Visible = false; } if (!Page.IsPostBack) { gwKasutajad.DataSource = Membership.GetAllUsers(); gwKasutajad.DataBind(); } } protected void gwKasutajad_RowCommand(object sender, GridViewCommandEventArgs e) { MembershipUser u = Membership.GetUser((string)e.CommandArgument); switch (e.CommandName.ToLower()) { case "kasutajakinni": u.IsApproved = !u.IsApproved; Membership.UpdateUser(u); break; case "muudamyyja": if (Roles.IsUserInRole(u.UserName, "MYYJA")) { Roles.RemoveUserFromRole(u.UserName, "MYYJA"); } else { Roles.AddUserToRole(u.UserName, "MYYJA"); } break; case "resetpassword": u.ChangePassword(u.ResetPassword(),"pwd"); u.UnlockUser(); Membership.UpdateUser(u); break; } gwKasutajad.DataSource = Membership.GetAllUsers(); gwKasutajad.DataBind(); } }