-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKitapiade.cs
88 lines (81 loc) · 3.29 KB
/
Kitapiade.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
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.SqlClient;
namespace BM102Poje
{
public partial class Kitapiade : Form
{
public Kitapiade()
{
InitializeComponent();
}
SqlConnection baglan = new SqlConnection("Data Source=DESKTOP-QMSN7VK\\SQLEXPRESS;Initial Catalog=Üyeler;Integrated Security=True");
DataSet daset = new DataSet();
private void EmanetListele()
{
baglan.Open();
SqlDataAdapter adtr = new SqlDataAdapter("select *from EmanetKitaplar", baglan);
adtr.Fill(daset, "EmanetKitaplar");
dataGridView1.DataSource = daset.Tables["EmanetKitaplar"];
baglan.Close();
}
private void Kitapiade_Load(object sender, EventArgs e)
{
EmanetListele();
}
private void iadetcaratxt_TextChanged(object sender, EventArgs e)
{
daset.Tables["EmanetKitaplar"].Clear();
baglan.Open();
SqlDataAdapter adtr = new SqlDataAdapter("select *from EmanetKitaplar where tc like '%" + iadetcaratxt.Text + "%'", baglan);
adtr.Fill(daset, "EmanetKitaplar");
baglan.Close();
if (iadetcaratxt.Text == "")
{
daset.Tables["EmanetKitaplar"].Clear();
EmanetListele();
}
}
private void iadebarkodtxt_TextChanged(object sender, EventArgs e)
{
daset.Tables["EmanetKitaplar"].Clear();
baglan.Open();
SqlDataAdapter adtr = new SqlDataAdapter("select *from EmanetKitaplar where barkodno like '%" + iadebarkodtxt.Text + "%'", baglan);
adtr.Fill(daset, "EmanetKitaplar");
baglan.Close();
if (iadebarkodtxt.Text == "")
{
daset.Tables["EmanetKitaplar"].Clear();
EmanetListele();
}
}
private void teslimalbtn_Click(object sender, EventArgs e)
{
baglan.Open();
SqlCommand komut = new SqlCommand("delete from EmanetKitaplar where tc=@tc and barkodno=@barkodno", baglan);
komut.Parameters.AddWithValue("@tc", dataGridView1.CurrentRow.Cells["tc"].Value.ToString());
komut.Parameters.AddWithValue("@barkodno", dataGridView1.CurrentRow.Cells["barkodno"].Value.ToString());
komut.ExecuteNonQuery();
SqlCommand komut2 = new SqlCommand("update kitaplar set stok=stok+'" + dataGridView1.CurrentRow.Cells["kitapsayısı"].Value.ToString() + "' where barkod=@barkodno", baglan);//Datagridde emanetkitaplar tablosundaki kitapsayısı
komut2.Parameters.AddWithValue("@barkodno", dataGridView1.CurrentRow.Cells["barkodno"].Value.ToString());
komut2.ExecuteNonQuery();
baglan.Close();
MessageBox.Show("Kitap(lar) iade edildi");
daset.Tables["EmanetKitaplar"].Clear();
EmanetListele();
}
private void button3_Click(object sender, EventArgs e)
{
emanetkitapfrm kl = new emanetkitapfrm();
this.Hide();
kl.ShowDialog();
}
}
}