-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFrmEvaluation.cs
68 lines (59 loc) · 2.45 KB
/
FrmEvaluation.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
using Evaluation_Manager.Models;
using Evaluation_Manager.Repositories;
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;
namespace Evaluation_Manager {
public partial class FrmEvaluation : Form {
private Student student;
public Student SelectedStudent { get => student; set => student = value; }
public FrmEvaluation(Student selectedStudent) {
InitializeComponent();
student = selectedStudent;
}
private void FrmEvaluation_Load(object sender, EventArgs e) {
SetFormText();
var activities = ActivityRepository.GetActivities();
cboActivities.DataSource = activities;
}
private void SetFormText() {
// test 4
Text = student.FirstName + " " + student.LastName;
}
private void cboActivities_SelectedIndexChanged(object sender, EventArgs e) {
var currentActivity = cboActivities.SelectedItem as Activity;
txtActivityDescription.Text = currentActivity.Description;
txtMinForGrade.Text = currentActivity.MinPointsForGrade + "/" + currentActivity.MaxPoints;
txtMinForSignature.Text = currentActivity.MinPointsForSignature + "/" + currentActivity.MaxPoints;
numPoints.Minimum = 0;
numPoints.Maximum = currentActivity.MaxPoints;
var evaluation = EvaluationRepository.GetEvaluation(SelectedStudent, currentActivity);
if (evaluation != null) {
txtTeacher.Text = evaluation.Evaluator.ToString();
txtEvaluationDate.Text = evaluation.EvaluationDate.ToString();
numPoints.Value = evaluation.Points;
}
else {
txtTeacher.Text = FrmLogin.LoggedTeacher.ToString();
txtEvaluationDate.Text = "-";
numPoints.Value = 0;
}
}
private void btnCancel_Click(object sender, EventArgs e) {
Close();
}
private void btnSave_Click(object sender, EventArgs e) {
var activity = cboActivities.SelectedItem as Activity;
var teacher = FrmLogin.LoggedTeacher;
int points = (int)numPoints.Value;
teacher.PerformEvaluation(SelectedStudent, activity, points);
Close();
}
}
}