Esempio n. 1
0
 private void SaveButton_Click(object sender, RoutedEventArgs e)
 {
     using (var db = new OnlineShopEntities1())
     {
         db.Items.Attach(tmp);
         db.Entry(tmp).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         this.DialogResult = true;
     }
 }
Esempio n. 2
0
 private void NewButton_Click(object sender, RoutedEventArgs e)
 {
     new NewDialogWindow().ShowDialog();
     using (var db = new OnlineShopEntities1())
     {
         _items = db.Items.ToList();
         _itemcharacteristics  = db.ItemCharacteristics.ToList();
         gridItems.ItemsSource = _items;
         gridItemCharacteristics.ItemsSource = _itemcharacteristics;
     }
 }
Esempio n. 3
0
 public NewDialogWindow()
 {
     InitializeComponent();
     using (var db = new OnlineShopEntities1())
     {
         _items               = db.Items.ToList();
         _categories          = db.Categories.ToList();
         _characteristics     = db.Characteristics.ToList();
         _itemcharacteristics = db.ItemCharacteristics.ToList();
     }
 }
Esempio n. 4
0
 private void EditButton_Click(object sender, RoutedEventArgs e)
 {
     if (gridItems.SelectedIndex != -1)
     {
         new EditDialogWindow(gridItems.SelectedIndex).ShowDialog();
         using (var db = new OnlineShopEntities1())
         {
             _items = db.Items.ToList();
             _itemcharacteristics  = db.ItemCharacteristics.ToList();
             gridItems.ItemsSource = _items;
             gridItemCharacteristics.ItemsSource = _itemcharacteristics;
         }
     }
 }
Esempio n. 5
0
 public MainWindow()
 {
     InitializeComponent();
     using (var db = new OnlineShopEntities1())
     {
         _items               = db.Items.ToList();
         _categories          = db.Categories.ToList();
         _characteristics     = db.Characteristics.ToList();
         _itemcharacteristics = db.ItemCharacteristics.ToList();
     }
     gridItems.ItemsSource               = _items;
     gridCategories.ItemsSource          = _categories;
     gridCharacteristics.ItemsSource     = _characteristics;
     gridItemCharacteristics.ItemsSource = _itemcharacteristics;
     FilterCategory.ItemsSource          = _categories;
 }
Esempio n. 6
0
 private void DeleteButton_Click(object sender, RoutedEventArgs e)
 {
     if (gridItems.SelectedIndex != -1)
     {
         using (var db = new OnlineShopEntities1())
         {
             var tmp = gridItems.SelectedItem as OnlineShop.Item;
             db.Items.Attach(tmp);
             db.Entry(tmp).State = System.Data.Entity.EntityState.Deleted;
             db.SaveChanges();
             _items = db.Items.ToList();
             _itemcharacteristics  = db.ItemCharacteristics.ToList();
             gridItems.ItemsSource = _items;
             gridItemCharacteristics.ItemsSource = _itemcharacteristics;
         }
     }
 }
Esempio n. 7
0
 private void AddCharacteristicButton_Click(object sender, RoutedEventArgs e)
 {
     if (characteristicsText.Text.Length > 0)
     {
         tmp1 = new ItemCharacteristic {
             itemId = tmp.itemId, characteristicId = Int32.Parse(characteristicsText.Text)
         };
         using (var db = new OnlineShopEntities1())
         {
             db.ItemCharacteristics.Attach(tmp1);
             db.Entry(tmp1).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
         }
     }
     else
     {
         MessageBox.Show("Fill all form");
     }
 }
Esempio n. 8
0
 private void AddButton_Click(object sender, RoutedEventArgs e)
 {
     if (titleText.Text.Length > 0 && categoryText.Text.Length > 0 && creatorText.Text.Length > 0)
     {
         using (var db = new OnlineShopEntities1())
         {
             tmp = new OnlineShop.Item {
                 itemTitle = titleText.Text, categoryId = Int32.Parse(categoryText.Text), creator = creatorText.Text, info = infoText.Text
             };
             tmp.itemId            = _items[id1].itemId;
             gridItems.ItemsSource = new List <OnlineShop.Item> {
                 tmp
             };
         }
     }
     else
     {
         MessageBox.Show("Fill all form");
     }
 }
Esempio n. 9
0
 public EditDialogWindow(int id)
 {
     InitializeComponent();
     using (var db = new OnlineShopEntities1())
     {
         _items               = db.Items.ToList();
         _categories          = db.Categories.ToList();
         _characteristics     = db.Characteristics.ToList();
         _itemcharacteristics = db.ItemCharacteristics.ToList();
     }
     id1 = id;
     tmp = _items[id];
     gridItems.ItemsSource = new List <OnlineShop.Item> {
         _items[id]
     };
     titleText.Text    = _items[id].itemTitle;
     creatorText.Text  = _items[id].creator;
     infoText.Text     = _items[id].info;
     categoryText.Text = _items[id].categoryId.ToString();
 }