Double-confirmation for database delete.

This commit is contained in:
2020-11-30 06:41:38 -08:00
parent 8bdddd2e16
commit bd71fc7ff8
6 changed files with 42 additions and 47 deletions

View File

@ -181,18 +181,20 @@ class Toplevel1:
# Next two lines commented out in Windows version - the connection commands work on macOS # Next two lines commented out in Windows version - the connection commands work on macOS
#conn = sqlite3.connect('checkouts.db') # Re-establish connection to the database #conn = sqlite3.connect('checkouts.db') # Re-establish connection to the database
#conn.close # Close out the current database #conn.close # Close out the current database
os.remove("checkouts.db") # Delete the current database self.ConfirmClear = tk.messagebox.askquestion ('PECOS - Confim','Final answer: Are you sure you wish to clear the database?')
shutil.copy("emptybase.db", "checkouts.db") # Copy over an empty database if self.ConfirmClear == 'yes':
shutil.rmtree('item') os.remove("checkouts.db") # Delete the current database
shutil.rmtree('patron') shutil.copy("emptybase.db", "checkouts.db") # Copy over an empty database
os.makedirs('item') shutil.rmtree('item')
os.makedirs('patron') shutil.rmtree('patron')
# Next two lines commented out in Windows version - the connection commands work on macOS os.makedirs('item')
#conn = sqlite3.connect('checkouts.db') # Restablish connection to the database os.makedirs('patron')
#c = conn.cursor() # Next two lines commented out in Windows version - the connection commands work on macOS
else: #conn = sqlite3.connect('checkouts.db') # Restablish connection to the database
messagebox.showinfo('PECOS - Database Retained','Database retained. No changes made.') #c = conn.cursor()
else:
messagebox.showinfo('PECOS - Database Retained','Database retained. No changes made.')
# --- EXPORT DATABASE TO HTML --- # --- EXPORT DATABASE TO HTML ---
def ExportDatabase(): def ExportDatabase():
if os.path.exists("export.html"): if os.path.exists("export.html"):

View File

@ -1,9 +1,9 @@
<html> <html>
<head> <head>
<title> <title>
PECOS Export - 06:14:31 on Wednesday, November 11, 2020 PECOS Export - 06:37:11 on Monday, November 30, 2020
</title> </title>
<h2>PECOS Export File &ndash; 06:14:31 on Wednesday, November 11, 2020</h2> <h2>PECOS Export File &ndash; 06:37:11 on Monday, November 30, 2020</h2>
<hr> <hr>
<style type="text/css"> <style type="text/css">
.tg {border-collapse:collapse;border-spacing:0;} .tg {border-collapse:collapse;border-spacing:0;}
@ -25,12 +25,3 @@ PECOS Export - 06:14:31 on Wednesday, November 11, 2020
<tr> <tr>
<th class="tg-cly1"><img src="patron/1230004231819.svg" width=200></th><th class="tg-cly1"><strong>Batch: </strong>2</th><th class="tg-cly1"><img src="item/1234567892.svg" width=200> <th class="tg-cly1"><img src="patron/1230004231819.svg" width=200></th><th class="tg-cly1"><strong>Batch: </strong>2</th><th class="tg-cly1"><img src="item/1234567892.svg" width=200>
</tr> </tr>
<tr>
<th class="tg-cly1"><img src="patron/1230004233141.svg" width=200></th><th class="tg-cly1"><strong>Batch: </strong>3</th><th class="tg-cly1"><img src="item/1234567893.svg" width=200>
</tr>
<tr>
<th class="tg-cly1"><img src="patron/1230004233141.svg" width=200></th><th class="tg-cly1"><strong>Batch: </strong>3</th><th class="tg-cly1"><img src="item/1234567894.svg" width=200>
</tr>
<tr>
<th class="tg-cly1"><img src="patron/1230004233141.svg" width=200></th><th class="tg-cly1"><strong>Batch: </strong>3</th><th class="tg-cly1"><img src="item/1234567895.svg" width=200>
</tr>

View File

@ -1 +0,0 @@
Item data will go here.

View File

@ -1 +0,0 @@
Patron data will go here.

View File

@ -181,17 +181,19 @@ class Toplevel1:
# Next two lines commented out in Windows version - the connection commands work on macOS # Next two lines commented out in Windows version - the connection commands work on macOS
#conn = sqlite3.connect('checkouts.db') # Re-establish connection to the database #conn = sqlite3.connect('checkouts.db') # Re-establish connection to the database
#conn.close # Close out the current database #conn.close # Close out the current database
os.remove("checkouts.db") # Delete the current database self.ConfirmClear = tk.messagebox.askquestion ('PECOS - Confim','Final answer: Are you sure you wish to clear the database?')
shutil.copy("emptybase.db", "checkouts.db") # Copy over an empty database if self.ConfirmClear == 'yes':
shutil.rmtree('item') os.remove("checkouts.db") # Delete the current database
shutil.rmtree('patron') shutil.copy("emptybase.db", "checkouts.db") # Copy over an empty database
os.makedirs('item') shutil.rmtree('item')
os.makedirs('patron') shutil.rmtree('patron')
# Next two lines commented out in Windows version - the connection commands work on macOS os.makedirs('item')
#conn = sqlite3.connect('checkouts.db') # Restablish connection to the database os.makedirs('patron')
#c = conn.cursor() # Next two lines commented out in Windows version - the connection commands work on macOS
else: #conn = sqlite3.connect('checkouts.db') # Restablish connection to the database
messagebox.showinfo('PECOS - Database Retained','Database retained. No changes made.') #c = conn.cursor()
else:
messagebox.showinfo('PECOS - Database Retained','Database retained. No changes made.')
# --- EXPORT DATABASE TO HTML --- # --- EXPORT DATABASE TO HTML ---
def ExportDatabase(): def ExportDatabase():

View File

@ -181,17 +181,19 @@ class Toplevel1:
# Next two lines commented out in Windows version - the connection commands work on macOS # Next two lines commented out in Windows version - the connection commands work on macOS
#conn = sqlite3.connect('checkouts.db') # Re-establish connection to the database #conn = sqlite3.connect('checkouts.db') # Re-establish connection to the database
#conn.close # Close out the current database #conn.close # Close out the current database
os.remove("checkouts.db") # Delete the current database self.ConfirmClear = tk.messagebox.askquestion ('PECOS - Confim','Final answer: Are you sure you wish to clear the database?')
shutil.copy("emptybase.db", "checkouts.db") # Copy over an empty database if self.ConfirmClear == 'yes':
shutil.rmtree('item') os.remove("checkouts.db") # Delete the current database
shutil.rmtree('patron') shutil.copy("emptybase.db", "checkouts.db") # Copy over an empty database
os.makedirs('item') shutil.rmtree('item')
os.makedirs('patron') shutil.rmtree('patron')
# Next two lines commented out in Windows version - the connection commands work on macOS os.makedirs('item')
#conn = sqlite3.connect('checkouts.db') # Restablish connection to the database os.makedirs('patron')
#c = conn.cursor() # Next two lines commented out in Windows version - the connection commands work on macOS
else: #conn = sqlite3.connect('checkouts.db') # Restablish connection to the database
messagebox.showinfo('PECOS - Database Retained','Database retained. No changes made.') #c = conn.cursor()
else:
messagebox.showinfo('PECOS - Database Retained','Database retained. No changes made.')
# --- EXPORT DATABASE TO HTML --- # --- EXPORT DATABASE TO HTML ---
def ExportDatabase(): def ExportDatabase():