Beispiel #1
0
 private void editOrderButton_Click(object sender, RoutedEventArgs e)
 {
     if (ordersList.SelectedItem != null)
     {
         var order = (Order)ordersList.SelectedItem.GetType().GetProperty("Order").GetValue(ordersList.SelectedItem);
         var modal = new AddOrderWindow(dbContext, order);
         modal.Owner = this;
         using (var transaction = dbContext.Database.BeginTransaction())
         {
             if (modal.Recall())
             {
                 try
                 {
                     dbContext.SaveChanges();
                     transaction.Commit();
                     refreshOrders();
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show(ex.ToString());
                     transaction.Rollback();
                 }
             }
             else
             {
                 transaction.Rollback();
             }
         }
     }
 }
Beispiel #2
0
        private void addOrderButton_Click(object sender, RoutedEventArgs e)
        {
            var order = new Order();
            var modal = new AddOrderWindow(dbContext, order);

            modal.Owner = this;
            using (var transaction = dbContext.Database.BeginTransaction())
            {
                if (modal.Recall())
                {
                    dbContext.Orders.Add(order);
                    dbContext.SaveChanges();
                    transaction.Commit();
                    refreshOrders();
                }
                else
                {
                    transaction.Rollback();
                }
            }
        }