Ejemplo n.º 1
0
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            UserContext db = new UserContext();
            if (delinfo == null)
            {

                OrderViewModel edit = dataGridGoods.SelectedItem as OrderViewModel;
                OrderViewModel f = lst.FirstOrDefault(x => x == edit);
                f.Price = Convert.ToDouble(textBLock_Price.Text);
                f.Count = Convert.ToInt32(textBox_Count.Text);
                dataGridGoods.ItemsSource = null;
            }
            else
            {
                delinfo.Price = Convert.ToDouble(textBLock_Price.Text);
                delinfo.Count = Convert.ToInt32(textBox_Count.Text);
                lst.Add(delinfo);
                dataGridGoods.ItemsSource = null;
                delinfo = null;
            }
            db.SaveChanges();

            button1_Click(null, null);
        }
Ejemplo n.º 2
0
 private void button3_Click(object sender, RoutedEventArgs e)
 {
     if (dataGrid.SelectedItem != null)
     {
         delinfo = new OrderViewModel();
         UserContext db = new UserContext();
         var q = db.Goodss.Include("Weapon");
         GoodsViewModel per = dataGrid.SelectedItem as GoodsViewModel;
         Goodss f = q.Include("Accessories").FirstOrDefault(x => x.Id == per.Id);
         delinfo.GoodsId = f.Id;
         delinfo.Id = i;
         i++;
         textBLock_Price.Text = Convert.ToString(f.PricePurchase);
         if (f.Accessories == null)
         {
             delinfo.Name = f.Weapon.CodeName;
         }
         else
         {
             delinfo.Name = f.Accessories.Name;
         }
         CountPriceGrid.Visibility = Visibility.Visible;
         textBox_Count.Focus();
     }
     else
     {
         MessageBox.Show("Вы ничего не выбрали!", "Ошибка");
     }
 }