Exemple #1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            frmDashb db = new frmDashb();

            db.Show();
            this.Close();
            db.labelUser = "******";
            db.labelRole = "Admin";
            // getUsers();
        }
Exemple #2
0
        void getUsers()
        {
            string user = txtUser.Text;
            string pass = txtPass.Text;


            try
            {
                adapter = new SqlDataAdapter("SELECT Username, Role from tblUsers WHERE Username= '******' AND Password= '******' AND Status= 'Access'", con);
                ds      = new DataSet(); adapter.Fill(ds, "Users");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    // display on input controls
                    string uname = ds.Tables[0].Rows[rno][0].ToString();
                    string role  = ds.Tables[0].Rows[rno][1].ToString();
                    if (role == "Admin")
                    {
                        frmDashb db = new frmDashb();
                        db.Show();
                        this.Close();
                        db.labelUser = uname;
                        db.labelRole = role;
                    }
                    else if (role == "Exams")
                    {
                        frmDashb db = new frmDashb();
                        db.Show();
                        this.Close();
                        db.labelUser = uname;
                        db.labelRole = role;
                        db.UpdateExam(true);
                    }
                    else if (role == "Fees")
                    {
                        frmDashb db = new frmDashb();
                        db.Show();
                        this.Close();
                        db.labelUser = uname;
                        db.labelRole = role;
                        db.UpdateFees(true);
                    }
                }
                else
                {
                    MessageBox.Show("Incorrect Login Credentials or Access Denied!", "User Login", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Login Failed!", "User Login", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }