-
Notifications
You must be signed in to change notification settings - Fork 0
/
frmMainForm.cs
221 lines (207 loc) · 6.9 KB
/
frmMainForm.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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using Microsoft.Win32;
using Infragistics.Win.Misc;
using System.Resources;
using System.Globalization;
using System.Threading;
using System.IO;
namespace Time_Attendance
{
public partial class frmMainForm : Form
{
public static SqlConnection _MasterCon;
public static string ServerName;
public static string _ConfigPlace;
public static string[] _Machin;
public static string main_door;
public frmMainForm()
{
InitializeComponent();
try
{
StreamReader sr = new StreamReader("Server.txt");
ServerName = sr.ReadLine();
string UserName = sr.ReadLine();
string Password = sr.ReadLine();
sr.Close();
_MasterCon = new SqlConnection("Data Source=" + ServerName + ";Initial Catalog=TimeAttendance_MONITOR;User ID=" + UserName + ";Password=" + Password);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
this.Close();
}
try
{
StreamReader sr = new StreamReader("configuration.txt");
_ConfigPlace = sr.ReadLine();
_Machin = new string[8];
string m = sr.ReadLine();
int x = 0;
while (m != null)
{
_Machin[x] = m;
m = sr.ReadLine();
x++;
}
sr.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
this.Close();
}
try
{
StreamReader sr = new StreamReader("main_door.txt");
main_door = sr.ReadLine();
sr.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
this.Close();
}
}
private bool CheckFormOpen(Form f)
{
foreach (Form childForm in MdiChildren)
{
if (f.Text == childForm.Text)
{
childForm.Activate();
return true;
}
}
return false;
}
private void frmMainForm_Load(object sender, EventArgs e)
{
frmEmpMange rr = new frmEmpMange();
if (!CheckFormOpen(rr))
{
rr.MdiParent = this;
rr.Text = "Monitor";
rr.Show();
}
/*frmLogin frm = new frmLogin();
frm.frm = this;
frm.ShowDialog();
try
{
StreamReader sr = new StreamReader("LastUpdate.txt");
lblLastUpdate.Text = sr.ReadLine();
sr.Close();
}
catch
{
lblLastUpdate.Text = "";
}
SqlCommand com = new SqlCommand("SELECT convert(char(10),MAX(TRN_TIME),103) AS Date , convert(char(19),MAX(TRN_TIME),8) AS Time FROM EMPLOYEE_TRANSACTIONS", _MasterCon);
com.CommandType = CommandType.Text;
SqlDataAdapter sda = new SqlDataAdapter(com);
DataTable dt = new DataTable();
sda.Fill(dt);
if (dt.Rows.Count > 0)
{
lblMaxUpdate.Text = dt.Rows[0][0].ToString() + " " + dt.Rows[0][1].ToString();
}
else
{
lblMaxUpdate.Text = "";
}
*/
}
/*public static int GetIDIndex(string id, string colName, DataTable NavDt)
{
for (int i = 0; i < NavDt.Rows.Count; i++)
{
if (id == NavDt.Rows[i][colName].ToString().Trim())
return i;
}
return -1;
}*/
private void ultraToolbarsManager1_ToolClick_1(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
{
if (main_door == "All")
{
switch (e.Tool.Key)
{
case "Exit Application":
Application.Exit();
break;
case "Monitor":
frmEmpMange rr = new frmEmpMange();
if (!CheckFormOpen(rr))
{
rr.MdiParent = this;
rr.Text = "Monitor";
rr.Show();
}
break;
case "ALL_TRANS":
FrmAllEmpTrans rr2 = new FrmAllEmpTrans();
if (!CheckFormOpen(rr2))
{
rr2.MdiParent = this;
rr2.Text = "All Transactions";
rr2.Show();
}
break;
case "TRANS":
FrmEmpTrans rr3 = new FrmEmpTrans();
if (!CheckFormOpen(rr3))
{
rr3.MdiParent = this;
rr3.Text = "Transactions";
rr3.Show();
}
break;
case "IN_COMPANY":
FrmNowIN rr4 = new FrmNowIN();
if (!CheckFormOpen(rr4))
{
rr4.MdiParent = this;
rr4.Text = "In Company";
rr4.Show();
}
break;
case "DELAYY":
Frm_Delay rr5 = new Frm_Delay();
if (!CheckFormOpen(rr5))
{
rr5.MdiParent = this;
rr5.Text = "Delay";
rr5.Show();
}
break;
}
}
else
{
switch (e.Tool.Key)
{
case "Exit Application":
Application.Exit();
break;
case "Monitor":
frmEmpMange rr = new frmEmpMange();
if (!CheckFormOpen(rr))
{
rr.MdiParent = this;
rr.Text = "Monitor";
rr.Show();
}
break;
}
}
}
}
}