-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMemberAdd.cs
More file actions
121 lines (97 loc) · 3.77 KB
/
MemberAdd.cs
File metadata and controls
121 lines (97 loc) · 3.77 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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SQLite;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Kutuphanecsharp
{
public partial class MemberAdd : Form
{
public MemberAdd()
{
InitializeComponent();
}
SQLiteConnection baglanti = new SQLiteConnection("Data Source=kihmed.db; Version=3");
SQLiteCommand komut;
private void close_Click(object sender, EventArgs e)
{
this.Close();
}
private void button1_Click(object sender, EventArgs e)
{
labelad.Visible = false;
labelsoyad.Visible = false;
labeltel.Visible = false;
labeladres.Visible = false;
lblWarninga.Visible = false;
if (adtbx.Text == "" | soyadtbx.Text == "" | telefontbx.Text.Length != 11 | adrestbx.Text == "")
{
if (adtbx.Text == "")
{
labelad.Visible = true;
lblWarninga.Visible = true;
lblWarninga.Text = " Lütfen boş veya \n eksik alanları doldurunuz";
}
if (soyadtbx.Text == "")
{
labelsoyad.Visible = true;
lblWarninga.Visible = true;
lblWarninga.Text = " Lütfen boş veya \n eksik alanları doldurunuz";
}
if (telefontbx.Text.Length != 11)
{
labeltel.Visible = true;
lblWarninga.Visible = true;
lblWarninga.Text = " Lütfen boş veya \n eksik alanları doldurunuz";
}
if (adrestbx.Text == "")
{
labeladres.Visible = true;
lblWarninga.Visible = true;
lblWarninga.Text = " Lütfen boş veya \n eksik alanları doldurunuz";
}
}
else
{
komut = new SQLiteCommand();
baglanti.Open();
komut.Connection = baglanti;
string dtnow = DateTime.Today.ToString("yyMM");
string kayit = DateTime.Today.ToString("dd.MM.yyyy");
komut.CommandText = $"select count(*) from Uyeler where ID like '{dtnow}%' ";
int sayi = Convert.ToInt32(komut.ExecuteScalar());
string uyeid = "";
int uyeno;
if (sayi == 0)
{
uyeid = $"{dtnow}10";
uyeno = Convert.ToInt32(uyeid);
}
else
{
komut.CommandText = $"select ID from Uyeler where ID like '{dtnow}%' order by ID desc limit 1 ";
uyeno = Convert.ToInt32(komut.ExecuteScalar());
uyeno += 1;
}
string deger = "insert into Uyeler(ID,adddt,name,surname,phone,address,okitaptoplam) values ('" + uyeno + "','" + kayit + "','" + adtbx.Text + "','" + soyadtbx.Text + "','" + telefontbx.Text + "','" + adrestbx.Text + "','" + 0 + "')";
komut.CommandText = deger;
komut.ExecuteNonQuery();
baglanti.Close();
MessageBox.Show("Kayıt Başarılı");
adtbx.Clear();
soyadtbx.Clear();
telefontbx.Clear();
adrestbx.Clear();
}
}
private void telefontbx_KeyPress(object sender, KeyPressEventArgs e)
{
e.Handled = !char.IsDigit(e.KeyChar) && !char.IsControl(e.KeyChar);
}
}
}