//a method for obtaining all of the new tireID's for the given session. public static List<string> getNewTireIDs(DBConnect DBCon) { string tireQuery = "SELECT (1+max(LF_LFTireID)), (1+max(RF_RFTireID)), (1+max(LR_LRTireID)), (1+max(RR_RRTireID)) FROM result_;"; //define the tire query string queryRunner queryR = new queryRunner(tireQuery); //make the query runner object for the tire query queryR.runQuery(DBCon.getConnection()); //run the query return queryR.getLastQueryResultsList(); //return the generic list object with the new tireIds }
// a method to check if an event with the specified name and date exists. public bool eventTest(string eventName) { sqlQuery = ""; //set the sql query equal to an empty string. if (testingDB.getConState()) { sqlQuery = "Select Distinct DATE_FORMAT(eventDate, '%Y-%m-%d') from `event`;"; //set the sql query equal to a query that returns all the dates in event. queryR = new queryRunner(sqlQuery); //tell the query runner object to initialize itself with the query defined above queryR.runQuery(connection); //tell the query runner object to run the query //Not using a sql query that checks date and name since it would return pairs of values that would make it difficult to //quickly find matches. //we have to check to make sure today's date even exists if (queryR.getLastQueryResultsList().BinarySearch(todaysDate) >= 0) //check if the results list has today's date using a quick binary search. { queryR.setQueryArgs("select eventname from `event` where `EventDate` = '" + todaysDate + "';"); //set the query args to search for events with today's today when it is verified that entries with today's date exist queryR.runQuery(connection); //run the query if (queryR.getLastQueryResultsList().BinarySearch(eventName) >= 0) //if today's date is an entry then we need to see if an event matches that day { return false; //if this is reached it means that an event with todays date and name exists; don't create a new event entry } else return true; //today's date exists, but no entry exists with today's name } else return true; //reached if none of the dates match today's date } else throw new Exception("The database connection passed to this sqlTesting object failed"); //happens if the connection doesn't work }