protected void Page_Load(object sender, EventArgs e)
        {
            var data   = new DataServiceContext();
            var source = data.GetResultOfCheckingDto();
            var result = Mapper.Map <IEnumerable <ResultOfCheckingDto>, IEnumerable <ResultOfCheckingViewModel> > (source);

            ListViewResult.DataSource = result;
            ListViewResult.DataBind();
        }
예제 #2
0
        //This event controls the actions, if the Button "Verbindung suchen" is clicked.
        private void BtnConnections_Click(object sender, EventArgs e)
        {
            //The items and columns in the ListView will be cleared if the button is clicked. Also 4 new Colums are getting created.
            //The Event .Items.Clear and .Colums.Clear, deletes eery item and every Column in the ListView.
            //.Columns.Add ist responsible for creating new Colums. These colums are used to view the Details for the Route.
            ListViewResult.Items.Clear();
            ListViewResult.Columns.Clear();
            ListViewResult.Columns.Add("Gleis");
            ListViewResult.Columns.Add("Abfahrt");
            ListViewResult.Columns.Add("Dauer");
            ListViewResult.Columns.Add("Ankunft");

            //In this section of the Code the Connections are geting calculated.
            //The object "transport" ist geting created from the class "SwissTransoport.Transport"
            //The variable "foundConnections" is geting defined. Now the Values from the two Comboboxes are written to the variable.
            //The ListView gets again cleared from the Items. If the user wants to search for another connection between two new Stations,
            //The Items will be cleared if the user clicks the button again.
            //Now the foreach loop calculates the connections between the two stations, which are selected by the user.

            SwissTransport.Transport transport = new SwissTransport.Transport();
            DateTime dtDate = this.DateTimeDate.Value;
            DateTime dtTime = this.DateTimeClock.Value;

            //var foundConnections = transport.GetConnections(ComboBoxStart.Text, ComboBoxEnd.Text, dtDate, dtTime);
            ListViewResult.Items.Clear();
            foreach (Connection conn in transport.GetConnections(ComboBoxStart.Text, ComboBoxEnd.Text, dtDate, dtTime).ConnectionList)

            {
                //The Date and the Time is geting parsed from the Depature and Arrival time.
                //After this step, the string for the ListView is getting created. the Values for the connection are saved in the string now.
                //Then, the String is added to the Listview with the .Items.Add(lvitem)
                //In the end the Colums are getting auto resized, for a better view.
                DateTime     dtDeparture = DateTime.Parse(conn.From.Departure);
                DateTime     dtArrival   = DateTime.Parse(conn.To.Arrival);
                String[]     item        = { conn.From.Platform, dtDeparture.ToString(), conn.Duration, dtArrival.ToString() };
                ListViewItem lvitem      = new ListViewItem(item);
                ListViewResult.Items.Add(lvitem);
                ListViewResult.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                ListViewResult.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
            }
        }
예제 #3
0
        //With this Button, the Connections from one Station will be showed to the user.
        private void btnTimetable_Click(object sender, EventArgs e)
        {
            try
            {
                //Again the items and de colums are getting cleared, and new Columns are getting created.
                ListViewResult.Items.Clear();
                ListViewResult.Columns.Clear();
                ListViewResult.Columns.Add("Verkehrsmittel");
                ListViewResult.Columns.Add("Nach");
                ListViewResult.Columns.Add("Abfahrt");
                ListViewResult.Columns.Add("Betreiber");
                DateTime dtDate = this.DateTimeDate.Value;
                DateTime dtTime = this.DateTimeClock.Value;

                //In this section the Departures from one selected station will be calculated.
                DateTime         DtDate     = this.DateTimeDate.Value;
                DateTime         DtTime     = this.DateTimeClock.Value;
                string           strAbfahrt = ComboBoxStart.SelectedItem.ToString();
                string           id         = mainTransport.GetStations(strAbfahrt).StationList[0].Id;
                StationBoardRoot sbRoot     = mainTransport.GetStationBoard(strAbfahrt, id, dtDate, dtTime);
                //In this loop, the Results for the Departures are getting calculated, and the Items will be wirtten down,
                //to a string, then, a new ListViewItem is created and will be written down in the ListView.
                foreach (StationBoard sb in sbRoot.Entries)
                {
                    String[]     result = { sb.Name, sb.To, sb.Stop.Departure.ToString(), sb.Operator };
                    ListViewItem lvItem = new ListViewItem(result);
                    ListViewResult.Items.Add(lvItem);
                }
                //In the end the Colums are getting auto resized again, for a better view.
                ListViewResult.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                ListViewResult.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
            }
            catch
            {
            }
        }