private void Sumbit_Click3(object sender, RoutedEventArgs e)
        {
            if (addForm4.koltext.Text.Length == 0 || addForm4.TovarList.SelectedItem == null || addForm4.PostavshickList.SelectedItem == null)
            {
                MessageBox.Show(
                    "Нужно указать товар, его количество и поставщика",
                    "Ошибка валидации",
                    MessageBoxButton.OK,
                    MessageBoxImage.Warning
                    );
                return;
            }

            if (!Int32.TryParse(addForm4.koltext.Text, out int count))
            {
                MessageBox.Show("Количество должно быть характеризовано номером!", "Ошибка валидации", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            Zakaz zakaz = new Zakaz()
            {
                Count          = count,
                stroredProduct = config.list.AllProducts.Where(x => x.Name == ((ListBoxItem)addForm4.TovarList.SelectedItem).Content.ToString()).First(),
                postavshick    = config.list.AllPostavshicks.Where(x => x.name == ((ListBoxItem)addForm4.PostavshickList.SelectedItem).Content.ToString()).First()
            };

            config.list.AllZakazs.Add(zakaz);
            config.Save();
            Refresh();
        }
Exemple #2
0
        private void Sumbit_Click3(object sender, RoutedEventArgs e)
        {
            Zakaz zakaz = new Zakaz()
            {
                Count          = Convert.ToInt32(addForm4.koltext.Text),
                stroredProduct = config.list.AllProducts.Where(x => x.Name == ((ListBoxItem)addForm4.TovarList.SelectedItem).Content.ToString()).First(),
                postavshick    = config.list.AllPostavshicks.Where(x => x.name == ((ListBoxItem)addForm4.PostavshickList.SelectedItem).Content.ToString()).First()
            };

            config.list.AllZakazs.Add(zakaz);
            config.Save();
            Refresh();
        }