コード例 #1
0
        private void bPlaceOrder_Click(object sender, EventArgs e)
        {
            double grandTotal = 0.00;
            double result1    = 0;
            double subTotal   = 0;
            double priceTemp  = 0;

            if (double.TryParse(tBItem1Price.Text, out priceTemp))
            {
                subTotal = subTotal + double.Parse(tBItem1Price.Text);
            }

            if (double.TryParse(tBItem2Price.Text, out priceTemp))
            {
                subTotal = subTotal + double.Parse(tBItem2Price.Text);
            }

            if (double.TryParse(tBItem3Price.Text, out priceTemp))
            {
                subTotal = subTotal + double.Parse(tBItem3Price.Text);
            }

            if (double.TryParse(tBItem4Price.Text, out priceTemp))
            {
                subTotal = subTotal + double.Parse(tBItem4Price.Text);
            }

            if (double.TryParse(tBItem5Price.Text, out priceTemp))
            {
                subTotal = subTotal + double.Parse(tBItem5Price.Text);
            }

            if (double.TryParse(tBItem6Price.Text, out priceTemp))
            {
                subTotal = subTotal + double.Parse(tBItem6Price.Text);
            }

            if (double.TryParse(tBItem7Price.Text, out priceTemp))
            {
                subTotal = subTotal + double.Parse(tBItem7Price.Text);
            }

            if (double.TryParse(tBItem8Price.Text, out priceTemp))
            {
                subTotal = subTotal + double.Parse(tBItem8Price.Text);
            }

            int count = 0;

            /*calculate tax on items in menuDataArray with itemTax value being greater than 1, add that
             * value to grandTotal and loop through menuDataArray  */
            while (count < menuDataArray.Length)
            {
                double totalPrice = 0;

                if (count == 0)
                {
                    totalPrice = menuDataArray[count].itemPrice * double.Parse(nUDItem1Qty.Value.ToString());

                    if (menuDataArray[count].itemTax > 1)
                    {
                        result1    = totalPrice * menuDataArray[count].itemTax;
                        grandTotal = result1 + grandTotal;
                    }

                    else
                    {
                        result1    = totalPrice;
                        grandTotal = grandTotal + result1;
                    }
                }


                if (count == 1)
                {
                    totalPrice = menuDataArray[count].itemPrice * double.Parse(nUDItem2Qty.Value.ToString());

                    if (menuDataArray[count].itemTax > 1)
                    {
                        result1    = totalPrice * menuDataArray[count].itemTax;
                        grandTotal = result1 + grandTotal;
                    }

                    else
                    {
                        result1    = totalPrice;
                        grandTotal = grandTotal + result1;
                    }
                }


                if (count == 2)
                {
                    totalPrice = menuDataArray[count].itemPrice * double.Parse(nUDItem3Qty.Value.ToString());

                    if (menuDataArray[count].itemTax > 1)
                    {
                        result1    = totalPrice * menuDataArray[count].itemTax;
                        grandTotal = result1 + grandTotal;
                    }

                    else
                    {
                        result1    = totalPrice;
                        grandTotal = grandTotal + result1;
                    }
                }


                if (count == 3)
                {
                    totalPrice = menuDataArray[count].itemPrice * double.Parse(nUDItem4Qty.Value.ToString());

                    if (menuDataArray[count].itemTax > 1)
                    {
                        result1    = totalPrice * menuDataArray[count].itemTax;
                        grandTotal = result1 + grandTotal;
                    }

                    else
                    {
                        result1    = totalPrice;
                        grandTotal = grandTotal + result1;
                    }
                }


                if (count == 4)
                {
                    totalPrice = menuDataArray[count].itemPrice * double.Parse(nUDItem5Qty.Value.ToString());

                    if (menuDataArray[count].itemTax > 1)
                    {
                        result1    = totalPrice * menuDataArray[count].itemTax;
                        grandTotal = result1 + grandTotal;
                    }

                    else
                    {
                        result1    = totalPrice;
                        grandTotal = grandTotal + result1;
                    }
                }


                if (count == 5)
                {
                    totalPrice = menuDataArray[count].itemPrice * double.Parse(nUDItem6Qty.Value.ToString());

                    if (menuDataArray[count].itemTax > 1)
                    {
                        result1    = totalPrice * menuDataArray[count].itemTax;
                        grandTotal = result1 + grandTotal;
                    }

                    else
                    {
                        result1    = totalPrice;
                        grandTotal = grandTotal + result1;
                    }
                }


                if (count == 6)
                {
                    totalPrice = menuDataArray[count].itemPrice * double.Parse(nUDItem7Qty.Value.ToString());

                    if (menuDataArray[count].itemTax > 1)
                    {
                        result1    = totalPrice * menuDataArray[count].itemTax;
                        grandTotal = result1 + grandTotal;
                    }

                    else
                    {
                        result1    = totalPrice;
                        grandTotal = grandTotal + result1;
                    }
                }


                if (count == 7)
                {
                    totalPrice = menuDataArray[count].itemPrice * double.Parse(nUDItem8Qty.Value.ToString());

                    if (menuDataArray[count].itemTax > 1)
                    {
                        result1    = totalPrice * menuDataArray[count].itemTax;
                        grandTotal = result1 + grandTotal;
                    }

                    else
                    {
                        result1    = totalPrice;
                        grandTotal = grandTotal + result1;
                    }
                }
                count++;
            }
            if (grandTotal == 0)
            {
                MessageBox.Show("Please select an item");
                return;
            }
            //create instance of global class called TransferData(contains list)
            //TransferData globalClass = new TransferData();

            OrderData[]      orderArray = new OrderData[8];
            List <OrderData> orderlist  = new List <OrderData>();

            if (nUDItem1Qty.Value > 0)
            {
                //pass data into constructor (in Program.cs) and save to 'record1'
                OrderData record1 = new OrderData(menuDataArray[0].itemName, menuDataArray[0].itemPrice, int.Parse(nUDItem1Qty.Value.ToString()));
                //orderArray[0] = record1;

                orderlist.Add(record1);
            }

            if (nUDItem2Qty.Value > 0)
            {
                OrderData record2 = new OrderData(menuDataArray[1].itemName, menuDataArray[1].itemPrice, int.Parse(nUDItem2Qty.Value.ToString()));
                orderlist.Add(record2);
            }

            if (nUDItem3Qty.Value > 0)
            {
                OrderData record3 = new OrderData(menuDataArray[2].itemName, menuDataArray[2].itemPrice, int.Parse(nUDItem3Qty.Value.ToString()));
                orderlist.Add(record3);
            }

            if (nUDItem4Qty.Value > 0)
            {
                OrderData record4 = new OrderData(menuDataArray[3].itemName, menuDataArray[3].itemPrice, int.Parse(nUDItem4Qty.Value.ToString()));
                orderlist.Add(record4);
            }

            if (nUDItem5Qty.Value > 0)
            {
                OrderData record5 = new OrderData(menuDataArray[4].itemName, menuDataArray[4].itemPrice, int.Parse(nUDItem5Qty.Value.ToString()));
                orderlist.Add(record5);
            }

            if (nUDItem6Qty.Value > 0)
            {
                OrderData record6 = new OrderData(menuDataArray[5].itemName, menuDataArray[5].itemPrice, int.Parse(nUDItem6Qty.Value.ToString()));
                orderlist.Add(record6);
            }

            if (nUDItem7Qty.Value > 0)
            {
                OrderData record7 = new OrderData(menuDataArray[6].itemName, menuDataArray[6].itemPrice, int.Parse(nUDItem7Qty.Value.ToString()));
                orderlist.Add(record7);
            }

            if (nUDItem8Qty.Value > 0)
            {
                OrderData record8 = new OrderData(menuDataArray[7].itemName, menuDataArray[7].itemPrice, int.Parse(nUDItem8Qty.Value.ToString()));
                orderlist.Add(record8);
            }

            //pass user input through constructor into element of list
            //MoveToNewForm ian instance of OrderConfirmation and passes info through orderlist
            OrderConfirmation MoveToNewForm = new OrderConfirmation(orderlist, grandTotal);

            MoveToNewForm.Show();

            this.Hide();
            {
            }
        }
コード例 #2
0
        private void bPlaceOrder_Click(object sender, EventArgs e)
        {
            double grandTotal = 0.00;
            double result1 = 0;
            double subTotal = 0;
            double priceTemp = 0;

            if (double.TryParse(tBItem1Price.Text, out priceTemp))
            {
                subTotal = subTotal + double.Parse(tBItem1Price.Text);
            }

             if (double.TryParse(tBItem2Price.Text, out priceTemp))
            {
                subTotal = subTotal + double.Parse(tBItem2Price.Text);
            }

             if (double.TryParse(tBItem3Price.Text, out priceTemp))
            {
                subTotal = subTotal + double.Parse(tBItem3Price.Text);
            }

             if (double.TryParse(tBItem4Price.Text, out priceTemp))
            {
                subTotal = subTotal + double.Parse(tBItem4Price.Text);
            }

             if (double.TryParse(tBItem5Price.Text, out priceTemp))
            {
                subTotal = subTotal + double.Parse(tBItem5Price.Text);
            }

             if (double.TryParse(tBItem6Price.Text, out priceTemp))
            {
                subTotal = subTotal + double.Parse(tBItem6Price.Text);
            }

             if (double.TryParse(tBItem7Price.Text, out priceTemp))
            {
                subTotal = subTotal + double.Parse(tBItem7Price.Text);
            }

             if (double.TryParse(tBItem8Price.Text, out priceTemp))
            {
                subTotal = subTotal + double.Parse(tBItem8Price.Text);
            }

             int count = 0;
            /*calculate tax on items in menuDataArray with itemTax value being greater than 1, add that 
            value to grandTotal and loop through menuDataArray  */
             while (count < menuDataArray.Length)
             {
                 double totalPrice = 0;

                 if (count == 0)
                 {
                     totalPrice = menuDataArray[count].itemPrice * double.Parse(nUDItem1Qty.Value.ToString());

                     if (menuDataArray[count].itemTax > 1)
                     {
                         result1 = totalPrice * menuDataArray[count].itemTax;
                         grandTotal = result1 + grandTotal;
                     }

                     else
                     {
                         result1 = totalPrice;
                         grandTotal = grandTotal + result1;
                     }
                 }


                 if (count == 1)
                 {
                     totalPrice = menuDataArray[count].itemPrice * double.Parse(nUDItem2Qty.Value.ToString());

                     if (menuDataArray[count].itemTax > 1)
                     {
                         result1 = totalPrice * menuDataArray[count].itemTax;
                         grandTotal = result1 + grandTotal;
                     }

                     else
                     {
                         result1 = totalPrice;
                         grandTotal = grandTotal + result1;
                     }
                 }


                 if (count == 2)
                 {
                     totalPrice = menuDataArray[count].itemPrice * double.Parse(nUDItem3Qty.Value.ToString());

                     if (menuDataArray[count].itemTax > 1)
                     {
                         result1 = totalPrice * menuDataArray[count].itemTax;
                         grandTotal = result1 + grandTotal;
                     }

                     else
                     {
                         result1 = totalPrice;
                         grandTotal = grandTotal + result1;
                     }
                 }


                 if (count == 3)
                 {
                     totalPrice = menuDataArray[count].itemPrice * double.Parse(nUDItem4Qty.Value.ToString());

                     if (menuDataArray[count].itemTax > 1)
                     {
                         result1 = totalPrice * menuDataArray[count].itemTax;
                         grandTotal = result1 + grandTotal;
                     }

                     else
                     {
                         result1 = totalPrice;
                         grandTotal = grandTotal + result1;
                     }
                 }


                 if (count == 4)
                 {
                     totalPrice = menuDataArray[count].itemPrice * double.Parse(nUDItem5Qty.Value.ToString());

                     if (menuDataArray[count].itemTax > 1)
                     {
                         result1 = totalPrice * menuDataArray[count].itemTax;
                         grandTotal = result1 + grandTotal;
                     }

                     else
                     {
                         result1 = totalPrice;
                         grandTotal = grandTotal + result1;
                     }
                 }


                 if (count == 5)
                 {
                     totalPrice = menuDataArray[count].itemPrice * double.Parse(nUDItem6Qty.Value.ToString());

                     if (menuDataArray[count].itemTax > 1)
                     {
                         result1 = totalPrice * menuDataArray[count].itemTax;
                         grandTotal = result1 + grandTotal;
                     }

                     else
                     {
                         result1 = totalPrice;
                         grandTotal = grandTotal + result1;
                     }
                 }


                 if (count == 6)
                 {
                     totalPrice = menuDataArray[count].itemPrice * double.Parse(nUDItem7Qty.Value.ToString());

                     if (menuDataArray[count].itemTax > 1)
                     {
                         result1 = totalPrice * menuDataArray[count].itemTax;
                         grandTotal = result1 + grandTotal;
                     }

                     else
                     {
                         result1 = totalPrice;
                         grandTotal = grandTotal + result1;
                     }
                 }


                 if (count == 7)
                 {
                     totalPrice = menuDataArray[count].itemPrice * double.Parse(nUDItem8Qty.Value.ToString());

                     if (menuDataArray[count].itemTax > 1)
                     {
                         result1 = totalPrice * menuDataArray[count].itemTax;
                         grandTotal = result1 + grandTotal;
                     }

                     else
                     {
                         result1 = totalPrice;
                         grandTotal = grandTotal + result1;
                     }
                 }
                 count++;
             }
             if (grandTotal == 0)
             {
                 MessageBox.Show("Please select an item");
                 return;
             }
            //create instance of global class called TransferData(contains list)
             //TransferData globalClass = new TransferData();

             OrderData[] orderArray = new OrderData[8];
             List<OrderData> orderlist = new List<OrderData>();

            if (nUDItem1Qty.Value > 0)
            {
                //pass data into constructor (in Program.cs) and save to 'record1'
                OrderData record1 = new OrderData(menuDataArray[0].itemName,menuDataArray[0].itemPrice,int.Parse(nUDItem1Qty.Value.ToString()));
                //orderArray[0] = record1;
                
                orderlist.Add(record1);
            }

            if (nUDItem2Qty.Value > 0)
            {
                OrderData record2 = new OrderData(menuDataArray[1].itemName, menuDataArray[1].itemPrice, int.Parse(nUDItem2Qty.Value.ToString()));
                orderlist.Add(record2);
            }

            if (nUDItem3Qty.Value > 0)
            {
                OrderData record3 = new OrderData(menuDataArray[2].itemName, menuDataArray[2].itemPrice, int.Parse(nUDItem3Qty.Value.ToString()));
                orderlist.Add(record3);
            }

            if (nUDItem4Qty.Value > 0)
            {
                OrderData record4 = new OrderData(menuDataArray[3].itemName, menuDataArray[3].itemPrice, int.Parse(nUDItem4Qty.Value.ToString()));
                orderlist.Add(record4);
            }

            if (nUDItem5Qty.Value > 0)
            {
                OrderData record5 = new OrderData(menuDataArray[4].itemName, menuDataArray[4].itemPrice, int.Parse(nUDItem5Qty.Value.ToString()));
                orderlist.Add(record5);
            }

            if (nUDItem6Qty.Value > 0)
            {
                OrderData record6 = new OrderData(menuDataArray[5].itemName, menuDataArray[5].itemPrice, int.Parse(nUDItem6Qty.Value.ToString()));
                orderlist.Add(record6);
            }

            if (nUDItem7Qty.Value > 0)
            {
                OrderData record7 = new OrderData(menuDataArray[6].itemName, menuDataArray[6].itemPrice, int.Parse(nUDItem7Qty.Value.ToString()));
                orderlist.Add(record7);
            }

            if (nUDItem8Qty.Value > 0)
            {
                OrderData record8 = new OrderData(menuDataArray[7].itemName, menuDataArray[7].itemPrice, int.Parse(nUDItem8Qty.Value.ToString()));
                orderlist.Add(record8);
            }

            //pass user input through constructor into element of list
            //MoveToNewForm ian instance of OrderConfirmation and passes info through orderlist
            OrderConfirmation MoveToNewForm = new OrderConfirmation(orderlist, grandTotal);
            MoveToNewForm.Show();

            this.Hide();
	        {
		
	        }
        }
コード例 #3
0
 public Menu(OrderConfirmation fr)
 {
     InitializeComponent();
     frm = fr;
 }
コード例 #4
0
 public Menu(OrderConfirmation fr)
 {
     InitializeComponent();
     frm = fr;
 }