コード例 #1
0
ファイル: ExamForm.cs プロジェクト: ConorForsey/QuickExams
 public ExamForm(int examId, MainStudentForm mainStudentForm)
 {
     this.Text = "Quick Exams - Student: " + GlobalConfig.CurrentUser.FirstName + " " + GlobalConfig.CurrentUser.LastName + " - User ID: " + GlobalConfig.CurrentUser.UserId;
     InitializeComponent();
     mExamController        = new ExamController();
     mStudentForm           = mainStudentForm;
     mExamId                = examId;
     mSelectionRadioButtons = new List <RadioButton>();
     mSelectionRadioButtons.Add(uiAnswer1RadioButton);
     mSelectionRadioButtons.Add(uiAnswer2RadioButton);
     mSelectionRadioButtons.Add(uiAnswer3RadioButton);
     mSelectionRadioButtons.Add(uiAnswer4RadioButton);
 }
コード例 #2
0
ファイル: LoginForm.cs プロジェクト: ConorForsey/QuickExams
        private async void uiLoginButton_Click(object sender, EventArgs e)
        {
            String username = uiUsernameTextBox.Text;
            String password = uiPasswordTextBox.Text;

            bool Authenticated = await loginController.SQLConnector().AuthenticateUserAsync(username, password);

            if (Authenticated)
            {
                GlobalConfig.CurrentUser = await loginController.SQLConnector().GetUserAsync(username, password);

                User currentUser = GlobalConfig.CurrentUser;

                switch (currentUser.RoleType)
                {
                case RoleType.Student:
                    setMessageLabelVisible(false);
                    this.Hide();                                                //Hide Login form
                    MainStudentForm studentForm = new MainStudentForm();        //Initialise and declare form
                    studentForm.Text = "Quick Exams - Student: " + currentUser.FirstName + " " + currentUser.LastName + " - User ID: " + currentUser.UserId;
                    studentForm.ShowDialog();                                   //Open form
                    this.Close();
                    break;

                case RoleType.Teacher:
                    setMessageLabelVisible(false);
                    this.Hide();                                                //Hide Login form
                    MainTeacherForm teacherForm = new MainTeacherForm();        //Initialise and declare form
                    teacherForm.Text = "Quick Exams - Teacher: " + currentUser.FirstName + " " + currentUser.LastName + " - User ID: " + currentUser.UserId;
                    teacherForm.ShowDialog();                                   //Open form
                    this.Close();                                               //Close login form
                    break;

                case RoleType.Admin:

                    break;

                default:
                    break;
                }
            }
            else
            {
                setMessageLabelVisible(true);
            }
        }