-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFormParams.cs
74 lines (65 loc) · 2.57 KB
/
FormParams.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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace OutlookLocker
{
public partial class FormParams : Form
{
public FormParams()
{
InitializeComponent();
}
private void cbOldPassword_CheckedChanged(object sender, EventArgs e)
{
this.tbOldPassword.UseSystemPasswordChar = !this.tbOldPassword.UseSystemPasswordChar;
}
private void cbNewPassword_CheckedChanged(object sender, EventArgs e)
{
this.tbNewPassword.UseSystemPasswordChar = !this.tbNewPassword.UseSystemPasswordChar;
}
private void cbConfirmNewPassword_CheckedChanged(object sender, EventArgs e)
{
this.tbNewPasswordConfirm.UseSystemPasswordChar = !this.tbNewPasswordConfirm.UseSystemPasswordChar;
}
private void btnSave_Click(object sender, EventArgs e)
{
List<SQLiteValue> values = SQLite.LoadParams();
if (values == null && values.Count == 0)
{
MessageBox.Show(this, "Values is not load!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
if (values.FirstOrDefault(x => x.name == "Password").value == "")
{
MessageBox.Show(this, "Password is empty!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
string oldPass = values.FirstOrDefault(x => x.name == "Password").value;
if (oldPass != this.tbOldPassword.Text)
{
MessageBox.Show(this, "Password is not correct!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
if (this.tbNewPassword.Text != this.tbNewPasswordConfirm.Text)
{
MessageBox.Show(this, "New password is not confirm!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
bool result = SQLite.SaveParams(this.tbOldPassword.Text);
if (result)
{
MessageBox.Show(this, "Password is changed!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
this.Close();
}
else
{
MessageBox.Show(this, "Password is no changed!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}
}