public static bool recoveryProgress = false; // the Name property with hidden backing field //Batch recovery/resync in case of batch failure : Ndey public dynamic batchRecovery() { // improve the batch update query if you want recoveryProgress = true; string fetchCustomersDB = "INSERT INTO PrimaryDB.mdb.Customers SELECT * FROM Customers", fetchFlightsDB = "INSERT INTO PrimaryDB.mdb.Flights SELECT * FROM Flights", fetchHotelDB = "INSERT INTO PrimaryDB.mdb.Hotel SELECT * FROM Hotel", fetchCarsDB = "INSERT INTO PrimaryDB.mdb.Cars SELECT * FROM Cars"; string[] dbList = { fetchCustomersDB, fetchFlightsDB, fetchHotelDB, fetchCarsDB }; var primaryDatabase = new PrimaryDatabase(); bool query = primaryDatabase.batchUpdate(dbList, true); recoveryProgress = false; return(true); }
public static void printInvoice(string date, string firstname, string surname, string address, string phonenumber, string destination, string flightprice, string carDetails, string carhirePrice, string hotellocation, string hotelprice, string total) { // batch update queries string fetchCustomersDB = "INSERT INTO SecondaryDB.mdb.Customers SELECT * FROM Customers", fetchFlightsDB = "INSERT INTO SecondaryDB.mdb.Flights SELECT * FROM Flights", fetchHotelDB = "INSERT INTO SecondaryDB.mdb.Hotel SELECT * FROM Hotel", fetchCarsDB = "INSERT INTO SecondaryDB.mdb.Cars SELECT * FROM Cars"; string[] dbList = { fetchCustomersDB, fetchFlightsDB, fetchHotelDB, fetchCarsDB }; var primaryDatabase = new PrimaryDatabase(); bool query = primaryDatabase.batchUpdate(dbList, false); MessageBox.Show("Your booking has been confirmed."); MessageBox.Show("Date: " + date + "\n" + "Firstname: " + firstname + "\n" + "Surname: " + surname + "\n" + "Phone Number: " + phonenumber + "\n" + "Address: " + address + "\n" + "Destination: " + destination + "\n" + "Flight Price: £" + flightprice + "\n" + "Car hire: " + carDetails + "\n" + "Car Price: £ " + carhirePrice + "\n" + "Hotel Location: " + hotellocation + "\n" + "Hotel Price: £ " + hotelprice + "\n" + "Total Price: £ " + total); }
public static void Main(string[] args) { // Primary Database + queries string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=PrimaryDB.mdb", secondaryConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=SecondaryDB.mdb", editDB = "UPDATE Customers SET [CustomerFirstName] = @CustomerFirstName, [CustomerLastName] = @CustomerLastName WHERE [CustomerID] = @CustomerID", checkDuplicateDB = "SELECT COUNT(*) FROM Customers WHERE [CustomerFirstName] = @CustomerFirstName AND [CustomerLastName] = @CustomerLastName", readDB = "SELECT * FROM Customers", deleteDB = "DELETE FROM Customers WHERE CustomerID BETWEEN 3 AND 100", deleteFDB = "DELETE FROM Flights WHERE ID BETWEEN 3 AND 100", deleteHDB = "DELETE FROM Hotel WHERE ID BETWEEN 3 AND 100", deleteCDB = "DELETE FROM Cars WHERE ID BETWEEN 3 AND 100"; // batch update queries string fetchCustomersDB = "INSERT INTO SecondaryDB.mdb.Customers SELECT * FROM Customers", fetchFlightsDB = "INSERT INTO SecondaryDB.mdb.Flights SELECT * FROM Flights", fetchHotelDB = "INSERT INTO SecondaryDB.mdb.Hotel SELECT * FROM Hotel", fetchCarsDB = "INSERT INTO SecondaryDB.mdb.Cars SELECT * FROM Cars"; string[] dbList = { fetchCustomersDB, fetchFlightsDB, fetchHotelDB, fetchCarsDB }; object[] duplicate = { "@CustomerFirstName", "Louis", "@CustomerLastName", "Gaye" }; object[] edit = { "@CustomerFirstName", "Lewis", "@CustomerLastName", "Guy", "@CustomerEmail", 1 }; // Must initalise class before use var dbFunc = new DatabaseFunctions(); var primaryDatabase = new PrimaryDatabase(); var secondaryDatabase = new SecondaryDatabase(); //bool checkRecovery = SecondaryDatabase.recoveryProgress; // tests //bool query = primaryDatabase.batchUpdate(dbList, false); //bool squery = secondaryDatabase.batchRecovery(); var details = dbFunc.createDict(); //primaryDatabase.fetchData(details); // Test database /* * dbFunc.deleteDatabase(deleteDB, connectionString); * dbFunc.deleteDatabase(deleteFDB, connectionString); * dbFunc.deleteDatabase(deleteHDB, connectionString); * dbFunc.deleteDatabase(deleteCDB, connectionString);*/ //dbFunc.editDatabase(editDB, connectionString, edit); //dbFunc.readDatabase(readDB, connectionString); //dbFunc.checkDuplicateDatabase(checkDuplicateDB, connectionString, duplicate); }