-
Notifications
You must be signed in to change notification settings - Fork 0
/
SignUp.aspx.cs
91 lines (80 loc) · 2.72 KB
/
SignUp.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
public partial class SignUp : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void txtsignup_Click(object sender, EventArgs e)
{
if(isformvalid())
{
using (SqlConnection con = new SqlConnection(ConfigurationManager .ConnectionStrings ["EasyBuy123"].ConnectionString ))
{
con.Open();
SqlCommand cmd = new SqlCommand("Insert into tblUsers(Username,Password,Email,Name,Usertype) Values('" + txtUname.Text + "','" + txtPass.Text + "','" + txtEmail.Text + "','" + txtName.Text + "','User')", con);
cmd.ExecuteNonQuery();
Response.Write("<script> alert('Registration Successfully done'); </script>");
clr();
con.Close();
lblMsg.Text = "Registration Successfully done";
lblMsg.ForeColor = System.Drawing.Color.Green;
}
Response.Redirect("~/SignIn.aspx");
}
else
{
Response.Write("<script> alert('Registration failed'); </script>");
lblMsg.ForeColor = System.Drawing.Color.Red;
}
}
private bool isformvalid()
{
if (txtUname.Text == "")
{
Response.Write("<script> alert('username not valid'); </script>");
txtUname.Focus();
return false;
}
else if(txtPass.Text =="")
{
Response.Write("<script> alert('Password not valid'); </script>");
txtPass.Focus();
return false;
}
else if (txtPass.Text != txtCPass .Text )
{
Response.Write("<script> alert('confirm Password not valid'); </script>");
txtCPass.Focus();
return false;
}
else if (txtEmail .Text == "")
{
Response.Write("<script> alert('Email not valid'); </script>");
txtEmail.Focus();
return false;
}
else if (txtName .Text == "")
{
Response.Write("<script> alert('Name not valid'); </script>");
txtName.Focus();
return false;
}
return true;
}
private void clr()
{
txtName.Text = string.Empty;
txtPass.Text = string.Empty;
txtUname. Text = string.Empty;
txtEmail. Text = string.Empty;
txtCPass.Text = string.Empty;
}
}