private void buttonAddSeries_Click(object sender, EventArgs e)
        {
            var seria = model.SeriesSet.Where(u => u.Name == textBoxTitle.Text).ToList();

            if (seria.Count <= 0)
            {
                if ((textBoxTitle.Text != "") && (comboBoxCoverType.SelectedItem != null))
                {
                    Series series = new Series()
                    {
                        Name      = textBoxTitle.Text,
                        CoverType = comboBoxCoverType.Text.ToString()
                    };
                    model.SeriesSet.Add(series);
                    model.SaveChanges();

                    if (ParentBookExemplar == null)
                    {
                        ParentChangeBookExemplar.ShowComboBoxes();
                        ParentChangeBookExemplar.Show();
                    }
                    else
                    {
                        ParentBookExemplar.ShowComboBoxes();
                        ParentBookExemplar.Show();
                    }

                    Close();
                }
                else
                {
                    if (textBoxTitle.Text == "")
                    {
                        MessageBox.Show("Вы не указали название серии");
                    }
                    if (comboBoxCoverType.SelectedItem == null)
                    {
                        MessageBox.Show("Вы не выбрали тип обложки");
                    }
                }
            }
            else
            {
                MessageBox.Show("Серия с указанным названием уже существует");
            }
        }
示例#2
0
        private void buttonAddStore_Click(object sender, EventArgs e)
        {
            var stores = model.StoreSet.Where(u => u.Name.Contains(textBoxName.Text) && u.City.Name.Contains(comboBoxCity.SelectedText)).ToList();

            if (stores.Count <= 0)
            {
                if ((textBoxName.Text != "") && (textBoxStreet.Text != "") && (textBoxHouse.Text != "") &&
                    (comboBoxCity.SelectedItem != null))
                {
                    Store store = new Store()
                    {
                        Name    = textBoxName.Text,
                        Address = textBoxStreet.Text + " " + textBoxHouse.Text
                    };

                    City city = model.CitySet.Find(
                        model.CitySet.Where(x => x.Name.Contains(comboBoxCity.Text)).ToList()[0]
                        .Id);
                    city.Store.Add(store);

                    model.StoreSet.Add(store);
                    model.SaveChanges();

                    if (ParentAddBookExemplar == null)
                    {
                        ParentChangeBookExemplar.ShowComboBoxes();
                        ParentChangeBookExemplar.Show();
                    }
                    else
                    {
                        ParentAddBookExemplar.ShowComboBoxes();
                        ParentAddBookExemplar.Show();
                    }

                    Close();
                }
                else
                {
                    if (textBoxName.Text == "")
                    {
                        MessageBox.Show("Вы не указали название магазина");
                    }
                    if (textBoxStreet.Text == "")
                    {
                        MessageBox.Show("Вы не указали название улицы");
                    }
                    if (textBoxHouse.Text == "")
                    {
                        MessageBox.Show("Вы не указали номер дома");
                    }
                    if (comboBoxCity.SelectedItem == null)
                    {
                        MessageBox.Show("Вы не выбрали город");
                    }
                }
            }
            else
            {
                MessageBox.Show("Магазин с указанным названием уже существует");
            }
        }