-
Notifications
You must be signed in to change notification settings - Fork 5
/
cDataController.cs
456 lines (435 loc) · 22.9 KB
/
cDataController.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
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data;
using System.Data.OleDb;
namespace RestoranOtomasyonu
{
class cDataController
{
// Genel veritabanı bağlantı cümlesi
public static string ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "\\Restoran.mdb";
// OleDb sınıfına ait nesneler
public OleDbConnection Connection = new OleDbConnection(ConnectionString);
public OleDbCommand Command = new OleDbCommand();
public OleDbDataAdapter Adapter;
public DataSet ds = new DataSet();
public cDataController()
{
if (Connection.State == ConnectionState.Closed) Connection.Open();
Command.Connection = Connection;
}
// Custom select sorgusu yapan metod
public void Custom_Query(string CommandString, string TableName)
{
Command = new OleDbCommand();
Command.Connection = Connection;
Command.CommandText = CommandString;
Adapter = new OleDbDataAdapter(Command);
Command.ExecuteNonQuery();
Adapter.Fill(ds, TableName);
}
/// <summary>
/// yyyy.m.d h:m:s formatındaki string bilgiyi DateTime tipine aktarır.
/// </summary>
/// <param name="Date">yyyy.m.d h:m:s formatındaki metin (ör: 2019.5.14 15:45:00)</param>
/// <returns>DateTime tipinde tarih</returns>
public DateTime CalculateTheTime(string Date)
{
int FirstDotIndex = Date.IndexOf('.');
int Day = int.Parse(Date.Substring(0, FirstDotIndex));
Date = Date.Substring(FirstDotIndex + 1, Date.Length - (FirstDotIndex + 1));
FirstDotIndex = Date.IndexOf('.');
int Month = int.Parse(Date.Substring(0, FirstDotIndex));
Date = Date.Substring(FirstDotIndex + 1, Date.Length - (FirstDotIndex + 1));
FirstDotIndex = Date.IndexOf(' ');
int Year = int.Parse(Date.Substring(0, FirstDotIndex));
Date = Date.Substring(FirstDotIndex + 1, Date.Length - (FirstDotIndex + 1));
FirstDotIndex = Date.IndexOf(':');
int Hour = int.Parse(Date.Substring(0, FirstDotIndex));
Date = Date.Substring(FirstDotIndex + 1, Date.Length - (FirstDotIndex + 1));
FirstDotIndex = Date.IndexOf(':');
int Minute = int.Parse(Date.Substring(0, FirstDotIndex));
Date = Date.Substring(FirstDotIndex + 1, Date.Length - (FirstDotIndex + 1));
FirstDotIndex = Date.IndexOf(':');
int Second = int.Parse(Date);
return new DateTime(Year, Month, Day, Hour, Minute, Second);
}
#region Personel İşlemleri
public void Select_Personel()
{
if (ds.Tables["Personeller"] != null) ds.Tables["Personeller"].Clear();
Command = new OleDbCommand();
Command.Connection = Connection;
Command.CommandText = "SELECT PersonelKodu,(Adi+' '+Soyadi) as [AdSoyad] FROM Personel";
Adapter = new OleDbDataAdapter(Command);
Command.ExecuteNonQuery();
Adapter.Fill(ds, "Personeller");
}
public void Insert_Personel(int GorevKodu, string TCNO, string Adi, string Soyadi, string KullaniciAdi, string Parola)
{
Command = new OleDbCommand();
Command.Connection = Connection;
Command.CommandText = "INSERT INTO Personel(GorevKodu,TCNO,Adi,Soyadi,KullaniciAdi,Parola,SonGiris) VALUES(@gkodu,@tc,@adi,@soyadi,@user,@pass,'Yok')";
Command.Parameters.AddWithValue("@gkodu", GorevKodu);
Command.Parameters.AddWithValue("@tc", TCNO);
Command.Parameters.AddWithValue("@adi", Adi);
Command.Parameters.AddWithValue("@soyadi", Soyadi);
Command.Parameters.AddWithValue("@user", KullaniciAdi);
Command.Parameters.AddWithValue("@pass", Parola);
Command.ExecuteNonQuery();
}
public void Update_Personel(int GorevKodu, string TCNO, string Adi, string Soyadi, string KullaniciAdi, string Parola, int PersonelKodu)
{
Command = new OleDbCommand();
Command.Connection = Connection;
Command.CommandText = "UPDATE Personel SET GorevKodu=@gkodu,TCNO=@tc,Adi=@adi,Soyadi=@soyadi,KullaniciAdi=@user,Parola=@pass,SonGiris='Yok' WHERE PersonelKodu=@pkodu";
Command.Parameters.AddWithValue("@gkodu", GorevKodu);
Command.Parameters.AddWithValue("@tc", TCNO);
Command.Parameters.AddWithValue("@adi", Adi);
Command.Parameters.AddWithValue("@soyadi", Soyadi);
Command.Parameters.AddWithValue("@user", KullaniciAdi);
Command.Parameters.AddWithValue("@pass", Parola);
Command.Parameters.AddWithValue("@pkodu", PersonelKodu);
Command.ExecuteNonQuery();
}
#endregion
#region Masa İşlemleri
public void Select_Masa()
{
Command = new OleDbCommand();
Command.Connection = Connection;
if (ds.Tables["Masalar"] != null) ds.Tables["Masalar"].Clear();
if (ds.Tables["Masalar1"] != null) ds.Tables["Masalar1"].Clear();
Command.CommandText = "SELECT MasaKodu,Masalar.Durum as [dk],MasaNumarasi as [Masa Numarası],Kapasite,Durumlar.Durum FROM Masalar,Durumlar WHERE Masalar.Durum=Durumlar.DurumID ORDER BY MasaNumarasi";
Adapter = new OleDbDataAdapter(Command);
Command.ExecuteNonQuery();
Adapter.Fill(ds, "Masalar");
Adapter.Fill(ds, "Masalar1");
}
public void Select_Durum()
{
Command = new OleDbCommand();
Command.Connection = Connection;
if (ds.Tables["Durum"] != null) ds.Tables["Durum"].Clear();
Command.CommandText = "SELECT * FROM Durumlar";
Adapter = new OleDbDataAdapter(Command);
Command.ExecuteNonQuery();
Adapter.Fill(ds, "Durum");
}
public void Select_Masa(int Durum)
{
Command = new OleDbCommand();
Command.Connection = Connection;
if (ds.Tables["Masalar"] != null) ds.Tables["Masalar"].Clear();
Command.CommandText = "SELECT MasaKodu, MasaNumarasi FROM Masalar WHERE Durum=@durum";
Command.Parameters.AddWithValue("@durum", Durum);
Adapter = new OleDbDataAdapter(Command);
Command.ExecuteNonQuery();
Adapter.Fill(ds, "Masalar");
}
public void Insert_Masa(int Kapasite, int MasaNumarasi)
{
Command = new OleDbCommand();
Command.Connection = Connection;
Command.CommandText = "INSERT INTO Masalar(MasaNumarasi,Kapasite,Durum) VALUES(@mno,@kap,1)";
Command.Parameters.AddWithValue("@mno", MasaNumarasi);
Command.Parameters.AddWithValue("@kap", Kapasite);
Command.ExecuteNonQuery();
}
public void Update_Masa(int MasaKodu, int Kapasite, int MasaNumarasi)
{
Command = new OleDbCommand();
Command.Connection = Connection;
Command.CommandText = "UPDATE Masalar SET Kapasite=@kap, MasaNumarasi=@mno WHERE MasaKodu=@mkodu";
Command.Parameters.AddWithValue("@kap", Kapasite);
Command.Parameters.AddWithValue("@mno", MasaNumarasi);
Command.Parameters.AddWithValue("@mkodu", MasaKodu);
Command.ExecuteNonQuery();
}
public void Delete_Masa(int MasaKodu)
{
Command = new OleDbCommand();
Command.Connection = Connection;
Command.CommandText = "DELETE FROM Masalar WHERE MasaKodu=@mkodu";
Command.Parameters.AddWithValue("@mkodu", MasaKodu);
Command.ExecuteNonQuery();
Command = new OleDbCommand();
Command.Connection = Connection;
Command.CommandText = "DELETE FROM Adisyon WHERE MasaKodu=@mkodu";
Command.Parameters.AddWithValue("@mkodu", MasaKodu);
Command.ExecuteNonQuery();
}
#endregion
#region Ödeme Türü İşlemleri
public void Select_OdemeTuru()
{
if (ds.Tables["Ödeme Türleri"] != null) ds.Tables["Ödeme Türleri"].Clear();
Command = new OleDbCommand();
Command.Connection = Connection;
Command.CommandText = "SELECT * FROM OdemeTurleri";
Adapter = new OleDbDataAdapter(Command);
Command.ExecuteNonQuery();
Adapter.Fill(ds, "Ödeme Türleri");
}
#endregion
#region Kategori İşlemleri
public void Select_Kategori()
{
Command = new OleDbCommand();
Command.Connection = Connection;
if (ds.Tables["Kategoriler"] != null) ds.Tables["Kategoriler"].Clear();
Command.CommandText = "SELECT KategoriKodu, KategoriAdi as [Kategori Adı], Aciklama as [Açıklama] FROM Kategoriler";
Adapter = new OleDbDataAdapter(Command);
Command.ExecuteNonQuery();
Adapter.Fill(ds, "Kategoriler");
}
public void Select_Kategori(string AramaCumlesi)
{
Command = new OleDbCommand();
Command.Connection = Connection;
if (ds.Tables["Kategoriler"] != null) ds.Tables["Kategoriler"].Clear();
Command.CommandText = "SELECT KategoriKodu, KategoriAdi as [Kategori Adı], Aciklama as [Açıklama] FROM Kategoriler WHERE KategoriAdi LIKE '%"+AramaCumlesi+"%' OR Aciklama LIKE '%"+AramaCumlesi+"%'";
Adapter = new OleDbDataAdapter(Command);
Command.ExecuteNonQuery();
Adapter.Fill(ds, "Kategoriler");
}
public void Insert_Kategori(string KategoriAdi, string Aciklama)
{
Command = new OleDbCommand();
Command.Connection = Connection;
Command.CommandText = "INSERT INTO Kategoriler(KategoriAdi,Aciklama) VALUES(@kadi,@aciklama)";
Command.Parameters.AddWithValue("@kadi", KategoriAdi);
Command.Parameters.AddWithValue("@aciklama", Aciklama);
Command.ExecuteNonQuery();
}
public void Update_Kategori(string KategoriAdi, string Aciklama, int KategoriKodu)
{
Command = new OleDbCommand();
Command.Connection = Connection;
Command.CommandText = "UPDATE Kategoriler SET KategoriAdi=@ad, Aciklama=@desc WHERE KategoriKodu=@kkodu";
Command.Parameters.AddWithValue("@ad", KategoriAdi);
Command.Parameters.AddWithValue("@desc", Aciklama);
Command.Parameters.AddWithValue("@kkodu", KategoriKodu);
Command.ExecuteNonQuery();
}
public void Delete_Kategori(int KategoriKodu)
{
Command = new OleDbCommand();
Command.Connection = Connection;
Command.CommandText = "DELETE FROM Kategoriler WHERE KategoriKodu=@kkodu";
Command.Parameters.AddWithValue("@kkodu", KategoriKodu);
Command.ExecuteNonQuery();
}
#endregion
#region Ürün İşlemleri
public void Select_Urun()
{
Command = new OleDbCommand();
Command.Connection = Connection;
if (ds.Tables["Ürünler"] != null) ds.Tables["Ürünler"].Clear();
Command.CommandText = "SELECT UrunKodu, Urunler.KategoriKodu, Kategoriler.KategoriAdi as [Kategori], UrunAdi as [Ürün Adı], Urunler.Aciklama as [Açıklama], Fiyat FROM Urunler,Kategoriler WHERE Urunler.KategoriKodu=Kategoriler.KategoriKodu";
Adapter = new OleDbDataAdapter(Command);
Command.ExecuteNonQuery();
Adapter.Fill(ds, "Ürünler");
}
public void Select_Urun(string AramaCumlesi)
{
Command = new OleDbCommand();
Command.Connection = Connection;
if (ds.Tables["Ürünler"] != null) ds.Tables["Ürünler"].Clear();
Command.CommandText = "SELECT UrunKodu, Urunler.KategoriKodu, Kategoriler.KategoriAdi as [Kategori], UrunAdi as [Ürün Adı], Urunler.Aciklama as [Açıklama], Fiyat FROM Urunler,Kategoriler WHERE (Urunler.KategoriKodu=Kategoriler.KategoriKodu) AND (UrunAdi LIKE '%" + AramaCumlesi + "%' OR Urunler.Aciklama LIKE '%" + AramaCumlesi + "%' OR Kategoriler.KategoriAdi LIKE '%" + AramaCumlesi + "%')";
Adapter = new OleDbDataAdapter(Command);
Command.ExecuteNonQuery();
Adapter.Fill(ds, "Ürünler");
}
public void Insert_Urun(int KategoriKodu, string UrunAdi, string Aciklama, decimal Fiyat)
{
Command = new OleDbCommand();
Command.Connection = Connection;
Command.CommandText = "INSERT INTO Urunler(KategoriKodu,UrunAdi,Aciklama,Fiyat) VALUES(@kkodu,@ad,@desc,@fiyat)";
Command.Parameters.AddWithValue("@kkodu", KategoriKodu);
Command.Parameters.AddWithValue("@ad", UrunAdi);
Command.Parameters.AddWithValue("@desc", Aciklama);
Command.Parameters.AddWithValue("@fiyat", Fiyat);
Command.ExecuteNonQuery();
}
public void Update_Urun(int KategoriKodu, string UrunAdi, string Aciklama, decimal Fiyat, int UrunKodu)
{
Command = new OleDbCommand();
Command.Connection = Connection;
Command.CommandText = "UPDATE Urunler SET KategoriKodu=@kkodu, UrunAdi=@uadi, Aciklama=@desc, Fiyat=@fiyat WHERE UrunKodu=@ukodu";
Command.Parameters.AddWithValue("@kkodu", KategoriKodu);
Command.Parameters.AddWithValue("@uadi", UrunAdi);
Command.Parameters.AddWithValue("@desc", Aciklama);
Command.Parameters.AddWithValue("@fiyat", Fiyat);
Command.Parameters.AddWithValue("@ukodu", UrunKodu);
Command.ExecuteNonQuery();
}
public void Delete_Urun(int UrunKodu)
{
Command = new OleDbCommand();
Command.Connection = Connection;
Command.CommandText = "DELETE FROM Urunler WHERE UrunKodu=@ukodu";
Command.Parameters.AddWithValue("@ukodu", UrunKodu);
Command.ExecuteNonQuery();
}
#endregion
#region Adisyon İşlemleri
public void Select_Adisyon()
{
Command = new OleDbCommand();
Command.Connection = Connection;
if (ds.Tables["Adisyonlar"] != null) ds.Tables["Adisyonlar"].Clear();
Command.CommandText = "SELECT * FROM Adisyon";
Adapter = new OleDbDataAdapter(Command);
Command.ExecuteNonQuery();
Adapter.Fill(ds, "Adisyonlar");
}
public void Select_Adisyon(int MasaKodu)
{
Command = new OleDbCommand();
Command.Connection = Connection;
if (ds.Tables["Adisyonlar"] != null) ds.Tables["Adisyonlar"].Clear();
Command.CommandText = "SELECT * FROM Adisyon WHERE MasaKodu=" + MasaKodu + "";
Adapter = new OleDbDataAdapter(Command);
Command.ExecuteNonQuery();
Adapter.Fill(ds, "Adisyonlar");
}
#endregion
#region Rezervasyon İşlemleri
public void Select_Rezervasyon()
{
Command = new OleDbCommand();
Command.Connection = Connection;
if (ds.Tables["Rezervasyonlar"] != null) ds.Tables["Rezervasyonlar"].Clear();
Command.CommandText = "SELECT RezervasyonKodu, Rezervasyonlar.MasaKodu, Masalar.MasaNumarasi as [Masa Numarası], MusteriAdiSoyadi as [İsim Soyisim], MusteriTelefonu as [Telefon], BaslangicZamani as [Başlangıç], BitisZamani as [Bitiş] FROM Rezervasyonlar,Masalar WHERE Rezervasyonlar.MasaKodu=Masalar.MasaKodu";
Adapter = new OleDbDataAdapter(Command);
Command.ExecuteNonQuery();
Adapter.Fill(ds, "Rezervasyonlar");
}
public void Select_Rezervasyon(string AramaCumlesi)
{
Command = new OleDbCommand();
Command.Connection = Connection;
if (ds.Tables["Rezervasyonlar"] != null) ds.Tables["Rezervasyonlar"].Clear();
Command.CommandText = "SELECT RezervasyonKodu, Rezervasyonlar.MasaKodu, Masalar.MasaNumarasi as [Masa Numarası], MusteriAdiSoyadi as [İsim Soyisim], MusteriTelefonu as [Telefon], BaslangicZamani as [Başlangıç], BitisZamani as [Bitiş] FROM Rezervasyonlar,Masalar WHERE (Rezervasyonlar.MasaKodu=Masalar.MasaKodu) AND (Masalar.MasaNumarasi Like '%" + AramaCumlesi + "%' OR MusteriAdiSoyadi Like '%" + AramaCumlesi + "%' OR MusteriTelefonu Like '%" + AramaCumlesi + "%')";
Adapter = new OleDbDataAdapter(Command);
Command.ExecuteNonQuery();
Adapter.Fill(ds, "Rezervasyonlar");
}
public void Insert_Rezervasyon(int MasaKodu,string MusteriAdiSoyadi,string MusteriTelefonu, string BaslangicZamani, string BitisZamani)
{
Command = new OleDbCommand();
Command.Connection = Connection;
Command.CommandText = "INSERT INTO Rezervasyonlar(MasaKodu,MusteriAdiSoyadi,MusteriTelefonu,BaslangicZamani,BitisZamani) VALUES(@mkodu,@mas,@mt,@baz,@biz)";
Command.Parameters.AddWithValue("@mkodu", MasaKodu);
Command.Parameters.AddWithValue("@mas", MusteriAdiSoyadi);
Command.Parameters.AddWithValue("@mt", MusteriTelefonu);
Command.Parameters.AddWithValue("@baz", BaslangicZamani);
Command.Parameters.AddWithValue("@biz", BitisZamani);
Command.ExecuteNonQuery();
}
public void Delete_Rezervasyon(int RezervasyonKodu)
{
Command = new OleDbCommand();
Command.Connection = Connection;
Command.CommandText = "DELETE FROM Rezervasyonlar WHERE RezervasyonKodu=@rkodu";
Command.Parameters.AddWithValue("@rkodu", RezervasyonKodu);
Command.ExecuteNonQuery();
}
#endregion
#region Müşteri İşlemleri
public void Select_Musteri()
{
Command = new OleDbCommand();
Command.Connection = Connection;
if (ds.Tables["Müşteriler"] != null) ds.Tables["Müşteriler"].Clear();
Command.CommandText = "SELECT MusteriKodu,MusteriAdiSoyadi as [İsim Soyisim],MusteriTelefonu as [Telefon] FROM Musteriler";
Adapter = new OleDbDataAdapter(Command);
Command.ExecuteNonQuery();
Adapter.Fill(ds, "Müşteriler");
}
public void Select_Musteri(string AramaCumlesi)
{
Command = new OleDbCommand();
Command.Connection = Connection;
if (ds.Tables["Müşteriler"] != null) ds.Tables["Müşteriler"].Clear();
Command.CommandText = "SELECT MusteriKodu,MusteriAdiSoyadi,MusteriTelefonu FROM Musteriler WHERE (MusteriAdiSoyadi Like '%"+AramaCumlesi+"%' OR MusteriTelefonu Like '%"+AramaCumlesi+"%')";
Adapter = new OleDbDataAdapter(Command);
Command.ExecuteNonQuery();
Adapter.Fill(ds, "Müşteriler");
}
#endregion
#region Hesap Hareketleri İşlemleri
public void Select_HesapHareketi()
{
if (ds.Tables["Hesap Hareketleri"] != null) ds.Tables["Hesap Hareketleri"].Clear();
Command = new OleDbCommand();
Command.Connection = Connection;
Command.CommandText = "SELECT HesapKodu, HesapHareketleri.PersonelKodu, (Personel.Adi + ' ' + Personel.Soyadi) as [pas],HesapHareketleri.OdemeTuruKodu, OdemeTurleri.OdemeTuru,AraToplam, KdvTutari,Indirim,ToplamTutar,Tarih FROM HesapHareketleri,Personel,OdemeTurleri WHERE (Personel.PersonelKodu=HesapHareketleri.PersonelKodu) AND (OdemeTurleri.OdemeTuruKodu=HesapHareketleri.OdemeTuruKodu)";
Adapter = new OleDbDataAdapter(Command);
Command.ExecuteNonQuery();
Adapter.Fill(ds, "Hesap Hareketleri");
}
public void Select_HesapHareketi(int PersonelKodu, int OdemeTuruKodu, decimal Max, decimal Min)
{
if (ds.Tables["Hesap Hareketleri"] != null) ds.Tables["Hesap Hareketleri"].Clear();
Command = new OleDbCommand();
Command.Connection = Connection;
Command.CommandText = "SELECT HesapKodu, HesapHareketleri.PersonelKodu, (Personel.Adi + ' ' + Personel.Soyadi) as [pas],HesapHareketleri.OdemeTuruKodu, OdemeTurleri.OdemeTuru,AraToplam, KdvTutari,Indirim,ToplamTutar,Tarih FROM HesapHareketleri,Personel,OdemeTurleri WHERE ((Personel.PersonelKodu=HesapHareketleri.PersonelKodu) AND (OdemeTurleri.OdemeTuruKodu=HesapHareketleri.OdemeTuruKodu)) AND (HesapHareketleri.PersonelKodu=@pkodu AND HesapHareketleri.OdemeTuruKodu=@okodu AND (ToplamTutar < @max AND ToplamTutar > @min))";
Command.Parameters.AddWithValue("@pkodu", PersonelKodu);
Command.Parameters.AddWithValue("@okodu", OdemeTuruKodu);
Command.Parameters.AddWithValue("@max", Max);
Command.Parameters.AddWithValue("@min", Min);
Adapter = new OleDbDataAdapter(Command);
Command.ExecuteNonQuery();
Adapter.Fill(ds, "Hesap Hareketleri");
}
#endregion
#region İndirim Kodu İşlemleri
public void Select_IndirimKodu()
{
Command = new OleDbCommand();
Command.Connection = Connection;
if (ds.Tables["İndirim Kodları"] != null) ds.Tables["İndirim Kodları"].Clear();
if (ds.Tables["İndirim Kodları1"] != null) ds.Tables["İndirim Kodları1"].Clear();
Command.CommandText = "SELECT * FROM IndirimKodlari";
Adapter = new OleDbDataAdapter(Command);
Command.ExecuteNonQuery();
Adapter.Fill(ds, "İndirim Kodları");
Adapter.Fill(ds, "İndirim Kodları1");
}
public void Insert_IndirimKodu(string Kod, int Yuzde)
{
Command = new OleDbCommand();
Command.Connection = Connection;
Command.CommandText = "INSERT INTO IndirimKodlari(IndirimKodu,IndirimYuzdesi) VALUES(@kod,@yuzde)";
Command.Parameters.AddWithValue("@kod", Kod);
Command.Parameters.AddWithValue("@yuzde", Yuzde);
Command.ExecuteNonQuery();
}
public void Update_IndirimKodu(int Kod,string IKod,int Yuzde)
{
Command = new OleDbCommand();
Command.Connection = Connection;
Command.CommandText = "UPDATE IndirimKodlari SET IndirimKodu=@ikod, IndirimYuzdesi=@yuzde WHERE Kod=@kod";
Command.Parameters.AddWithValue("@ikod", IKod);
Command.Parameters.AddWithValue("@yuzde", Yuzde);
Command.Parameters.AddWithValue("@kod", Kod);
Command.ExecuteNonQuery();
}
public void Delete_IndirimKodu(int Kod)
{
Command = new OleDbCommand();
Command.Connection = Connection;
Command.CommandText = "DELETE FROM IndirimKodlari WHERE Kod=@kod";
Command.Parameters.AddWithValue("@kod", Kod);
Command.ExecuteNonQuery();
}
#endregion
}
}