private void FileToDatas(string filename)
 {
     for (int dayHour = 0; dayHour < 24; dayHour++)
     {
         string monday    = null;
         string tuesday   = null;
         string wednesday = null;
         string thursday  = null;
         string friday    = null;
         string saturday  = null;
         string sunday    = null;
         Week   week      = new Week((dayHour + " - " + (dayHour + 1)), monday, tuesday, wednesday, thursday, friday, saturday, sunday);
         this.WeekGrid.RemoveAt(dayHour);
         this.WeekGrid.Insert(dayHour, week);
     }
     StudentList.Clear();
     GroupStudentList.Clear();
     GroupList.Clear();
     using (var readFromFile = new StreamReader(filename))
     {
         var deserializer = new XmlSerializer(typeof(ObservableCollection <Student>));
         ObservableCollection <Student> tmpStudentList = (ObservableCollection <Student>)deserializer.Deserialize(readFromFile);
         foreach (var item in tmpStudentList)
         {
             StudentList.Add(item);
         }
         deserializer = new XmlSerializer(typeof(ObservableCollection <Student>));
         foreach (var item in tmpStudentList)
         {
             GroupStudentList.Add(item);
         }
         deserializer = new XmlSerializer(typeof(ObservableCollection <Group>));
         ObservableCollection <Group> tmpGroupList = (ObservableCollection <Group>)deserializer.Deserialize(readFromFile);
         foreach (var item in tmpGroupList)
         {
             GroupList.Add(item);
         }
         deserializer = new XmlSerializer(typeof(ObservableCollection <Week>));
         ObservableCollection <Week> tmpWeekGrid = (ObservableCollection <Week>)deserializer.Deserialize(readFromFile);
         foreach (var item in tmpWeekGrid)
         {
             WeekGrid.Add(item);
         }
     }
 }
 private void DeleteFromGroupButtonClick(object sender, RoutedEventArgs e)
 {
     try
     {
         Student student = new Student
                               (this.GroupStudentList[this.GroupStudentListView.SelectedIndex].Name,
                               this.GroupStudentList[this.GroupStudentListView.SelectedIndex].LastName,
                               this.GroupStudentList[this.GroupStudentListView.SelectedIndex].Bid,
                               this.GroupStudentList[this.GroupStudentListView.SelectedIndex].PhoneNumber,
                               this.GroupStudentList[this.GroupStudentListView.SelectedIndex].Adress, null);
         StudentList.Add(student);
         GroupStudentList.RemoveAt(this.GroupStudentListView.SelectedIndex);
     }
     catch (Exception)
     {
         MessageBox.Show("You have to select student from the list.", "Student not selected");
     }
 }
 private void NewButtonClick(object sender, RoutedEventArgs e)
 {
     for (int dayHour = 0; dayHour < 24; dayHour++)
     {
         string monday    = null;
         string tuesday   = null;
         string wednesday = null;
         string thursday  = null;
         string friday    = null;
         string saturday  = null;
         string sunday    = null;
         Week   week      = new Week((dayHour + " - " + (dayHour + 1)), monday, tuesday, wednesday, thursday, friday, saturday, sunday);
         this.WeekGrid.RemoveAt(dayHour);
         this.WeekGrid.Insert(dayHour, week);
     }
     StudentList.Clear();
     GroupStudentList.Clear();
     GroupList.Clear();
 }
 private void AddToGroupButtonClick(object sender, RoutedEventArgs e)
 {
     try
     {
         Student groupStudent = new Student
                                    (this.StudentList[this.UngroupStudentListView.SelectedIndex].Name,
                                    this.StudentList[this.UngroupStudentListView.SelectedIndex].LastName,
                                    this.StudentList[this.UngroupStudentListView.SelectedIndex].Bid,
                                    this.StudentList[this.UngroupStudentListView.SelectedIndex].PhoneNumber,
                                    this.StudentList[this.UngroupStudentListView.SelectedIndex].Adress,
                                    this.GroupList[this.GroupComboBox.SelectedIndex].GroupName);
         GroupStudentList.Add(groupStudent);
         StudentList.RemoveAt(this.UngroupStudentListView.SelectedIndex);
     }
     catch (Exception)
     {
         MessageBox.Show("You have to select student and group from the lists.", "Student or group not selected");
     }
 }