-
Notifications
You must be signed in to change notification settings - Fork 1
/
removeaccount.aspx.cs
62 lines (60 loc) · 2.09 KB
/
removeaccount.aspx.cs
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
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class removeaccount : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Interaction.redirIfNotLoggedIn();
if (!(Interaction.LoggedInUser is Admin)) Interaction.redirUnauthorize();
if (!Page.IsPostBack)
{
Session["userDel"] = null;
if (Request.QueryString["success"] == ("1"))
{
Interaction.setSuccessMessage(Literal1, "user removed");
}
}
else
{
GridView1.DataBind();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
if (GridView1.SelectedIndex < 0)
{
Interaction.setFailureMessage(Literal1, "please select a user first");
return;
}
else
{
int theUserNumber=Convert.ToInt32(GridView1.SelectedRow.Cells[1].Text);
if (theUserNumber == Interaction.LoggedInUser.UserNumber)
{
Interaction.setFailureMessage(Literal1, "cannot remove admin himself");
return;
}
User u = new User(theUserNumber, GridView1.SelectedRow.Cells[2].Text, GridView1.SelectedRow.Cells[3].Text, Convert.ToInt32(GridView1.SelectedRow.Cells[4].Text), GridView1.SelectedRow.Cells[5].Text,
GridView1.SelectedRow.Cells[6].Text, GridView1.SelectedRow.Cells[7].Text, GridView1.SelectedRow.Cells[8].Text);
Session["userDel"] = u;
Response.Redirect("confirmremove.aspx");
}
}
protected void searchBtn_Click(object sender, EventArgs e)
{
GridView1.DataSourceID = "SqlDataSource1";
GridView1.DataBind();
if (GridView1.Rows.Count <= 0)
{
Interaction.setFailureMessage(Literal1, "no result found");
Panel1.Visible = false;
}
else
{
Panel1.Visible = true;
}
}
}