-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddAgency.aspx.cs
73 lines (65 loc) · 2.81 KB
/
AddAgency.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
63
64
65
66
67
68
69
70
71
72
73
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Web.Configuration;
public partial class AddAgency : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(
WebConfigurationManager.ConnectionStrings["Connect"].ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{
if (Session["AdEmailID"] == null)
{ Response.Redirect("Default.aspx"); }
else
{
HyperLink login = (HyperLink)Master.FindControl("login");
login.Visible = false;
//login.NavigateUrl = "Account.aspx";
HyperLink reg = (HyperLink)Master.FindControl("register");
reg.Visible = false;
HyperLink home = (HyperLink)Master.FindControl("home");
home.NavigateUrl = "AdminHome.aspx";
}
}
protected void Register_Button(object sender, EventArgs e)
{
int status;
con.Open();
SqlCommand cmd1 = new SqlCommand("select * from Agency where AEmailID='" + Email.Text.ToString().Trim() + "'", con);
int count = Convert.ToInt32(cmd1.ExecuteScalar());
if (count != 0)
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Email ID already exists.')", true);
Email.Text = "";
}
else
{
SqlCommand cmd = new SqlCommand("Insert into Agency Values(@fname,@email,@password,1)", con);
cmd.Parameters.AddWithValue("fname", FirstName.Text.ToString().Trim());
//cmd.Parameters.AddWithValue("lname", LastName.Text.ToString().Trim());
cmd.Parameters.AddWithValue("email", Email.Text.ToString().Trim());
//cmd.Parameters.AddWithValue("address", Address.Text.ToString().Trim());
//cmd.Parameters.AddWithValue("gender", RadioButtonList1.SelectedValue.ToString());
cmd.Parameters.AddWithValue("password", Password.Text.ToString().Trim());
//cmd.Parameters.AddWithValue("dob", Dob.Text.Trim());
status = cmd.ExecuteNonQuery();
if (status == 1)
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Account Created Successfully , You will be redirected to admin home page');window.location='AdminHome.aspx'", true);
//Response.Redirect("Login.aspx");
}
else
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Account couldnot be created , try again later.')", true);
}
}
}
protected void Cancel_Click(object sender, EventArgs e)
{
Response.Redirect("AdminHome.aspx");
}
}