示例#1
0
        private void CheckOut_Click(object sender, EventArgs e)
        {
            string student = "";

            student = comboBoxStudents.Text;

            List <string> drink = new List <string>();

            foreach (var item in checkedListBoxDrinks.CheckedItems.OfType <CashRegister>())
            {
                if (item.Stock < 1)
                {
                    MessageBox.Show("Sorry!! Not Enough Stock of " + item.Name + "!!");
                    continue;
                }

                drink.Add(item.Name);
            }
            if (drink == null && drink.Count == 0)
            {
                // there is no drink in the list to buy
                MessageBox.Show("Nothing to buy!!");
                return;
            }


            if (student != "" && drink[0] != "")
            {
                SomerenLogic.Cash_Service studService = new SomerenLogic.Cash_Service();
                studService.InsertCashBill(student, drink);
                comboBoxStudents.ResetText();
                foreach (int i in checkedListBoxDrinks.CheckedIndices)
                {
                    checkedListBoxDrinks.SetItemCheckState(i, CheckState.Unchecked);
                }
            }
            else
            {
                MessageBox.Show("Please Enter all values");
            }
        }
示例#2
0
        private void showPanel(string panelName)
        {
            try
            {
                if (panelName == "Dashboard")
                {
                    // hide all other panels
                    pnl_Students.Hide();
                    //thigns i added
                    pnl_Teachers.Hide();
                    pnl_Students.Hide();
                    pnl_Rooms.Hide();
                    pnl_Sales.Hide();
                    pnl_Drinks.Hide();
                    pnl_Activities.Hide();
                    panel_TimeTable.Hide();
                    pnl_Supervisors.Hide();



                    //this is for the barservice
                    pnl_BarService.Hide();
                    // show dashboard
                    pnl_Dashboard.Show();
                    img_Dashboard.Show();
                }
                else if (panelName == "Students")
                {
                    // hide all other panels
                    pnl_Dashboard.Hide();
                    img_Dashboard.Hide();
                    //things i added
                    pnl_Teachers.Hide();
                    pnl_Rooms.Hide();
                    pnl_Sales.Hide();
                    pnl_Drinks.Hide();
                    pnl_Activities.Hide();
                    panel_TimeTable.Hide();
                    pnl_Supervisors.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();

                    listViewStudents.Clear();
                    listViewStudents.View = View.Details;
                    listViewStudents.Columns.Add("Student Id", 100, HorizontalAlignment.Left);
                    listViewStudents.Columns.Add("First Name", 100, HorizontalAlignment.Left);
                    listViewStudents.Columns.Add("Last Name", 100, HorizontalAlignment.Left);
                    listViewStudents.Columns.Add("Class", 100, HorizontalAlignment.Left);
                    listViewStudents.Columns.Add("Contact Info", 100, HorizontalAlignment.Left);

                    // clear the listview before filling it again

                    foreach (SomerenModel.Student s in studentList)
                    {
                        ListViewItem li = new ListViewItem(s.Number.ToString());
                        li.SubItems.Add(s.FirstName);
                        li.SubItems.Add(s.LastName);
                        li.SubItems.Add(s.Group);
                        li.SubItems.Add(s.Contact);
                        listViewStudents.Items.Add(li);
                    }
                }
                else if (panelName == "Teachers")
                {
                    // hide all other panels
                    pnl_Dashboard.Hide();
                    img_Dashboard.Hide();
                    //things that i added -stephen
                    pnl_Students.Hide();
                    pnl_Rooms.Hide();
                    pnl_BarService.Hide();
                    pnl_Sales.Hide();
                    pnl_Drinks.Hide();
                    pnl_Activities.Hide();
                    panel_TimeTable.Hide();
                    pnl_Supervisors.Hide();



                    // show Teachers
                    pnl_Teachers.Show();


                    // fill the teacher listview within the teacher panel with a list of teachers
                    SomerenLogic.Teacher_Service teacherService = new SomerenLogic.Teacher_Service();
                    List <Teacher> teacherList = teacherService.GetTeachers();

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

                    foreach (SomerenModel.Teacher t in teacherList)
                    {
                        ListViewItem ListofT = new ListViewItem(t.Number.ToString());
                        ListofT.SubItems.Add(t.firstName);
                        ListofT.SubItems.Add(t.lastName);
                        ListofT.SubItems.Add(t.supervisor);
                        ListofT.SubItems.Add(t.Department);
                        ListofT.SubItems.Add(t.Contact.ToString());
                        listViewTeachers.Items.Add(ListofT);
                    }

                    // this is for the display
                    listViewTeachers.GridLines     = true;
                    listViewTeachers.FullRowSelect = true;
                    listViewTeachers.View          = View.Details;
                    listViewTeachers.Columns.Add("Teacher ID", 100, HorizontalAlignment.Left);
                    listViewTeachers.Columns.Add("First Name", 100, HorizontalAlignment.Left);
                    listViewTeachers.Columns.Add("Last Name", 100, HorizontalAlignment.Left);
                    listViewTeachers.Columns.Add("Supervisor", 100, HorizontalAlignment.Left);
                    listViewTeachers.Columns.Add("Department", 100, HorizontalAlignment.Left);
                    listViewTeachers.Columns.Add("Contact info.", 100, HorizontalAlignment.Left);
                }
                else if (panelName == "Rooms")
                {
                    // hide all other panels
                    pnl_Dashboard.Hide();
                    img_Dashboard.Hide();
                    pnl_Students.Hide();
                    pnl_Teachers.Hide();
                    pnl_BarService.Hide();
                    pnl_Sales.Hide();
                    pnl_Drinks.Hide();
                    pnl_Activities.Hide();
                    panel_TimeTable.Hide();
                    pnl_Supervisors.Hide();



                    //show rooms
                    pnl_Rooms.Show();


                    //fill the rooms listview within rooms panel with a list of rooms
                    SomerenLogic.Room_Service studService = new SomerenLogic.Room_Service();
                    List <Room> roomList = studService.GetRooms();

                    // clear the listview before filling it again
                    listViewRooms.Clear();
                    listViewRooms.View = View.Details;
                    listViewRooms.Columns.Add("Room Id", 100, HorizontalAlignment.Left);
                    listViewRooms.Columns.Add("TypeOfRoom", 100, HorizontalAlignment.Left);
                    listViewRooms.Columns.Add("Taken/Not-Taken", 100, HorizontalAlignment.Left);
                    listViewRooms.Columns.Add("Size", 100, HorizontalAlignment.Left);



                    foreach (SomerenModel.Room r in roomList)
                    {
                        ListViewItem li = new ListViewItem(r.Room_Id.ToString());
                        li.SubItems.Add(r.Type);
                        li.SubItems.Add(r.Occupied);
                        li.SubItems.Add(r.Size.ToString());

                        listViewRooms.Items.Add(li);
                    }
                }
                else if (panelName == "Cash Register")
                {
                    pnl_Dashboard.Hide();
                    pnl_Students.Hide();
                    pnl_Teachers.Hide();
                    pnl_Rooms.Hide();
                    pnl_Sales.Show();
                    pnl_Drinks.Hide();
                    panel_TimeTable.Hide();
                    pnl_Supervisors.Hide();



                    SomerenLogic.Cash_Service studService = new SomerenLogic.Cash_Service();
                    //List<CashRegister> drList = studService.GetDrinks();
                    SomerenLogic.Student_Service ss = new SomerenLogic.Student_Service();
                    List <Student> stList           = ss.GetStudents();
                    comboBoxStudents.DataSource    = stList;
                    comboBoxStudents.DisplayMember = "Name";
                    //checkedListBoxDrinks.DataSource = drList;
                    checkedListBoxDrinks.DisplayMember = "Name";
                }

                else if (panelName == "Bar Service")
                {
                    // hide all other panels
                    pnl_Dashboard.Hide();
                    img_Dashboard.Hide();
                    pnl_Students.Hide();
                    pnl_Teachers.Hide();
                    pnl_Rooms.Hide();
                    pnl_Sales.Hide();
                    pnl_Drinks.Hide();
                    pnl_Activities.Hide();



                    //show the
                    //pnl_BarService.Show();
                }
                else if (panelName == "Drinks")
                {
                    pnl_Dashboard.Hide();
                    img_Dashboard.Hide();
                    pnl_Students.Hide();
                    pnl_Teachers.Hide();
                    pnl_Rooms.Hide();
                    pnl_Sales.Hide();
                    pnl_BarService.Hide();
                    pnl_Activities.Hide();
                    panel_TimeTable.Hide();
                    pnl_Supervisors.Hide();



                    pnl_Drinks.Show();

                    ShowData();
                }
                else if (panelName == "Sales Report")
                {
                    // hide all other panels
                    pnl_Dashboard.Hide();
                    img_Dashboard.Hide();
                    pnl_Students.Hide();
                    pnl_Teachers.Hide();
                    pnl_Rooms.Hide();
                    pnl_Sales.Hide();
                    pnl_Drinks.Hide();
                    pnl_Activities.Hide();
                    panel_TimeTable.Hide();
                    pnl_Supervisors.Hide();



                    StartCalendar.MaxDate = DateTime.Today;//this is for the calendar to only show the dates til today.


                    //show the
                    pnl_BarService.Show();

                    //this is to show all the transaction.. with no specific date, just all the current transaction in the
                    //the database.

                    SomerenLogic.Revenue_Service revenueService = new SomerenLogic.Revenue_Service();
                    List <Revenue> revenueList = revenueService.GetRevenue();


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

                    foreach (SomerenModel.Revenue r in revenueList)
                    {
                        ListViewItem ListofRev = new ListViewItem((r.Students).ToString());//(r.Date.ToString("yyyy-dd-MM"));
                        //ListViewItem ListofRev = new ListViewItem((r.Date).ToString("dd-MM-yyyy"));
                        ListofRev.SubItems.Add((r.Price).ToString());
                        ListofRev.SubItems.Add((r.Prod_Sold).ToString());
                        ListofRev.SubItems.Add((r.Date).ToString("dd-MM-yyyy"));
                        ListofRev.SubItems.Add((r.Turnover).ToString());

                        listViewRevenue.Items.Add(ListofRev);
                    }


                    listViewRevenue.GridLines     = true;
                    listViewRevenue.FullRowSelect = true;
                    listViewRevenue.View          = View.Details;
                    listViewRevenue.Columns.Add("Student", 100, HorizontalAlignment.Left);
                    listViewRevenue.Columns.Add("Price", 100, HorizontalAlignment.Left);
                    listViewRevenue.Columns.Add("Amount product Sold", 120, HorizontalAlignment.Left);
                    listViewRevenue.Columns.Add("Date", 100, HorizontalAlignment.Left);
                    listViewRevenue.Columns.Add("Turnover", 100, HorizontalAlignment.Left);

                    //clear the list after for the display when the date is selecteds


                    lblmsg.Text   = "General overview of transaction";
                    lblStart.Text = "";
                    lblEnd.Text   = "";
                }
                else if (panelName == "Activities")
                {
                    //hide

                    // hide all other panels
                    pnl_Dashboard.Hide();
                    img_Dashboard.Hide();
                    pnl_Students.Hide();
                    pnl_Teachers.Hide();
                    pnl_Rooms.Hide();
                    pnl_Sales.Hide();
                    pnl_Drinks.Hide();
                    panel_TimeTable.Hide();
                    pnl_Supervisors.Hide();


                    //show
                    pnl_Activities.Show();

                    SomerenLogic.Activities_Service activityService = new SomerenLogic.Activities_Service();
                    List <Activity> activityList = activityService.GetActivity();

                    //clear listview before filling in the informations
                    listViewActivity.Clear();

                    //the informations that needs to be shown
                    foreach (SomerenModel.Activity a in activityList)
                    {
                        ListViewItem ListofActivities = new ListViewItem(a.ID.ToString());
                        ListofActivities.SubItems.Add((a.Description));
                        ListofActivities.SubItems.Add(a.numbOfStudent.ToString());
                        ListofActivities.SubItems.Add(a.numbOfTeacher.ToString());
                        ListofActivities.Tag = a;

                        listViewActivity.Items.Add(ListofActivities);
                    }

                    listViewActivity.GridLines     = true;
                    listViewActivity.FullRowSelect = true;
                    listViewActivity.View          = View.Details;
                    listViewActivity.Columns.Add("Activity ID", 100, HorizontalAlignment.Left);
                    listViewActivity.Columns.Add("Description", 100, HorizontalAlignment.Left);
                    listViewActivity.Columns.Add("Number Of Students", 100, HorizontalAlignment.Left);
                    listViewActivity.Columns.Add("Number Of Supervisors", 100, HorizontalAlignment.Left);
                }
                else if (panelName == "Supervisors")
                {
                    pnl_Dashboard.Hide();
                    img_Dashboard.Hide();
                    pnl_Students.Hide();
                    pnl_Teachers.Hide();
                    pnl_Rooms.Hide();
                    pnl_Sales.Hide();
                    pnl_Drinks.Hide();
                    pnl_BarService.Hide();
                    pnl_Activities.Hide();
                    panel_TimeTable.Hide();


                    pnl_Supervisors.Show();

                    //displaying datagridview in another method
                    DisplayDataSup();

                    //to get all the info from teacher's table
                    SomerenLogic.Teacher_Service teacherdb = new SomerenLogic.Teacher_Service();
                    List <Teacher> TeacherList             = teacherdb.GetTeachers();

                    combo_Teacher.DataSource = TeacherList;
                    //only displaying the first name in the combo box
                    combo_Teacher.DisplayMember = "FirstName";
                }
                //time table
                else if (panelName == "Time Table")
                {
                    pnl_Dashboard.Hide();
                    img_Dashboard.Hide();
                    pnl_Students.Hide();
                    pnl_Teachers.Hide();
                    pnl_Rooms.Hide();
                    pnl_Sales.Hide();
                    pnl_Drinks.Hide();
                    pnl_Activities.Hide();
                    pnl_BarService.Hide();
                    pnl_Activities.Hide();
                    pnl_Supervisors.Hide();

                    //to show
                    panel_TimeTable.Show();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                StreamWriter writer = new StreamWriter($"errorLog.txt", true);
                writer.WriteLine($"{ DateTime.Now}, error message:  {e.Message}");
                writer.Close();
            }
        }