Ejemplo n.º 1
0
 public MainWindow()
 {
     InitializeComponent();
     WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
     myDataHandler         = this.InitializeListBox_PlayerList;
     GOLFDB.ProcessRecord(myDataHandler);
 }
Ejemplo n.º 2
0
        private void GridViewColumnHeaderClickedHandler(object sender, RoutedEventArgs e)
        {
            GridViewColumnHeader headerClicked =
                e.OriginalSource as GridViewColumnHeader;
            ListSortDirection direction;

            if (headerClicked != null)
            {
                if (headerClicked.Role != GridViewColumnHeaderRole.Padding)
                {
                    if (_lastHeaderClicked != null && headerClicked != _lastHeaderClicked)
                    {
                        direction = ListSortDirection.Ascending;
                    }
                    else
                    {
                        if (_lastDirection == ListSortDirection.Ascending)
                        {
                            direction = ListSortDirection.Descending;
                        }
                        else
                        {
                            direction = ListSortDirection.Ascending;
                        }
                    }

                    string header = headerClicked.Column.Header as string;
                    string SQL    = " ORDER BY ";
                    switch (header)
                    {
                    case "ID": SQL += GOLFDB.ID; break;

                    case "Title": SQL += GOLFDB.Title; break;

                    case "First Name": SQL += GOLFDB.FirstName + "+" + GOLFDB.SurName; break;

                    case "Last Name": SQL += GOLFDB.SurName + "+" + GOLFDB.FirstName; break;

                    case "Gender": SQL += GOLFDB.Gender; break;

                    case "Handicap": SQL += GOLFDB.Handicap; break;

                    case "DOB": SQL += GOLFDB.DOB; break;

                    case "Street": SQL += GOLFDB.Street; break;

                    case "Suburb": SQL += GOLFDB.Suburb; break;

                    case "City": SQL += GOLFDB.City; break;

                    case "Available": SQL += "[" + GOLFDB.Availiable_Week_Days + "]"; break;
                    }

                    SQL += " " + (direction == ListSortDirection.Ascending ? "ASC" : "DESC");
                    this.ListView_Players.Items.Clear();
                    GOLFDB.ProcessRecord(myDataHandler, SQL);
                    _lastHeaderClicked = headerClicked;
                    _lastDirection     = direction;
                }
            }
        }