示例#1
0
        internal string getLName(int primeKey)
        {
            string          encryptedLName;
            string          lastName       = null;
            cryptography    decrypt        = new cryptography();
            OleDbConnection myDbConnection = new OleDbConnection(connectionString);
            OleDbCommand    command        = new OleDbCommand();

            command.CommandType = CommandType.Text;
            command.Connection  = myDbConnection;
            command.CommandText = "SELECT lastName from myTable where PrimaryKey = p1";
            command.Parameters.AddWithValue("p1", primeKey);
            try
            {
                myDbConnection.Open();
                OleDbDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    encryptedLName = (string)reader.GetValue(0);
                    lastName       = decrypt.decryptString(encryptedLName);
                }
                reader.Close();
                return(lastName);
            }
            catch (OleDbException ex)
            {
                DisplayOleDbErrorCollection(ex);
                return(lastName);
            }
            finally
            {
                myDbConnection.Close();
            }
        }
示例#2
0
        internal string getVideoLoc(int keyNum)
        {
            string          encryptedFileLoc = null;
            string          fileLoc          = null;
            cryptography    decrypt          = new cryptography();
            OleDbConnection myDbConnection   = new OleDbConnection(connectionString);

            try
            {
                string queryString;

                queryString = String.Format("SELECT videoLink from myTable where PrimaryKey = {0}", keyNum);
                OleDbCommand command = new OleDbCommand(queryString, myDbConnection);
                myDbConnection.Open();
                OleDbDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    encryptedFileLoc = (string)reader.GetValue(0);
                    fileLoc          = decrypt.decryptString(encryptedFileLoc);
                }
                reader.Close();
                return(fileLoc);
            }
            catch (OleDbException ex)
            {
                DisplayOleDbErrorCollection(ex);
                return(fileLoc);
            }
            finally
            {
                myDbConnection.Close();
            }
        }
示例#3
0
        internal List <string> populateUserIdList()
        {
            List <string> userNames = new List <string>();

            userNames.Add("Select User");
            try
            {
                string          fName;
                string          lName;
                cryptography    decrypt        = new cryptography();
                OleDbConnection myDbConnection = new OleDbConnection(connectionString);
                OleDbCommand    command        = new OleDbCommand();
                command.CommandType = CommandType.Text;
                command.Connection  = myDbConnection;
                command.CommandText = "SELECT firstName, lastName from myTable";
                myDbConnection.Open();
                OleDbDataReader reader = command.ExecuteReader();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        fName = decrypt.decryptString(reader.GetString(reader.GetOrdinal("firstName")));
                        lName = decrypt.decryptString(reader.GetString(reader.GetOrdinal("lastName")));
                        userNames.Add(fName + " " + lName);
                    }
                    reader.Close();
                }
                myDbConnection.Close();
                return(userNames);
            }
            catch (OleDbException ex)
            {
                DisplayOleDbErrorCollection(ex);
                return(userNames);
            }
        }
示例#4
0
 internal bool isAdmin(int myPrimeKey)
 {
     try
     {
         string          cryptPermissionLevel = null;
         cryptography    decrypt        = new cryptography();
         OleDbConnection myDbConnection = new OleDbConnection(connectionString);
         OleDbCommand    command        = new OleDbCommand();
         command.CommandType = CommandType.Text;
         command.Connection  = myDbConnection;
         command.CommandText = "SELECT permission from myTable where PrimaryKey = p1";
         command.Parameters.AddWithValue("p1", myPrimeKey);
         myDbConnection.Open();
         OleDbDataReader reader = command.ExecuteReader();
         if (reader.HasRows)
         {
             while (reader.Read())
             {
                 cryptPermissionLevel = reader.GetString(reader.GetOrdinal("permission"));
             }
             reader.Close();
         }
         myDbConnection.Close();
         string permissionLevel = decrypt.decryptString(cryptPermissionLevel);
         if (permissionLevel == "Admin")
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (OleDbException ex)
     {
         DisplayOleDbErrorCollection(ex);
         return(false);
     }
 }