示例#1
0
 // This event handler is fired when the delete activity button is clicked. It deletes an activity from the list of
 // activities that a group is involved with.
 private void BtnDeleteActivity_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         GroupActivityVM activity = (GroupActivityVM)dgGroupActivities.SelectedItem;
         _activityManager.DeleteGroupActivity(activity.ActivityID, activity.GroupID);
         dgGroupActivities.ItemsSource = _groupManager.RetrieveActivitiesByGroupID(lbUserGroups.SelectedItem.ToString());
     }
     catch (Exception)
     {
         MessageBox.Show("You must make an Activity selection.");
     }
 }
示例#2
0
        // This selects a list of group activity view models. They are selected based upon their group ID.
        public List <GroupActivityVM> SelectActivitiesByGroupID(string groupID)
        {
            List <GroupActivityVM> activities = new List <GroupActivityVM>();
            var conn = DBConnection.GetConnection();
            var cmd  = new SqlCommand("sp_select_activities_by_group_id", conn);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@GroupID", groupID);
            try
            {
                conn.Open();
                var reader = cmd.ExecuteReader();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        var activity = new GroupActivityVM();

                        activity.ActivityID   = reader.GetInt32(0);
                        activity.ActivityName = reader.GetString(1);
                        activity.Start        = reader.GetDateTime(2);
                        activity.End          = reader.GetDateTime(3);
                        activity.GroupID      = reader.GetString(4);

                        activities.Add(activity);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }
            return(activities);
        }