Пример #1
0
        /// <summary>
        /// Dodaje do SearchEmpList DataGrid, rekordy spełniające wpisany warunek w empTextBlock TextBox.
        /// </summary>
        private void EmpSearchTextChanged(object sender, TextChangedEventArgs args)
        {
            if (!employerChecked)
            {
                var emps = (from e in context.Employees
                            orderby e.LastName
                            select new { Employee = (e.LastName + " " + e.FirstName), ID = e.EmployeeID });;

                var empsList = emps.ToList();
                empsList.Clear();

                SearchEmpList.Visibility  = Visibility.Collapsed;
                SearchEmpList.ItemsSource = null;

                string txt = (sender as TextBox).Text.ToLower();
                if (txt != "")
                {
                    SearchEmpList.Visibility = Visibility.Visible;
                    foreach (var e in emps.ToList())
                    {
                        var names = e.Employee.ToLower().Split();
                        try
                        {
                            if (int.TryParse(txt, out int ID))
                            {
                                if (DataGridTools.CheckString(e.ID.ToString(), ID.ToString()))
                                {
                                    empsList.Add(e);
                                }
                            }

                            if (DataGridTools.CheckString(names[0], txt))
                            {
                                empsList.Add(e);
                            }
                            if (DataGridTools.CheckString(names[1], txt))
                            {
                                if (!empsList.Exists(elem => elem == e))
                                {
                                    empsList.Add(e);
                                }
                            }
                        }
                        catch (IndexOutOfRangeException)
                        {
                        }
                    }


                    SearchEmpList.ItemsSource = empsList;
                }
            }
            else
            {
                employerChecked = false;
            }
        }
Пример #2
0
        /*SearchBoxs*/

        /// <summary>
        /// Dodaje do SearchCustomersList DataGrid, rekordy spełniające wpisany warunek w customerSearch TextBox.
        /// </summary>
        private void CustomerSearchTextChanged(object sender, TextChangedEventArgs args)
        {
            if (!customerChecked)
            {
                var customers = (from c in context.Customers
                                 orderby c.LastName
                                 select new { Customer = (c.LastName + " " + c.FirstName), ID = c.CustomerID });;

                var customersList = customers.ToList();
                customersList.Clear();

                SearchCustomersList.Visibility  = Visibility.Collapsed;
                SearchCustomersList.ItemsSource = null;

                string txt = (sender as TextBox).Text.ToLower();
                if (txt != "")
                {
                    SearchCustomersList.Visibility = Visibility.Visible;

                    foreach (var e in customers.ToList())
                    {
                        var names = e.Customer.ToLower().Split();
                        try
                        {
                            if (int.TryParse(txt, out int ID))
                            {
                                if (DataGridTools.CheckString(e.ID.ToString(), ID.ToString()))
                                {
                                    customersList.Add(e);
                                }
                            }

                            if (DataGridTools.CheckString(names[0], txt))
                            {
                                customersList.Add(e);
                            }
                            if (DataGridTools.CheckString(names[1], txt))
                            {
                                if (!customersList.Exists(elem => elem == e))
                                {
                                    customersList.Add(e);
                                }
                            }
                        }
                        catch (IndexOutOfRangeException)
                        {
                        }
                    }

                    SearchCustomersList.ItemsSource = customersList;
                }
            }
            else
            {
                customerChecked = false;
            }
        }
Пример #3
0
        /// <summary>
        /// Dodaje do reservationsList DataGrid, rekordy spełniające wpisany warunek w TextBox reservationSearch.
        /// </summary>
        private void ReservSearchTextChanged(object sender, TextChangedEventArgs args)
        {
            var reservations = (from r in context.Reservations
                                orderby r.Customer
                                select new { Customer = r.Customers.LastName + " " + r.Customers.FirstName, ID = r.ReservID });;

            var reservationsList = reservations.ToList();

            reservationsList.Clear();

            SearchReservList.Visibility  = Visibility.Collapsed;
            SearchReservList.ItemsSource = null;

            string txt = (sender as TextBox).Text.ToLower();

            if (txt != "")
            {
                SearchReservList.Visibility = Visibility.Visible;
                foreach (var e in reservations.ToList())
                {
                    var names = e.Customer.ToLower().Split();
                    try
                    {
                        if (int.TryParse(txt, out int ID))
                        {
                            if (DataGridTools.CheckString(e.ID.ToString(), ID.ToString()))
                            {
                                reservationsList.Add(e);
                            }
                        }

                        if (DataGridTools.CheckString(names[0], txt))
                        {
                            reservationsList.Add(e);
                        }
                        if (DataGridTools.CheckString(names[1], txt))
                        {
                            if (!reservationsList.Exists(elem => elem == e))
                            {
                                reservationsList.Add(e);
                            }
                        }
                    }
                    catch (IndexOutOfRangeException)
                    {
                    }
                }

                SearchReservList.ItemsSource = reservationsList;
            }
        }
Пример #4
0
        /*SearchBox*/

        /// <summary>
        /// Dodaje do SearchClassList DataGrid, rekordy spełniające wpisany warunek w TextBox classTextBox.
        /// </summary>
        private void ClassSearchTextChanged(object sender, TextChangedEventArgs args)
        {
            if (!classChecked)
            {
                var classes = (from c in context.RoomsClass
                               orderby c.ClassName
                               select new { ClassName = c.ClassName, ID = c.ClassID });;

                var classesList = classes.ToList();
                classesList.Clear();

                SearchClassList.Visibility  = Visibility.Collapsed;
                SearchClassList.ItemsSource = null;

                string txt = (sender as TextBox).Text.ToLower();
                if (txt != "")
                {
                    SearchClassList.Visibility = Visibility.Visible;

                    foreach (var e in classes.ToList())
                    {
                        var name = e.ClassName.ToLower();
                        try
                        {
                            if (int.TryParse(txt, out int ID))
                            {
                                if (DataGridTools.CheckString(e.ID.ToString(), ID.ToString()))
                                {
                                    classesList.Add(e);
                                }
                            }

                            if (DataGridTools.CheckString(name, txt))
                            {
                                classesList.Add(e);
                            }
                        }
                        catch (IndexOutOfRangeException)
                        {
                        }
                    }

                    SearchClassList.ItemsSource = classesList;
                }
            }
            else
            {
                classChecked = false;
            }
        }