private void Add_Click(object sender, RoutedEventArgs e) { ItemWindow iWin = new ItemWindow(); // из команд в бд формируем список List <Channel> channels = db.Channels.ToList(); iWin.comboBox1.ItemsSource = db.Channels.Local.ToBindingList(); iWin.comboBox1.DisplayMemberPath = "Title"; //ComboBox.ItemsSource = DS.Tables["TypeUser"].DefaultView; //ComboBox.DisplayMemberPath = "Name"; if (iWin.ShowDialog() == true) { Item item = new Item(); item.Title = iWin.textBox1.Text; item.Description = iWin.textBox2.Text; item.Link = iWin.textBox3.Text; item.PubDate = iWin.textBox4.Text; item.Channel = (Channel)iWin.comboBox1.SelectedItem; db.Items.Add(item); db.SaveChanges(); MessageBox.Show("Новая статья добавлена"); } else { return; } }
private void Add_Click(object sender, RoutedEventArgs e) { ChannelWin cWin = new ChannelWin(); if (cWin.ShowDialog() == true) { Channel channel = new Channel(); channel.Title = cWin.textBox1.Text; channel.Description = cWin.textBox2.Text; channel.Link = cWin.textBox3.Text; channel.Copyright = cWin.textBox4.Text; db.Channels.Add(channel); db.SaveChanges(); MessageBox.Show("Новый канал добавлен"); } else { return; } }