コード例 #1
0
        private void Change_Docents_Click(object sender, EventArgs e)
        {
            string value = "";

            if (txtValue.Text == "")
            {
                MessageBox.Show("The value can't be nothing");
                return;
            }
            if (!IsInt(txtValue.Text))
            {
                MessageBox.Show("Not a valid value(Only number, No comma's)");
                return;
            }
            try
            {
                value = txtValue.Text;
                ListViewItem item = listViewActivity.SelectedItems[0];
                SomerenLogic.Activity_Service activity_Service = new Activity_Service();
                activity_Service.UpdateDocent(value, int.Parse(item.Text));
            }
            catch (ArgumentOutOfRangeException)
            {
                MessageBox.Show("Select an item");
                return;
            }

            showPanel("Activity");
        }
コード例 #2
0
ファイル: SomerenUI.cs プロジェクト: Salati00/Project_1
        private void Btn_Activities_Add_Click(object sender, EventArgs e)
        {
            Activity_Service eys = new Activity_Service();

            if (!Btn_Activities_Delete.Visible)
            {
                try
                {
                    eys.InsertActivity(Txt_Activities_Name.Text, Txt_Activities_Location.Text, (Dtp_Activities_DatePart.Value.Date + Dtp_Activities_TimePart.Value.TimeOfDay), Txt_Activities_Description.Text);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                try
                {
                    eys.UpdateActivity(Convert.ToInt32(Txt_Activities_Id.Text), Txt_Activities_Name.Text, Txt_Activities_Location.Text, (Dtp_Activities_DatePart.Value.Date + Dtp_Activities_TimePart.Value.TimeOfDay), Txt_Activities_Description.Text);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

            Btn_Activities_Add.Text       = "Add";
            Btn_Activities_Delete.Visible = false;

            showPanel("Activities");
        }
コード例 #3
0
        private void AddActivityForm_Load(object sender, EventArgs e)
        {
            calendarActivity.MinDate = DateTime.Today;

            Activity_Service activity_service = new Activity_Service();
            List <string>    activityTypes    = activity_service.GetActivityTypes();

            cmbActivityTypes.Items.Add("Create own activity type");

            foreach (string s in activityTypes) //fill the combo box with the activity types
            {
                cmbActivityTypes.Items.Add(s);
            }

            for (int i = 1; i <= 24; i++)
            {
                cmbHour.Items.Add(i.ToString());
            }

            for (int i = 0; i <= 55; i += 5)
            {
                cmbMins.Items.Add(i.ToString());
            }

            cmbHour.SelectedIndex = 0;
            cmbMins.SelectedIndex = 0;
        }
コード例 #4
0
        private void btnDeleteActivity_Click(object sender, EventArgs e)
        {
            SomerenLogic.Activity_Service activity_Service = new Activity_Service();

            // check for empty field
            if (String.IsNullOrEmpty(txtDeleteId.Text))
            {
                MessageBox.Show("No id was given!");
                return; // when field is empty, display message and return
            }

            // get value from textbox
            int id = int.Parse(txtDeleteId.Text);

            // validate the users choice by asking via a messagebox
            string            message = "Are you sure you want to delete this activity?";
            string            caption = "Deleting an activity";
            MessageBoxButtons buttons = MessageBoxButtons.YesNo; // yes and no button
            DialogResult      result;

            // get the result from the messagebox
            result = MessageBox.Show(this, message, caption, buttons);

            // when user says yes, delete the acticvity
            if (result == DialogResult.Yes)
            {
                activity_Service.DeleteActivity(id);
            }
        }
        //code van de methode voor het wijzigen van de geselecteerde activiteit in een te wijzigen of verwijderen activiteit van de activiteitenlijst
        private void Cmb_Activiteiten_SelectedIndexChanged(object sender, EventArgs e)
        {
            Activity_Service activityService = new Activity_Service();

            //het op nul zetten van de text in de wijzigen/verwijderen textboxen (gebruikt bij testen/debuggen)
            Txtactiviteitnr.Text           = "";
            Txtactiviteitomschrijving.Text = "";
            Txtaantalstudenten.Text        = "";
            Txtaantaldocenten.Text         = "";

            EditOrDeleteCalendar.MaxSelectionCount = 1;

            //de twee regels hieronder om de gebruikte ActiviteitcmbBoxToString() string te gebruiken om vervolgens het juiste activiteitnummer te kunnen gebruiken om in de database te kunnen zoeken en op te halen (geen combobox indexnummers meer nodig)
            string selectedActivity = cmb_Activiteiten.GetItemText(cmb_Activiteiten.SelectedItem);

            int activitynumber = int.Parse(selectedActivity);

            Activity activity = activityService.GetActivityById(activitynumber);

            Txtactiviteitnr.Text                = activity.Number.ToString();
            Txtactiviteitomschrijving.Text      = activity.Description.ToString();
            EditOrDeleteCalendar.SelectionStart = activity.StartTime;
            Txtaantalstudenten.Text             = activity.NumberofStudents.ToString();
            Txtaantaldocenten.Text              = activity.NumberofLecturers.ToString();

            Txtactiviteitnr.Enabled = false;
        }
        //Code voor de wijzigingsknop in en van de activiteiten in de activiteitenlijst
        private void Btnwijzigen_Click(object sender, EventArgs e)
        {
            Activity_Service activityService = new Activity_Service();

            int activityNumber = int.Parse(Txtactiviteitnr.Text);

            string NewDescription = Txtactiviteitomschrijving.Text;

            DateTime NewStartTime = EditOrDeleteCalendar.SelectionRange.Start;

            int NewNumberofStudents = int.Parse(Txtaantalstudenten.Text);

            int NewNumberofLecturers = int.Parse(Txtaantaldocenten.Text);

            if (NewDescription != "" && NewStartTime != null && NewNumberofStudents != 0 && NewNumberofLecturers != 0)
            {
                activityService.EditActivity(activityNumber, NewDescription, NewStartTime, NewNumberofStudents, NewNumberofLecturers);
            }
            else
            {
                lbl_ActivityErrorMessage.Text = "Niet alle velden zijn volledig of correct ingevuld!";
            }

            ShowPanel("Activities");
        }
コード例 #7
0
        private List <Activity> GetActivities()
        {
            Activity_Service activityService = new Activity_Service();
            List <Activity>  activityList    = activityService.GetActivities();

            activityList = activityList.OrderBy(activity => activity.ActivityName).ToList();
            return(activityList);
        }
コード例 #8
0
ファイル: SomerenUI.cs プロジェクト: Salati00/Project_1
        private void Btn_Activities_Delete_Click(object sender, EventArgs e)
        {
            Activity_Service eys = new Activity_Service();

            if (MessageBox.Show("Are you sure you want to delete this item?", "Confirm Delete!", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                eys.RemoveActivity(Convert.ToInt32(Txt_Activities_Id.Text));
                EnDisableActivityButtons(Override: true);
            }
        }
コード例 #9
0
        private void RefreshActivityPanel()
        {
            txtActivityID.Enabled     = false;
            btnRemoveActivity.Enabled = false;
            btnUpdateActivity.Enabled = false;

            txtActivityID.ResetText();
            txtActivityDescription.ResetText();
            txtActivityDate.ResetText();
            txtStartTime.ResetText();
            txtEndTime.ResetText();

            //fill activity list with all activities retrieved from the database
            Activity_Service activityService = new Activity_Service();
            List <Activity>  activities      = activityService.GetAllActivities();

            //Clear listview before filling again
            listViewActivities.Clear();

            //fill listview with list from database
            foreach (Activity a in activities)
            {
                ListViewItem lvi = new ListViewItem(a.activityID.ToString(), 0);
                lvi.SubItems.Add(a.description);
                lvi.SubItems.Add(a.startDate.ToString("dd-MM-yyyy HH:mm"));
                lvi.SubItems.Add(a.endDate.ToString("dd-MM-yyyy HH:mm"));
                lvi.Tag = a;

                listViewActivities.Items.Add(lvi);
            }

            //Add Columns
            ColumnHeader actId = new ColumnHeader();

            actId.Text = "Activity ID";

            ColumnHeader desc = new ColumnHeader();

            desc.Text = "Description";

            ColumnHeader start = new ColumnHeader();

            start.Text = "StartDate/Time";

            ColumnHeader end = new ColumnHeader();

            end.Text = "EndDate/Time";

            listViewActivities.Columns.AddRange(new ColumnHeader[] { actId, desc, start, end });

            listViewActivities.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            listViewActivities.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
        }
コード例 #10
0
        private void btn_Remove_Activity_Click(object sender, EventArgs e)
        {
            var      selectedItem     = listViewActivities.SelectedItems[0];
            Activity selectedActivity = activities.Where(t => t.countStudents == int.Parse(selectedItem.Text)).FirstOrDefault();

            DialogResult dr = MessageBox.Show("Do you want to remove this activity?", "Removing activity", MessageBoxButtons.YesNo);

            if (dr == DialogResult.Yes)
            {
                Activity_Service actService = new Activity_Service();
                actService.DeleteActivity(selectedActivity.Id);
            }
            btn_Edit_Activities.Enabled = false;
            btn_Add_Activity.Enabled    = false;
        }
コード例 #11
0
ファイル: SomerenUI.cs プロジェクト: Sholden8340/Someren1920F
        private void buttonDeleteActivity_Click(object sender, EventArgs e)
        {
            groupBoxEdit.Hide();

            ListViewItem     item       = listViewActivities.SelectedItems[0];
            Activity_Service activitydb = new Activity_Service();

            DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete this activity?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (dialogResult == DialogResult.Yes)
            {
                activitydb.RemoveActivity(int.Parse(item.SubItems[0].Text));
            }

            showPanel("Activities");
        }
コード例 #12
0
        private void btnChangeActivity_Click(object sender, EventArgs e)
        {
            SomerenLogic.Activity_Service activity_Service = new Activity_Service();

            // check for empty fields
            if (String.IsNullOrEmpty(txtChangeActivityId.Text) || String.IsNullOrEmpty(txtChangeActivityName.Text))
            {
                MessageBox.Show("Field(s) empty!");
                return; // when fields are empty display message and return
            }

            // get values from textboxes
            int    id          = int.Parse(txtChangeActivityId.Text);
            string description = txtChangeActivityName.Text;

            // change activity
            activity_Service.ChangeActivity(id, description);
        }
コード例 #13
0
        private void btnAddActivity_Click(object sender, EventArgs e)
        {
            SomerenLogic.Activity_Service activity_Service = new Activity_Service();

            // check for empty fields
            if (String.IsNullOrEmpty(txtAddActivityId.Text) || String.IsNullOrEmpty(txtAddDescription.Text))
            {
                MessageBox.Show("Field(s) empty!");
                return; // when a field is empty, display message and return
            }

            // get all values from the textboxes
            int    id          = int.Parse(txtAddActivityId.Text);
            string description = txtAddDescription.Text;

            // insert the activity, reference to service layer
            activity_Service.InsertActivity(id, description);
        }
コード例 #14
0
ファイル: SomerenUI.cs プロジェクト: Sholden8340/Someren1920F
        private void buttonActivitySave_Click(object sender, EventArgs e)
        {
            if (textBoxActivityDescription.Text != null && textBoxActivityName.Text != null && textBoxActivityStudents.Text != null && textBoxActivitySupervisors.Text != null)
            {
                Activity_Service activitydb = new Activity_Service();
                if (groupBoxEdit.Text == "Add")
                {
                    if (listViewActivities.Items.Contains(listViewActivities.FindItemWithText(textBoxActivityName.Text)))
                    {
                        MessageBox.Show("This Activity Already Exists", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    Activity a = new Activity
                    {
                        ID                  = -1,
                        Name                = textBoxActivityName.Text,
                        Description         = textBoxActivityDescription.Text,
                        NumberOfStudents    = int.Parse(textBoxActivityStudents.Text),
                        NumberOfSupervisors = int.Parse(textBoxActivitySupervisors.Text),
                    };
                    activitydb.AddActivity(a);
                }
                else if (groupBoxEdit.Text == "Edit")
                {
                    ListViewItem item = listViewActivities.SelectedItems[0];
                    Activity     a    = new Activity
                    {
                        ID                  = int.Parse(item.SubItems[0].Text),
                        Name                = textBoxActivityName.Text,
                        Description         = textBoxActivityDescription.Text,
                        NumberOfStudents    = int.Parse(textBoxActivityStudents.Text),
                        NumberOfSupervisors = int.Parse(textBoxActivitySupervisors.Text),
                    };
                    activitydb.EditActivity(a);
                }

                showPanel("Activities");
            }
            else
            {
                MessageBox.Show("Fields cannot be empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #15
0
        private void btnNewActivity_Click(object sender, EventArgs e)
        {
            if (NewName.Text == "" || NewStudents.Text == "" || NewDocents.Text == "")
            {
                MessageBox.Show("De invoer boxen mogen niet leeg zijn. Probeer het opnieuw makker");
                return;
            }
            try
            {
                SomerenLogic.Activity_Service activity_Service = new Activity_Service();
                activity_Service.NewActivity(NewName.Text, int.Parse(NewStudents.Text), int.Parse(NewDocents.Text));
            }
            catch (ArgumentOutOfRangeException)
            {
                MessageBox.Show("Geen geldig cijfer");
            }

            showPanel("Activity");
        }
コード例 #16
0
        private void Delete_Click(object sender, EventArgs e)
        {
            DialogResult confirmation = MessageBox.Show("Are you sure?", "sure?", MessageBoxButtons.YesNo);

            if (confirmation == DialogResult.Yes)
            {
                try
                {
                    ListViewItem item = listViewActivity.SelectedItems[0];
                    SomerenLogic.Activity_Service activity_Service = new Activity_Service();
                    activity_Service.Delete(int.Parse(item.Text));
                }
                catch (ArgumentOutOfRangeException)
                {
                    MessageBox.Show("Select an item");
                    return;
                }
            }
            showPanel("Activity");
        }
コード例 #17
0
        private void btn_insert_Click(object sender, EventArgs e)
        {
            SomerenLogic.Activity_Service activity_Service = new Activity_Service();

            Activity activity = new Activity()
            {
                name                = txtname.Text,
                numberofstudents    = int.Parse(txtnrstud.Text),
                numberofsupervisors = int.Parse(txtnrsup.Text)
            };


            activity_Service.AddActivity(activity);

            showPanel("Activities");

            txtname.Clear();
            txtnrstud.Clear();
            txtnrsup.Clear();
        }
        //code voor de toevoegknop van een nieuwe activiteit in de activiteitenlijst
        private void Btntoevoegen_Click(object sender, EventArgs e)
        {
            Activity_Service activityService = new Activity_Service();

            AddCalendar.MaxSelectionCount = 1;

            string AddedDescription = Txtaddomschrijving.Text;

            DateTime AddedStartTime = AddCalendar.SelectionRange.Start;

            int AddedNumberofStudents = int.Parse(Txtaddstudentenaantal.Text);

            int AddedNumberofLecturers = int.Parse(Txtadddocentenaantal.Text);

            if (AddedDescription != "" && AddedStartTime != null && AddedNumberofStudents != 0 && AddedNumberofLecturers != 0)
            {
                activityService.AddNewActivity(AddedDescription, AddedStartTime, AddedNumberofStudents, AddedNumberofLecturers);
            }

            ShowPanel("Activities");
        }
        //Code voor de verwijderknop in en van de activiteiten in de activiteitenlijst
        private void Btnverwijderen_Click(object sender, EventArgs e)
        {
            string message = "Weet u zeker dat u deze activiteit wilt verwijderen?";
            string caption = "Activiteit verwijderen";
            var    result  = MessageBox.Show(message, caption, MessageBoxButtons.YesNo);

            if (result == DialogResult.No)
            {
                ShowPanel("Activities");
            }
            else if (result == DialogResult.Yes)
            {
                Activity_Service activityService = new Activity_Service();

                int activityNumber = int.Parse(Txtactiviteitnr.Text);

                activityService.DeleteActivity(activityNumber);
            }

            ShowPanel("Activities");
        }
コード例 #20
0
        public void loadDataViews()
        {
            Activity_Service actService = new Activity_Service();
            List <Activity>  activities = actService.getActivities();

            Participant_Service prtService   = new Participant_Service();
            List <Participant>  participants = prtService.getParticipants();

            DataGridView gridView = new DataGridView();

            foreach (Activity activity in activities)
            {
                switch (activity.ActivityStartDate.DayOfWeek)
                {
                case (DayOfWeek.Monday):
                    gridView = gridViewMon;
                    break;

                case (DayOfWeek.Tuesday):
                    gridView = gridViewTue;
                    break;

                case (DayOfWeek.Wednesday):
                    gridView = gridViewWed;
                    break;

                case (DayOfWeek.Thursday):
                    gridView = gridViewThu;
                    break;

                case (DayOfWeek.Friday):
                    gridView = gridViewFri;
                    break;
                }

                int rowId = gridView.Rows.Add();

                DataGridViewRow row = gridView.Rows[rowId];

                row.Cells[0].Value = activity.ActivityName;

                string counsellorList = "";

                foreach (Participant participant in participants)
                {
                    if (participant.ActivityId == activity.ActivityId && participant.ParticipancyType == "CNS")
                    {
                        counsellorList += participant.UserId.ToString();
                        counsellorList += ", ";
                    }
                }

                if (counsellorList == "")
                {
                    counsellorList = "Onbegeleid";
                }
                else
                {
                    counsellorList = counsellorList.Remove(counsellorList.Length - 2);
                }


                row.Cells[1].Value = counsellorList;
            }
        }
        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;
            }
        }
コード例 #22
0
        private void btnApply_Click(object sender, EventArgs e)
        {
            Activity_Service activityService = new Activity_Service();

            if (cmbActivityTypes.SelectedIndex <= 0 && txtCreateActivity.Text.Length == 0)
            {
                MessageBox.Show("You need to select an activity type!", "Select activity", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                bool          error = false;
                string        activityType;
                List <string> activityTypes = activityService.GetActivityTypes();

                // if there is nothing selected in the combo box or the index 0 is selected, use the text box as the activity type
                if (cmbActivityTypes.SelectedIndex <= 0)
                {
                    activityType = txtCreateActivity.Text;

                    foreach (string s in activityTypes) //check if that activity type already exists
                    {
                        if (s.ToLower() == activityType.ToLower())
                        {
                            MessageBox.Show("Activity type already exists!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            error = true;
                        }
                    }

                    if (!error) // if there are no errors, add the new activity type
                    {
                        activityService.AddActivityType(activityType);
                    }
                }

                else
                {
                    activityType = cmbActivityTypes.SelectedItem.ToString();
                }

                //format the activity date into a string
                string activityDate = calendarActivity.SelectionStart.Year.ToString() + "-"
                                      + calendarActivity.SelectionStart.Month.ToString("00") + "-"
                                      + calendarActivity.SelectionStart.Day.ToString("00");

                if (cmbHour.SelectedItem.ToString().Length < 2)
                {
                    activityDate += " 0" + cmbHour.SelectedItem.ToString();
                }
                else
                {
                    activityDate += " " + cmbHour.SelectedItem.ToString();
                }

                if (cmbMins.SelectedItem.ToString().Length < 2)
                {
                    activityDate += ":0" + cmbMins.SelectedItem.ToString();
                }
                else
                {
                    activityDate += ":" + cmbMins.SelectedItem.ToString();
                }


                if (!error)
                {
                    Activity _activity = new Activity(activityType, activityDate);
                    _activity.activity_Date = DateTime.ParseExact(activityDate, "yyyy-MM-dd HH:mm", null);

                    DateTime _startTime = _activity.activity_Date;
                    //create a random duration for the activity, between 30 minutes and 120 minutes(only divisible by 5)
                    Random rnd             = new Random();
                    int    activityMinutes = rnd.Next(6, 25) * 5;
                    //set the activity end time to the start time + the activity minutes
                    DateTime _endTime = _startTime.AddMinutes(activityMinutes);

                    activityService.AddActivity(_activity);
                    Activity  activityTime = activityService.GetBiggestId();
                    Timetable timetable    = new Timetable()
                    {
                        activity  = activityTime,
                        startTime = _startTime,
                        endTime   = _endTime
                    };
                    activityService.AddTimetable(timetable);

                    MessageBox.Show("New activity added!\nRefresh to see changes!", "Succes", MessageBoxButtons.OK);
                }
            }
        }
コード例 #23
0
ファイル: SomerenUI.cs プロジェクト: Salati00/Project_1
        private void showPanel(string panelName)
        {
            switch (panelName)
            {
            case "Students":
                Student_Service studService = new Student_Service();
                List <Student>  studentList = studService.GetStudents();

                ListViewStuPrint(listViewStudents, studentList);
                break;

            case "Lecturers":
                Lecturer_Service lecService = new Lecturer_Service();
                List <Teacher>   lecList    = lecService.GetTeachers();

                ListViewLecPrint(listView_Lec, lecList);
                break;

            case "Supervisors":
                Supervisor_Service supService = new Supervisor_Service();
                List <Supervisor>  supList    = supService.GetSupervisors();
                PrintSup(listView_Sup, supList);
                Activity_Service actService = new Activity_Service();
                List <Activity>  actList    = actService.GetActivities();
                cmb_ActivityID.DataSource    = actList;
                cmb_ActivityID.DisplayMember = "Name";
                cmb_ActivityID.ValueMember   = "ID";
                break;

            case "Rooms":
                Room_Service roomService = new Room_Service();
                List <Room>  roomList    = roomService.GetRooms();

                ListViewRoomPrint(listViewRooms, roomList);
                break;

            case "DrinkSup":
                Btn_Supplies_Save.Enabled  = false;
                Txt_Supplies_Id.Text       = string.Empty;
                Txt_Supplies_NewName.Text  = string.Empty;
                Txt_Supplies_NewStock.Text = string.Empty;
                Txt_Supplies_Price.Text    = string.Empty;
                Txt_Supplies_Sold.Text     = string.Empty;

                // fill the students listview within the students panel with a list of students
                Drink_Service drinkService = new Drink_Service();
                List <Drink>  DrinkList    = drinkService.GetDrinks();

                ListViewStockPrint(Lst_Supplies, DrinkList);
                break;

            case "Activities":
                Dtp_Activities_TimePart.Format       = DateTimePickerFormat.Custom;
                Dtp_Activities_TimePart.CustomFormat = "hh:mm tt";
                Dtp_Activities_TimePart.ShowUpDown   = true;

                Txt_Activities_Id.Text          = "";
                Txt_Activities_Description.Text = "";
                Txt_Activities_Location.Text    = "";
                Txt_Activities_Name.Text        = "";
                Dtp_Activities_DatePart.Value   = DateTime.Today;
                Dtp_Activities_TimePart.Value   = DateTime.UtcNow;

                Activity_Service actServe     = new Activity_Service();
                List <Activity>  ActivityList = actServe.GetActivities();

                ListViewActivitiesPrint(Lst_Activities, ActivityList);
                break;

            case "CashRegister":
                FillRegistryStudents();
                FillRegistryDrinks();
                Btn_Register_Checkout.Enabled = false;
                break;

            case "RevRep":
                mcRev.MaxDate = DateTime.Today;
                PrintReport();
                break;

            case "Timetable":
                Timetable_Service timeServ      = new Timetable_Service();
                List <Timetable>  TimetableList = timeServ.GetTimetable();

                ListViewTimetablePrint(listViewTimetable, TimetableList);
                break;

            default:
                break;
            }
        }
コード例 #24
0
        private void ChangeAndAddActivity(string changeoradd)
        {
            //NEW GUIDES
            Activity_Service activity_Service = new Activity_Service();
            List <Guide>     guideNew         = new List <Guide>();
            List <string>    guideNamesNew    = new List <string>();

            if (cbSelectGuideName1.Text != string.Empty)
            {
                Guide guide = new Guide()
                {
                    GuideName   = cbSelectGuideName1.Text,
                    GuideNumber = int.Parse(lblGuideIdOutput1.Text),
                };
                guideNew.Add(guide);
            }
            if (cbSelectGuideName2.Text != string.Empty)
            {
                Guide guide = new Guide()
                {
                    GuideName   = cbSelectGuideName2.Text,
                    GuideNumber = int.Parse(lblGuideIdOutput2.Text),
                };
                guideNew.Add(guide);
            }
            if (cbSelectGuideName3.Text != string.Empty)
            {
                Guide guide = new Guide()
                {
                    GuideName   = cbSelectGuideName3.Text,
                    GuideNumber = int.Parse(lblGuideIdOutput3.Text),
                };
                guideNew.Add(guide);
            }
            if (cbSelectGuideName4.Text != string.Empty)
            {
                Guide guide = new Guide()
                {
                    GuideName   = cbSelectGuideName4.Text,
                    GuideNumber = int.Parse(lblGuideIdOutput4.Text),
                };
                guideNew.Add(guide);
            }

            foreach (Guide guideNameNew in guideNew)
            {
                guideNamesNew.Add(guideNameNew.GuideName);
            }

            bool isUnique = guideNamesNew.Distinct().Count() == guideNamesNew.Count();

            if (isUnique == false)
            {
                throw new Exception($"Not all guidenames are unique ");
            }
            TimeSpan     startTime        = dtpActivityStartDate.Value.TimeOfDay;
            TimeSpan     endTime          = dtpActivityEndDate.Value.TimeOfDay;
            DateTime     date             = dtpActivityDate.Value.Date;
            string       activityName     = txtActivityName.Text;
            int          numberOfStudents = int.Parse(txtNumberOfStudents.Text);
            List <Guide> guideNew2        = new List <Guide>(guideNew);
            List <Guide> guideNew4        = new List <Guide>(guideNew);
            string       output           = "";

            // check of de naam al wordt gebruikt
            activityList = activity_Service.GetActivities();
            foreach (Activity activityL in activityList)
            {
                if (activityL.ActivityName == activityName)
                {
                    string exc = $"There is already an activity with name {activityName}";
                    lblModifyActivityLogOutput.Text = exc;
                    throw new Exception($"There is already an activity with name {activityName}");
                }
            }


            if (changeoradd == "change")
            {
                guides = GetAllGuidesById(int.Parse(lblActivityIdOutput.Text));
                string activityNameOld = cbSelectActivity.Text;
                int    activityId      = int.Parse(lblActivityIdOutput.Text);
                //CHANGE ACTIVITY
                //CHECK OLD WANS
                for (int i = 0; i < guides.Count; i++)
                {
                    //als de nieuwe lijst een persoon uit de oude lijst bevat: schrijf de nieuwe info over de oude persoon heen
                    //if (guideNew.Contains(guides[i]))
                    if (guideNew.Any(guiden => guiden.GuideNumber == guides[i].GuideNumber))
                    {
                        activity_Service.ChangeSchedule(activityId, guides[i].GuideNumber, date, startTime, endTime);
                        //Verwijder uit de nieuwe begeleiderlijst de nog te doorlopen begeleider, je hebt hem hier immers al gecheckt.

                        //CHECK WHO THIS IS AND REMOVE FROM NEW
                        Guide        guideSelect = guides[i];
                        List <Guide> guideNew3   = new List <Guide>(guideNew2);
                        foreach (Guide guideN in guideNew3)
                        {
                            if (guideN.GuideNumber == guideSelect.GuideNumber)
                            {
                                guideNew2.Remove(guideN);
                            }
                        }
                    } //als de nieuwe lijst de persoon uit de oude lijst niet bevat: verwijder de persoon uit de oude lijst
                    else
                    {
                        activity_Service.DeleteFromSchedule(guides[i].GuideNumber);
                    }
                }
                for (int i = 0; i < guideNew2.Count; i++)
                {
                    //Hier zitten nu alleen unieke nieuwe waarden in.
                    activity_Service.AddToSchedule(activityId, guideNew2[i].GuideNumber, date, startTime, endTime);
                }

                if (guideNew4.Count == 0)
                {
                    try
                    {
                        activity_Service.DeleteFromSchedule(0);
                    }
                    catch { };
                    activity_Service.AddToSchedule(activityId, 0, date, startTime, endTime);
                }

                activity_Service.ChangeActivity(activityName, numberOfStudents, guideNamesNew.Count, activityNameOld);

                output = $"{activityName} has been changed in the database ";
                ResetModifyActivity();
                lblModifyActivityLogOutput.Text = output;
            }
            else if (changeoradd == "add")
            {
                //ADD ACTIVITY
                activity_Service.AddToActivities(activityName, numberOfStudents, guideNamesNew.Count);
                //ADD GUIDES
                Activity activity = activity_Service.GetActivityByName(activityName);
                if (guideNew2.Count == 0)
                {
                    for (int i = 0; i < guideNew2.Count; i++)
                    {
                        activity_Service.AddToSchedule(activity.ActivityNumber, guideNew2[i].GuideNumber, date, startTime, endTime);
                    }
                }
                else
                {
                    activity_Service.AddToSchedule(activity.ActivityNumber, 0, date, startTime, endTime);
                }

                lblModifyActivityLogOutput.Text = $"{activityName} has been changed in the database ";
                output = $"{activityName} has been added in the database ";
            }
            ResetModifyActivity();
            lblModifyActivityLogOutput.Text = output;
        }