public frmMain() { InitializeComponent(); pnlMain.BringToFront(); pnlTopLeft.Visible = false; pnlTopMid.Visible = false; pnlTopRight.Visible = false; pnlBottomLeft.Visible = false; pnlBottomMid.Visible = false; pnlBottomRight.Visible = false; lbxCart.Visible = false; cmdAdd.Visible = false; cmdRemove.Visible = false; CSVPharser pharser = new CSVPharser(); string path = @"C:\repos\1819\1819-sew-csharp-3AHIT-AdriHaun\Projects\Halbjahresprojekt\Bestellanwendung\csv\Burger.csv"; string veg = @"C:\repos\1819\1819-sew-csharp-3AHIT-AdriHaun\Projects\Halbjahresprojekt\Bestellanwendung\Bilder\Veggie\Veggie.png"; burger = pharser.CSVToList(path); burgerArray = burger.ToArray(); if (burgerArray[5].Veg == true) { pbxTopRightVeg.BackgroundImage = new Bitmap(veg); } lblTopRightName.Text = burgerArray[5].Name; lblTopRightPrice.Text = Convert.ToString(burgerArray[5].Price) + " €"; lblTopRightAllergy.Text = burgerArray[5].Allergy; cmdTopRight.BackgroundImage = new Bitmap(burgerArray[5].Path); pnlTopRight.Visible = true; sheet = "Burger"; }
private void cmdBurger_Click(object sender, EventArgs e) { #region Initialisation pbxTopLeftVeg.BackgroundImage = null; pbxTopMidVeg.BackgroundImage = null; pbxTopRightVeg.BackgroundImage = null; pbxBottomLeftVeg.BackgroundImage = null; pbxBottomMidVeg.BackgroundImage = null; pbxBottomRightVeg.BackgroundImage = null; pnlWrap.BackColor = Color.White; pnlSideDishes.BackColor = Color.White; pnlDrinks.BackColor = Color.White; pnlDesserts.BackColor = Color.White; pnlCart.BackColor = Color.White; pnlBurger.BackColor = Color.DarkGray; lbxCart.Visible = false; cmdAdd.Visible = false; cmdRemove.Visible = false; lblRec.Visible = false; sheet = "Burger"; CSVPharser pharser = new CSVPharser(); string path = @"C:\repos\1819\1819-sew-csharp-3AHIT-AdriHaun\Projects\Halbjahresprojekt\Bestellanwendung\csv\Burger.csv"; string veg = @"C:\repos\1819\1819-sew-csharp-3AHIT-AdriHaun\Projects\Halbjahresprojekt\Bestellanwendung\Bilder\Veggie\Veggie.png"; #endregion burger = pharser.CSVToList(path); burgerArray = burger.ToArray(); int length = burgerArray.GetLength(0); #region SettingLogic if (length >= 1) { if (burgerArray[0].Veg == true) { pbxTopLeftVeg.BackgroundImage = new Bitmap(veg); } lblTopLeftName.Text = burgerArray[0].Name; lblTopLeftPrice.Text = Convert.ToString(burgerArray[0].Price) + " €"; lblTopLeftAllergy.Text = burgerArray[0].Allergy; cmdTopLeft.BackgroundImage = new Bitmap(burgerArray[0].Path); pnlTopLeft.Visible = true; } else { pnlTopLeft.Visible = false; } if (length >= 2) { if (burgerArray[1].Veg == true) { pbxTopMidVeg.BackgroundImage = new Bitmap(veg); } lblTopMidName.Text = burgerArray[1].Name; lblTopMidPrice.Text = Convert.ToString(burgerArray[1].Price) + " €"; lblTopMidAllergy.Text = burgerArray[1].Allergy; cmdTopMid.BackgroundImage = new Bitmap(burgerArray[1].Path); pnlTopMid.Visible = true; } else { pnlTopMid.Visible = false; } if (length >= 3) { if (burgerArray[2].Veg == true) { pbxTopRightVeg.BackgroundImage = new Bitmap(veg); } lblTopRightName.Text = burgerArray[2].Name; lblTopRightPrice.Text = Convert.ToString(burgerArray[2].Price) + " €"; lblTopRightAllergy.Text = burgerArray[2].Allergy; cmdTopRight.BackgroundImage = new Bitmap(burgerArray[2].Path); pnlTopRight.Visible = true; } else { pnlTopRight.Visible = false; } if (length >= 4) { if (burgerArray[3].Veg == true) { pbxBottomLeftVeg.BackgroundImage = new Bitmap(veg); } lblBottomLeftName.Text = burgerArray[3].Name; lblBottomLeftPrice.Text = Convert.ToString(burgerArray[3].Price) + " €"; lblBottomLeftAllergy.Text = burgerArray[3].Allergy; cmdBottomLeft.BackgroundImage = new Bitmap(burgerArray[3].Path); pnlBottomLeft.Visible = true; } else { pnlBottomLeft.Visible = false; } if (length >= 5) { if (burgerArray[4].Veg == true) { pbxBottomMidVeg.BackgroundImage = Image.FromFile(veg); } lblBottomMidName.Text = burgerArray[4].Name; lblBottomMidPrice.Text = Convert.ToString(burgerArray[4].Price) + " €"; lblBottomMidAllergy.Text = burgerArray[4].Allergy; cmdBottomMid.BackgroundImage = new Bitmap(burgerArray[4].Path); pnlBottomMid.Visible = true; } else { pnlBottomMid.Visible = false; } if (length >= 6) { if (burgerArray[5].Veg == true) { pbxBottomRightVeg.BackgroundImage = new Bitmap(veg); } lblBottomRightName.Text = burgerArray[5].Name; lblBottomRightPrice.Text = Convert.ToString(burgerArray[5].Price) + " €"; lblBottomRightAllergy.Text = burgerArray[5].Allergy; cmdBottomRight.BackgroundImage = new Bitmap(burgerArray[5].Path); pnlBottomRight.Visible = true; } else { pnlBottomRight.Visible = false; } #endregion }