Пример #1
0
        public static List <SomerenModel.Activities> DB_getActivities()
        {
            // make a sql connection
            SqlConnection connection = openConnectionDB();
            // make a list to store data from DB into it
            List <SomerenModel.Activities> activityList = new List <SomerenModel.Activities>();
            // sql query
            string sqlQuery = "SELECT activity_id, activity_desc, numberofStudents, numberofSupervisors " +
                              "FROM Activities";

            // execute the sql query
            SqlCommand    command = new SqlCommand(sqlQuery, connection);
            SqlDataReader reader  = command.ExecuteReader();

            // read data from DB
            while (reader.Read())
            {
                SomerenModel.Activities activities = new SomerenModel.Activities();

                activities.setId((int)reader["activity_id"]);
                activities.setActivity_desc((string)reader["activity_desc"]);
                activities.setNumOfStudents((int)reader["numberofStudents"]);
                activities.setNumOfSupervisors((int)reader["numberofSupervisors"]);
                activityList.Add(activities);
            }
            // close all connections
            reader.Close();
            connection.Close();

            return(activityList);
        }
Пример #2
0
        public static void deleteActivity(int id)
        {
            // make a new variable of type SomerenModel.Activities in order to store data to it
            SomerenModel.Activities newActivity = new SomerenModel.Activities();

            // store data to the newActivity variable
            newActivity.setId(id);

            // passing data to the DB layer
            SomerenDB.DB_deleteActivity(newActivity);
        }
Пример #3
0
        public static void uppdateActivity(int id, string desc, int numOfStudents, int numberOfSupervisor)
        {
            // make a new variable of type SomerenModel.Activities in order to store data to it
            SomerenModel.Activities newActivity = new SomerenModel.Activities();

            // store data to the newActivity variable
            newActivity.setId(id);
            newActivity.setActivity_desc(desc);
            newActivity.setNumOfStudents(numOfStudents);
            newActivity.setNumOfSupervisors(numberOfSupervisor);

            // passing data to the DB layer
            SomerenDB.DB_uppdateActivity(newActivity);
        }