-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKitapOduncAl.cs
More file actions
139 lines (106 loc) · 4.38 KB
/
KitapOduncAl.cs
File metadata and controls
139 lines (106 loc) · 4.38 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
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;
namespace Kutuphanecsharp
{
public partial class KitapOduncAl : Form
{
public KitapOduncAl()
{
InitializeComponent();
}
SQLiteConnection baglanti = new SQLiteConnection("Data Source=kihmed.db;Version=3");
SQLiteDataAdapter da;
DataSet ds;
SQLiteCommand komut;
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
private void KitapOduncAl_Load(object sender, EventArgs e)
{
OduncData();
}
void OduncData()
{
da = new SQLiteDataAdapter("select uyeid,ad,soyad,phone,kitap,rafid,alistarihi,sontarih,teslim from odunc where teslim='Teslim Edilmedi'", baglanti);
ds = new DataSet();
baglanti.Open();
da.Fill(ds, "kihmed");
dgw1.DataSource = ds.Tables["kihmed"];
baglanti.Close();
}
private void btnKayit_Click(object sender, EventArgs e)
{
string teslim = dgw1.CurrentRow.Cells["teslim"].Value.ToString();
if (teslim == "Teslim Edildi")
{
MessageBox.Show("Bu Kitap Zaten Teslim Alındı");
}
else
{
DialogResult secenek = MessageBox.Show("Kitabı teslim alma işlemini onaylıyor musunuz?", "Ödünç Teslim Alma Penceresi", MessageBoxButtons.YesNo);
if (secenek == DialogResult.Yes)
{
komut = new SQLiteCommand();
baglanti.Open();
komut.Connection = baglanti;
string rafid = dgw1.CurrentRow.Cells["rafid"].Value.ToString();
komut.CommandText = $@"update Books set durum='Mevcut' where rafid like '{rafid}'";
komut.ExecuteNonQuery();
string bugun = DateTime.Today.ToString("yyyyMMdd");
komut.CommandText = $@"update odunc set teslim='Teslim Edildi' where rafid like '{rafid}'";
komut.ExecuteNonQuery();
int uyeid = Convert.ToInt32(dgw1.CurrentRow.Cells["uyeid"].Value);
komut.CommandText = $@"select okitaptoplam from Uyeler where ID like {uyeid}";
int okitaptoplam = Convert.ToInt32(komut.ExecuteScalar());
okitaptoplam += 1;
komut.CommandText = $@"update Uyeler set okitaptoplam={okitaptoplam} where ID like {uyeid}";
komut.ExecuteNonQuery();
baglanti.Close();
}
else if (secenek == DialogResult.No)
{
}
}
OduncData();
uyeAdtbx.Clear();
uyeSoyadtbx.Clear();
kitapAdtbx.Clear();
}
private void tbxAra_TextChanged(object sender, EventArgs e)
{
baglanti.Open();
komut = new SQLiteCommand("select uyeid,ad,soyad,kitap,rafid,alistarihi,sontarih,teslim from odunc where ad Like '%" + tbxAra.Text + "%'", baglanti);
da = new SQLiteDataAdapter(komut);
DataSet ds = new DataSet();
da.Fill(ds);
dgw1.DataSource = ds.Tables[0];
baglanti.Close();
}
private void dgw1_CellClick_1(object sender, DataGridViewCellEventArgs e)
{
uyeAdtbx.Text = dgw1.CurrentRow.Cells["ad"].Value.ToString();
uyeSoyadtbx.Text = dgw1.CurrentRow.Cells["soyad"].Value.ToString();
kitapAdtbx.Text = dgw1.CurrentRow.Cells["kitap"].Value.ToString();
DateTime sontarih = (DateTime)dgw1.CurrentRow.Cells["sontarih"].Value;
DateTime bugun = DateTime.Today;
if (sontarih<bugun)
{
TimeSpan kalangun = sontarih - bugun;//Sonucu zaman olarak döndürür
double toplamGun = kalangun.TotalDays;
toplamGun *= -1;
lbltutar.Visible = true;
lbltutarad.Visible = true;
lbltutar.Text = $"{toplamGun} ₺";
}
}
}
}