Пример #1
0
 private void btnSave_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         CustomerArtistIntDto intDto = new CustomerArtistIntDto();
         intDto.Artist   = cbArtist.SelectedItem as ArtistDto;
         intDto.Customer = cbClient.SelectedItem as CustomerDto;
         ICustomerArtistIntProcess intProcess = ProcessFactory.GetCustomerArtistIntProcess();
         if (customerid == 0 && artistid == 0)
         {
             intProcess.Add(intDto);
         }
         else
         {
             intDto.Artist.Id           = artistid;
             intDto.Customer.CustomerID = customerid;
             intProcess.Update(intDto);
         }
         Close();
     }
     catch (Exception msg)
     {
         MessageBox.Show(msg.Message, "Ошибка");
     }
 }
        private void btnAddI_Click(object sender, RoutedEventArgs e)
        {
            AddCustomerArtistIntWindow window = new AddCustomerArtistIntWindow();

            window.ShowDialog();

            //Получаем список художников и передаем его на отображение таблице
            dgInterests.ItemsSource = ProcessFactory.GetCustomerArtistIntProcess().GetList();
        }
        private void btnDeleteI_Click(object sender, RoutedEventArgs e)
        {
            //Получаем выделенную строку с объектом художника
            CustomerArtistIntDto item = dgInterests.SelectedItem as CustomerArtistIntDto;

            //если там не художник или пользователь ничего не выбрал сообщаем об этом
            if (item == null)
            {
                MessageBox.Show("Выберите запись для удаления", "Удаление интересов");
                return;
            }
            //Просим подтвердить удаление
            MessageBoxResult result = MessageBox.Show("Удалить интерес " + item.Customer + " в " + item.Artist + "?", "Удаление удаление интереса", MessageBoxButton.YesNo, MessageBoxImage.Warning);

            //Если пользователь не подтвердил, выходим
            if (result != MessageBoxResult.Yes)
            {
                return;
            }
            //Если все проверки пройдены и подтверждение получено, удаляем художника
            ProcessFactory.GetCustomerArtistIntProcess().Delete(item.Customer.CustomerID.Value, item.Artist.Id);
            //И перезагружаем список художников
            btnRefresh_Click(sender, e);
        }
 private void btnRefreshI_Click(object sender, RoutedEventArgs e)
 {
     //Получаем список  и передаем его на отображение таблице
     dgInterests.ItemsSource = ProcessFactory.GetCustomerArtistIntProcess().GetList();
 }