Exemple #1
0
        /// <summary>
        /// add the customer to specific gymclass
        /// </summary>
        /// <param name="Class">GymClass object that the customer choose</param>
        public void AddToClass(GymClass Class)
        {
            //check if the class have reached full capcaety(isFull)
            if (Class.isFull())
            {
                MessageBox.Show("Class have reached maximum capacity");
                return;
            }
            //if the customer not registered to any class yet 
            else if (this.listGymClass.Count() == 0)
            {
                //add the gymclass to the customer object
                this.listGymClass.Add(Class);
                //add the preson to the gymclass listed customer 
                Class.AddNewPersonToClass(this);
                MessageBox.Show("you just registered to " + Class.getClassName() + " you can see details,just click the View Registered button ");
                return;

            }
            else
            {
                //if the customer already registered to the class he choose
                if (this.listGymClass.Contains(Class))
                {
                    MessageBox.Show("You already registerd to this class.(You can see which course you already registered,just click the View Registered button)");
                    return;
                }


                else
                {//for each class the customer registered , we checked if the hours between his classes to the new classes conflicted
                    foreach (GymClass Element in this.listGymClass)
                    {
                        if (Class.hoursCollied(Element) == true)
                        {
                            MessageBox.Show("Hours conflicted with another class you are registered to");
                            return;
                        }

                    }
                }
            }

            this.listGymClass.Add(Class);
            Class.AddNewPersonToClass(this);

            MessageBox.Show("you just registered to " + Class.getClassName() + " you can see detail ,just clicked the View Registered button");

        }
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            //check what the user choose and get the specific gymclass
            Class = allgymClasses.Find(g => (g.getClassName().Equals(comboBox1.Text)));
            if (Class != null)
            {
                labelClassName.Text = Class.getClassName();
                labelClassRagisterd.Text = Class.getClassListed().ToString();
                labelClassCapacity.Text = Class.getClassCapacity().ToString();
                labelInstructorName.Text = Class.getClassInstructor().getNameFirst() + " " + Class.getClassInstructor().getNameLast();
                label10.Text = Class.getTimeDay();
                label12.Text = Class.getTimeHours();
                //check if the customer already registered to the choosen class if he is switch the button text from add to delete
                if (Curr.getListGymClass().Any(g => g.getClassName().Equals(comboBox1.Text)))
                {
                    buttonAddSelected.Text = "Delete Selected";
                }
                else
                {
                    buttonAddSelected.Text = "Add Selected";
                }
            }
            else
            {
                labelClassName.Text ="";
                labelClassRagisterd.Text = "";
                labelClassCapacity.Text = "";
                labelInstructorName.Text = "";
                label10.Text = "";
                label12.Text = "";
            }







        }
Exemple #3
0
        /// <summary>
        /// remove customer from choosen gymclass
        /// </summary>
        /// <param name="Class">GymClass object that the customer choose</param>
        public void RemoveFromClass(GymClass Class)
        {
            //checking if the customer is registered to the class
            if (!(this.listGymClass.Any(x => x.getClassName().Equals(Class.getClassName()))))
            {
                MessageBox.Show("You are not registered to " + Class.getClassName());
                return;
            }
            this.listGymClass.Remove(Class);
            Class.DeleteCustomerFromClass(this);

        }