//private to internal because we will reference it from the other form internal void showPanel(string panelName) { //hide all panels pnl_Dashboard.Hide(); img_Dashboard.Hide(); pnl_Students.Hide(); pnl_Teachers.Hide(); pnl_Drinks.Hide(); pnl_CashRegister.Hide(); pnl_Supervisors.Hide(); if (panelName == "Dashboard") { // show dashboard pnl_Dashboard.Show(); img_Dashboard.Show(); } else if (panelName == "Students") { //Check if the listview already exist, if not create one. if (viewStudentList == null) { viewStudentList = CreateStudentListView(); pnl_Students.Controls.Add(viewStudentList); } // show students pnl_Students.Show(); // fill the students listview within the students panel with a list of students Student_Service studService = new Student_Service(); List <Student> studentList = studService.GetStudents(); // clear the listview before filling it again viewStudentList.Items.Clear(); foreach (Student s in studentList) { ListViewItem student = new ListViewItem(new string[] { s.Number.ToString(), s.FirstName, s.LastName }); viewStudentList.Items.Add(student); } } else if (panelName == "Lecturers") { // show teachers panel pnl_Teachers.Show(); // fill the teachers listview within the teacher panel with a list of teachers Teacher_Service teacherService = new Teacher_Service(); List <Teacher> teacherList = teacherService.GetTeachers(); // clear the items in listview listViewTeachers.Items.Clear(); // fill list foreach (Teacher s in teacherList) { ListViewItem teacher = new ListViewItem(s.Number.ToString()); teacher.SubItems.Add(s.FirstName); teacher.SubItems.Add(s.LastName); listViewTeachers.Items.Add(teacher); } } //this is part of variant A from assignment 3 //this is part of variant A from assignment 3 else if (panelName == "Drinks Supplies") { //show drinks panel pnl_Drinks.Show(); //fill the drinks listview wihin the drink panel with a list of drinks Drink_Service drinkService = new Drink_Service(); List <Drink> drinkList = drinkService.GetDrinks(); //clear the items in listview listViewDrinks.Items.Clear(); //fill list foreach (Drink d in drinkList) { ListViewItem drink = new ListViewItem(new string[] { d.DrinkName, String.Format("{0:0.00}", d.Price), d.StockAmount.ToString() }); drink.Tag = d; if (d.StockAmount < 10) { //show half bottle icon drink.ImageIndex = 1; } else { //show full bottle icon drink.ImageIndex = 0; } listViewDrinks.Items.Add(drink); } this.Refresh(); } //this is a part of variant B from assignment 3 //this is a part of variant B from assignment 3 else if (panelName == "CashRegister") { //show panel pnl_CashRegister.Show(); //get list of drinks and students Student_Service studService = new Student_Service(); List <Student> studentList = studService.GetStudents(); Drink_Service drinkService = new Drink_Service(); List <Drink> drinkList = drinkService.GetDrinks(); //clear the listview before filling it again lv_Cash_Student.Items.Clear(); lv_Cash_Drinks.Items.Clear(); //get students foreach (Student s in studentList) { ListViewItem student = new ListViewItem(s.Number.ToString()); student.SubItems.Add(s.FullName); lv_Cash_Student.Items.Add(student); } //get drinks foreach (Drink d in drinkList) { ListViewItem drink = new ListViewItem(d.DrinkNumber.ToString()); drink.SubItems.Add(d.DrinkName); drink.SubItems.Add(d.Price.ToString("0.00")); drink.SubItems.Add(d.StockAmount.ToString()); lv_Cash_Drinks.Items.Add(drink); } } //this is a part of variant B from assignment 4 //this is a part of variant B from assignment 4 else if (panelName == "Supervisors") { //show supervisor panek pnl_Supervisors.Show(); //fill the supervisors listview within the supervisor panel with list of supervisors Supervisor_Service supervisorService = new Supervisor_Service(); List <Supervisor> supervisorList = supervisorService.GetSupervisors(); //clear items in listview listViewSupervisors.Items.Clear(); //fill list foreach (Supervisor s in supervisorList) { ListViewItem supervisor = new ListViewItem(new string[] { s.LecturerID.ToString(), s.FirstName, s.LastName }); supervisor.Tag = s; listViewSupervisors.Items.Add(supervisor); } } }
private void ShowPanel(string panelName) { if (panelName == "Dashboard") { // hide all other panels pnl_Students.Hide(); pnl_Lecturers.Hide(); pnl_Rooms.Hide(); pnl_Activiteitenlijst.Hide(); pnl_Drank.Hide(); pnl_Kassa.Hide(); pnl_Omzetrapportage.Hide(); pnl_Begeleiders.Hide(); // show dashboard pnl_Dashboard.Show(); img_Dashboard.Show(); } else if (panelName == "Students") { // hide all other panels pnl_Dashboard.Hide(); img_Dashboard.Hide(); pnl_Lecturers.Hide(); pnl_Rooms.Hide(); pnl_Activiteitenlijst.Hide(); pnl_Drank.Hide(); pnl_Kassa.Hide(); pnl_Omzetrapportage.Hide(); pnl_Begeleiders.Hide(); // show students pnl_Students.Show(); // fill the students listview within the students panel with a list of students SomerenLogic.Student_Service studService = new SomerenLogic.Student_Service(); List <Student> studentList = studService.GetStudents(); // clear the listview before filling it again listViewStudents.Clear(); foreach (SomerenModel.Student s in studentList) { ListViewItem li = new ListViewItem(s.Studentname, s.Studentnumber); listViewStudents.Items.Add(li); } } else if (panelName == "Lecturers") { //hide all other panels pnl_Dashboard.Hide(); img_Dashboard.Hide(); pnl_Students.Hide(); pnl_Rooms.Hide(); pnl_Activiteitenlijst.Hide(); pnl_Drank.Hide(); pnl_Kassa.Hide(); pnl_Omzetrapportage.Hide(); pnl_Begeleiders.Hide(); pnl_Lecturers.Show(); Teacher_Service teachService = new Teacher_Service(); List <Teacher> teacherList = teachService.GetTeachers(); listViewLecturers.Clear(); foreach (Teacher t in teacherList) { ListViewItem li = new ListViewItem(t.Teachername, t.Teachernumber); listViewLecturers.Items.Add(li); } } else if (panelName == "Rooms") { pnl_Dashboard.Hide(); img_Dashboard.Hide(); pnl_Students.Hide(); pnl_Lecturers.Hide(); pnl_Activiteitenlijst.Hide(); pnl_Drank.Hide(); pnl_Kassa.Hide(); pnl_Omzetrapportage.Hide(); pnl_Begeleiders.Hide(); pnl_Rooms.Show(); Room_Service roomService = new Room_Service(); List <Room> roomList = roomService.GetRooms(); ListRoomBox.Items.Clear(); foreach (Room r in roomList) { ListRoomBox.Items.Add(r.RoomToString()); } } else if (panelName == "Activities") { pnl_Dashboard.Hide(); img_Dashboard.Hide(); pnl_Students.Hide(); pnl_Lecturers.Hide(); pnl_Rooms.Hide(); pnl_Drank.Hide(); pnl_Kassa.Hide(); pnl_Omzetrapportage.Hide(); pnl_Begeleiders.Hide(); pnl_Activiteitenlijst.Show(); Activity_Service activityService = new Activity_Service(); List <Activity> activityList = activityService.GetActivities(); lv_Activiteitenlijst.Items.Clear(); cmb_Activiteiten.Items.Clear(); foreach (Activity a in activityList) { ListViewItem li = new ListViewItem(a.Number.ToString()); li.SubItems.Add(a.Description.ToString()); li.SubItems.Add(a.StartTime.ToString()); li.SubItems.Add(a.NumberofStudents.ToString()); li.SubItems.Add(a.NumberofLecturers.ToString()); lv_Activiteitenlijst.Items.Add(li); cmb_Activiteiten.Items.Add(a.ActiviteitcmbBoxToString()); } cmb_Activiteiten.SelectedIndex = 0; } else if (panelName == "Drank") { //Hide all other panels (once again) pnl_Dashboard.Hide(); img_Dashboard.Hide(); pnl_Students.Hide(); pnl_Lecturers.Hide(); pnl_Rooms.Hide(); pnl_Activiteitenlijst.Hide(); pnl_Kassa.Hide(); pnl_Omzetrapportage.Hide(); pnl_Begeleiders.Hide(); //show the Drinks panel pnl_Drank.Show(); Drank_Service drankService = new Drank_Service(); List <Drank> drankList = drankService.GetDrinks(); lv_Drank.Items.Clear(); foreach (Drank d in drankList) { //drankService.StockCheck(d); ListViewItem li = new ListViewItem(d.DrankName.ToString()); li.SubItems.Add(d.StockAmount.ToString()); li.SubItems.Add(d.Price.ToString()); li.SubItems.Add(drankService.StockCheck(d)); lv_Drank.Items.Add(li); } } else if (panelName == "Kassa") { //Hide all the other panels pnl_Dashboard.Hide(); img_Dashboard.Hide(); pnl_Students.Hide(); pnl_Lecturers.Hide(); pnl_Rooms.Hide(); pnl_Activiteitenlijst.Hide(); pnl_Drank.Hide(); pnl_Omzetrapportage.Hide(); pnl_Begeleiders.Hide(); //show the Kassa panel pnl_Kassa.Show(); cmb_Students.Items.Clear(); Student_Service studentService = new Student_Service(); List <Student> studentList = studentService.GetStudents(); foreach (Student s in studentList) { cmb_Students.Items.Add(s.Studentname); } //eerste student selecteren als standaard. cmb_Students.SelectedIndex = 0; cmb_Drinks.Items.Clear(); Drank_Service drinksService = new Drank_Service(); List <Drank> drankList = drinksService.GetAllDrinks(); foreach (Drank d in drankList) { cmb_Drinks.Items.Add(d.DrankName); } //eerste drank selecteren als standaard. cmb_Drinks.SelectedIndex = 0; Bestelling_Kassa_Service bestellingService = new Bestelling_Kassa_Service(); List <Bestelling> orderList = bestellingService.GetOrders(); //hier de listview van de bestellingen leegmaken om daarna weer te kunnen vullen lv_Bestelling.Items.Clear(); foreach (Bestelling b in orderList) { //drankService.StockCheck(d); ListViewItem Order = new ListViewItem(b.Bestellingsnummer.ToString()); Order.SubItems.Add(b.Datum.ToString()); Drank Ordereddrank = drinksService.GetDrankById(b.Dranknummer); Order.SubItems.Add(Ordereddrank.DrankName.ToString()); Student OrderedStudent = studentService.GetStudentById(b.Studentnummer); Order.SubItems.Add(OrderedStudent.Studentname.ToString()); lv_Bestelling.Items.Add(Order); } } else if (panelName == "Omzetrapportage") { //Hide all the other panels pnl_Dashboard.Hide(); img_Dashboard.Hide(); pnl_Students.Hide(); pnl_Lecturers.Hide(); pnl_Rooms.Hide(); pnl_Activiteitenlijst.Hide(); pnl_Drank.Hide(); pnl_Kassa.Hide(); pnl_Begeleiders.Hide(); //show this panel pnl_Omzetrapportage.Show(); } else if (panelName == "Begeleiders") { //Hide all the other panels pnl_Dashboard.Hide(); img_Dashboard.Hide(); pnl_Students.Hide(); pnl_Lecturers.Hide(); pnl_Rooms.Hide(); pnl_Activiteitenlijst.Hide(); pnl_Drank.Hide(); pnl_Kassa.Hide(); pnl_Omzetrapportage.Hide(); //show this panel pnl_Begeleiders.Show(); Begeleider_Service begeleiderService = new Begeleider_Service(); List <Begeleider> begeleiderList = begeleiderService.GetBegeleiders(); lv_Begeleiders.Items.Clear(); cmb_Begeleiders.Items.Clear(); foreach (Begeleider b in begeleiderList) { ListViewItem li = new ListViewItem(b.Begeleidernummer.ToString()); li.SubItems.Add(b.Teachernumber.ToString()); li.SubItems.Add(b.Teachername.ToString()); li.SubItems.Add(b.Subject.ToString()); li.SubItems.Add(b.Teacherroomnumber.ToString()); lv_Begeleiders.Items.Add(li); cmb_Begeleiders.Items.Add(b.Begeleidernummer.ToString()); } cmb_Begeleiders.SelectedIndex = 0; Teacher_Service teacherService = new Teacher_Service(); List <Teacher> teacherList = teacherService.GetTeachers(); cmb_Docenten.Items.Clear(); foreach (Teacher t in teacherList) { cmb_Docenten.Items.Add(t.Teachernumber); } cmb_Docenten.SelectedIndex = 0; } }
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); } }