private bool IsChangesInListOfBranches(XmlPlanInterpreter xmlInterpreter) { if (ChoosedBranch.BranchType == "group") { foreach (Group group in xmlInterpreter.GetGroupsElements()) { if (group.gid == ChoosedBranch.id) { if (group.name != ChoosedBranch.Name) { return(true); } } } } if (ChoosedBranch.BranchType == "teacher") { foreach (Teacher teacher in xmlInterpreter.GetTeachersElements()) { if (teacher.tid == ChoosedBranch.id) { if (teacher.name != ChoosedBranch.Name) { return(true); } } } } if (ChoosedBranch.BranchType == "room") { foreach (Room room in xmlInterpreter.GetRoomsElements()) { if (room.rid == ChoosedBranch.id) { if (room.name != ChoosedBranch.Name) { return(true); } } } } return(false); }
private async void LoadPlan(string path) { Title = ChoosedBranch.Name; ClearPlan(); try { XmlPlanInterpreter xmlInterpreter = new XmlPlanInterpreter(path); // if (IsChangesInListOfBranches(xmlInterpreter)) { ChoosedBranch.id = -1; await ChoosedBranch.ShowDialogChooseBranch(path); Title = ChoosedBranch.Name; } if (ChoosedBranch.id == -1) { Title = "Nie wybrano klasy!"; } // List <string> Hours = xmlInterpreter.GetHours(); for (int a = 0; a != 5; a++) { if (a == 0) { for (int n = 1; n <= Hours.Count; n++) { MondayItems.Add(new LessonItem(n.ToString(), Hours[n - 1], xmlInterpreter.GetPlanForHour(ChoosedBranch.BranchType, ChoosedBranch.id, n, "Poniedziałek"), 14)); } } if (a == 1) { for (int n = 1; n <= Hours.Count; n++) { TuesdayItems.Add(new LessonItem(n.ToString(), Hours[n - 1], xmlInterpreter.GetPlanForHour(ChoosedBranch.BranchType, ChoosedBranch.id, n, "Wtorek"), 14)); } } if (a == 2) { for (int n = 1; n <= Hours.Count; n++) { WednesdayItems.Add(new LessonItem(n.ToString(), Hours[n - 1], xmlInterpreter.GetPlanForHour(ChoosedBranch.BranchType, ChoosedBranch.id, n, "Środa"), 14)); } } if (a == 3) { for (int n = 1; n <= Hours.Count; n++) { ThursdayItems.Add(new LessonItem(n.ToString(), Hours[n - 1], xmlInterpreter.GetPlanForHour(ChoosedBranch.BranchType, ChoosedBranch.id, n, "Czwartek"), 14)); } } if (a == 4) { for (int n = 1; n <= Hours.Count; n++) { FridayItems.Add(new LessonItem(n.ToString(), Hours[n - 1], xmlInterpreter.GetPlanForHour(ChoosedBranch.BranchType, ChoosedBranch.id, n, "Piątek"), 14)); } } } } catch (Exception) { await App.Current.MainPage.DisplayAlert("Błąd!", "Wystąpił błąd podczas odczytywania pliku z planem. Prawdopodobnie plik jest uszkodzony lub używasz nieaktualnej wersji programu!", "OK"); } }