/
SignUp.cs
150 lines (136 loc) · 5.15 KB
/
SignUp.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Security.Cryptography;
namespace NEWPROJECT
{
public partial class SignUp : Form
{
ConnectionClass conn = new ConnectionClass();
public SignUp()
{
InitializeComponent();
}
private void SignUp_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
SignupUser();
}
private bool SignupUser()
{
bool ret = true;
if (txtName.Text == "")
{
lblNameIsRequired.Visible = true;
ret = false;
}
else
{
lblNameIsRequired.Visible = false;
}
if (txtEmail.Text == "")
{
lblEmailIsRequired.Visible = true;
ret = false;
}
else
{
lblEmailIsRequired.Visible = false;
}
if (txtPassword.Text == "")
{
lblPasswordIsRequired.Visible = true;
ret = false;
}
else
{
lblPasswordIsRequired.Visible = false;
}
if (txtConfirmPassword.Text == "")
{
lblConfirmPasswordIsRequired.Visible = true;
ret = false;
}
else
{
lblConfirmPasswordIsRequired.Visible = false;
}
if (txtPassword.Text != "" && txtConfirmPassword.Text != "")
{
if (txtPassword != txtConfirmPassword)
{
lblConfirmPasswordAndPasswordSame.Visible = true;
ret = false;
}
}
else
{
lblConfirmPasswordAndPasswordSame.Visible = false;
}
if ((txtName.Text != "") && (txtEmail.Text != "") && (txtPassword.Text != "") && (txtConfirmPassword.Text != "") && (txtPassword.Text == txtConfirmPassword.Text))
{
lblConfirmPasswordAndPasswordSame.Visible = false;
ConnectionClass con = new ConnectionClass();
SqlCommand cmd = new SqlCommand("Select Count(*) From Admin Where E_mail = @E_mail", con.connect);
cmd.Parameters.AddWithValue("@E_mail", txtEmail.Text);
con.connect.Open();
int Result = (int)cmd.ExecuteScalar();
if (Result != 1)
{
SqlCommand cmdInsert = new SqlCommand("Insert Into Admin (E_mail,Password,Name) Values (@E_mail,@Password,@Name)", con.connect);
cmdInsert.Parameters.AddWithValue("@E_mail", txtEmail.Text);
//MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
//UTF8Encoding utf8 = new UTF8Encoding();
//byte[] data = md5.ComputeHash(utf8.GetBytes(txtPassword.Text));
//string EncryptedPassword = Convert.ToBase64String(data);
cmdInsert.Parameters.AddWithValue("@Password", txtConfirmPassword.Text);
cmdInsert.Parameters.AddWithValue("@Name", txtName.Text);
cmdInsert.ExecuteNonQuery();
conn.connect.Close();
DialogResult DR=MessageBox.Show("New User Added","Successfully",MessageBoxButtons.OK,MessageBoxIcon.Information);
if (DR == DialogResult.OK)
{
EMSLOGINFORM ems = new EMSLOGINFORM();
RefreshClass LoadEvent = new RefreshClass();
LoadEvent.zeeshansami(ems.textBox1);
//this.Refresh();
//MyForm1Instance.Refresh();
//MyForm1Instance.EMSLOGINFORM_Load_1(null, null);
//MyForm1Instance.EMSLOGINFORM_Load_1(this, new EventArgs());
//MessageBoxButtons.OK += new System.EventHandler(this.button1_Click);
}
}
else
{
MessageBox.Show("This Email is already exist");
txtPassword.Clear();
txtConfirmPassword.Clear();
con.connect.Close();
}
}
return ret;
}
private void button2_Click(object sender, EventArgs e)
{
}
private void button2_Click_1(object sender, EventArgs e)
{
this.Close();
}
private void lblPasswordIsRequired_Click(object sender, EventArgs e)
{
}
private void SignUp_Load_1(object sender, EventArgs e)
{
}
}
}