-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnasayfa.cs
262 lines (207 loc) · 8.53 KB
/
Anasayfa.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
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
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.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms.DataVisualization.Charting;
using System.Data.OleDb;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using System.Collections;
namespace OkulOtomasyonSitemi
{
public partial class Form1 : Form
{
public static int flagForEvent = 0; // Butona göre işlem sayfasına götürür.
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.ACE.Oledb.12.0;Data Source = C:\\Users\\yakup\\OneDrive\\Masaüstü\\OgrenciOtomation1.accdb");
public Form1()
{
InitializeComponent();
}
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
GraphicsPath gp = new GraphicsPath();
gp.AddEllipse(0, 0, pictureBox1.Width - 1, pictureBox1.Height - 1);
Region rg = new Region(gp);
pictureBox1.Region = rg;
}
private void Form1_Load(object sender, EventArgs e)
{
kullanici();
ogrenciSayisi();
idariSayisi();
ogretimUyesiSayisi();
enCokBolum();
// Chart alanı ve serisi oluşturulur
chart1.Series["Bolumler"].Points.AddXY("Yazılım Mühendisliği", 10);
chart1.Series["Bolumler"].Points.AddXY("Bilgisayar Mühendisliği", 20);
}
private void label5_Click(object sender, EventArgs e)
{
}
private void panel8_Paint(object sender, PaintEventArgs e)
{
}
private void label12_Click(object sender, EventArgs e)
{
}
public void kullanici() // Kullanici Adini Belirler.
{
if (1 == 1)
{
string username = Giriş.userName;
label1.Text = username;
}
}
public void ogrenciSayisi() // Güncel Öğrenci Sayısı
{
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.ACE.Oledb.12.0;Data Source = C:\\Users\\yakup\\OneDrive\\Masaüstü\\OgrenciOtomation1.accdb");
try
{
conn.Open();
OleDbCommand cmd = new OleDbCommand("SELECT COUNT(*) FROM ogrenciler ", conn);
int rowCount = (int)cmd.ExecuteScalar();
label12.Text = rowCount.ToString();
}
catch (Exception ex)
{
MessageBox.Show("Öğrenci Sayısı Gösterilirken Bir Hata Oluştu: " + ex.Message);
}
finally
{
if (conn != null)
{
conn.Close();
}
}
}
public void idariSayisi()
{
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.ACE.Oledb.12.0;Data Source = C:\\Users\\yakup\\OneDrive\\Masaüstü\\OgrenciOtomation1.accdb");
try
{
conn.Open();
OleDbCommand cmd = new OleDbCommand("SELECT COUNT(*) FROM kullanicilar ", conn);
int rowCount = (int)cmd.ExecuteScalar();
label8.Text = rowCount.ToString();
}
catch (Exception ex)
{
MessageBox.Show("İdari Kullanıcı Sayısı Gösterilirken Bir Hata Oluştu: " + ex.Message);
}
finally
{
if (conn != null)
{
conn.Close();
}
}
}
public void ogretimUyesiSayisi()
{
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.ACE.Oledb.12.0;Data Source = C:\\Users\\yakup\\OneDrive\\Masaüstü\\OgrenciOtomation1.accdb");
try
{
conn.Open();
OleDbCommand cmd = new OleDbCommand("SELECT COUNT(*) FROM ogretimuyesi ", conn);
int rowCount = (int)cmd.ExecuteScalar();
label16.Text = rowCount.ToString();
}
catch (Exception ex)
{
MessageBox.Show("İdari Kullanıcı Sayısı Gösterilirken Bir Hata Oluştu: " + ex.Message);
}
finally
{
if (conn != null)
{
conn.Close();
}
}
}
public void enCokBolum()
{
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.ACE.Oledb.12.0;Data Source = C:\\Users\\yakup\\OneDrive\\Masaüstü\\OgrenciOtomation1.accdb");
try
{
conn.Open();
OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM ogrenciler", conn);
DataTable dt = new DataTable();
adapter.Fill(dt);
var result = from row in dt.AsEnumerable()
group row by row.Field<string>("bolum") into grp
select new
{
Element = grp.Key,
Count = grp.Count()
};
/*
"var result =" : "result" adında bir değişken tanımlanır.
"from row in dt.AsEnumerable()" : "dt" DataTable nesnesindeki her bir satır "row" adlı bir değişkene atılır. AsEnumerable() metodu, DataTable'yı IEnumerable<T> arayüzüne dönüştürür.
"group row by row.Field<string>("sütun_adı") into grp" : "row" değişkenindeki her bir satır, "sütun_adı" adlı sütuna göre gruplandırılır ve "grp" adlı bir değişkene atanır.
"select new { Element = grp.Key, Count = grp.Count() }" : "grp" değişkenindeki her bir grup için, bir anonim tipte bir nesne oluşturulur ve "result" değişkenine atılır. Bu anonim tipte nesne, "Element" ve "Count" adlı iki özelliğe sahiptir. "Element", grup anahtarını (yani, "sütun_adı" sütunundaki bir elemanı) ve "Count", o gruptaki eleman sayısını (yani, "sütun_adı" sütununda kaç tane aynı eleman olduğunu) temsil eder
*/
var maxElement = result.OrderByDescending(x => x.Count).First();
string maxElementValue = maxElement.Element;
int maxElementCount = maxElement.Count;
label7.Text = maxElementValue + " - " + maxElementCount;
}
catch (Exception ex)
{
MessageBox.Show("Bölümü En Fazla Olan Öğrenci Sayısı Gösterilirken Bir Hata Oluştu: " + ex.Message);
}
finally
{
if (conn != null)
{
conn.Close();
}
}
}
private void chart1_Click(object sender, EventArgs e)
{
}
private void button5_Click(object sender, EventArgs e)
{
DialogResult = MessageBox.Show("Programdan Çıkmak İstediğinize Emin Misiniz?", "Emin Misin?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (DialogResult == DialogResult.OK)
{
Environment.Exit(0);
}
}
private void button4_Click(object sender, EventArgs e)
{
Yardım yardim = new Yardım();
yardim.Show();
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
flagForEvent = 1;
Islemler islem = new Islemler();
islem.Show();
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
flagForEvent = 2;
Islemler islem = new Islemler();
islem.Show();
}
private void button3_Click(object sender, EventArgs e)
{
this.Close();
flagForEvent = 3;
Islemler islem = new Islemler();
islem.Show();
}
private void label1_Click(object sender, EventArgs e)
{
}
}
}