-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKitapEkle.cs
97 lines (90 loc) · 3.58 KB
/
KitapEkle.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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace KütüphaneOtomasyonu
{
public partial class KitapEkle : Form
{
public KitapEkle()
{
InitializeComponent();
}
SqlConnection baglanti;
SqlCommand komut;
SqlDataAdapter da;
void kitap_türü()
{
baglanti = new SqlConnection("Server=(localdb)\\V11.0; Initial Catalog=KütüphaneDB;Integrated Security=SSPI");
baglanti.Open();
da = new SqlDataAdapter("Select * From KitapTürü", baglanti);
DataTable dt = new DataTable();
da.Fill(dt);
comboBox2.ValueMember = "ID";
comboBox2.DisplayMember = "KitapTürü";
comboBox2.DataSource = dt;
baglanti.Close();
}
private void button1_Click(object sender, EventArgs e) //Kapat
{
this.Close();
KütüphaneTakipIslemleri yeni = new KütüphaneTakipIslemleri();
yeni.Hide();
yeni.Show();
}
private void textclear(Control ctl) //Temizleye basıldığında textboxları temizleme
{
foreach (Control item in ctl.Controls)
{
if (item is TextBox)
{
((TextBox)item).Clear();
}
if (item.Controls.Count > 0)
{
textclear(item);
}
}
}
private void button2_Click(object sender, EventArgs e) //Temizleme
{
textclear(this);
dateTimePicker1.Text = "";
comboBox1.Text = "";
comboBox2.Text = "";
numericUpDown1.ResetText();
}
private void button3_Click(object sender, EventArgs e) //Kaydet
{
baglanti = new SqlConnection("Server=(localdb)\\V11.0; Initial Catalog=KütüphaneDB;Integrated Security=SSPI");
baglanti.Open();
string sorgu = "Insert Into Kitaplar (BarkodNo,KitapAdi,YazarAdi,YayinEvi,SayfaSayisi,KitapTürü,TeminTürü,TeminTarihi,CiltNo,StokSayisi) Values (@BarkodNo,@KitapAdi,@YazarAdi,@YayinEvi,@SayfaSayisi,@KitapTürü,@TeminTürü,@TeminTarihi,@CiltNo,@StokSayisi)";
komut = new SqlCommand(sorgu, baglanti);
komut.Parameters.AddWithValue("@BarkodNo", Convert.ToInt32(textBox1.Text));
komut.Parameters.AddWithValue("@KitapAdi", textBox2.Text);
komut.Parameters.AddWithValue("@YazarAdi", textBox3.Text);
komut.Parameters.AddWithValue("@YayinEvi", textBox4.Text);
komut.Parameters.AddWithValue("@SayfaSayisi", Convert.ToInt32(textBox5.Text));
komut.Parameters.AddWithValue("@KitapTürü", comboBox2.Text);
komut.Parameters.AddWithValue("@TeminTürü", comboBox1.Text);
komut.Parameters.AddWithValue("@TeminTarihi", dateTimePicker1.Value);
komut.Parameters.AddWithValue("@CiltNo", Convert.ToInt32(textBox6.Text));
komut.Parameters.AddWithValue("@StokSayisi", numericUpDown1.Value);
komut.ExecuteNonQuery();
baglanti.Close();
MessageBox.Show("Kitap Kaydedildi.");
}
private void KitapEkle_Load(object sender, EventArgs e)
{
comboBox1.Items.Add("Satın Alma");
comboBox1.Items.Add("Bağış");
kitap_türü();
}
}
}