コード例 #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);
        }
コード例 #2
0
ファイル: PaymentForm.cs プロジェクト: NWTC85464/82781_Team1
        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
                }
            }
        }
コード例 #3
0
ファイル: PaymentForm.cs プロジェクト: NWTC85464/82781_Team1
        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;
                    }
                }
            }
        }
コード例 #4
0
ファイル: ManagerForm.cs プロジェクト: NWTC85464/82781_Team1
        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);
                        }
                    }
                }
            }
        }
コード例 #5
0
ファイル: ChefForm.cs プロジェクト: NWTC85464/82781_Team1
        private void BtnCompleteOrderThree_Click(object sender, EventArgs e)
        {
            // Clear Chef list three
            lstOrderThree.Items.Clear();

            // Delete the order from the queue
            RestaurantDataSet.OrdersRow orderRow = orders.Where(o => o.orderNumber == orderThree).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);
            orderThree = 0;

            // Enable Load Next Order Button
            btnLoadOrderThree.Enabled = true;
        }