-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKitapGuncelle.cs
More file actions
152 lines (125 loc) · 5.03 KB
/
KitapGuncelle.cs
File metadata and controls
152 lines (125 loc) · 5.03 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
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 KitapGuncelle : Form
{
public KitapGuncelle()
{
InitializeComponent();
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
SQLiteConnection baglanti = new SQLiteConnection("Data Source=kihmed.db; Version=3");
SQLiteDataAdapter da;
DataSet ds;
private void KitapGuncelle_Load(object sender, EventArgs e)
{
listele();
}
public void listele()
{
da = new SQLiteDataAdapter("select * from Books", baglanti);
ds = new DataSet();
baglanti.Open();
da.Fill(ds, "kihmed");
dgw1.DataSource = ds.Tables["kihmed"];
baglanti.Close();
}
private void btnara_Click(object sender, EventArgs e)
{
da = new SQLiteDataAdapter($"Select ID,name,surname,phone,address from Uyeler where name Like '%" + tbxara.Text + "%'", baglanti);
ds = new DataSet();
baglanti.Open();
da.Fill(ds, "kihmed");
dgw1.DataSource = ds.Tables["kihmed"];
baglanti.Close();
}
private void btnUpdate_Click(object sender, EventArgs e)
{
labelraf.Visible = false;
labelkitap.Visible = false;
labelyazar.Visible = false;
labelkategori.Visible = false;
labelyayinevi.Visible = false;
labelwarning.Visible = false;
if (cbxraf.Text == "" | tbxad.Text == "" | tbxyazar.Text == "" | tbxyayinevi.Text == "" | cbxkategori.Text == "")
{
if (cbxraf.Text == "")
{
labelwarning.Visible = true;
labelraf.Visible = true;
labelwarning.Text = " Lütfen boş veya \n eksik alanları doldurunuz";
}
if (tbxad.Text == "")
{
labelwarning.Visible = true;
labelkitap.Visible = true;
labelwarning.Text = " Lütfen boş veya \n eksik alanları doldurunuz";
}
if (tbxyazar.Text == "")
{
labelwarning.Visible = true;
labelyazar.Visible = true;
labelwarning.Text = " Lütfen boş veya \n eksik alanları doldurunuz";
}
if (tbxyayinevi.Text == "")
{
labelwarning.Visible = true;
labelyayinevi.Visible = true;
labelwarning.Text = " Lütfen boş veya \n eksik alanları doldurunuz";
}
if (cbxkategori.Text == "")
{
labelwarning.Visible = true;
labelkategori.Visible = true;
labelwarning.Text = " Lütfen boş veya \n eksik alanları doldurunuz";
}
}
else
{
foreach (DataGridViewRow drow in dgw1.SelectedRows)
{
baglanti.Open();
string update = $@"update Books set rafid=@rafid , book=@book , author=@author , category=@category , publisher=@publisher where ID=@ID";
SQLiteCommand cmd = new SQLiteCommand(update, baglanti);
cmd.Parameters.AddWithValue("@ID", dgw1.SelectedCells[0].Value);
cmd.Parameters.AddWithValue("rafid", cbxraf.Text);
cmd.Parameters.AddWithValue("@book", tbxad.Text);
cmd.Parameters.AddWithValue("@author", tbxyazar.Text);
cmd.Parameters.AddWithValue("@category", cbxkategori.Text);
cmd.Parameters.AddWithValue("@publisher", tbxyayinevi.Text);
cmd.ExecuteNonQuery();
baglanti.Close();
}
tbxad.Clear();
tbxyazar.Clear();
cbxraf.Items.Clear();
tbxyayinevi.Clear();
cbxkategori.Items.Clear();
listele();
}
}
private void dgw1_CellClick(object sender, DataGridViewCellEventArgs e)
{
cbxraf.Text = dgw1.CurrentRow.Cells["rafid"].Value.ToString();
tbxad.Text = dgw1.CurrentRow.Cells["book"].Value.ToString();
tbxyazar.Text = dgw1.CurrentRow.Cells["author"].Value.ToString();
tbxyayinevi.Text = dgw1.CurrentRow.Cells["publisher"].Value.ToString();
cbxkategori.Text = dgw1.CurrentRow.Cells["category"].Value.ToString();
}
private void tbxara_TextChanged(object sender, EventArgs e)
{
}
}
}