-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.cs
98 lines (88 loc) · 2.74 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
using Microsoft.EntityFrameworkCore.ChangeTracking.Internal;
using Microsoft.SqlServer.Server;
using System.Linq;
using System.Security.Cryptography;
using System.Security.Principal;
namespace PharmacyProjectITI
{
public partial class Form1 : Form
{
private pharmacyContext dadabase = new pharmacyContext();
~Form1()
{
Application.Exit();
}
public Form1()
{
InitializeComponent();
}
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
User user = new User();
string name = textBox1.Text;
string password = textBox2.Text;
string email = textBox4.Text;
string copassword = textBox3.Text;
if (name == "")
{
MessageBox.Show("You have to enter your name first:");
}
else if (password == "")
{
MessageBox.Show("You have to enter your password first:");
}
else if (email == "")
{
MessageBox.Show("You have to enter your email first:");
}
else if (copassword != password)
{
MessageBox.Show("You have to confirm your password first:");
}
else
{
var idList = dadabase.user.Select(s => s.uEmail).ToList();
bool isexist = false;
foreach (var item in idList)
{
if (item == textBox4.Text)
{
isexist = true;
break;
}
}
if (isexist)
{
MessageBox.Show("User alrady exists:");
textBox4.Text = "";
}
else
{
user.uName = name;
user.uEmail = email;
user.uPassword = password;
dadabase.Add(user);
dadabase.SaveChanges();
textBox1.Text = "";
textBox2.Text = "";
textBox4.Text = "";
textBox3.Text = "";
MessageBox.Show("User Added succesfuly: \n Now you can login");
}
}
}
private void button2_Click(object sender, EventArgs e)
{
LoginPage loginPage = new LoginPage();
this.Hide();
//this.Close();
loginPage.Show();
}
}
}