-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogOn.cs
190 lines (137 loc) · 3.65 KB
/
logOn.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
188
189
190
/*
* Created by SharpDevelop.
* User: abdulaziz
* Date: 15/11/33
* Time: 01:12 م
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Threading;
using Expire.Model;
using Expire.Control;
using System.Diagnostics;
namespace Expire
{
/// <summary>
/// Description of logOn.
/// </summary>
public partial class logOn : Form
{
public string username="Null";
public logOn()
{
InitializeComponent();
CenterToScreen();
ShowUserList();
}
public void ShowUserList(){
LogOnC users = new LogOnC();
if(users.Crach()){this.Close();}
foreach(UserM use in users.GetUser()){
this.user.Items.Add(use.UserName);
};
}
public void Login(){
LogOnC lo = new LogOnC();
bool check = lo.CheckUser(user.Text,pass.Text);
if(check)
{
Create();
// this.Close();
}
else
{
MessageBox.Show("Invalid username / password");
this.DialogResult=DialogResult.None;
}
}
void Create()
{
LimitC lc = new LimitC();
if (lc.Count == 0)
{
lc = new LimitC();
lc.Insert(new Limit()
{
Current_Date = lc.DateNow(),
Date_End = lc.DatePeroidTime(),
Date_Start = lc.DateNow()
});
}
else
{
lc = new LimitC();
lc.Update(new Limit()
{
Current_Date = lc.DateNow(),
});
foreach (object obj in lc.GetRecord())
{
Limit li =(Limit)obj;
long trie = lc.GetTotalDay(new Limit()
{
Current_Date = li.Current_Date,
Date_End = li.Date_End,
Date_Start = li.Date_Start
}
);
if (trie > 0)
{
this.DialogResult = DialogResult.OK;
username = user.Text;
}
else {
lc = new LimitC();
lc.KillApp(new Limit()
{
Date_End = lc.DateKiller(),
});
MessageBox.Show("30-Day Trial Version Finished !. Please Contact With Abdulaziz For More Information");
this.DialogResult = DialogResult.None;
username = user.Text;
}
}
}
}
void Button1Click(object sender, EventArgs e)
{
Login();
}
void ClickEnter(object sender, KeyEventArgs e)
{
if(e.KeyCode == Keys.Enter){
Login();
}
}
void MoveToPasswordTextBox(object sender, KeyEventArgs e)
{
if(e.KeyCode==Keys.Enter){
pass.Focus();
}
}
void Label2Click(object sender, EventArgs e)
{
//forget password
}
void Button2Click(object sender, EventArgs e)
{
this.Close();
//FIXME shows null exception when click cancel button
}
private void label6_Click(object sender, EventArgs e)
{
}
private void label3_Click(object sender, EventArgs e)
{
}
private void pass_TextChanged(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
}
}