-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.cs
148 lines (124 loc) · 4.99 KB
/
Form1.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
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.OleDb;
namespace QuizProject2
{
public partial class Form_Register : Form
{
public Form_Register()
{
InitializeComponent();
}
OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db_users.mdb");
OleDbCommand cmd = new OleDbCommand();
OleDbDataAdapter da = new OleDbDataAdapter();
private void button_register_Click(object sender, EventArgs e)
{
if (textBox_user_signup.Text == "" && textBox_pass_signup.Text == "" && textBox_confirm_pass_signup.Text == "")
{
MessageBox.Show("Username or Password fields are empty", "Registration Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else if (textBox_pass_signup.Text == textBox_confirm_pass_signup.Text)
{
con.Open();
if (checkBox_agree.Checked)
{
string checkDuplicate = "SELECT username FROM tbl_users WHERE username =@username";
cmd = new OleDbCommand(checkDuplicate, con);
cmd.Parameters.AddWithValue("@username", textBox_user_signup.Text);
OleDbDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
MessageBox.Show("Name Existing Already!", "Registration Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
cmd = new OleDbCommand("INSERT INTO tbl_users VALUES ('" + textBox_user_signup.Text + "','" + textBox_pass_signup.Text + "')", con);
cmd.ExecuteNonQuery();
MessageBox.Show("Your Account has been Successfully Created", "Registration Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
textBox_user_signup.Text = "";
textBox_pass_signup.Text = "";
textBox_confirm_pass_signup.Text = "";
new Form_Login().Show();
this.Hide();
textBox_balanceplaced.Hide();
}
}
else
{
MessageBox.Show("Please check the Privacy Policy!");
}
con.Close();
}
else
{
MessageBox.Show("Passwords does not match, Please Re-enter", "Registration Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
textBox_pass_signup.Text = "";
textBox_confirm_pass_signup.Text = "";
textBox_pass_signup.Focus();
}
}
private void checkBox_showpass_signup_CheckedChanged(object sender, EventArgs e)
{
if (checkBox_showpass_signup.Checked)
{
textBox_pass_signup.PasswordChar = '\0';
textBox_confirm_pass_signup.PasswordChar = '\0';
}
else
{
textBox_pass_signup.PasswordChar = '*';
textBox_confirm_pass_signup.PasswordChar = '*';
}
}
private void label_signin_Click(object sender, EventArgs e)
{
new Form_Login().Show();
this.Hide();
}
private void Form_Register_Load(object sender, EventArgs e)
{
//Remove Top
this.FormBorderStyle = FormBorderStyle.None;
}
private void Form_Register_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
this.Left += e.X - lastPoint.X;
this.Top += e.Y - lastPoint.Y;
}
}
Point lastPoint;
private void Form_Register_MouseDown(object sender, MouseEventArgs e)
{
lastPoint = new Point(e.X, e.Y);
}
private void btn_Minimized_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
}
private void btn_Maximize_Click(object sender, EventArgs e)
{
if (WindowState == FormWindowState.Normal)
{
this.WindowState = FormWindowState.Maximized;
}
else
{
this.WindowState = FormWindowState.Normal;
}
}
private void btn_close_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}