コード例 #1
0
        private void profRemoveStudentFromAllClassesButton_Click(object sender, EventArgs e)
        {
            //this will remove a student from all classes
            //make an instance of myFillDatabase
            FillDatabase myFillDatabase = new FillDatabase();

            myFillDatabase.deleteStudentFromAllCourses(returnRemoveStudentID());
        }
コード例 #2
0
ファイル: DatabaseTest.cs プロジェクト: ribler/CS-Connection
        public static void deleteStudentFromAllClassesTest()
        {
            //First we need to add the student so that it is there ot be deleted
            //since we cannot rely anything else
            // Declare and set array element values

            string[] classIDIn = new string[3];
            string[] studentIDIn = new string[3];
            string[] lastNameIn = new string[3];
            string[] firstNameIn = new string[3];
            string[] emailIn = new string[3];

            //to match the first data field when the data is read from excel, set
            //element 2 - just add as a string
            classIDIn[2] = "385";
            studentIDIn[2] = "111111";
            lastNameIn[2] = "Johnson";
            firstNameIn[2] = "Demarcus";
            emailIn[2] = "*****@*****.**";

            //make an instance of myFillDatabase
            FillDatabase myFillDatabase = new FillDatabase();
            //since we are not using an excel file we have to set the fields
            myFillDatabase.setUserInfo(classIDIn, studentIDIn, lastNameIn, firstNameIn, emailIn);
            //send the info to the database
            myFillDatabase.rosterToDatabaseTables();

            //now delete the student
            myFillDatabase.deleteStudentFromAllCourses("*****@*****.**");

            //check it
            //call database connection function
            OleDbConnection connection = DatabaseConnector.CommonFunctions.connectToDB();

            //Create the command for the database connection
            OleDbCommand cmd = DatabaseConnector.CommonFunctions.buildDatabaseConnectionCommand(connection);

            //make the query string to see if there is a match with the info from the login form
            string checkStudentDeletedQueryText = "select count(*) from classesTaking where Username = '******' and Course = '" + classIDIn[2] + "';";

            //run the query and get back the number of rows that match the query
            int noRowEnteredStudent = DatabaseConnector.CommonFunctions.noRowsContainingInfo(connection, checkStudentDeletedQueryText);

            //check if the number of rows is 0
            Assert.AreEqual(noRowEnteredStudent, 0);
        }