-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMemberSearch.cs
83 lines (72 loc) · 2.47 KB
/
MemberSearch.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
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 MemberSearch : Form
{
public MemberSearch()
{
InitializeComponent();
}
SQLiteConnection baglanti = new SQLiteConnection("Data Source=kihmed.db; Version=3");
SQLiteCommand komut;
SQLiteDataAdapter da;
DataSet ds;
private void UyeAra_Load(object sender, EventArgs e)
{
listele();
}
public void listele()
{
da = new SQLiteDataAdapter("select ID,name,surname,phone,address from Uyeler", baglanti);
ds = new DataSet();
baglanti.Open();
da.Fill(ds, "kihmed");
dgw1.DataSource = ds.Tables["kihmed"];
baglanti.Close();
}
private void tbxSearch_TextChanged(object sender, EventArgs e)
{
baglanti.Open();
komut = new SQLiteCommand("Select ID,name,surname,phone,address from Uyeler where name Like '%" + tbxSearch.Text + "%'", baglanti);
da = new SQLiteDataAdapter(komut);
DataSet ds = new DataSet();
da.Fill(ds);
dgw1.DataSource = ds.Tables[0];
baglanti.Close();
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnDelete_Click(object sender, EventArgs e)
{
DialogResult secenek = MessageBox.Show("Üyeliği silmek istediğinize emin misiniz?", "Silme Onay Penceresi", MessageBoxButtons.YesNo);
if (secenek == DialogResult.Yes)
{
foreach (DataGridViewRow drow in dgw1.SelectedRows) //Seçili Satırları Silme
{
baglanti.Open();
int id = Convert.ToInt32(drow.Cells[0].Value);
string sql = "DELETE FROM Uyeler WHERE ID=@ID";
komut = new SQLiteCommand(sql, baglanti);
komut.Parameters.AddWithValue("@ID", id);
komut.ExecuteNonQuery();
baglanti.Close();
}
listele();
}
else if (secenek == DialogResult.No)
{
}
}
}
}