-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm1.cs
More file actions
502 lines (407 loc) · 14.9 KB
/
Form1.cs
File metadata and controls
502 lines (407 loc) · 14.9 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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
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.SQLite;
using System.IO;
namespace Kutuphanecsharp
{
public partial class PanelSideMenu : Form
{
public PanelSideMenu()
{
InitializeComponent();
}
SQLiteConnection baglanti = new SQLiteConnection("Data Source=kihmed.db;Version=3");
SQLiteCommand komut;
private Form activeForm = null;
int tempIndex;
Random random;
private void Form1_Load(object sender, EventArgs e)
{
customizeDesign();
CreateDb();
lblName.Text = "ANA MENÜ";
Alert();
}
void CreateDb()
{
if (!File.Exists("kihmed.db"))
{
SQLiteConnection.CreateFile("kihmed.db");
baglanti.Open();
#region Üyelik Tablosu
string uye = @"CREATE TABLE Uyeler(
ID INTEGER NOT NULL,
adddt text not null,
name text not null,
surname text not null,
phone text not null,
address text not null,
okitaptoplam int not null
);";
komut = new SQLiteCommand(uye, baglanti);
komut.ExecuteNonQuery();
#endregion
#region Kitap Tablosu
string book = @"CREATE TABLE Books(
ID INTEGER PRIMARY KEY AUTOINCREMENT,
rafid text not null,
book text not null,
author text not null,
category text not null,
publisher text not null,
durum text not null
);";
komut = new SQLiteCommand(book, baglanti);
komut.ExecuteNonQuery();
#endregion
#region Raf Tablosu
string raf = @"create table raf(
ID integer not null,
rafname text not null);";
komut = new SQLiteCommand(raf, baglanti);
komut.ExecuteNonQuery();
#endregion
#region Kategori Tablosu
string category = @"create table category(
ID integer PRIMARY KEY AUTOINCREMENT,
categoryname text not null);";
komut = new SQLiteCommand(category,baglanti);
komut.ExecuteNonQuery();
#endregion
#region Büfe Tablosu
string bufe = @"create table bufe(
ID integer PRIMARY KEY AUTOINCREMENT,
urunad text not null,
fiyat double not null,
adet int not null);";
komut = new SQLiteCommand(bufe,baglanti);
komut.ExecuteNonQuery();
#endregion
#region Kasa Tablosu
string kasa = @"create table kasa(
urun text not null,
adet int not null,
ucret double not null,
tarih date not null)";
komut = new SQLiteCommand(kasa,baglanti);
komut.ExecuteNonQuery();
#endregion
#region Ciro
string ciro = @"create table ciro(
gunluk date not null,
ciro double not null)";
komut = new SQLiteCommand(ciro,baglanti);
komut.ExecuteNonQuery();
#endregion
#region Ödünç Kitap
string odunc = @"create table odunc(
id integer PRIMARY KEY autoincrement,
uyeid int not null,
ad text not null,
soyad text not null,
phone text not null,
kitap text not null,
rafid text not null,
alistarihi date not null,
sontarih date not null,
teslim text not null
)";
komut = new SQLiteCommand(odunc,baglanti);
komut.ExecuteNonQuery();
#endregion
baglanti.Close();
}
}
private void customizeDesign()
{
panelBookSubMenu.Visible = false;
panelMemberSubMenu.Visible = false;
panelBufeSubMenu.Visible = false;
panelSettingsSubMenu.Visible = false;
}
private void hideSubMenu()
{
if (panelBookSubMenu.Visible == true)
panelBookSubMenu.Visible = false;
if (panelMemberSubMenu.Visible == true)
panelMemberSubMenu.Visible = false;
if (panelBufeSubMenu.Visible == true)
panelBufeSubMenu.Visible = false;
if (panelSettingsSubMenu.Visible == true)
panelSettingsSubMenu.Visible = false;
}
private void showSubMenu(Panel subMenu)
{
if (subMenu.Visible == false)
{
hideSubMenu();
subMenu.Visible = true;
}
else
{
subMenu.Visible = false;
}
}
public void color_change(Color color)
{
panelUstSolMenu.BackColor = ColorBrightness(color, -0.5);
panelUstMenu.BackColor = color;
btnMenu.BackColor = color;
btnBooks.BackColor = color;
btnMembers.BackColor = color;
btnBufe.BackColor = color;
btnSettings.BackColor = color;
btnStatistics.BackColor = color;
btnRezevasyon.BackColor = color;
PanelArayuz.BackColor = color;
btnBookAdd.BackColor = ColorBrightness(color, +0.3);
btnBookLoan.BackColor = ColorBrightness(color, +0.3);
btnBookSearch.BackColor = ColorBrightness(color, +0.3);
btnBookLoan1.BackColor = ColorBrightness(color, +0.3);
btnKitapGuncelle.BackColor = ColorBrightness(color, +0.3);
btnMemberAdd.BackColor = ColorBrightness(color, +0.3);
btnMemberUpdate.BackColor = ColorBrightness(color, +0.3);
btnMemberSearch.BackColor = ColorBrightness(color, +0.3);
btnBufeKasa.BackColor = ColorBrightness(color, +0.3);
BtnBufeSatis.BackColor = ColorBrightness(color, +0.3);
BtnBufeStok.BackColor = ColorBrightness(color, +0.3);
btnKitapAyarlari.BackColor = ColorBrightness(color, +0.3);
}
public void openChildForm(Form childForm)
{
if (activeForm != null)
{
activeForm.Close();
}
activeForm = childForm;
childForm.TopLevel = false;
childForm.FormBorderStyle = FormBorderStyle.None;
childForm.Dock = DockStyle.Fill;
panel1.Controls.Add(childForm);
panel1.Tag = childForm;
childForm.BringToFront();
childForm.Show();
btnGecikme.Visible = false;
btnKapat.Visible = false;
Color color = SelectThemeColor();
color_change(color);
}
public static List<string> ColorList = new List<string>()
{
"#3F51B5",
"#009688",
"#FF5722",
"#607D8B",
"#FF9800",
"#9C27B0",
"#2196F3",
"#EA676C",
"#E41A4A",
"#5978BB",
"#018790",
"#0E3441",
"#00B0AD",
"#721D47",
"#EA4833",
"#EF937E",
"#F37521",
"#A12059",
"#126881",
"#8BC240",
"#364D5B",
"#C7DC5B",
"#0094BC",
"#E4126B",
"#43B76E",
"#7BCFE9",
"#B71C46"
};
public static Color ColorBrightness(Color color, double correctionFactor)
{
double red = color.R;
double green = color.G;
double blue = color.B;
if (correctionFactor<0)
{
correctionFactor += 1;
red *= correctionFactor;
green *= correctionFactor;
blue *= correctionFactor;
}
else
{
red = (255 - red) * correctionFactor + red;
green = (255 - green) * correctionFactor + green;
blue = (255 - blue) * correctionFactor + blue;
}
return Color.FromArgb(color.A,(byte)red, (byte)green, (byte)blue);
}
private Color SelectThemeColor()
{
random = new Random();
int index = random.Next(ColorList.Count);
while (tempIndex == index)
{
index = random.Next(ColorList.Count);
}
tempIndex = index;
string color = ColorList[index];
return ColorTranslator.FromHtml(color);
}
#region KitapMenü
private void btnBooks_Click(object sender, EventArgs e)
{
showSubMenu(panelBookSubMenu);
}
private void btnBookAdd_Click(object sender, EventArgs e)
{
openChildForm(new KitapKayit());
hideSubMenu();
lblName.Text = btnBookAdd.Text;
}
private void btnBookSearch_Click(object sender, EventArgs e)
{
openChildForm(new KitapAra());
hideSubMenu();
lblName.Text = btnBookSearch.Text;
}
private void btnBookLoan1_Click(object sender, EventArgs e)
{
openChildForm(new KitapOduncAl());
hideSubMenu();
lblName.Text = btnBookLoan1.Text;
}
private void btnBookLoan_Click(object sender, EventArgs e)
{
openChildForm(new KitapOduncVer());
hideSubMenu();
lblName.Text = btnBookLoan.Text;
}
private void btnKitapGuncelle_Click(object sender, EventArgs e)
{
openChildForm(new KitapGuncelle());
hideSubMenu();
lblName.Text = btnKitapGuncelle.Text;
}
#endregion
#region ÜyeMenü
private void btnMembers_Click(object sender, EventArgs e)
{
showSubMenu(panelMemberSubMenu);
}
private void btnMemberAdd_Click(object sender, EventArgs e)
{
openChildForm(new MemberAdd());
hideSubMenu();
lblName.Text = btnMemberAdd.Text;
}
private void btnMemberUpdate_Click(object sender, EventArgs e)
{
openChildForm(new MemberUpdate());
hideSubMenu();
lblName.Text = btnMemberUpdate.Text;
}
private void btnMemberSearch_Click(object sender, EventArgs e)
{
openChildForm(new MemberSearch());
hideSubMenu();
lblName.Text = btnMemberSearch.Text;
}
#endregion
#region Büfe
private void btnBufe_Click(object sender, EventArgs e)
{
showSubMenu(panelBufeSubMenu);
}
private void BtnBufeSatis_Click(object sender, EventArgs e)
{
openChildForm(new BufeSatis());
hideSubMenu();
lblName.Text = BtnBufeSatis.Text;
}
private void BtnBufeStok_Click(object sender, EventArgs e)
{
openChildForm(new BufeStok());
hideSubMenu();
lblName.Text = BtnBufeStok.Text;
}
private void btnBufeKasa_Click(object sender, EventArgs e)
{
openChildForm(new BufeKasa());
hideSubMenu();
lblName.Text = btnBufeKasa.Text;
}
#endregion
#region AyarMenü
private void btnSettings_Click(object sender, EventArgs e)
{
showSubMenu(panelSettingsSubMenu);
}
private void btnKitapAyarlari_Click(object sender, EventArgs e)
{
openChildForm(new AyarKitap());
hideSubMenu();
lblName.Text = btnKitapAyarlari.Text;
}
#endregion
private void btnMenu_Click(object sender, EventArgs e)
{
if (activeForm != null)
{
activeForm.Close();
}
lblName.Text = btnMenu.Text;
btnGecikme.Visible = true;
btnKapat.Visible = true;
Color color = SelectThemeColor();
color_change(color);
Alert();
}
private void btnStatistics_Click(object sender, EventArgs e)
{
openChildForm(new Statistics());
lblName.Text = btnStatistics.Text;
}
void Alert()
{
btnGecikme.Visible = false;
btnKapat.Visible = false;
baglanti.Open();
komut = new SQLiteCommand();
komut.Connection = baglanti;
string bugun = DateTime.Today.ToString("yyyyMMdd");
string uc = DateTime.Today.AddDays(3).ToString("yyyyMMdd");
komut.CommandText = $@"select count(*) from odunc where sontarih between '{bugun}' and '{uc}' and teslim='Teslim Edilmedi'";
int adet = Convert.ToInt32(komut.ExecuteScalar());
baglanti.Close();
if (adet != 0)
{
btnKapat.Visible = true;
btnGecikme.Visible = true;
btnGecikme.Text = $"Üç ve daha az günü kalan teslim edilmeyen {adet} adet kitap var";
}
}
private void btnKapat_Click(object sender, EventArgs e)
{
btnKapat.Visible = false;
btnGecikme.Visible = false;
}
private void btnGecikme_Click(object sender, EventArgs e)
{
openChildForm(new KitapGecikme());
}
private void btnRezevasyon_Click(object sender, EventArgs e)
{
openChildForm(new rezervasyon());
hideSubMenu();
lblName.Text = btnRezevasyon.Text;
}
}
}