Exemplo n.º 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;
            }
        }
Exemplo n.º 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;
            }
        }
Exemplo n.º 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;
            }
        }
Exemplo n.º 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;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Event intepretuje wybrany rekord z SearchEmpList DataGrid i zapisuje wybraną klase do zmiennej.
        /// </summary>
        private void EmpDataGridSearchRowClick(object sender, MouseButtonEventArgs e)
        {
            var txt = (e.OriginalSource as TextBlock).Text;

            if (txt != null)
            {
                int ID;
                if (!int.TryParse(txt, out ID))
                {
                    var row = sender as DataGridRow;

                    var cell = DataGridTools.GetCell(SearchEmpList, row, 1);
                    cell.IsEnabled = false;

                    ID = int.Parse((cell.Content as TextBlock).Text);
                }

                SearchEmpList.Visibility = Visibility.Collapsed;
                currentEmployer          = context.Employees.Find(ID);
                employerChecked          = true;
                empTextBlock.Text        = currentEmployer.FirstName + " " + currentEmployer.LastName;
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Event intepretuje wybrany rekord z SearchEmpList DataGrid i otwiera wybranego pracownika w stronie EmployePage.
        /// </summary>
        private void EmpDataGridSearchRowClick(object sender, MouseButtonEventArgs e)
        {
            var txt = (e.OriginalSource as TextBlock).Text;

            if (txt != null)
            {
                int ID;
                if (!int.TryParse(txt, out ID))
                {
                    var row = sender as DataGridRow;

                    var cell = DataGridTools.GetCell(SearchEmpList, row, 1);
                    cell.IsEnabled = false;

                    ID = int.Parse((cell.Content as TextBlock).Text);
                }

                SearchEmpList.Visibility = Visibility.Collapsed;
                var empPage = new EmployePage(ID);
                var window  = (Window)this.Parent;
                window.Content = empPage;
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Event intepretuje wybrany rekord z SearchClassList DataGrid i zapisuje wybraną klase do zmiennej.
        /// </summary>
        private void ClassDataGridSearchRowClick(object sender, MouseButtonEventArgs e)
        {
            var txt = (e.OriginalSource as TextBlock).Text.ToLower();

            if (txt != null)
            {
                int ID;
                if (!int.TryParse(txt, out ID))
                {
                    var row = sender as DataGridRow;

                    var cell = DataGridTools.GetCell(SearchClassList, row, 1);
                    cell.IsEnabled = false;

                    ID = int.Parse((cell.Content as TextBlock).Text);
                }

                SearchClassList.Visibility = Visibility.Collapsed;
                roomClass         = context.RoomsClass.Find(ID);
                classChecked      = true;
                classTextBox.Text = roomClass.ClassName;
            }
        }