Esempio n. 1
0
        private void BtnCompleteOrderOne_Click(object sender, EventArgs e)
        {
            // Clear Chef list one
            lstOrderOne.Items.Clear();

            // Delete the order from the queue
            RestaurantDataSet.OrdersRow orderRow = orders.Where(o => o.orderNumber == orderOne).First();

            // Setting isActive to 0 to show the order has been completed
            OrderTableAdapt.Update("0", orderRow.tableNumber, orderRow.isPaid, orderRow.totalPrice, orderRow.orderNumber, orderRow.tableNumber, orderRow.totalPrice);
            orderOne = 0;

            // Enable Load Next Order Button
            btnLoadOrderOne.Enabled = true;
        }
Esempio n. 2
0
        private void BtnSendOrder_Click(object sender, EventArgs e)
        {
            int.TryParse(insertedOrderId, out int orderNumber);
            // Enable the select table button
            btnCreateNewOrder.Enabled = true;
            // Disable add item to order button
            btnAddToOrder.Enabled = false;
            // Disable send order button
            btnSendOrder.Enabled = false;
            // Add end of order to preview
            orderPreviewListBox.Items.Add("----------------------------------------------------");
            orderPreviewListBox.Items.Add("Total: $" + orderGrandTotal);

            // Setting up a variable for the datatable from the database
            RestaurantDataSet.OrdersDataTable orders = new RestaurantDataSet.OrdersDataTable();
            // Setting up a orders adaptor and it's to fill in the datatable
            RestaurantDataSetTableAdapters.OrdersTableAdapter ordersTableAdap = new RestaurantDataSetTableAdapters.OrdersTableAdapter();
            // Getting the item data from the database
            ordersTableAdap.GetData();
            // Filling the data to the datatable
            ordersTableAdap.Fill(orders);
            // Going and looking in the datatable for a given order number and returning the row
            RestaurantDataSet.OrdersRow ordersRow = orders.FindByorderNumber(orderNumber);
            // Set order to active so the chef can pick it up

            ordersTableAdap.Update("1", activeTableNumber, "0", orderGrandTotal, orderNumber, activeTableNumber, ordersRow.totalPrice);
        }
Esempio n. 3
0
        private void btnPayBill_Click(object sender, EventArgs e)
        {
            int orderNumber;

            if (int.TryParse(textBoxOrderNumber.Text, out orderNumber) == false)
            {
                MessageBox.Show("Please enter a valid Order Number.");
            }
            else
            {
                RestaurantDataSet.OrdersDataTable orders = new RestaurantDataSet.OrdersDataTable();

                RestaurantDataSetTableAdapters.OrdersTableAdapter ordersTableAdapt = new RestaurantDataSetTableAdapters.OrdersTableAdapter();

                ordersTableAdapt.GetData();
                ordersTableAdapt.Fill(orders);


                RestaurantDataSet.OrdersRow ordersRow = orders.FindByorderNumber(orderNumber);

                double amountPaid;
                double amountDue;

                if (double.TryParse(amountPaidTextbox.Text.ToString(), out amountPaid) == true)
                {
                    if (double.TryParse(labelTotalDue.Text.ToString(), out amountDue) == true)
                    {
                        if (amountPaid >= amountDue)
                        {
                            double change = amountPaid - amountDue;
                            lblChangeDueValue.Text = "$" + change;

                            ordersTableAdapt.Update(ordersRow.isActive, ordersRow.tableNumber, "1", ordersRow.totalPrice, ordersRow.orderNumber, ordersRow.tableNumber, ordersRow.totalPrice);

                            lblPaymentStatusValue.Text = "Payment processed and Completed Successfully";
                        }
                        else
                        {
                            MessageBox.Show("Payment amount does not cover the Total Amount.");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Invalid Amount Due; Possible Data Corruption");
                    }
                }
                else
                {
                    MessageBox.Show("Please enter a valid Amount."); // Currently Have problems parsing textbox to double
                }
            }
        }
Esempio n. 4
0
        private void BtnGiveDiscount_Click(object sender, EventArgs e)
        {
            if (int.TryParse(txtDiscountOrderNumber.Text.ToString(), out int orderNumber) == false)
            {
                MessageBox.Show("Please enter valid Order Number");
            }
            else
            {
                RestaurantDataSet.OrdersDataTable orders = new RestaurantDataSet.OrdersDataTable();
                RestaurantDataSetTableAdapters.OrdersTableAdapter ordersTableAdapter = new RestaurantDataSetTableAdapters.OrdersTableAdapter();
                ordersTableAdapter.GetData();
                ordersTableAdapter.Fill(orders);

                RestaurantDataSet.OrdersRow ordersRow = orders.FindByorderNumber(orderNumber);

                if (ordersRow == null)
                {
                    MessageBox.Show("Order does not exist.");
                }
                else
                {
                    double totalWithDiscount;

                    if (double.TryParse(txtDiscountPercent.Text.ToString(), out double discountPercent) == false)
                    {
                        MessageBox.Show("Please enter valid percentage.");
                    }
                    else
                    {
                        if (discountPercent < 0)
                        {
                            MessageBox.Show("Percentage must be greater than 0");
                        }
                        else
                        {
                            discountPercent = (discountPercent / 100);

                            double orderTotal = ordersRow.totalPrice;

                            totalWithDiscount = orderTotal - (orderTotal * discountPercent);

                            ordersTableAdapter.Update(ordersRow.isActive, ordersRow.tableNumber, ordersRow.isPaid, totalWithDiscount, ordersRow.orderNumber, ordersRow.tableNumber, ordersRow.totalPrice);

                            MessageBox.Show("Discount Successfully added to Order number " + orderNumber);
                        }
                    }
                }
            }
        }