private void InitBinding(string id) { try { using (var reader = new StreamReader("PersonList.xml")) { XmlSerializer deserializer = new XmlSerializer(typeof(List <MainWindow.Person>), new XmlRootAttribute("ArrayOfPerson")); MainWindow.m_oPersonList = (List <MainWindow.Person>)deserializer.Deserialize(reader); } } catch { MessageBox.Show("Brak pliku do zaĆadowania!", "Uwaga", MessageBoxButton.OK); } MainWindow.Person oFoundPerson = MainWindow.m_oPersonList.Find(oElement => oElement.StudentId == Convert.ToInt32(id)); imie.Text = oFoundPerson.FirstName; nazwisko.Text = oFoundPerson.LastName; wiek.Text = Convert.ToString(oFoundPerson.Age); Pesel.Text = Convert.ToString(oFoundPerson.Pesel); Uri image = new Uri(oFoundPerson.obraz); Picture.Source = new BitmapImage(image); idP = id; }
private void Button_Click3(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Image Filses(*.jpg; *.jpeg; *.gif; .bmp;)|.jpg; *.jpeg; *.gif; *.bmp; *.png;"; if (openFileDialog.ShowDialog() == true) { sciezka = openFileDialog.FileName; Uri fileUri = new Uri(openFileDialog.FileName); Picture.Source = new BitmapImage(fileUri); } MainWindow.Person oFoundPerson = MainWindow.m_oPersonList.Find(oElement => oElement.StudentId == Convert.ToInt32(idP)); oFoundPerson.obraz = Convert.ToString(Picture.Source); }
private void Button_Click2(object sender, RoutedEventArgs e) { if (imie.Text == "" || nazwisko.Text == "" || wiek.Text == "" || Pesel.Text == "") { MessageBox.Show("Wprowadz wszystkie dane"); } else { MainWindow.Person oFoundPerson = MainWindow.m_oPersonList.Find(oElement => oElement.StudentId == Convert.ToInt32(idP)); oFoundPerson.FirstName = imie.Text; oFoundPerson.LastName = nazwisko.Text; oFoundPerson.Age = Convert.ToInt32(wiek.Text); oFoundPerson.Pesel = Convert.ToInt64(Pesel.Text); MessageBox.Show("Edytowano dane"); } }