-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSign_Up.xaml.cs
187 lines (160 loc) · 5.34 KB
/
Sign_Up.xaml.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data.SqlClient;
using System.IO;
using System.Speech.Synthesis;
namespace Money_Savings_Tool
{
/// <summary>
/// Interaction logic for Sign_Up.xaml
/// </summary>
public partial class Sign_Up : Window
{
DateTime date = DateTime.Now;
DatabaseConnection db = new DatabaseConnection();
SpeechSynthesizer speech = new SpeechSynthesizer();
public Sign_Up()
{
InitializeComponent();
}
public int AddUser(params string[] inputs)
{
int check = 0;
try
{
string sql = "INSERT INTO [Registration] (Name,Email,Phone,Password,Date) VALUES('" + inputs[0] + "','" + inputs[1] + "','" + inputs[2] + "','" + inputs[3] + "','" + date + "')";
db.command = new SqlCommand(sql, db.con);
check = db.command.ExecuteNonQuery();
}
catch (Exception E)
{
MessageBox.Show("Email has been already used.\nIf you forget your password, go to forget password");
}
return check;
}
void Null_Email()
{
string line = "Please Enter Email to Continue";
try
{
speech.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Teen);
speech.SpeakAsync(line);
}
catch (Exception E)
{
MessageBox.Show(E.Message);
}
}
public bool CheckTextBox()
{
bool check = false;
if (Name.Text == "")
{
BlankName.Content = "Name Required !!";
}
else
{
BlankName.Content = "";
}
if (Email.Text == "")
{
BlankEmail.Content = "Email Required !!";
}
else
{
BlankEmail.Content = "";
}
if (Phone.Text == "")
{
BlankPhone.Content = "Phone Required !!";
}
else
{
BlankPhone.Content = "";
}
if (Password.Password == "")
{
BlankPassword.Content = "Password Required !!";
}
else
{
BlankPassword.Content = "";
}
if (Confirm_Password.Password == "")
{
BlankConfirmPassword.Content = "Confirm Password Required !!";
}
else
{
BlankConfirmPassword.Content = "";
}
if (Password.Password != Confirm_Password.Password)
{
MessageBox.Show("Password and Confirm Password Doesn't Match !");
}
if (Password.Password.Length < 8)
{
BlankPassword.Content = "Password length should be 8 ";
BlankConfirmPassword.Content = "Password length should be 8";
BlankPassword.Foreground = Brushes.Red;
BlankConfirmPassword.Foreground = Brushes.Red;
}
if (Name.Text != "" && Email.Text != "" && Phone.Text != "" && Password.Password != "" && Confirm_Password.Password != "" && Password.Password.Equals(Confirm_Password.Password) && Password.Password.Length >= 8)
{
if (MyCheckBox.IsChecked == true)
{
check = true;
}
else
{
MessageBox.Show("Click on agree to continue");
}
}
return check;
}
private void Sign_Up_Button(object sender, RoutedEventArgs e)
{
// String date = System.DateTime.Now.ToString("dd.MM.yyyy");
string name, email, phone, password, confirm_password;
name = Name.Text.ToUpper();
email = Email.Text.ToUpper();
phone = Phone.Text;
password = Password.Password;
confirm_password = Confirm_Password.Password;
if (CheckTextBox().Equals(true))
{
if (AddUser(name, email, phone, password) == 1)
{
MessageBox.Show("User Added Successfully");
Login f1 = new Login();
this.Hide();
f1.Show();
}
db.CloseConnection();
}
}
private void Back_Button(object sender, RoutedEventArgs e)
{
Login obj = new Login();
this.Hide();
obj.Show();
}
private void CheckBox_Checked(object sender, RoutedEventArgs e)
{
}
private void Name_TextChanged(object sender, TextChangedEventArgs e)
{
}
}
}