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] + "';"; //run the query and get back the number of rows that match the query int noRowEnteredStudent = DatabaseConnector.CommonFunctions.noRowsContainingInfo(connection, checkStudentEnteredQueryText); //check if the number of rows is >0 Assert.GreaterOrEqual(noRowEnteredStudent, 1); }
private void button1_Click(object sender, EventArgs e) { FillDatabase dbf = new FillDatabase(); dbf.createDatabase(); }
public void FillDatabase() { FillDatabase fillDatabase = new FillDatabase(_educationRepository); fillDatabase.FillDatabaseTestData(); }
protected override void Seed(DataStorageAndProcessing.Data.Context context) { FillDatabase.Fill(context); }
/// <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(); }
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()); }
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(); }
/// <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(); }
public static void rosterToDatabaseTablesTest() { string excelFileName = "C:\\Users\\briggs_mc\\cs350\\CS-connect\\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); }
public static void getRosterTest() { string excelFileName = "C:\\Users\\briggs_mc\\cs350\\CS-connect\\DatabaseConnector\\CS142roosterTest.xlsx"; FillDatabase myFillDatabase = new FillDatabase(); myFillDatabase.getRoster(excelFileName); Assert.IsNotEmpty(myFillDatabase.course[2]); }
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); }