예제 #1
0
        private void Create_Button_Click(object sender, RoutedEventArgs e)
        {
            Workshop    newWorkshop   = new Workshop();
            workshopWPF workshopModal = new workshopWPF(newWorkshop);

            if (workshopModal.ShowDialog() == true)
            {
                newWorkshop.Count = Workshops_List.Items.Count + 1;
                Workshops_List.Items.Add(newWorkshop.ToShortString());
                workshops.Add(newWorkshop);
            }
            else
            {
                MessageBox.Show("Изменения не сохранены");
            }
        }
예제 #2
0
        private void Edit_Button_Click(object sender, RoutedEventArgs e)
        {
            int selectedIndex = Workshops_List.SelectedIndex;

            if (selectedIndex < 0 || selectedIndex >= workshops.Count)
            {
                MessageBox.Show("Выберете магазин!");
                return;
            }
            workshopWPF workshopModal = new workshopWPF(workshops[Workshops_List.SelectedIndex]);
            bool?       result        = workshopModal.ShowDialog();

            if (result == true)
            {
                Workshops_List.Items[selectedIndex] = workshops[Workshops_List.SelectedIndex].ToShortString();
            }
            else
            {
                MessageBox.Show("Изменения не сохранены");
            }
        }