-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaddagent.aspx.cs
30 lines (29 loc) · 1.05 KB
/
addagent.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
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class addagent : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Interaction.redirIfNotLoggedIn();
if (!(Interaction.LoggedInUser is Admin)) Interaction.redirUnauthorize();
}
protected void registerBtn_Click(object sender, EventArgs e)
{
if (!(Interaction.LoggedInUser is Admin)) Interaction.redirUnauthorize();
if (!Page.IsValid) return;
Admin ad = (Admin)Interaction.LoggedInUser;
try
{
ad.addAgent(addressTxt.Text, firstNameTxt.Text, lastNameTxt.Text, passTxt.Text, phoneTxt.Text, usernameTxt.Text);
Interaction.setSuccessMessage(Literal1, "agent added");
}
catch (UserAlreadyExistsException ex)
{
userExistsValidate.ErrorMessage = "user " + ex.UserName + " already exists";
userExistsValidate.IsValid = false;
}
}
}