// Событие на клик кнопки добавить продукт private void AddProduct_Click(object sender, RoutedEventArgs e) { var type = (TypesOfComponents)cb_type.SelectedItem; var manufact = (Manufacturers)cb_manufact.SelectedItem; // Если ввели не пустые данные, то добавь в базу данных if (name.Text != string.Empty && type != null && manufact != null && price.Text != string.Empty && count.Text != string.Empty && Application.Current.Properties["json"]?.ToString() != null) { MessageBox.Show("Добавляем в БД"); // Добавляем продукт в БД var added = CommonLogic.AddComponent( name.Text, type.IdType, manufact.IdManufacturer, Convert.ToInt16(price.Text), Convert.ToInt16(count.Text), Application.Current.Properties["json"].ToString() ); // Если товар добавлен успешно, то обнули значение в словаре и закрой текущее окно if (added == true) { Application.Current.Properties["json"] = null; // Обнуляем значение в словаре this.DialogResult = true; // Возвращаем true, т.к. добавлено успешно } } else { MessageBox.Show("Не можем добавить в БД"); } }