-
Notifications
You must be signed in to change notification settings - Fork 0
/
AdminGiris.cs
119 lines (112 loc) · 3.99 KB
/
AdminGiris.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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using Microsoft.Win32;
namespace KütüphaneTakipProgramı
{
public partial class AdminGiris : Form
{
public AdminGiris()
{
InitializeComponent();
}
private void btnAdminGiris_Click(object sender, EventArgs e)
{
baglanti db = new baglanti();
if (chkHatirla.Checked)
{
RegistryKey key = Registry.CurrentUser.OpenSubKey("Kutuphane", true);
key.SetValue("Kadi", txtAdminAdi.Text);
}
else
{
RegistryKey key = Registry.CurrentUser.OpenSubKey("Kutuphane", true);
try
{
key.SetValue("Kadi", string.Empty);
}
catch (Exception)
{
throw;
}
}
try
{
RegistryKey register = Registry.CurrentUser;
register = register.OpenSubKey("", true);
string ad = (string)register.GetValue("ad");
int oturum_sayisi = Convert.ToInt32(register.GetValue("oturum")) + 1;
register.SetValue("oturum", oturum_sayisi);
MessageBox.Show("Hoşgeldin " + ad + " Programı " + oturum_sayisi + " kez açtınız");
}
catch (Exception)
{
RegistryKey register = Registry.CurrentUser;
register = register.CreateSubKey("");
register.SetValue("ad", "");
register.SetValue("Oturum", 1);
MessageBox.Show("Oturumu ilk kez açtınız");
}
string kuladi = txtAdminAdi.Text.ToString();
string parola = txtAdminParola.Text.ToString();
bool giris = db.adminGirisKontrol(kuladi, parola);
if (giris == true)
{
AnaEkran ana = new AnaEkran();
ana.Show();
this.Hide();
}
else
{
MessageBox.Show("Hatalı Giriş");
}
}
private void btnAdminİptal_Click(object sender, EventArgs e)
{
Giris giris = new Giris();
giris.Show();
this.Hide();
}
private void AdminGiris_Load(object sender, EventArgs e)
{
string[] a = Registry.CurrentUser.GetSubKeyNames();
foreach (string klasor in a)
{
if (klasor == "Kutuphane")
{
string[] b = Registry.CurrentUser.OpenSubKey("Kutuphane", true).GetValueNames();
foreach (var item in b)
{
if (item != "Kadi")
{
Registry.CurrentUser.OpenSubKey("Kutuphane", true).SetValue("Kadi", string.Empty);
}
else
{
txtAdminAdi.Text = Registry.CurrentUser.OpenSubKey("Kutuphane").GetValue("Kadi").ToString();
}
}
}
else
{
Registry.CurrentUser.CreateSubKey("Kutuphane");
string[] b = Registry.CurrentUser.OpenSubKey("Kutuphane", true).GetValueNames();
foreach (var item in b)
{
if (item != "Kadi")
{
Registry.CurrentUser.OpenSubKey("Kutuphane", true).SetValue("Kadi", string.Empty);
}
}
}
}
}
}
}