private void CbSelectDrinksName_SelectedIndexChanged(object sender, EventArgs e) { int selectedStockValue = cbSelectDrinksName.SelectedIndex; // STANDARD Stock_Service stock_Service = new Stock_Service(); List <Stock> stockpiles = stock_Service.GetStocks(); stockpiles = stockpiles.OrderBy(stockpile => stockpile.Name).ToList(); txtModifyDrinksName.Text = stockpiles[selectedStockValue].Name; //name if (stockpiles[selectedStockValue].Kind == "Alcoholisch") //kind { cbModifyDrinksAlcohol.Checked = true; } else { cbModifyDrinksAlcohol.Checked = false; } tbModifyDrinksSellprice.Value = stockpiles[selectedStockValue].Sellprice; //sellprice if (stockpiles[selectedStockValue].Tax == 21) //tax { cbModifyDrinksBTW.SelectedIndex = 1; } else { cbModifyDrinksBTW.SelectedIndex = 0; } txtModifyDrinksSoled.Text = stockpiles[selectedStockValue].SellAmounts.ToString(); // amounts solled txtModifyDrinksStock.Text = stockpiles[selectedStockValue].Stockpile.ToString(); // stock }
private void BtnDeleteDrinks_Click(object sender, EventArgs e) { try { lblModifyStockLogOutput.Text = string.Empty; if (cbSelectDrinksName.SelectedIndex == -1) { throw new Exception($"You have not selected a drink "); } if (cbIAmSure.Checked) { Stock_Service stock_Service = new Stock_Service(); List <Stock> stockpiles = stock_Service.GetStocks(); stockpiles = stockpiles.OrderBy(stockpile => stockpile.Name).ToList(); string DrinkName = cbSelectDrinksName.Text; int Id = stock_Service.GetIdByName(DrinkName); stock_Service.DeleteStock(DrinkName, Id); lblModifyStockLogOutput.Text = $"{DrinkName} has been deleted in the database "; ResetModifyStock(); } else { throw new Exception($"You must agree to delete this drink "); } } catch (Exception exception) { Catch(exception); lblModifyStockLogOutput.Text += exception.Message; } }
// ADD DRINKS private void BntAddDrinks_Click(object sender, EventArgs e) { try { lblModifyStockLogOutput.Text = string.Empty; Stock_Service stock_Service = new Stock_Service(); int VoorraadAantal = int.Parse(txtModifyDrinksStock.Text); string DrankNaam = txtModifyDrinksName.Text; if (DrankNaam == string.Empty) { throw new Exception("The name may not be empty"); } string DrankSoort; if (cbModifyDrinksAlcohol.Checked) { DrankSoort = "Alcoholisch"; } else { DrankSoort = "Non-Alcoholisch"; } int DrankPrijs = tbModifyDrinksSellprice.Value; int DrankBTW = int.Parse(cbModifyDrinksBTW.Text); int VerkoopAantal = int.Parse(txtModifyDrinksSoled.Text); // CHECK IF NAME EXCISTS List <Stock> stockpiles = stock_Service.GetStocks(); stockpiles = stockpiles.OrderBy(stockpile => stockpile.Name).ToList(); foreach (Stock stockpile in stockpiles) { if (stockpile.Name == DrankNaam) { throw new Exception("The name of the drink already excists."); } } stock_Service.AddToStock(VoorraadAantal, DrankNaam, DrankSoort, DrankPrijs, DrankBTW, VerkoopAantal); lblModifyStockLogOutput.Text = $"{DrankNaam} has been added to the database"; ResetModifyStock(); } catch (Exception exception) { Catch(exception); lblModifyStockLogOutput.Text += exception.Message; } }
private void showPanel(string panelName) { try { if (panelName == "Dashboard") { hideAllPanels(); // show dashboard pnl_Dashboard.Show(); img_Dashboard.Show(); } else if (panelName == "Revenue") { hideAllPanels(); pnl_Revenue.Show(); //pnl_Revenue.Show(); //lstvw_Revenue.Clear(); pnl_Revenue.Show(); mntclndr_Revenue.MaxDate = DateTime.Today; } else if (panelName == "Rooms") { hideAllPanels(); pnl_Rooms.Show(); // fill the rooms listview within the students panel with a list of students SomerenLogic.Room_Service rmService = new SomerenLogic.Room_Service(); List <Room> roomList = rmService.GetRooms(); // clear the listview before filling it again listViewRooms.Items.Clear(); foreach (SomerenModel.Room r in roomList) { ListViewItem li = new ListViewItem(r.Number.ToString()); li.SubItems.Add(r.Capacity.ToString()); li.SubItems.Add(r.Type); listViewRooms.Items.Add(li); } } else if (panelName == "Students") { // hide all other panels hideAllPanels(); pnl_Students.Show(); // fill the students listview within the students panel with a list of students SomerenLogic.Student_Service studService = new SomerenLogic.Student_Service(); studentList = studService.GetStudents(); // clear the listview before filling it again listViewStudents.Items.Clear(); fillListViewStudents(studentList); } else if (panelName == "Teachers") { hideAllPanels(); pnl_Teachers.Show(); Teacher_Service lecService = new Teacher_Service(); List <Teacher> lectList = lecService.GetTeachers(); listViewTeachers.Items.Clear(); foreach (Teacher t in lectList) { ListViewItem item = new ListViewItem(t.Number.ToString()); item.SubItems.Add(t.Name); listViewTeachers.Items.Add(item); } } else if (panelName == "Activities") { hideAllPanels(); pnl_Activities.Show(); ResetModifyActivity(); } else if (panelName == "RoomLayout") { hideAllPanels(); pnl_kamerindeling.Show(); // fill the Combobox within the kamerindeling panel with a list of the roomnumbers SomerenLogic.Student_Service indelingService = new SomerenLogic.Student_Service(); List <Student> kamers = indelingService.GetKamers(); foreach (Student kamer in kamers) { comboBoxKamerindeling.Items.Add(kamer.RoomNumber); } } else if (panelName == "Stock") { hideAllPanels(); pnl_Stock.Show(); Stock_Service stockService = new Stock_Service(); List <Stock> stockList = stockService.GetStocksCondition(); stockList = stockList.OrderBy(stockpile => stockpile.Name).ToList(); listViewStock.Items.Clear(); foreach (Stock stock in stockList) { ListViewItem item = new ListViewItem(stock.Name.ToString()); // ENOUGHT IN STOCK? string icon; if (stock.Stockpile >= 10) { icon = "✔ "; } else { icon = "❌ "; } item.SubItems.Add(icon + stock.Stockpile.ToString()); item.SubItems.Add(stock.Sellprice.ToString()); listViewStock.Items.Add(item); } } else if (panelName == "ModifyStock") { hideAllPanels(); pnl_ModifyStock.Show(); ResetModifyStock(); } else if (panelName == "Log") { hideAllPanels(); pnl_Log.Show(); listViewLogs.Items.Clear(); foreach (Log log in logList) { ListViewItem item = new ListViewItem(log.Date.ToString()); item.SubItems.Add(log.Message); item.SubItems.Add(log.Source); item.SubItems.Add(log.Method); item.SubItems.Add(log.Fullname); listViewLogs.Items.Add(item); } } else if (panelName == "Cash Register") { hideAllPanels(); pnl_CashRegister.Show(); lvDrink.View = View.Details; lvDrink.Columns.Add("ID", 30); lvDrink.Columns.Add("Name"); lvDrink.Columns.Add("Kind", 100); lvDrink.Columns.Add("Price"); lvDrink.Columns.Add("Amount Left", 75); lvStudent.View = View.Details; lvStudent.Columns.Add("ID", 30); lvStudent.Columns.Add("Name", 100); lvDrink.Items.Clear(); Stock_Service stockservice = new Stock_Service(); Student_Service studentService = new Student_Service(); foreach (Stock stock in stockservice.GetStocks()) { //de lijst vullen met alle data in de juiste volgorde. ListViewItem item = new ListViewItem(stock.Number.ToString()); item.SubItems.Add(stock.Name); item.SubItems.Add(stock.Kind); item.SubItems.Add((stock.Sellprice * ((decimal)stock.Tax / 100 + 1)).ToString("0.00")); item.SubItems.Add(stock.SellAmounts.ToString()); lvDrink.Items.Add(item); //"\u20AC " + } lvDrink.Select(); lvStudent.Items.Clear(); foreach (Student student in studentService.GetStudents()) { ListViewItem item = new ListViewItem(student.Number.ToString()); item.SubItems.Add(student.Name); lvStudent.Items.Add(item); } lvStudent.Select(); } else if (panelName == "VAT Calculation") { hideAllPanels(); pnl_BTWBerekenen.Show(); } } catch (Exception exception) { Catch(exception); } }