Beispiel #1
0
        private void btnDashboard_Click(object sender, EventArgs e)
        {
            var admindashboard = new AdminDashboard();

            admindashboard.Show();
            Hide();
        }
Beispiel #2
0
        private void btnLoginAccount_Click(object sender, EventArgs e)
        {
            int roleid;

            try
            {
                Connection.Connection.DB();
                Functions.Function.gen     = "SELECT * FROM Users WHERE Username = '******' AND Password = '******' ";
                Functions.Function.command = new SqlCommand(Functions.Function.gen, Connection.Connection.con);
                Functions.Function.reader  = Functions.Function.command.ExecuteReader();

                if (Functions.Function.reader.HasRows)
                {
                    Functions.Function.reader.Read();

                    roleid = Convert.ToInt32(Functions.Function.reader["RoleId"]);

                    if (roleid == 1)
                    {
                        txtUsername.Text = Functions.Function.reader["Username"].ToString();
                        txtPassword.Text = Functions.Function.reader["Password"].ToString();

                        setfirstname = Functions.Function.reader["FirstName"].ToString();
                        setlastname  = Functions.Function.reader["LastName"].ToString();
                        setuserId    = Convert.ToInt32(Functions.Function.reader["UserId"]);

                        var student = new Student.StudentDashboard();
                        student.Show();
                        Hide();
                    }
                    else if (roleid == 2)
                    {
                        txtUsername.Text = Functions.Function.reader["Username"].ToString();
                        txtPassword.Text = Functions.Function.reader["Password"].ToString();

                        setfirstname = Functions.Function.reader["FirstName"].ToString();
                        setlastname  = Functions.Function.reader["LastName"].ToString();

                        var admin = new Admin.AdminDashboard();
                        admin.Show();
                        Hide();
                    }
                }
                else
                {
                    MessageBox.Show("Incorrect username or password", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }