-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfirmremove.aspx.cs
46 lines (43 loc) · 1.59 KB
/
confirmremove.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class confirmremove : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Interaction.redirIfNotLoggedIn();
if (!(Interaction.LoggedInUser is Admin)) Interaction.redirUnauthorize();
if (!Page.IsPostBack)
{
ViewState["ReferrerUrl"] = Request.UrlReferrer.ToString();
}
if(Session["userDel"]==null) Response.Redirect("removeaccount.aspx"); //no user to remove
User u = (User)Session["userDel"];
if (u.TheTicket == null) Label1.Text = "user has no flight booked, continue to remove?";
else Label1.Text = "still has flight booked, continue to remove?";
}
protected void Button1_Click(object sender, EventArgs e)
{
User u = (User)Session["userDel"];
Admin a = (Admin)Interaction.LoggedInUser;
try
{
a.removeUser(u);
}
catch (Exception ex)
{
Interaction.setFailureMessage(Literal1, ex.Message);
return;
}
//Literal1.Text = "<script language=\"javascript\">alert('account removed');</script>";
Response.Redirect("removeaccount.aspx?success=1");
}
protected void Cancel_Click(object sender, EventArgs e)
{
if(ViewState["ReferrerUrl"]!=null) Response.Redirect(ViewState["ReferrerUrl"].ToString());
else { Response.Redirect("removeaccount.aspx"); }
}
}