예제 #1
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var w1 = Window.GetWindow(this) as MainWindow;
         var w2 = new GetCustomerIDWindow {
             Owner = w1
         };
         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!");
         }
         App.currentOrder.StoreID = store.StoreID;
         if (delivCheckBox.IsChecked != null)
         {
             App.currentOrder.OrderDeliv = delivCheckBox.IsChecked.Value;
         }
         App.currentOrder.OrderID = FactoryDatabase.getDatabase().getNewOrderID();
         w2.ShowDialog();
     } catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
예제 #2
0
 public GetCustomerIDWindow()
 {
     db = FactoryDatabase.getDatabase();
     InitializeComponent();
     customer         = new Customer();
     this.DataContext = customer;
 }
예제 #3
0
        public ManagementPage()
        {
            InitializeComponent();
            var bl = FactoryDatabase.getDatabase();

            bl.loadLists();
        }
예제 #4
0
        private void customerDataGrid_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
        {
            var row = (e.Row).DataContext as Customer;

            FactoryDatabase.getDatabase().updateCustomer(row.CustID, row);
            DataSource.setCustomerList();
        }
예제 #5
0
        public NewOrderPage()
        {
            InitializeComponent();
            var bl = FactoryDatabase.getDatabase();

            bl.loadLists();
            App.currentOrder                = new Order();
            customerGrid.DataContext        = customer;
            this.storesComboBox.ItemsSource = DataSource.stores.Where(x => x.StoreID < 50).Select(x => x.StoreName);
        }
예제 #6
0
 private void addButton_Click(object sender, RoutedEventArgs e)
 {
     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!");
     }
     FactoryDatabase.getDatabase().loadLists();
     NavigationService?.GoBack();
 }
예제 #7
0
 private void DeleteCustomerButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var obj = ((FrameworkElement)sender).DataContext as Customer;
         if (obj != null)
         {
             FactoryDatabase.getDatabase().delCustomer(obj.CustID);
         }
         DataSource.setCustomerList();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
예제 #8
0
파일: Program.cs 프로젝트: 1danmi/PizzaHack
 private static void Main(string[] args)
 {
     try
     {
         var db = FactoryDatabase.getDatabase();
         db.loadLists();
         foreach (var employee in DataSource.employees)
         {
             Console.WriteLine(employee.Bod.Date.ToString("d"));
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
     Console.ReadLine();
 }
예제 #9
0
 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);
     }
 }