コード例 #1
0
 public StudentSearch(StaffDashboard dashboard, Staff staff)
 {
     Dashboard = dashboard;
     InitializeComponent();
     this.staff = staff;
     ShowAll();
 }
コード例 #2
0
 private void GoBack_Click(object sender, RoutedEventArgs e)
 {
     Hide();
     if (mUser is Student)
     {
         StudentDashboard studentDashboardWindow = new StudentDashboard((Student)mUser);
         studentDashboardWindow.Show();
     }
     else
     {
         StaffDashboard staffDashboard = new StaffDashboard((PersonalSupervisor)mUser);
     }
 }
コード例 #3
0
        private void GoBack_Click(object sender, RoutedEventArgs e)
        {
            if (mUser is Staff)
            {
                Staff          staff          = mUser as Staff;
                StaffDashboard staffDashboard = new StaffDashboard((Staff)mUser, staff.messages1);
                staffDashboard.Show();
            }
            //if it is staff this should be null and goto catch block
            StudentDashboard studentDashboardWindow = new StudentDashboard((Student)mUser);

            studentDashboardWindow.Show();
        }
コード例 #4
0
        private void GoBack_Click(object sender, RoutedEventArgs e)
        {
            Hide();

            if (mStudent != null)
            {
                StudentDashboard studentDashboardWindow = new StudentDashboard(mStudent);
                studentDashboardWindow.Show();
            }
            else
            {
                StaffDashboard staffDashboardWindow = new StaffDashboard(mStaff, mStaff.messages1);
                staffDashboardWindow.Show();
            }
        }
コード例 #5
0
        public AddDeleteUserWindow(StaffDashboard dashboard)
        {
            InitializeComponent();

            mDashboard = dashboard;

            Supervisor.Text += "Write N/A if not applicable";

            SqlCommand supervisors_ = new SqlCommand();

            supervisors_.CommandText = "select FirstName, LastName from [Users_] where Classification='Personal Supervisor';";
            supervisors_.Connection  = mConnection;
            mConnection.Open();
            SqlDataReader supervisorReader = supervisors_.ExecuteReader();

            supervisorReader.Close();
            mConnection.Close();
        }
コード例 #6
0
        public void Login_Click(object sender, RoutedEventArgs e)
        {
            string username = Username.Text;
            string password = Password.Password;

            mConnection.Open();
            SqlCommand search = new SqlCommand();

            //search.CommandText = "select User_Id, password, Classification, FirstName, LastName,email,password,Supervisor from [Users_]";
            search.CommandText = "select User_Id, password, Classification, FirstName, LastName,email,password,Supervisor,Message.Body,Message.Subject,Message.Sender from [Users_] full outer join Message on FirstName+' '+LastName=Message.Receiver ";
            search.Connection  = mConnection;
            SqlDataReader reader         = search.ExecuteReader();
            string        classification = "";

            while (reader.Read())
            {
                if (reader[0].ToString() == username)
                {
                    username_match = true;
                    if (reader[1].ToString() == password)
                    {
                        classification = reader[2].ToString();
                        password_match = true;
                        break;
                    }
                }
            }

            if (username_match && password_match)
            {
                int    userId    = int.Parse(reader[0].ToString());
                string firstName = reader[3].ToString();
                string lastName  = reader[4].ToString();
                string userName  = firstName + " " + lastName;

                string         MessageSubject = reader[9].ToString();
                string         messageBody    = reader[8].ToString();
                string         _sender        = reader[10].ToString();
                Message        message        = new Message(0, DateTime.Now, MessageSubject, messageBody, _sender, null);
                List <Message> messages       = new List <Message>();
                messages.Add(message);

                switch (classification)
                {
                case "Student":

                    this.Hide();
                    Student          student   = new Student(userId, userName, messages);
                    StudentDashboard dashboard = new StudentDashboard(student);
                    dashboard.Show();

                    break;

                case "Student Hub":

                    this.Hide();
                    StudentHub     studentHub     = new StudentHub(userId, userName, classification, messages);
                    StaffDashboard staffDashboard = new StaffDashboard(studentHub, messages);
                    staffDashboard.Show();

                    break;

                case "Personal Supervisor":

                    this.Hide();
                    PersonalSupervisor personalSupervisor = new PersonalSupervisor(userId, userName, classification, messages);
                    StaffDashboard     staffDashboard_PS  = new StaffDashboard(personalSupervisor, messages);
                    staffDashboard_PS.Show();
                    break;

                case "Director of Study":
                    this.Hide();
                    DirectorOfStudy director           = new DirectorOfStudy(userId, userName, classification, messages);
                    StaffDashboard  staffDashboard_DoS = new StaffDashboard(director, messages);
                    staffDashboard_DoS.Show();
                    break;
                }
            }
            else
            {
                MessageBox.Show("Invalid credentials", "Access Denied", MessageBoxButton.OK, MessageBoxImage.Warning);
                InitializeComponent();
            }
            mConnection.Close();
        }
コード例 #7
0
        private void Login_Click(object sender, RoutedEventArgs e)
        {
            string username = Username.Text;
            string password = Password.Password;

            SqlConnection connection = new SqlConnection();
            var           path       = Environment.CurrentDirectory + @"\DataBase\Users.mdf";

            connection.ConnectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=" + path + ";Integrated Security=True";
            connection.Open();

            SqlCommand search = new SqlCommand();

            search.CommandText = "select User_Id, password, Classification, FirstName, LastName,email,password,Supervisor,Message.Body,Message.Subject from [Users_] full outer join Message on FirstName+' '+LastName=Message.Receiver ";
            search.Connection  = connection;
            SqlDataReader reader         = search.ExecuteReader();
            string        Classification = ""; // What is it for?

            while (reader.Read())
            {
                if (reader[0].ToString() == username)
                {
                    username_match = true;
                    if (reader[1].ToString() == password)
                    {
                        Classification = reader[2].ToString();
                        password_match = true;
                        break;
                    }
                }
            }


            if (username_match && password_match)
            {
                int     userId         = int.Parse(reader[0].ToString());
                string  firstName      = reader[3].ToString();
                string  lastName       = reader[4].ToString();
                string  userName       = firstName + " " + lastName;
                string  MessageSubject = reader[9].ToString();
                string  messageBody    = reader[8].ToString();
                Message message        = new Message(0, DateTime.Now, MessageSubject, messageBody, null, null);
                switch (Classification)
                {
                case "Student":
                    this.Hide();
                    List <Message> messages = new List <Message>();
                    messages.Add(message);
                    Student          student   = new Student(userId, userName, messages);
                    StudentDashboard dashboard = new StudentDashboard(student);
                    dashboard.Show();
                    break;

                case "Student Hub":
                    this.Hide();
                    Staff          staff          = new Staff(userId, userName);
                    StaffDashboard staffDashboard = new StaffDashboard(staff);
                    staffDashboard.Show();
                    break;

                case "Personal Supervisor":
                    this.Hide();
                    StaffDashboard staffDashboard_PS = new StaffDashboard();
                    staffDashboard_PS.Show();
                    break;

                case "Director of Study":
                    this.Hide();
                    StaffDashboard staffDashboard_DoS = new StaffDashboard();
                    staffDashboard_DoS.Show();
                    break;
                }
            }
            else
            {
                MessageBox.Show("Invalid credentials", "Access Denied", MessageBoxButton.OK, MessageBoxImage.Warning);
                InitializeComponent();
            }
        }