1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
public partial class EditionUsers : System.Web.UI.Page
{
private string ConnectionString;
private string iduser;
private string thm;
private string query;
protected void Page_PreInit(object sender, EventArgs e)
{
thm = ConfigurationManager.AppSettings["siteTheme"]; ;
if (thm != null)
{
Page.Theme = thm;
}
else
{
Session["themeSelected"] = thm;
Page.Theme = "Default";
}
}
protected void Page_Load(object sender, EventArgs e)
{
ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString2"].ConnectionString;
try
{
SqlConnection myConnection = new SqlConnection(ConnectionString);
//Response.Write(Request.Params["id"]);
iduser = Request.Params["id"];
query = "SELECT UserId, Email, PasswordQuestion, IsApproved, IsLockedOut, CreateDate, LastLoginDate,Comment, UserName, IsAnonymous FROM vw_aspnet_MembershipUsers WHERE ([UserId] = '" + Request.Params["id"] + "')";
myConnection.Open();
SqlCommand myCommand = new SqlCommand(query, myConnection);
SqlDataReader myReader = myCommand.ExecuteReader();
if (!myReader.HasRows)
{
}
else
{
DetailsView1.DataSourceID = null;
DetailsView1.DataSource = myReader;
DetailsView1.DataBind();
}
myConnection.Close();
}
catch (Exception ex)
{
Response.Write(ex);
}
}
protected void Button1_Click(object sender, EventArgs e)
{
query = "UPDATE aspnet_UsersInRoles SET UserId= UserId, RoleId=@RoleId WHERE UserId= '" + iduser + "'";
SqlConnection myConnection = new SqlConnection(ConnectionString);
SqlCommand myCommand = new SqlCommand(role, myConnection);
myConnection.Open();
Response.Write(DropDownList1.SelectedValue.ToString());
SqlParameter RoleId = new SqlParameter();
RoleId.ParameterName = "@RoleId";
RoleId.SqlDbType = SqlDbType.UniqueIdentifier;
RoleId.Value = DropDownList1.SelectedValue.ToString();
myCommand.Parameters.Add(RoleId);
myConnection.Close();
}
} |
Partager