Exemple #1
0
        private void LoginValidation()
        {
            Cursor.Current = Cursors.WaitCursor;
            SQLCon.DbCon();
            SQLCon.sql        = "SELECT USER_ID, Username, Password, FirstName, LastName , AccessLevel, IsActive FROM Accounts WHERE Username=@1 AND Password=@2";
            SQLCon.sqlCommand = new SqlCommand(SQLCon.sql, SQLCon.sqlConnection);
            SQLCon.sqlCommand.Parameters.AddWithValue("@1", tb_Username.Text);
            SQLCon.sqlCommand.Parameters.AddWithValue("@2", tb_Password.Text);
            SQLCon.sqlDataReader = SQLCon.sqlCommand.ExecuteReader();

            while (SQLCon.sqlDataReader.Read())
            {
                WelcomeForm.AccountID = Convert.ToInt32((SQLCon.sqlDataReader["USER_ID"].ToString()));
                WelcomeForm.Username  = (SQLCon.sqlDataReader["Username"].ToString());
                WelcomeForm.Password  = (SQLCon.sqlDataReader["Password"].ToString());
                WelcomeForm.FirstName = (SQLCon.sqlDataReader["FirstName"].ToString());
                WelcomeForm.LastName  = (SQLCon.sqlDataReader["LastName"].ToString());
                accountValidation     = (SQLCon.sqlDataReader["IsActive"].ToString());
                role = (SQLCon.sqlDataReader["AccessLevel"].ToString());
            }


            if (WelcomeForm.Username == tb_Username.Text && WelcomeForm.Password == tb_Password.Text && accountValidation == "True")
            {
                if (role == "ADMIN")
                {
                    MainForm.accessLevel = "ADMIN";
                }
                else if (role == "TECHNICIAN")
                {
                    MainForm.accessLevel = "TECHNICIAN";
                }
                else if (role == "PROGRAMMER")
                {
                    MainForm.accessLevel = "PROGRAMMER";
                }
                this.Close();
                WelcomeForm welcomeForm = new WelcomeForm();
                welcomeForm.ShowDialog();
            }
            else if (accountValidation == "False" && WelcomeForm.Username == tb_Username.Text && WelcomeForm.Password == tb_Password.Text)
            {
                MessageBox.Show("Your account has been suspended. Please contact the Administrator");
                tb_Password.Clear();
                tb_Username.Clear();
            }
            else
            {
                MessageBox.Show("Incorrect username or password");
                tb_Password.Clear();
                tb_Username.Clear();
            }
            Cursor.Current = Cursors.Default;
        }
Exemple #2
0
        private void BackgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            WelcomeForm welcomeForm = new WelcomeForm();

            welcomeForm.ShowDialog();
        }