예제 #1
0
        // Takes us to the browse session page
        private void buttonBrowse_Click(object sender, EventArgs e)
        {
            //you have seen this plenty of times, I hope it is self explainatory now
            Hide();
            InstructorConsole InstructorSchedule2 = new InstructorConsole("cfrisby");

            InstructorSchedule2.ShowDialog();
            //WeekResourcesAvailabilityPage WeekResourceAvailability = new WeekResourcesAvailabilityPage();
            //WeekResourceAvailability.ShowDialog();
            //CustomerAppointmentsPage CustomerAppointment = new CustomerAppointmentsPage();
            //CustomerAppointment.ShowDialog();
            //CarAssignationPage CarAssignationPage = new CarAssignationPage();
            //CarAssignationPage.ShowDialog();
            Close();
        }
예제 #2
0
        // Clicked when user decides they are ready to log in,
        // Will get username and password, use that to query database and check that username and password are correct.
        // A message box will be used to state whether or not we logged in successfully
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            string username = "", password = "";

            //It checks that the text boxes has something typed in it using a method
            bool hasText = checkTextBoxes();

            if (!hasText)
            {
                MessageBox.Show("Please make sure all fields have data.");
                comboBoxUserType.Focus();
                return;
            }

            //(1) GET the username and password from the text boxes, is good to put them in a try catch
            try
            {
                username = textBoxUserName.Text.Trim();
                password = textBoxPassword.Text.Trim();
            }
            catch
            {
                //Error message, more useful when you are storing numbers etc. into the database.
                MessageBox.Show("Username or Password given is in an incorrect format.");
                return;
            }

            //(2) SELECT statement getting all data from users, i.e. SELECT * FROM Users
            //(3) IF it returns some data, THEN check each username and password combination, ELSE There are no registered users
            string message = checkLogin(username, password, comboBoxUserType.Text.Trim());

            MessageBox.Show($"{message}");
            if (message.Substring(0, 7) == "Success")
            {
                Hide();
                //Depending on the user type opens one or other form
                switch (comboBoxUserType.Text)
                {
                case "Admins":
                    //InstructorsSchedulePage InstructorSchedule1 = new InstructorsSchedulePage(username, "Admins");
                    //InstructorSchedule1.ShowDialog();
                    //CarAssignationPage CarAssignationPage = new CarAssignationPage();
                    //CarAssignationPage.ShowDialog();
                    AdminConsole WeekResourceAvailability = new AdminConsole();
                    WeekResourceAvailability.ShowDialog();
                    break;

                case "Clients":
                    ClientConsole CustomerAppointment = new ClientConsole(username);
                    CustomerAppointment.ShowDialog();
                    break;

                case "Instructors":
                    InstructorConsole InstructorSchedule2 = new InstructorConsole(username);
                    InstructorSchedule2.ShowDialog();
                    break;

                default:
                    break;
                }
                Close();
            }

            //initialiseTextControls();
        }