private void searchEvent() { searchEventTextBox.Text = searchEventTextBox.Text.Trim(); ActiveUser userRole = new ActiveUser(currentUser); this.listMainEventView.Items.Clear(); int i; if (searchEventTextBox.Text == "" || searchEventTextBox.Text == "Search Your Event Here") { List<EventEntity> outputEventListing = userRole.viewEventListing(); for (i = 0; i < outputEventListing.Count; i++) { EventEntity outputEvent = outputEventListing[i]; ListViewItem newEvent = new ListViewItem((i + 1).ToString()); newEvent.SubItems.Add(outputEvent.getEventId().ToString()); newEvent.SubItems.Add(outputEvent.getEventName()); newEvent.SubItems.Add(outputEvent.getEventDate().ToString("dd/MM/yy")); newEvent.SubItems.Add(outputEvent.getEventDate().ToString("t")); listMainEventView.Items.Add(newEvent); } displayMainEventList(); } else { List<EventEntity> outputEventListing = userRole.viewEventListingByEventName(searchEventTextBox.Text); for (i = 0; i < outputEventListing.Count; i++) { EventEntity outputEvent = outputEventListing[i]; ListViewItem newEvent = new ListViewItem((i + 1).ToString()); newEvent.SubItems.Add(outputEvent.getEventId().ToString()); newEvent.SubItems.Add(outputEvent.getEventName()); newEvent.SubItems.Add(outputEvent.getEventDate().ToString("dd/MM/yy")); newEvent.SubItems.Add(outputEvent.getEventDate().ToString("t")); listMainEventView.Items.Add(newEvent); } displayMainEventList(); } }
public void initMainEventList() { this.listMainEventView.Hide(); //Clear ListBox Column and Items this.listMainEventView.Columns.Clear(); this.listMainEventView.Items.Clear(); this.listMainEventView.Columns.Insert(0, "No", 50, HorizontalAlignment.Left); this.listMainEventView.Columns.Insert(1, "Id", 0, HorizontalAlignment.Left); this.listMainEventView.Columns.Insert(2, "Event", 220, HorizontalAlignment.Left); this.listMainEventView.Columns.Insert(3, "Date", 80, HorizontalAlignment.Center); this.listMainEventView.Columns.Insert(4, "Time", 80, HorizontalAlignment.Center); //All users can view all current events ActiveUser obtainedAccessUser = new ActiveUser(currentUser); List<EventEntity> mainEventListing = obtainedAccessUser.viewEventListing(); for (int i = 0; i < mainEventListing.Count; i++) { EventEntity outputEvent = mainEventListing[i]; ListViewItem newEvent = new ListViewItem((i + 1).ToString()); newEvent.SubItems.Add(outputEvent.getEventId().ToString()); newEvent.SubItems.Add(outputEvent.getEventName()); newEvent.SubItems.Add(outputEvent.getEventDate().ToString("dd/MM/yy")); newEvent.SubItems.Add(outputEvent.getEventDate().ToString("t")); listMainEventView.Items.Add(newEvent); } listMainEventView.Show(); }