-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm1.cs
More file actions
247 lines (209 loc) · 8.64 KB
/
Form1.cs
File metadata and controls
247 lines (209 loc) · 8.64 KB
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using Microsoft.Win32;
using System.Data.SqlClient;
namespace Banka
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
SqlConnection connection = new SqlConnection(" server= . ; initial catalog = Banka; integrated security = sspi ");
public static int musteriID;
public static string kullaniciAdi;
public static string adSoyad;
public static float musteriBakiye = 0.0f;
private void Form1_Load(object sender, EventArgs e)
{
string wallpaperPath = Registry.GetValue(@"HKEY_CURRENT_USER\Control Panel\Desktop", "WallPaper", null).ToString();
Image wallpaper = Image.FromFile(wallpaperPath);
this.BackgroundImage = wallpaper;
this.BackgroundImageLayout = ImageLayout.Stretch;
opacity(buttons,128);
groupBoxGiris.Visible = false;
groupBoxKayit.Visible = false;
radioButton1.Checked = true;
}
private void opacity(GroupBox groupBox, int opacity)
{
groupBox.BackColor = Color.FromArgb(opacity, groupBox.BackColor);
}
private void button1_Click(object sender, EventArgs e)
{
groupBoxGiris.Visible=true;
btnKapat.Visible = true;
}
private void button2_Click(object sender, EventArgs e)
{
groupBoxKayit.Visible = true;
btnKapat.Visible = true;
}
private void btnKapat_Click(object sender, EventArgs e)
{
if (groupBoxGiris.Visible || groupBoxKayit.Visible )
{
groupBoxGiris.Visible = false;
groupBoxKayit.Visible = false;
btnKapat.Visible=false;
}
}
private void btnGirisYap_Click(object sender, EventArgs e)
{
kullaniciAdi = txtKullaniciAdi.Text;
string parola = txtParola.Text;
bool sonuc = false;
if (radioButton2.Checked)
{
if (kullaniciAdi == "kivanc" && parola == "12345")
{
adminPanel admin = new adminPanel();
admin.Show();
this.Hide();
}
else
{
MessageBox.Show("Hatalı giriş denemesi", "Admin giriş İşlemi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
else
{
connection.Open();
SqlCommand komut = new SqlCommand("select * from Musteriler where kullaniciAdi = @p1 and parola = @p2",connection);
komut.Parameters.AddWithValue("@p1", kullaniciAdi);
komut.Parameters.AddWithValue("@p2", parola);
SqlDataReader dataReader = komut.ExecuteReader();
while (dataReader.Read())
{
kullaniciAdi = dataReader["kullaniciAdi"].ToString();
musteriID = int.Parse(dataReader["ID"].ToString());
musteriBakiye = float.Parse(dataReader["bakiye"].ToString());
adSoyad = dataReader["adSoyad"].ToString();
sonuc = true;
}
connection.Close();
if (sonuc)
{
sonuc = false;
musteriPanel mPanel = new musteriPanel();
mPanel.Show();
this.Hide();
}
else
{
MessageBox.Show("Hatalı kullanıcı girişi", "kullanıcı giriş işlemi", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
txtKullaniciAdi.Text = "";
txtParola.Text = "";
}
private void btnKayitOl_Click(object sender, EventArgs e)
{
SqlCommand kullaniciAdiKontrolKomutu = new SqlCommand("SELECT COUNT(*) FROM musteriler WHERE kullaniciAdi = @kullaniciAdi", connection);
kullaniciAdiKontrolKomutu.Parameters.AddWithValue("@kullaniciAdi", kayitKullaniciAdi.Text);
connection.Open();
int kullaniciAdiKayitSayisi = (int)kullaniciAdiKontrolKomutu.ExecuteScalar();
connection.Close();
if (kullaniciAdiKayitSayisi > 0)
{
MessageBox.Show("Bu kullanıcı adı zaten kayıtlıdır.", "Kayıt Hatası", MessageBoxButtons.OK, MessageBoxIcon.Warning);
temizle();
return;
}
SqlCommand komut = new SqlCommand("insert into musteriler (kullaniciAdi,tc,adSoyad,adres,telefon,email,cinsiyet,yas,parola,bakiye,aktif) values (@p1,@p2,@p3,@p4,@p5,@p6,@p7,@p8,@p9,@p10,@p11)", connection);
komut.Parameters.AddWithValue("@p1", kayitKullaniciAdi.Text);
komut.Parameters.AddWithValue("@p2", kayitTC.Text);
komut.Parameters.AddWithValue("@p3", kayitAdSoyad.Text);
komut.Parameters.AddWithValue("@p4", kayitAdres.Text);
komut.Parameters.AddWithValue("@p5", kayitTel.Text);
komut.Parameters.AddWithValue("@p6", kayitEmail.Text);
if (radioErkek.Checked)
{
komut.Parameters.AddWithValue("@p7", "Erkek");
}else if (radioKadın.Checked)
{
komut.Parameters.AddWithValue("@p7", "Kadın");
}
else
{
MessageBox.Show("Lütfen cinsiyetinizi seçiniz", "Kayıt işlemi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
if(int.Parse(kayitYas.Text)>= 18)
{
komut.Parameters.AddWithValue("@p8", kayitYas.Text);
}
else
{
MessageBox.Show("18 yaşından küçük olan kişiler banka hesabı açamaz", "kayıt işlemi", MessageBoxButtons.OK, MessageBoxIcon.Information);
temizle();
return;
}
if(kayitParola.Text == kayitParolaOnay.Text)
{
komut.Parameters.AddWithValue("@p9", kayitParola.Text);
}else
{
MessageBox.Show("Parolalar eşleşmiyor", "Kayıt hatası", MessageBoxButtons.OK, MessageBoxIcon.Error);
kayitParola.Text = "";
kayitParolaOnay.Text = "";
}
komut.Parameters.AddWithValue("@p10", 0);
komut.Parameters.AddWithValue("@p11",1);
if( kayitKullaniciAdi.Text == "" || kayitTC.Text == "" || kayitAdSoyad.Text == ""|| kayitAdres.Text == "" || kayitTel.Text == "" || kayitEmail.Text == "" || kayitYas.Text == "" ||kayitParola.Text == "")
{
MessageBox.Show("Tüm alanları doldurunuz", "Kayıt Hatası", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
if (koumadimOnayladım.Checked)
{
connection.Open();
int sonuc = komut.ExecuteNonQuery();
connection.Close();
if (sonuc == 1)
{
MessageBox.Show("Yeni Musteri Kaydı oluşturuldu", "musteri kaydı");
groupBoxKayit.Visible = false;
btnKapat.Visible = false;
}
else
{
MessageBox.Show("Yeni Musteri Kaydı oluşturulamadı", "Kayıt Hatası", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
else
{
MessageBox.Show("Lütfen Okumadım,onayladım kısmını işaretleyiniz", "Kayıt işlemi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
private void temizle()
{
kayitTC.Text = "";
kayitAdSoyad.Text = "";
kayitAdres.Text = "";
kayitTel.Text = "";
kayitParola.Text = "";
kayitParolaOnay.Text = "";
kayitEmail.Text = "";
kayitKullaniciAdi.Text = "";
kayitYas.Text = "";
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
}
}
}