-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram_User.cs
More file actions
70 lines (63 loc) · 2.28 KB
/
Copy pathProgram_User.cs
File metadata and controls
70 lines (63 loc) · 2.28 KB
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
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DormitoryManagment
{
internal static partial class Program
{
internal class User
{
protected string Name;
protected string Email;
protected string Username;
protected string Password;
public User()
{
Name = "";
Email = "";
Username = "";
Password = "";
}
public string GetName() { return Name; }
public string GetEmail() { return Email; }
public void ChangePassword(string oldPass, string newPass, string checkSame)
{
if (oldPass != Password)
{
MessageBox.Show("The old password is incorrect, please re-input!", "Update failed",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
if (newPass != checkSame)
{
MessageBox.Show("The 2 new password isn't the same, please re-input!", "Update failed",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
if (newPass == "")
{
MessageBox.Show("The password can't be empty", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
Password = newPass;
MessageBox.Show("Update the new password successfully!", "Update success",MessageBoxButtons.OK, MessageBoxIcon.Information);
SaveData();
}
virtual public void SaveData() { }
public void LogOut()
{
conn.Open();
string sql = "UPDATE Users SET Online = 0 WHERE Username = '" + Username + "'";
MySqlCommand cmd = new MySqlCommand(sql, conn);
Console.WriteLine(cmd.ExecuteNonQuery());
conn.Close();
SaveData();
}
}
}
}