-
Notifications
You must be signed in to change notification settings - Fork 0
/
bursarDashboard.cs
219 lines (188 loc) · 7.94 KB
/
bursarDashboard.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
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 MySql.Data.MySqlClient;
namespace Academix
{
public partial class bursarDashboard : Form
{
private DataTable dataTable;
public bursarDashboard()
{
InitializeComponent();
}
private void all_stds_Click(object sender, EventArgs e)
{
dataGridView1.DataSource = null;
Global.grid_view = "student";
string constr = "datasource=127.0.0.1;port=3306;username=root;password=;database=academix;";
string querystr = "select `matric_number`, `full_name`, `email`, `phone_no`, `level`, `faculty`, `dept`, `amt_paid`, `fees_balance` from student";
//string querystr = "select `matric_number`, `full_name`, `email`, `phone_no`, `level`, `faculty`, `dept`, `amt_paid`, `fees_balance` from student";
MySqlConnection databaseconnection = new MySqlConnection(constr);
MySqlCommand databasecommand = new MySqlCommand(querystr, databaseconnection);
dataTable = new DataTable();
try
{
databaseconnection.Open();
// Fill the DataTable with the retrieved data
MySqlDataAdapter adapter = new MySqlDataAdapter(databasecommand);
adapter.Fill(dataTable);
// Bind the DataTable to the DataGridView control
dataGridView1.DataSource = dataTable;
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex.Message);
}
finally
{
databaseconnection.Close();
}
}
private void view_depts_Click(object sender, EventArgs e)
{
dataGridView1.DataSource = null;
Global.grid_view = "department";
string constr = "datasource=127.0.0.1;port=3306;username=root;password=;database=academix;";
string querystr = "select dept, faculty, total_fees from department";
MySqlConnection databaseconnection = new MySqlConnection(constr);
MySqlCommand databasecommand = new MySqlCommand(querystr, databaseconnection);
dataTable = new DataTable();
try
{
databaseconnection.Open();
// Fill the DataTable with the retrieved data
MySqlDataAdapter adapter = new MySqlDataAdapter(databasecommand);
adapter.Fill(dataTable);
// Bind the DataTable to the DataGridView control
dataGridView1.DataSource = dataTable;
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex.Message);
}
finally
{
databaseconnection.Close();
}
}
private void bursarDashboard_Load(object sender, EventArgs e)
{
dataGridView1.DataSource = null;
Global.grid_view = "student";
string constr = "datasource=127.0.0.1;port=3306;username=root;password=;database=academix;";
string querystr = "select `matric_number`, `full_name`, `email`, `phone_no`, `level`, `faculty`, `dept`, `amt_paid`, `fees_balance` from student";
MySqlConnection databaseconnection = new MySqlConnection(constr);
MySqlCommand databasecommand = new MySqlCommand(querystr, databaseconnection);
dataTable = new DataTable();
try
{
databaseconnection.Open();
// Fill the DataTable with the retrieved data
MySqlDataAdapter adapter = new MySqlDataAdapter(databasecommand);
adapter.Fill(dataTable);
// Bind the DataTable to the DataGridView control
dataGridView1.DataSource = dataTable;
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex.Message);
}
finally
{
databaseconnection.Close();
}
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
DataGridViewRow row = dataGridView1.Rows[e.RowIndex];
if (Global.grid_view == "student")
{
Global.studentMatricNo = row.Cells[0].Value.ToString();
string constr = "datasource=127.0.0.1;port=3306;username=root;password=;database=academix;";
string querystr = "SELECT * FROM `student` WHERE matric_number = " + Global.studentMatricNo;
MySqlConnection databaseconnection = new MySqlConnection(constr);
databaseconnection.Open();
string querystr1 = "SELECT total_fees FROM `department` WHERE dept = @dept";
MySqlCommand databasecommand1 = new MySqlCommand(querystr1, databaseconnection);
databasecommand1.Parameters.AddWithValue("@dept", Global.studentDept);
MySqlDataReader reader1 = databasecommand1.ExecuteReader();
if (reader1.HasRows)
{
while (reader1.Read())
{
Global.studentTotalFees = int.Parse(reader1["total_fees"].ToString());
}
}
Visible = false;
userDetails view = new userDetails();
view.Show();
}
else if (Global.grid_view == "department")
{
Global.departmentName = row.Cells[0].Value.ToString();
Visible = false;
deptDetails view = new deptDetails();
view.Show();
}
}
private void signoutBtn_Click(object sender, EventArgs e)
{
Visible = false;
MessageBox.Show("Logout successful!");
user_login view = new user_login();
view.Show();
}
private void add_dept_Click(object sender, EventArgs e)
{
Visible = false;
addDepartment f2 = new addDepartment();
f2.Show();
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
private void search_btn_Click(object sender, EventArgs e)
{
if (search_input.Text == "")
{
MessageBox.Show("Please enter a student or department to search for");
}
string searchQuery = "'%" + search_input.Text + "%'";
string constr = "datasource=127.0.0.1;port=3306;username=root;password=;database=academix;";
string querystr = "select `matric_number`, `full_name`, `email`, `phone_no`, `level`, `faculty`, `dept`, `amt_paid`, `fees_balance` from student where full_name like " + searchQuery;
MySqlConnection databaseconnection = new MySqlConnection(constr);
MySqlCommand databasecommand = new MySqlCommand(querystr, databaseconnection);
dataTable = new DataTable();
try
{
databaseconnection.Open();
// Fill the DataTable with the retrieved data
MySqlDataAdapter adapter = new MySqlDataAdapter(databasecommand);
adapter.Fill(dataTable);
// Bind the DataTable to the DataGridView control
dataGridView1.DataSource = dataTable;
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex.Message);
}
finally
{
databaseconnection.Close();
}
}
private void search_input_TextChanged(object sender, EventArgs e)
{
}
}
}