Ejemplo n.º 1
0
 private void button_Update_Click(object sender, EventArgs e)
 {
     if ((textBox_Name.Text != "") && (textBox_Price.Text != "") && (textBox_Stock.Text != ""))
     {
         Decimal VAT = 0;
         if (radioButton_No.Checked)
         {
             SomerenLogic.Drinks_Service drink_Db = new SomerenLogic.Drinks_Service();
             drink_Db.UpdateDrinks(ID, textBox_Name.Text, Convert.ToInt32(textBox_Price.Text), Convert.ToInt32(textBox_Stock.Text), radioButton_No.Text, VAT);
             ShowData();
             ClearData();
         }
         else
         {
             SomerenLogic.Drinks_Service drink_Db = new SomerenLogic.Drinks_Service();
             drink_Db.UpdateDrinks(ID, textBox_Name.Text, Convert.ToInt32(textBox_Price.Text), Convert.ToInt32(textBox_Stock.Text), radioButton_Yes.Text, VAT);
             ShowData();
             ClearData();
         }
     }
     else
     {
         MessageBox.Show("Select Field to Update");
     }
 }
Ejemplo n.º 2
0
        private void ShowData()
        {
            //used a datagridview since it was an easier way to display the data, also watched a few youtube videos where they showed it in a datagrid view.
            SomerenLogic.Drinks_Service drinks_db = new SomerenLogic.Drinks_Service();
            List <Drinks> drinkList = drinks_db.GetDrinks();

            dataGridViewDrinks.AutoGenerateColumns = true;
            dataGridViewDrinks.DataSource          = drinkList;
        }
Ejemplo n.º 3
0
        void DisplayDrinks()
        {
            SomerenLogic.Drinks_Service drinkService = new SomerenLogic.Drinks_Service();
            List <Drinks> drinksList = drinkService.GetDrinks();

            foreach (SomerenModel.Drinks item in drinksList)
            {
                if (item != null)
                {
                    comboBoxDrinks.Items.Add(item.DrinkName);
                }
            }
        }
Ejemplo n.º 4
0
        private void button_Delete_Click(object sender, EventArgs e)
        {
            if (textBox_Name.Text != "" && textBox_Price.Text != "" && textBox_Stock.Text != "")
            {
                SomerenLogic.Drinks_Service studService = new SomerenLogic.Drinks_Service();
                studService.DeleteDrinks(ID);


                ShowData();
                ClearData();
            }
            else
            {
                MessageBox.Show("Please Select Record to Update");
            }
        }
Ejemplo n.º 5
0
        public double BerekenBTWHoog(DateTime beginDatum, DateTime eindDatum)
        {
            List <DrinkOrders> alleOrders  = GetDrinkOrders();
            Drinks_Service     d           = new Drinks_Service();
            List <Drinks>      alleDranken = d.GetDrinks();
            //Drinks dranken = new Drinks();


            double totaalprijs = 0;

            double totaalBtwHoog = 0;

            foreach (DrinkOrders order in alleOrders)
            {
                if (order.dateTime >= beginDatum && order.dateTime < eindDatum)
                {
                    string drankNaam = order.DrinkName;
                    double hoeveel   = order.Amount;
                    int    btw       = 21;
                    double prijs     = 0;
                    double orderprijs;

                    foreach (Drinks drink in alleDranken)
                    {
                        if (drink.Naam == drankNaam && drink.BTW == 21)
                        {
                            prijs += drink.Prijs;

                            orderprijs    = hoeveel * prijs;
                            totaalprijs  += orderprijs;
                            totaalBtwHoog = totaalBtwHoog + (btw * 0.01 * orderprijs);
                        }
                    }
                }
            }
            return(totaalBtwHoog);
        }
Ejemplo n.º 6
0
        private void showPanel(string panelName)
        {
            if (IamAdmin == false)
            {
                btnAdd.Hide();
                btnChange.Hide();
                btnRemove.Hide();
                btnSubmit.Hide();
                btn_EditDrinks.Hide();
                btn_saveDrink.Hide();
                btn_Add.Hide();
                btn_Remove.Hide();
            }
            DisplayActivityID();
            //normally hidden stuff:
            //filter panel
            pnl_Filter.Hide();

            if (panelName == "Dashboard")
            {
                // hide all other panels
                pnl_Students.Hide();
                btn_Filter.Hide();
                btn_RemoveFilter.Hide();
                pnl_Activity.Hide();

                // show dashboard
                pnl_Dashboard.Show();
                img_Dashboard.Show();
            }
            else if (panelName == "Activities")
            {
                //
                pnl_Dashboard.Hide();
                img_Dashboard.Hide();
                //pnl_Students.Hide();
                pnl_EditDrink.Hide();
                pnl_Drinks.Hide();
                panel1Activity.Hide();
                panel3Activity.Hide();
                //
                pnl_Activity.Show();
                pnl_Students.Show();

                //
                DisplayListViewActivity();
            }
            else if (panelName == "Students")
            {
                // hide all other panels
                pnl_Dashboard.Hide();
                img_Dashboard.Hide();
                btn_Filter.Hide();
                btn_RemoveFilter.Hide();
                pnl_Drinks.Hide();
                pnl_EditDrink.Hide();
                pnl_Activity.Hide();

                // show students

                lbl_Students.Text = "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();

                //add columns and allign
                listViewStudents.Columns.Add("Student number");
                listViewStudents.Columns[0].Width = 100;
                listViewStudents.Columns.Add("First Name");
                listViewStudents.Columns[1].Width = 125;
                listViewStudents.Columns.Add("Last Name");
                listViewStudents.Columns[2].Width = 125;

                foreach (SomerenModel.Student s in studentList)
                {
                    ListViewItem li = new ListViewItem(s.Number.ToString());
                    li.SubItems.Add(s.FirstName);
                    li.SubItems.Add(s.LastName);
                    listViewStudents.Items.Add(li);
                }
            }
            else if (panelName == "Teachers")
            {
                //hiding the dashboard
                pnl_Dashboard.Hide();
                img_Dashboard.Hide();
                btn_Filter.Hide();
                pnl_Drinks.Hide();
                pnl_EditDrink.Hide();
                btn_RemoveFilter.Hide();
                pnl_Activity.Hide();

                //show teachers
                lbl_Students.Text = "Teachers";
                pnl_Students.Show();

                // fill the Teachers listview within the Teachers panel with a list of lecturers
                SomerenLogic.Lecturers_Service lecService = new SomerenLogic.Lecturers_Service();
                List <Teacher> lecturersList = lecService.GetLecturers();

                // clear the listview before filling it again
                listViewStudents.Clear();

                //Adding columns
                listViewStudents.View = View.Details;
                listViewStudents.Columns.Add("Teacher Number");
                listViewStudents.Columns[0].Width = 100;
                listViewStudents.Columns.Add("Name");
                listViewStudents.Columns[1].Width = 125;

                foreach (SomerenModel.Teacher s in lecturersList)
                {
                    ListViewItem li = new ListViewItem(s.Number.ToString());
                    li.SubItems.Add(s.Name.ToString());
                    listViewStudents.Items.Add(li);
                }
            }
            else if (panelName == "Rooms")
            {
                // hide all other panels
                pnl_Dashboard.Hide();
                img_Dashboard.Hide();
                btn_Filter.Hide();
                pnl_Drinks.Hide();
                pnl_EditDrink.Hide();
                btn_RemoveFilter.Hide();
                pnl_Activity.Hide();

                //show rooms
                pnl_Students.Show();
                lbl_Students.Text = "Rooms     ";


                //filling the roomList a list of rooms
                SomerenLogic.Room_Service roomService = new SomerenLogic.Room_Service();
                List <Room> roomList = roomService.GetRooms();

                //clearing listView
                listViewStudents.Clear();

                //add columns and allign
                listViewStudents.Columns.Add("Room Number");
                listViewStudents.Columns[0].Width = 100;
                listViewStudents.Columns.Add("Type");
                listViewStudents.Columns[1].Width = 125;
                listViewStudents.Columns.Add("Capacity");
                listViewStudents.Columns[2].Width = 125;

                foreach (SomerenModel.Room s in roomList)
                {
                    ListViewItem li = new ListViewItem(s.Number.ToString());
                    if (s.Type == true)
                    {
                        li.SubItems.Add("teacher");
                    }
                    else
                    {
                        li.SubItems.Add("student");
                    }

                    li.SubItems.Add(s.Capacity.ToString());
                    listViewStudents.Items.Add(li);

                    //li.SubItems.Add(s.Type.ToString());
                    //saved for potential later use
                }
            }
            else if (panelName == "Drinks")
            {
                //hiding the dashboard and other panels
                pnl_Dashboard.Hide();
                img_Dashboard.Hide();
                pnl_Students.Hide();
                pnl_EditDrink.Hide();
                btn_Filter.Hide();
                btn_RemoveFilter.Hide();
                pnl_Activity.Hide();

                //show drinks
                lbl_Drinks.Text = "Drinks";
                pnl_Drinks.Show();
                // clear the listview before filling it again
                listViewDrinks.Clear();

                // fill the drinks listview within the drinks panel with a list of drinks
                SomerenLogic.Drinks_Service drinkService = new SomerenLogic.Drinks_Service();
                List <Drinks> drinksList = drinkService.GetDrinks();

                //Adding columns
                listViewDrinks.View = View.Details;
                listViewDrinks.Columns.Add("Name");
                listViewDrinks.Columns[0].Width = 100;
                listViewDrinks.Columns.Add("Stock");
                listViewDrinks.Columns[1].Width = 100;
                listViewDrinks.Columns.Add("Price");
                listViewDrinks.Columns[2].Width = 100;

                foreach (SomerenModel.Drinks d in drinksList)
                {
                    ListViewItem li = new ListViewItem(d.DrinkName.ToString());
                    if (d.Stock >= 10)
                    {
                        li.SubItems.Add("✔️" + "  (" + d.Stock.ToString() + ")");
                    }
                    else
                    {
                        li.SubItems.Add("⚠️" + "  (" + d.Stock.ToString() + ")");
                    }
                    li.SubItems.Add(d.Price.ToString());
                    listViewDrinks.Items.Add(li);
                }
            }
            else if (panelName == "Edit drinks")
            {
                //hiding the dashboard
                pnl_Dashboard.Hide();
                img_Dashboard.Hide();
                pnl_Drinks.Hide();
                pnl_Students.Hide();
                btn_Filter.Hide();
                btn_RemoveFilter.Hide();
                pnl_Activity.Hide();

                //show datagridview drinks
                pnl_EditDrink.Show();
            }
            else if (panelName == "RevenueReport")
            {
                //hide all other panels
                pnl_Dashboard.Hide();
                img_Dashboard.Hide();
                pnl_Activity.Hide();

                //show report
                pnl_Students.Show();
                btn_Filter.Show();
                btn_RemoveFilter.Show();
                lbl_Students.Text = "Revenue Report";

                //clearing listView
                listViewStudents.Clear();

                //prep
                listViewStudents.GridLines = false;

                //calling the list with drinks
                SomerenLogic.Drinks_Service drinkService = new SomerenLogic.Drinks_Service();
                List <Drinks> drinksList = drinkService.GetDrinks();

                //calling the list of students from the register
                SomerenLogic.SomerenDAL CashService  = new SomerenLogic.SomerenDAL();
                List <Register>         registerList = CashService.GetRegister();

                //calculating sales and turnover
                int     Sales = 0, Customers = 0;
                decimal Turnover = 0m;

                foreach (SomerenModel.Drinks s in drinksList)
                {
                    Sales    += s.DrinkSold;
                    Turnover += (s.Price * s.DrinkSold);
                }

                //calculating the amount of customers
                List <string> TempCustomerList = new List <string>();
                foreach (Register s in registerList)
                {
                    if (!TempCustomerList.Contains(s.StudentName))
                    {
                        TempCustomerList.Add(s.StudentName);
                        Customers++;
                    }
                }

                //displaying report
                listViewStudents.Columns.Add("Sales");
                listViewStudents.Columns[0].Width = 100;
                listViewStudents.Columns.Add("Turnover");
                listViewStudents.Columns[1].Width = 100;
                listViewStudents.Columns.Add("Num of Customers");
                listViewStudents.Columns[2].Width = 100;

                ListViewItem li = new ListViewItem(Sales.ToString());
                li.SubItems.Add("€ " + Turnover.ToString("0.00"));
                li.SubItems.Add(Customers.ToString());
                listViewStudents.Items.Add(li);
            }
            else if (panelName == "Supervisors")
            {
                //hiding the dashboard
                pnl_Dashboard.Hide();
                img_Dashboard.Hide();
                pnl_Drinks.Hide();
                pnl_EditDrink.Hide();
                pnl_Students.Hide();
                btn_Filter.Hide();
                btn_RemoveFilter.Hide();
                comboBoxAdd.Items.Clear();
                comboBoxDelete.Items.Clear();

                //show supervisor panel
                pnl_Supervisor.Show();

                // clear the listview before filling it again
                listViewSupervisor.Clear();

                // fill the drinks listview within the supervisor panel with a list of supervisor
                SomerenLogic.Supervisor_Service supervisor_Service = new SomerenLogic.Supervisor_Service();
                List <Supervisor> supervisors = supervisor_Service.GetSupervisors();

                //Adding columns
                listViewSupervisor.View = View.Details;
                listViewSupervisor.Columns.Add("Name");
                listViewSupervisor.Columns[0].Width = 100;
                listViewSupervisor.Columns.Add("ID");
                listViewSupervisor.Columns[1].Width = 100;

                foreach (SomerenModel.Supervisor s in supervisors)
                {
                    ListViewItem li = new ListViewItem(s.name);
                    li.SubItems.Add(s.LecturerID.ToString());
                    listViewSupervisor.Items.Add(li);
                }

                DisplayTeachersComboBox();
                DisplaySupervisorsComboBox();
            }
            else if (panelName == "WeeklyTimetable")
            {
                //hiding all the other stuff
                pnl_Dashboard.Hide();
                img_Dashboard.Hide();
                pnl_Drinks.Hide();
                pnl_EditDrink.Hide();
                pnl_Students.Hide();
                btn_Filter.Hide();
                btn_RemoveFilter.Hide();

                //show report
                pnl_Students.Show();
                lbl_Students.Text = "Weekly Timetable";

                //clearing listView
                listViewStudents.Clear();

                //calling the timetable list
                SomerenLogic.Timetable_Service timetable_Service = new SomerenLogic.Timetable_Service();
                List <Timetable> timetables = timetable_Service.GetTimetables();

                //displaying timetable
                listViewStudents.Columns.Add("Date");
                listViewStudents.Columns[0].Width = 100;
                listViewStudents.Columns.Add("Day of Week");
                listViewStudents.Columns[1].Width = 100;
                listViewStudents.Columns.Add("Activities");
                listViewStudents.Columns[2].Width = 100;
                listViewStudents.Columns.Add("Supervisors");
                listViewStudents.Columns[3].Width = 100;

                int counter = 0;

                foreach (SomerenModel.Timetable s in timetables)
                {
                    ListViewItem li = new ListViewItem(s.Date.ToShortDateString().ToString());
                    li.SubItems.Add(s.Date.DayOfWeek.ToString());
                    li.SubItems.Add(s.Activity);
                    li.SubItems.Add(s.Supervisor);
                    listViewStudents.Items.Add(li);
                    counter++;
                    if (counter == 7)
                    {
                        return;
                    }
                }
            }
        }