Exemple #1
0
 private void Delete_Click(object sender, RoutedEventArgs e)
 {
     if (DataList.SelectedItems.Count > 0)
     {
         var Res = MessageBox.Show("Are you sure you want to delete " + DataList.SelectedItems.Count + " this record?", "Deleting Records", MessageBoxButton.YesNo, MessageBoxImage.Exclamation);
         if (Res == MessageBoxResult.Yes)
         {
             foreach (var row in DataList.SelectedItems)
             {
                 Good g = row as Good;
                 db.Good.Remove(g);
             }
             db.SaveChanges();
             MessageBox.Show(DataList.SelectedItems.Count + " Record have being deleted!");
         }
     }
     Switcher.Switch(new Main());
 }
Exemple #2
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     goods.Type     = TypeBox.Text;
     goods.Name     = NameBox.Text;
     goods.Price    = decimal.Parse(PriceBox.Text);
     goods.Quantity = int.Parse(QuantityBox.Text);
     db.Good.Add(goods);
     db.SaveChanges();
     Switcher.Switch(new Main());
 }