Example #1
0
        private void show()
        {
            dataGridMovies.ItemsSource = null;
            if (!parseIn())
            {
                return;
            }
            IEnumerable <Movie> results;

            try
            {
                searchC choice = (searchC)comboBox.SelectedValue;
                switch (choice)
                {
                case searchC.Tytul:
                    results = from x in myMovie
                              where x.title.ToLower().Contains(textBoxName.Text.ToLower())
                              select x;
                    dataGridMovies.ItemsSource = myMovie.Intersect(results).ToList();
                    break;

                case searchC.Ocena:
                    results = from x in myMovie
                              where x.rating == Int32.Parse(textBoxName.Text)
                              select x;
                    dataGridMovies.ItemsSource = myMovie.Intersect(results).ToList();
                    break;

                case searchC.Rok_produkcji:
                    results = from x in myMovie
                              where x.year == Int32.Parse(textBoxName.Text)
                              select x;
                    dataGridMovies.ItemsSource = myMovie.Intersect(results).ToList();
                    break;

                case searchC.Kategoria:
                    string str = comboBoxCategory.SelectedItem.ToString();
                    results = from x in myMovie
                              where x.category.ToString().Contains(str)
                              select x;
                    dataGridMovies.ItemsSource = myMovie.Intersect(results).ToList();
                    break;

                default:
                    ShowAll();
                    break;
                }
            }
            catch
            {
            }
        }
Example #2
0
        private bool parseIn()
        {
            bool ok = true;

            textBoxName.Background      = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));
            comboBoxCategory.Background = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));
            int number;

            try
            {
                searchC choice = (searchC)comboBox.SelectedValue;
                switch (choice)
                {
                case searchC.Tytul:
                    if (textBoxName.Text == "")
                    {
                        textBoxName.Background = new SolidColorBrush(Color.FromArgb(255, 255, 55, 55));
                    }
                    break;

                case searchC.Ocena:
                    if (textBoxName.Text == "" || !Int32.TryParse(textBoxName.Text, out number))
                    {
                        textBoxName.Background = new SolidColorBrush(Color.FromArgb(255, 255, 55, 55));
                        ok = false;
                    }
                    break;

                case searchC.Rok_produkcji:
                    if (textBoxName.Text == "" || !Int32.TryParse(textBoxName.Text, out number))
                    {
                        textBoxName.Background = new SolidColorBrush(Color.FromArgb(255, 255, 55, 55));
                        ok = false;
                    }
                    break;

                case searchC.Kategoria:
                    if (comboBoxCategory.SelectedItem == null)
                    {
                        comboBoxCategory.Background = new SolidColorBrush(Color.FromArgb(255, 255, 55, 55));
                        ok = false;
                    }
                    break;
                }
            }
            catch
            {
                ok = false;
            }
            return(ok);
        }