public HairDressingSalonForm(HairDressingSalon hairDressingSalon) { InitializeComponent(); HairDressingSalon = hairDressingSalon; editBtn.Enabled = haircutsListBox.SelectedIndices.Count == 1; FillFormWithExistingProps(); }
public static IEnumerable <HairDressingSalon> ReadFrom(string path) { if (!File.Exists(path)) { File.Create(path).Close(); } var hairDressingSalons = new List <HairDressingSalon>(); try { using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read)) { using (var reader = XmlReader.Create(fs)) { if (reader.EOF) { return(hairDressingSalons); } reader.Read(); if (reader.IsEmptyElement) { return(hairDressingSalons); } while (reader.Read()) { if (reader.IsStartElement() && reader.Name.Equals("HairDressingSalon")) { var salon = new HairDressingSalon(); salon.ReadXml(reader); hairDressingSalons.Add(salon); } if (reader.Name.Equals("HairDressingSalons")) { break; } } } } } catch (IOException ex) { MessageBox.Show( $"Не вдалося знайти файл з раніше збереженими перукарнями.\nДеталі помилки: {ex.Message}"); } return(hairDressingSalons); }
public HairDressingSalonForm() { InitializeComponent(); editBtn.Enabled = haircutsListBox.SelectedIndices.Count == 1; HairDressingSalon = new HairDressingSalon(); }