-
Notifications
You must be signed in to change notification settings - Fork 0
/
ApplicationHome.cs
89 lines (76 loc) · 2.57 KB
/
ApplicationHome.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
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.Diagnostics;
namespace VisualProgrammingProject
{
public partial class ApplicationHomeForm : Form
{
List<Student> studentsList;
public ApplicationHomeForm()
{
InitializeComponent();
// initialize the students list and fetch students from database
studentsList = new List<Student>();
FetchAndUpdateStudentsList();
}
public void FetchAndUpdateStudentsList()
{
// use DBRepo to get the list of students from the db
studentsList = DBRepo.FetchAllStudents();
//clear existing students and add them to the list
studentsListView.Items.Clear();
foreach (Student s in studentsList)
{
Console.WriteLine(s.ToString());
string[] items = new string[7];
items[0] = s.StudentId;
items[1] = s.FirstName;
items[2] = s.LastName;
items[3] = s.Year.ToString();
items[4] = s.Branch;
items[5] = s.Cgpa.ToString();
items[6] = s.Campus;
// append the students to the listView
studentsListView.Items.Add(new ListViewItem(items));
}
// Event handler to get more details of students
}
// TODO: Add methods update and delete student information
private void StudentDetailsList_DoubleClick(object sender, EventArgs e)
{
ListViewItem s = ((ListView)sender).SelectedItems[0];
UpdateDeleteForm form = new UpdateDeleteForm(s.Text);
DialogResult result = form.ShowDialog();
if (result == DialogResult.OK)
{
FetchAndUpdateStudentsList();
} else
{
}
}
///Event handler for the Add students button
private void AddStudentDetailsButton_Click(object sender, EventArgs e)
{
AddStudentDetails form = new AddStudentDetails();
DialogResult result = form.ShowDialog();
// if the result was ok
if (result == DialogResult.OK)
{
FetchAndUpdateStudentsList();
} else
{
}
form.Dispose();
}
private void ViewAllStudents_Load(object sender, EventArgs e)
{
}
}
}