Esempio n. 1
0
        private void ConfirmPurchase_Click(object sender, RoutedEventArgs e)
        {
            DatabaseManipulation dataMani = new DatabaseManipulation();

            vmvo.OrderList = orderList;

            if (dataMani.AddOrdersFromList() == true)
            {
                vmvo.OnPropertyChanged();

                // Find the frame.
                Frame            frame  = null;
                DependencyObject parent = VisualTreeHelper.GetParent(this);

                // Cycles through to MainWindow frame
                while (parent != null && frame == null)
                {
                    frame  = parent as Frame;
                    parent = VisualTreeHelper.GetParent(parent);
                }

                // Change the page of the frame.
                if (frame != null)
                {
                    frame.Navigate(new SalesRecordPage());
                }
                //Code Courtesy of Shmuel Zang in codeprojects.com https://www.codeproject.com/Questions/281551/frame-navigation-in-WPF
            }
            else
            {
                MessageBox.Show("Could Not Complete All Orders.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 2
0
        private void ConfirmRefund_Click(object sender, RoutedEventArgs e)
        {
            //Database Command class
            DatabaseManipulation dataMani = new DatabaseManipulation();

            if (vmvo.Order.Quantity > vmvo.ProductQuantity && vmvo.ProductQuantity > 0)
            {
                //Adjust Order's Quantity and set order to refund
                vmvo.Order.Quantity = vmvo.ProductQuantity;
                vmvo.Order.Status   = "RFND";

                //Moving over the Static order to a local order
                ord                = vmvo.Order;
                ord.OrderDate      = DateTime.Now;
                ord.SalesPrice     = 0.0;
                vmvo.CurrentBranch = ord.Branch;
                orderList          = new List <Orders>();

                //Clearing the OrderList just in case and Adding order to order list
                orderList.Add(ord);
                vmvo.OrderList = orderList;

                //Clear Static Order
                vmvo.Order = new Orders();

                if (dataMani.AddOrdersFromList() == true)
                {
                    // Find the frame.
                    Frame            frame  = null;
                    DependencyObject parent = VisualTreeHelper.GetParent(this);

                    // Cycles through to MainWindow frame
                    while (parent != null && frame == null)
                    {
                        frame  = parent as Frame;
                        parent = VisualTreeHelper.GetParent(parent);
                    }

                    // Change the page of the frame.
                    if (frame != null)
                    {
                        frame.Navigate(new SalesRecordPage());
                    }
                    //Code Courtesy of Shmuel Zang in codeprojects.com https://www.codeproject.com/Questions/281551/frame-navigation-in-WPF
                }
                else
                {
                    MessageBox.Show("Could Not Return Your Order", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                MessageBox.Show("Quantity of Products Returned Cannot Be More Than What Was Ordered.", "Alert!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }