Example #1
0
        private void button4_Click(object sender, EventArgs e)
        {
            ProfessorGradeForm login = new ProfessorGradeForm();

            this.Hide();
            login.Show();
        }
Example #2
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            //try
            //{
            DataTable dt       = new DataTable();
            Database  database = new Database();

            dt = database.Read("Select Role from Users Where Username='******' and Password='******'");

            if (dt.Rows.Count == 1)
            {
                var role = dt.Rows[0][0].ToString();
                switch (role)
                {
                case "Student":
                    role = "StudentID";
                    break;

                case "Professor":
                    role = "ProfessorID";
                    break;

                case "Administrator":
                    role = "ID";
                    break;
                }
                dt = database.Read("Select " + role + " from Users Where Username='******' and Password='******'");

                var userID = dt.Rows[0][0].ToString();

                if (role == "StudentID")
                {
                    StudentViewForm studentViewForm = new StudentViewForm();

                    studentViewForm.userName = unameBox.Text;
                    studentViewForm.userID   = userID;
                    this.Hide();
                    studentViewForm.Show();
                }
                else if (role == "ProfessorID")
                {
                    ProfessorGradeForm professorGradeForm = new ProfessorGradeForm();

                    professorGradeForm.userName = unameBox.Text;
                    professorGradeForm.userID   = userID;
                    this.Hide();
                    professorGradeForm.Show();
                }
                else if (role == "ID")
                {
                    AdminForm adminForm = new AdminForm();
                    adminForm.userName = unameBox.Text;
                    adminForm.userID   = userID;
                    this.Hide();
                    adminForm.Show();
                }
            }
            else
            {
                MessageBox.Show("Username/Password not found. Please try again.");
            }
        }