Exemplo n.º 1
0
        public void SearchTables(object sender, RoutedEventArgs args)
        {
            if (comboTableSearch.SelectedIndex != -1)
            {
                lblSearchMessage.Content = String.Empty;
                TablesList tablesLeft = new TablesList();
                Timing     timing     = comboTableSearch.SelectedItem as Timing;

                var tableQuery = from table in tables.Tables
                                 select table;

                foreach (Table table in tableQuery)
                {
                    var timingsQuery = from startTiming in table.Timings.Timings
                                       where startTiming.StartTime == timing.StartTime
                                       select startTiming.Duration;

                    if (timingsQuery.ToList().Count == 0)
                    {
                        tablesLeft.Add(table);
                    }
                }

                listBoxTables.ItemsSource       = tablesLeft.Tables;
                listBoxTables.DisplayMemberPath = "TableInfo";
            }
            else
            {
                lblSearchMessage.Content = "Please select a time to search!";
            }
        }
Exemplo n.º 2
0
        public void FetchTables()
        {
            XmlReaderSettings settings = new XmlReaderSettings();

            settings.IgnoreWhitespace = true;
            settings.IgnoreComments   = true;


            try
            {
                reader = XmlReader.Create("Tables.xml", settings);
                if (reader.ReadToDescendant("Table"))
                {
                    do
                    {
                        Table table = new Table();
                        reader.ReadStartElement("Table");
                        table.TableNumber = reader.ReadElementContentAsString();;
                        table.Seats       = uint.Parse(reader.ReadElementContentAsString());
                        table.TableInfo   = "Table - " + table.TableNumber + " | Seats - " + table.Seats.ToString();
                        tables.Add(table);
                    } while (reader.ReadToNextSibling("Table"));
                }
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.Message);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }