This repository was archived by the owner on Dec 7, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResearcherView.xaml.cs
More file actions
204 lines (179 loc) · 7.76 KB
/
ResearcherView.xaml.cs
File metadata and controls
204 lines (179 loc) · 7.76 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
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
using RAP_Assignment.Controller;
using RAP_Assignment.DataSource;
using RAP_Assignment.Entity;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Xml.Linq;
namespace RAP_Assignment
{
/// <summary>
/// Interaction logic for ResearcherView.xaml
/// </summary>
public partial class ResearcherView : Window
{
private Researcher selectedResearcher = null;
public ResearcherView(Researcher r)
{
selectedResearcher = r;
DataContext = this;
InitializeComponent();
WindowState = WindowState.Maximized;
Topmost = true;
r = ResearcherController.LoadResearcherDetails(r.id);
Name.Text = "Name: " + r.FullName();
School_Unit.Text = "School/Unit: " + r.school;
Campus.Text = "Campus: " + (r.campus.ToString()).Replace("_", " ");
Email.Text = "Email: " + r.email;
Q1_Percentage.Text = "Q1 Percentage: " + r.Q1PercentageCalc();
Commence_with_Institute.Text = "Commenced with Institution: " + r.utasStart;
ResearcherImage.Source = new BitmapImage(r.photo);
if (r.type == TYPE.Staff)
{
Staff s = new Staff
{
id = r.id,
photo = r.photo,
level = r.level,
campus = r.campus,
utasStart = r.utasStart,
familyName = r.familyName,
givenName = r.givenName,
email = r.email,
school = r.school,
title = r.title,
type = r.type,
positions = r.positions,
publications = r.publications
};
s = ResearcherController.AddSuperVisions(s);
Current_Job_Title.Text = "Current Job Title: " + r.GetCurrJob().ToTitle();
Commenced_current_position.Text = "Commenced Current Position: " + r.GetCurrJob().start;
Tenure.Text = "Tenure: " + r.Tenure();
_3_year_Average.Text = "3-Year Average: " + s.CalcThreeYearAve();
Funding_received.Text = "Funding Recieved: " + ResearcherController.TotalFundings(s.id);
Performance_by_publication.Text = "Performance by Publication: " + s.PerformanceByPublication();
Performance_by_funding_received.Text = "Performance by Funding: " + s.PerformanceByFunding();
SupervisionsText.Text = "No. Supervisions: " + ResearcherController.SupervisionsCount(s.id);
Degree.Visibility = Visibility.Hidden;
Supervisor.Visibility = Visibility.Hidden;
Performace.Text = "Performace: " + ResearcherController.GetPerformance(r);
}
else
{
Student s = new Student
{
id = r.id,
photo = r.photo,
campus = r.campus,
utasStart = r.utasStart,
familyName = r.familyName,
givenName = r.givenName,
email = r.email,
school = r.school,
title = r.title,
type = r.type,
positions = r.positions,
publications = r.publications,
};
s = EnRDBAdapter.GetStudentDetails(s);
Current_Job_Title.Text = "Current Job Title: N/A";
Commenced_current_position.Text = "Commenced Current Position: N/A";
Tenure.Text = "Tenure: N/A";
_3_year_Average.Text = "3-Year Average: N/A";
Funding_received.Text = "Funding Recieved: N/A";
Performance_by_publication.Text = "Performance by Publication: N/A";
Performance_by_funding_received.Text = "Performance by Funding: N/A";
SupervisionsText.Text = "No. Supervisions: N/A";
Degree.Text = "Degree: " + s.degree;
Supervisor.Text = "Supervisor: " + s.supervisor;
ExpandButton.Visibility = Visibility.Hidden;
Performace.Visibility = Visibility.Hidden;
}
}
public ObservableCollection<Publication> Publications
{
get
{
List<Publication> publications = PublicationsController.SortByYear(selectedResearcher.id, false);
ObservableCollection<Publication> publist = new ObservableCollection<Publication>(publications);
return publist;
}
}
public ObservableCollection<Student> Supervisions
{
get
{
if (selectedResearcher.type == TYPE.Staff)
{
Staff s = new Staff
{
id = selectedResearcher.id,
};
s = ResearcherController.AddSuperVisions(s);
return new ObservableCollection<Student>(s.supervisions);
}
return null;
}
}
private bool sortByYearAscending = true;
private void Button_Click_1(object sender, RoutedEventArgs e)
{
// Toggle the sort order flag
sortByYearAscending = !sortByYearAscending;
// Rebind the data to the ListView
UpdatePublicationList();
}
private void UpdatePublicationList()
{
// Get the sorted publications based on the current sort order
List<Publication> sortedPublications = PublicationsController.SortByYear(selectedResearcher.id, sortByYearAscending);
// Update the ObservableCollection to reflect the new sorting
ObservableCollection<Publication> publist = new ObservableCollection<Publication>(sortedPublications);
PublicationListBox.ItemsSource = publist;
}
private void PublicationListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Topmost = false;
if (PublicationListBox.SelectedItem != null)
{
// Retrieve the selected publication
Publication selectedPublication = (Publication)PublicationListBox.SelectedItem;
// Open the PublicationDetailsView window with the selected publication
PublicationDetailsView publicationDetailsView = new PublicationDetailsView(selectedPublication);
publicationDetailsView.Show();
}
}
private void Button_Click_2(object sender, RoutedEventArgs e)
{
// Toggle the visibility of the SupervisionsList ListView
if (SupervisionsList.Visibility == Visibility.Collapsed)
{
SupervisionsList.Visibility = Visibility.Visible;
}
else
{
SupervisionsList.Visibility = Visibility.Collapsed;
}
}
private void SortByYear_Click(object sender, RoutedEventArgs e)
{
if(!(StartYearTextBox.Text == "Start Year" || EndYearTextBox.Text == "End Year"))
{
PublicationListBox.ItemsSource = PublicationsController.FilterByYearRange(Publications, int.Parse(StartYearTextBox.Text), int.Parse(EndYearTextBox.Text));
}
}
}
}