예제 #1
0
        public List <Snack> GetAllSnacks()
        {
            string       sql     = "SELECT * FROM Product WHERE IsItSnack = \"1\";";
            MySqlCommand command = new MySqlCommand(sql, MySqlconnection);

            snackList = new List <Snack>();

            try
            {
                MySqlconnection.Open();
                MySqlDataReader reader = command.ExecuteReader();
                Snack           snack;

                int    productId;
                String name;
                int    quantity;
                double price;
                bool   isItSnack;
                string pathstring;
                while (reader.Read())
                {
                    productId  = Convert.ToInt32(reader[0]);
                    name       = Convert.ToString(reader[1]);
                    quantity   = Convert.ToInt32(reader[2]);
                    price      = Convert.ToDouble(reader[3]);
                    isItSnack  = Convert.ToBoolean(reader[4]);
                    pathstring = Convert.ToString(reader[5]);
                    snack      = new Snack(productId, name, quantity, price, isItSnack, pathstring);

                    snackList.Add(snack);
                }
            }
            catch (MySqlException e)
            {
                MessageBox.Show(e.Message);
            }
            finally
            {
                MySqlconnection.Close();
            }
            return(snackList);
        }
예제 #2
0
        private void onClick(object sender, EventArgs e)
        {
            quanTextbox = Convert.ToInt16(numericUpDown1.Value);
            holder1     = ((MyButton)sender).Text;
            holder2     = ((MyButton)sender).Price;
            produrcID   = ((MyButton)sender).ProductId1;

            //client = bar.SearchClient(myRfid);

            if (tabControl1.SelectedTab == tabPage1)
            {
                s         = new Snack(produrcID, holder1, quanTextbox, holder2, true, "");
                orderLine = new OrderLine(holder1, quanTextbox, s);
                order.AddOrderLine(orderLine);
                listBox1.Items.Add(orderLine.AsString());
                double p = 0;
                foreach (OrderLine item in order.getAllOrderLines())
                {
                    p += item.Price * item.Quantity;
                }
                label4.Text = "Total: € " + p;
            }
            else if (tabControl1.SelectedTab == tabPage2)
            {
                d         = new Drink(produrcID, holder1, quanTextbox, holder2, false, "");
                orderLine = new OrderLine(d.Name, quanTextbox, d);
                order.AddOrderLine(orderLine);
                listBox1.Items.Add(orderLine.AsString());
                double p = 0;
                foreach (OrderLine item in order.getAllOrderLines())
                {
                    p += item.Price * item.Quantity;
                }
                label4.Text = "Total: € " + p;
            }


            // bar.MakeOrderLine(orderLine);
        }