Ejemplo n.º 1
0
        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            WindowNewService wnClient = new WindowNewService
            {
                Title = "Редактирование услуги",
                Owner = this
            };
            Service role = Services.SelectedItem as Service;

            if (role != null)
            {
                Service tempRole = role.ShallowCopy();
                wnClient.DataContext = tempRole;
                if (wnClient.ShowDialog() == true)
                {
                    role.Price           = tempRole.Price;
                    role.Name            = tempRole.Name;
                    Services.ItemsSource = null;
                    Services.ItemsSource = vmService.ServiceList;
                }
            }
            else
            {
                MessageBox.Show("Необходимо выбрать запись для редактированния",
                                "Предупреждение", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Ejemplo n.º 2
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            WindowNewService wnClient = new WindowNewService {
                Title = "Новая услуга", Owner = this
            };
            // формирование кода новой должности
            int     maxId = vmService.MaxId() + 1;
            Service role  = new Service
            {
                Id = maxId
            };

            wnClient.DataContext = role;
            if (wnClient.ShowDialog() == true)
            {
                vmService.ServiceList.Add(role);
            }
        }