/
Input_NIP.cs
183 lines (167 loc) · 5.64 KB
/
Input_NIP.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
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;
using MySql.Data;
using MySql.Data.MySqlClient;
namespace MultiFaceRec
{
public partial class Input_NIP : Form
{
public Input_NIP()
{
InitializeComponent();
}
//Hide Close Button
private const int WS_SYSMENU = 0x80000;
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.Style &= ~WS_SYSMENU;
return cp;
}
}
string usernamewelcome = "";
string jabat = "";
private void tampillogin()
{
this.Hide();
Login fmLogin = new Login();
DialogResult dr = fmLogin.ShowDialog();
if (dr != DialogResult.OK)
{
this.Close();
}
else
{
//this.Text = "Input NIP : " + fmLogin.usernamelogin;
usernamewelcome = fmLogin.usernamelogin;
this.Show();
}
if (usernamewelcome != "")
{
CariPengguna cp = new CariPengguna();
if (cp.statusCariUser2(usernamewelcome) == true)
{
DBConnect koneksi_db = new DBConnect();
MySqlConnection db = new MySqlConnection(koneksi_db.koneksi());
db.Open();
MySqlCommand dbcmd2 = db.CreateCommand();
string sql = "select user_login,Jab from user_system";
dbcmd2.CommandText = sql;
MySqlDataReader reader = dbcmd2.ExecuteReader();
while (reader.Read())
{
if ((reader.GetString(0).ToString().ToLower() == usernamewelcome))
{
//label_Nama.Text = reader.GetString(1).ToString();
jabat = reader.GetString(1).ToString();
if (jabat == "Admin")
{
button_Daftar.Enabled = true;
}
}
}
db.Close();
}
}
}
private void Input_NIP_Load(object sender, EventArgs e)
{
//button_Daftar.Visible = false;
button_Daftar.Enabled = false;
DBConnect koneksi_db = new DBConnect();
MySqlConnection conn = new MySqlConnection(koneksi_db.koneksi());
try
{
conn.Open();
tampillogin();
}
catch (Exception ex)
{
MessageBox.Show("Koneksi ke database gagal", "Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Warning);
MessageBox.Show(ex.Message);
Close();
}
}
private void button_logout_Click(object sender, EventArgs e)
{
//button_Daftar.Visible = false;
button_Daftar.Enabled = false;
tampillogin();
}
private void button_Masuk_Click(object sender, EventArgs e)
{
//CariPengguna cp = new CariPengguna();
//if (cp.statuscariuser3(NIP_Textbox.Text) == true)
//{
//if (cp.statuscariuser(NIP_Textbox.Text) == false)
//{
//FrmPrincipal frmmain = new FrmPrincipal(NIP_Textbox.Text);
//DialogResult dr = frmmain.ShowDialog();
//this.Close();
//this.Hide();
//frmmain.Show();
//NIP_Textbox.Clear();
//NIP_Textbox.Focus();
// }
//else
//{
// MessageBox.Show("Anda Sudah Melakukan Absensi untuk hari ini");
//NIP_Textbox.Clear();
//NIP_Textbox.Focus();
//}
//}
//else
//{
// MessageBox.Show("N.I.P yang anda masukkan tidak terdaftar di database");
// NIP_Textbox.Clear();
// NIP_Textbox.Focus();
//}
}
private void button_Daftar_Click(object sender, EventArgs e)
{
DaftarPeg Daftar = new DaftarPeg();
DialogResult dr = Daftar.ShowDialog();
}
private void NIP_Textbox_TextChanged(object sender, EventArgs e)
{
Exception X = new Exception();
TextBox T = (TextBox)sender;
try
{
if (T.Text != "-")
{
int x = int.Parse(T.Text);
}
}
catch (Exception)
{
try
{
int CursorIndex = T.SelectionStart - 1;
T.Text = T.Text.Remove(CursorIndex, 1);
T.SelectionStart = CursorIndex;
T.SelectionLength = 0;
}
catch (Exception) { }
}
}
private void Button_Absensi_Click(object sender, EventArgs e)
{
string NIP_Awal = "1";
string path = "All";
string folder = "TrainedFaces2";
FrmPrincipal frmmain = new FrmPrincipal(NIP_Awal,path,folder);
DialogResult dr = frmmain.ShowDialog();
//this.Close();
//this.Hide();
}
}
}