private void CreateEventList() { CommnunityEvents = new List<community_event>(); // call the extract Data method. ExtractData(); if (CommnunityEvents.Count > 0) { //if there are no events for the date selected display the following eventComboBox.Text = " -Events- "; descriptionTextBox.Text = "Pick an event"; } else { //if there are no events for the date selected display the following eventComboBox.Text = " No Events "; descriptionTextBox.Text = "No events today."; } } //Assignment 4 Part 2 – Create Method ExtractData private void ExtractData() { CommnunityEvents.Clear(); // load the data from the file List<community_event> tempList = new List<community_event>(); //string[] fileLines = File.ReadLines(@"C:\Users\IAN\Documents\calendar.txt"); foreach(string line in File.ReadLines("Calendar.txt")) { string[] items = line.Split(",".ToCharArray()); Community_Event newEvent = new Community_Event(); newEvent.Day = Convert.ToInt32(items[0]);//Converting the Integer to a string. newEvent.Time = items[1]; newEvent.Price = Convert.ToDecimal(items[2]);//Converting the decimal to a string. newEvent.Event = items[3]; newEvent.Description = items[4]; } CommnunityEvents = (from ev in tempList where ev.Day == 1 select ev).ToList(); } private void dateMonthCalendar_DateChanged(object sender, DateRangeEventArgs e) { //calling the create event list method to display any events in the eventscombo box. CreateEventList(); } private void eventComboBox_SelectedIndexChanged(object sender, EventArgs e) { /*display time, price and desription of any events selected in the combo box and display them in the description TextBox*/ } private void descriptionTextBox_TextChanged(object sender, EventArgs e) { } private void TicketInformationForm_Load(object sender, EventArgs e) { //calling the create event list to open the form //with today's events displayed if any. CreateEventList(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)