public static void addActivity(string desc, int numOfStudents, int numberOfSupervisor) { // make a list for retrieving data from it List <SomerenModel.Activities> activities = new List <SomerenModel.Activities>(); // linking the list to the DB connection in order to get data from it activities = SomerenDB.DB_getActivities(); // make a new variable of type SomerenModel.Activities in order to store data to it SomerenModel.Activities newActivity = new SomerenModel.Activities(); // make a list to store avtivity description in it List <string> activityDesc = new List <string>(); // add avtivity description to the activityDesc list foreach (SomerenModel.Activities activity in activities) { activityDesc.Add(activity.getActivity_desc().ToLower()); } // make a validation to know if the data entered is diffrenet from DB data if (activityDesc.Contains(desc.ToLower())) { // show a message if the entered data exists in the DB MessageBox.Show("You can not add the same activity twice, please enter another activity name!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { //store data to the newActivity variable newActivity.setActivity_desc(desc); newActivity.setNumOfStudents(numOfStudents); newActivity.setNumOfSupervisors(numberOfSupervisor); // passing data to the DB layer SomerenDB.DB_addActivity(newActivity); // show a messagebox after a successfull addition MessageBox.Show("You have successfully added a new activity!!\n" + "Enter Refresh the list to see the changes", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } }