Exemplo n.º 1
0
 private void Change_Click(object sender, EventArgs e)
 {
     if (DataGrid1.SelectedItems.Count <= 0)
     {
         return;
     }
     foreach (var t in DataGrid1.SelectedItems)
     {
         if (!(t is Channel channel))
         {
             continue;
         }
         var cWin = new ChannelWin
         {
             textBox1 = { Text = channel.Title },
             textBox2 = { Text = channel.Description },
             textBox3 = { Text = channel.Link },
             textBox4 = { Text = channel.Copyright }
         };
         if (cWin.ShowDialog() == true)
         {
             channel.Title       = cWin.textBox1.Text;
             channel.Description = cWin.textBox2.Text;
             channel.Link        = cWin.textBox3.Text;
             channel.Copyright   = cWin.textBox4.Text;
             _chRep.Update(channel);
             UpdateDb();
             MessageBox.Show("Статья редактирована");
         }
         else
         {
             return;
         }
     }
 }
Exemplo n.º 2
0
        private void Change_Click(object sender, EventArgs e)
        {
            if (DataGrid1.SelectedItems.Count > 0)
            {
                for (int i = 0; i < DataGrid1.SelectedItems.Count; i++)
                {
                    Channel channel = DataGrid1.SelectedItems[i] as Channel;
                    if (channel != null)
                    {
                        ChannelWin cWin = new ChannelWin();

                        cWin.textBox1.Text = channel.Title;
                        cWin.textBox2.Text = channel.Description;
                        cWin.textBox3.Text = channel.Link;
                        cWin.textBox4.Text = channel.Copyright;

                        if (cWin.ShowDialog() == true)
                        {
                            channel.Title       = cWin.textBox1.Text;
                            channel.Description = cWin.textBox2.Text;
                            channel.Link        = cWin.textBox3.Text;
                            channel.Copyright   = cWin.textBox4.Text;

                            chRep.Update(channel);
                            UpdateDB();

                            //db.Entry(channel).State = EntityState.Modified;
                            //db.SaveChanges();

                            MessageBox.Show("Статья редактирована");
                        }
                        else
                        {
                            return;
                        }
                        //DataGrid1.ItemsSource = null;

                        // DataGrid1.ItemsSource = db.Channels.Local.ToBindingList();
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            var cWin = new ChannelWin();

            if (cWin.ShowDialog() == true)
            {
                var channel = new Channel
                {
                    Title       = cWin.textBox1.Text,
                    Description = cWin.textBox2.Text,
                    Link        = cWin.textBox3.Text,
                    Copyright   = cWin.textBox4.Text
                };
                _chRep.Create(channel);
                UpdateDb();
                MessageBox.Show("Новый канал добавлен");
            }
            else
            {
                return;
            }
        }
Exemplo n.º 4
0
        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;
            }
        }