private void AddMarkToList(object sender, EventArgs e) { var selectedGradeV = GPick.SelectedItem.ToString(); bool SgradetoInt = int.TryParse(selectedGradeV, out int selectedGrade); // parse Selected grade to int "selectedGrade" bool a = int.TryParse(WPick.Text, out int weight); // parse Weight pick to int "weight" string subject = SPick.SelectedItem.ToString(); int subID = 0; for (int i = 0; i < SubjectsX.Count(); i++) { if (SubjectsX[i].Subject == subject) { subID = SubjectsX[i].SubjectID; } } Mark mark = new Mark(selectedGrade, weight, subID); Marks.Add(mark); Action.Insert(mark); GradeClass Grade = new GradeClass(selectedGrade, weight, subject, subID); Grades.Add(Grade); SubjectsX = Action.GetAverages(); }
private void AtAppStart() { SubjectsX = Action.GetAverages(); foreach (Subjects b in SubjectsX) { SPick.Items.Add(b.Subject); } Marks = new ObservableCollection <Mark>(Action.QueryMarks().ToList()); string subj = ""; for (int i = 0; i < Marks.Count(); i++) { for (int a = 0; a < SubjectsX.Count(); a++) { if (Marks[i].Subject == SubjectsX[a].SubjectID) { subj = SubjectsX[a].Subject; } } GradeClass NGrade = new GradeClass(Marks[i].Grade, Marks[i].Weight, subj, Marks[i].Subject); Grades.Add(NGrade); } AddedMarks.ItemsSource = Grades; AllMarks.ItemsSource = SubjectsX; }