Beispiel #1
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);
        }
Beispiel #2
0
        public void GetDataTables()
        {
            // Getting the order data from the database
            OrderTableAdapt.GetData();
            // Filling the data to the datatable
            OrderTableAdapt.Fill(orders);


            // Getting the order data from the database
            OrderItemsTableAdapt.GetData();
            // Filling the data to the datatable
            OrderItemsTableAdapt.Fill(orderItems);


            // Getting the order data from the database
            MenuItemsTableAdapt.GetData();
            // Filling the data to the datatable
            MenuItemsTableAdapt.Fill(menuItems);

            ActiveOrders.Clear();
            // Put active orders inside active order list
            foreach (RestaurantDataSet.OrdersRow order in orders.Where(o => o.isActive == "1"))
            {
                ActiveOrders.Add(order);
            }
        }
Beispiel #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
                }
            }
        }
Beispiel #4
0
        private void Button1_Click(object sender, EventArgs e)
        {
            lblPaymentStatusValue.Text = "";
            amountPaidTextbox.Text     = "";
            labelTotalDue.Text         = "";
            lblChangeDueValue.Text     = "";

            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);

                if (ordersRow == null)
                {
                    MessageBox.Show("Order could not be found.");
                }
                else
                {
                    labelTotalDue.Text = ordersRow.totalPrice.ToString();
                }

                // Display order status depending on if the bill is paid or not
                if (ordersRow.isPaid == "0")
                {
                    lblPaymentStatusValue.Text = "Payment Pending";
                    btnPayBill.Enabled         = true;
                }
                else
                {
                    if (ordersRow.isPaid == "1")
                    {
                        lblPaymentStatusValue.Text = "Payment Processed and Completed";
                        btnPayBill.Enabled         = false;
                    }
                }
            }
        }
Beispiel #5
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);
                        }
                    }
                }
            }
        }