public Form1() { InitializeComponent(); try { myRfidReader = new RFID(); myRfidReader.Tag += new TagEventHandler(RfidReaderTag); } catch (PhidgetException e) { MessageBox.Show(e.Message); } ReadChip(); bar = new BarApp(); connection = new DataHelper(); order = new Order(); connection.connect(); bar.GetAllDrinks(); bar.GetAllSnacks(); getAllSnackFromDb(); getAllDrinksFromDb(); toPay = false; if (bar.CheckEmpty() == 0) { bar.InitializeOrder(order, 777777, 0); } }
public void getAllSnackFromDb() { int counter = 0; MyButton my = new MyButton(); MyButton[] snacksButtons = new MyButton[100]; int wOfButton = 110; //width int hOfButton = 100; //hight Point xy = new Point(10, 10); int space = 130; int maxPossition = 4; List <Snack> tempSnackList = bar.GetAllSnacks(); int possition; for (int y = 0; y < 3; y++) { for (int x = 0; x < maxPossition; x++) { possition = (y * (maxPossition) + x); snacksButtons[possition] = new MyButton(); snacksButtons[possition].Location = xy; snacksButtons[possition].Price = tempSnackList[possition].Price; snacksButtons[possition].Text = tempSnackList[possition].Name; snacksButtons[possition].ProductId1 = tempSnackList[possition].ProductId; // snacksButtons[possition].Image = imageList1.Images[counter]; snacksButtons[possition].Image = imageList1.Images[tempSnackList[possition].ProductId - 1]; snacksButtons[possition].Size = new System.Drawing.Size(wOfButton, hOfButton); tabPage1.Controls.Add(snacksButtons[possition]); snacksButtons[possition].Click += new EventHandler(onClick); xy.X += space; counter++; if (counter >= 12) { counter = 0; } } xy.Y += space; xy.X = 10; } }