示例#1
0
        private void addBtn_Click(object sender, EventArgs e)
        {
            var salonForm = new HairDressingSalonForm();

            if (salonForm.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            var newSalon = salonForm.HairDressingSalon;

            hairDressingSalons.Add(newSalon.ToShortString(), newSalon);
            salonsListBox.Items.Add(newSalon.ToShortString());
        }
示例#2
0
        private void editBtn_Click(object sender, EventArgs e)
        {
            var selectedIndex = salonsListBox.SelectedIndex;
            var id            = salonsListBox.SelectedItem.ToString();

            hairDressingSalons.TryGetValue(id, out var selectedSalon);
            if (selectedSalon == null)
            {
                return;
            }
            var hairDressingSalonForm = new HairDressingSalonForm(selectedSalon);

            if (hairDressingSalonForm.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            hairDressingSalons.Remove(id);
            var updatedSalon = hairDressingSalonForm.HairDressingSalon;

            hairDressingSalons.Add(updatedSalon.ToShortString(), updatedSalon);
            salonsListBox.Items[selectedIndex] = updatedSalon.ToShortString();
        }