コード例 #1
0
        private void LoginButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            string matricId = usernameText.Text;
            string password = passwordText.Password;
            if (this._validateUser(matricId, password))
            {
                Console.WriteLine("authentication successful");
                model.Student student = model.DomainModels.StudentModel.getByMatricId(matricId);

                // Create NavigationData object to store values and transport them between pages.
                NavigationData navData = new NavigationData();
                navData.loggedInUser = student;

                EventsScreen eventsScreen = new EventsScreen();
                eventsScreen.SetupNavigationHandler(this.NavigationService);
                this.NavigationService.Navigate(eventsScreen, navData);
            }
            else
            {
                MessageBox.Show(
                    "Your matriculation number and password were not recognized. Please check and try again.",
                    "Authentication Failed",
                    MessageBoxButton.OK,
                    MessageBoxImage.Exclamation
                );
                Console.WriteLine("authentication failed");
            }
        }
コード例 #2
0
        private void cancelButton_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show("Are you sure you wish to cancel? Any unsaved changes will be lost!", "Cancel", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (result == MessageBoxResult.Yes)
            {
                // Redirect back to Event Main screen with notify box showing that it is cancelled.
                NavigationData navData = new NavigationData();
                navData.loggedInUser = this._loggedInUser;

                EventsScreen eventsScreen = new EventsScreen();
                eventsScreen.SetupNavigationHandler(this.NavigationService);
                this.NavigationService.Navigate(eventsScreen, navData);
            }
        }
コード例 #3
0
        private void saveButton_Click(object sender, RoutedEventArgs e)
        {
            if (this._curEvent.Id != -1)
            {
                // Update entry to database.
                model.DomainModels.EventModel.updateObj(this._curEvent);
                /*model.DomainModels.EventModel.update(
                    this._curEvent.Id,
                    this._loggedInUser.MatricId,
                    this._curEvent.Name,
                    this._curEvent.VenueId,
                    this._curEvent.Start,
                    this._curEvent.End,
                    this._curEvent.Capacity,
                    Convert.ToInt32(this._curEvent.Budget),
                    this._curEvent.Description,
                    this._curEvent.ViewAtLoginPage
               );*/
            }
            else
            {
                // Create new event entry to database.
                model.DomainModels.EventModel.createObj(this._curEvent);
                /*model.DomainModels.EventModel.create(
                    this._loggedInUser.MatricId,
                    this._curEvent.Name,
                    this._curEvent.VenueId,
                    this._curEvent.Start,
                    this._curEvent.End,
                    this._curEvent.Capacity,
                    Convert.ToInt32(this._curEvent.Budget),
                    this._curEvent.Description,
                    this._curEvent.ViewAtLoginPage
               );*/
            }

            // Redirect back to Event Main screen with notify box showing that it has been saved.
            NavigationData navData = new NavigationData();
            navData.loggedInUser = this._loggedInUser;
            navData.statusCode = NavigationData.STATUS_NOTICE;

            if (this._curEvent.Id != -1)
            {
                navData.statusMessage = "Your event has been successfully edited.";
            }
            else
            {
                navData.statusMessage = "Your event has been successfully created.";
            }

            EventsScreen eventsScreen = new EventsScreen();
            eventsScreen.SetupNavigationHandler(this.NavigationService);
            this.NavigationService.Navigate(eventsScreen, navData);
        }