Beispiel #1
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);
        }