示例#1
0
        public static void addSingleStudentTest()
        {
            // 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] = "250";
            studentIDIn[2] = "54545";
            lastNameIn[2] = "Micheals";
            firstNameIn[2] = "Mary";
            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();

            //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 checkStudentEnteredQueryText = "select count(*) from classesTaking where Username = '******' and Course = '" + classIDIn[2] + "';";
            string checkStudentEnteredQueryText = "select count(*) from userInfo where Username = '******';";
            int noRowEnteredStudent = 100;
            //run the query and get back the number of rows that match the query
            noRowEnteredStudent = DatabaseConnector.CommonFunctions.noRowsContainingInfo(connection, checkStudentEnteredQueryText);

            //check if the number of rows is >0
            Assert.GreaterOrEqual(noRowEnteredStudent, 1);
        }
示例#2
0
 public static void getRosterTest()
 {
     string excelFileName = "C:\\Users\\briggs_mc\\Desktop\\Final\\databaseConnector\\CS142roosterTest.xlsx";
     FillDatabase myFillDatabase = new FillDatabase();
     myFillDatabase.getRoster(excelFileName);
     Assert.IsNotEmpty(myFillDatabase.course[2]);
 }
示例#3
0
        public static void rosterToDatabaseTablesTest()
        {
            string excelFileName = "C:\\Users\\briggs_mc\\Desktop\\Final\\databaseConnector\\CS142roosterTest.xlsx";
            FillDatabase myFillDatabase = new FillDatabase();
            myFillDatabase.getRoster(excelFileName);
            myFillDatabase.rosterToDatabaseTables();

            OleDbConnection connection = DatabaseConnector.CommonFunctions.connectToDB();

            string commandCourse = "SELECT Course from allCourses where Course = '" + myFillDatabase.course[2] + "';";

            //returns list of courses that matches - should be either course name or nothing?
            List<string> coursesAlreadyInTable = DatabaseConnector.CommonFunctions.readData(connection, commandCourse);
            bool inTable = coursesAlreadyInTable.Any();
            //   Assert.IsTrue(inTable);
        }
示例#4
0
        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);
        }
 /// <summary>
 /// When the professor wants to add a class roster to the database
 /// he puts the path and file name for the roster and clicks 
 /// add class this will read the excel file and put the necessary info into
 /// the database
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void profAddClassButton_Click(object sender, EventArgs e)
 {
     string excelFileName = profFilePathTextBox.Text;
     FillDatabase myFillDatabase = new FillDatabase();
     myFillDatabase.getRoster(excelFileName);
     myFillDatabase.rosterToDatabaseTables();
     profFilePathTextBox.Clear();
     profActionAccepted.Text = "Request Accepted";
 }
        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());
            profRemoveStudentIDTextBox.Clear();
            profRemoveClassIDTextBox.Clear();
            profActionAccepted.Text = "Request Accepted";
        }
        private void profClearAllDataButton_Click(object sender, EventArgs e)
        {
            //clear the userInfo, classesTaking, and allCourses tables
            //this should only be done at the end of the semester

            FillDatabase myFillDatabase = new FillDatabase();

            myFillDatabase.purgeAllStudentData();
            profActionAccepted.Text = "Request Accepted";
        }
        /// <summary>
        /// This will allow a professor to add a single student to a class in the database
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void profAddStudentButton_Click(object sender, EventArgs e)
        {
            // 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
            classIDIn[2]   = returnAddStudentClass();
            studentIDIn[2] = returnStudentID();
            lastNameIn[2]  = returnLastName();
            firstNameIn[2] = returnFirstName();
            emailIn[2]     = returnStudentEmailID() + "@students.lynchburg.edu";

            //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();
            profAddStudentEmailTextBox.Clear();
            profAddClassIDTextBox.Clear();
            firstNameTextBox.Clear();
            lastNameTextBox.Clear();
            studentIDTextBox.Clear();
            profActionAccepted.Text = "Request Accepted";
        }