コード例 #1
0
ファイル: NewOrderPage.xaml.cs プロジェクト: 1danmi/PizzaHack
 private void nextButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (validateFields())
         {
             var store = DS.DataSource.stores.FirstOrDefault(
                 x => x.StoreName == storesComboBox.SelectedItem as string);
             if (store == null)
             {
                 this.storesComboBox.BorderBrush = (SolidColorBrush)(new BrushConverter().ConvertFrom("#f44336"));
                 throw new Exception("Store doesn't exist!");
             }
             customer.CustID = FactoryDatabase.getDatabase().getNewCustomerID();
             FactoryDatabase.getDatabase().addCustomer(customer);
             if (FactoryDatabase.getDatabase().new_customers(customer.CustID))
             {
                 MessageBox.Show($"You are the {customer.CustID}th customer! You won an extra credit!");
             }
             App.currentOrder.StoreID = store.StoreID;
             if (delivCheckBox.IsChecked != null)
             {
                 App.currentOrder.OrderDeliv = delivCheckBox.IsChecked.Value;
             }
             App.currentOrder.OrderID = FactoryDatabase.getDatabase().getNewOrderID();
             App.currentOrder.CustID  = customer.CustID;
             DataSource.setCustomerList();
             var p = new NewOrderDetailsPage();
             db.addOrder(App.currentOrder);
             NavigationService?.Navigate(p);
         }
         else
         {
             MessageBox.Show("Please fill all the fields!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         }
     } catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
コード例 #2
0
 private void OKButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var c = DataSource.customers.FirstOrDefault(x => x.CustID == customer.CustID);
         if (c == null)
         {
             throw new Exception("Order doesn't exist!");
         }
         var w = this.Owner as MainWindow;
         var t = w.MainFrame.Content as NewOrderPage;
         var p = new NewOrderDetailsPage();
         App.currentOrder.CustID = c.CustID;
         t.NavigationService.Navigate(p);
         db.addOrder(App.currentOrder);
         var w2 = Window.GetWindow(this) as GetCustomerIDWindow;
         w2.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }