def runApp(): ''' Runs all the functions in a loop If the submit button is pressed for each app, the next app will shows If the back button is pressed, the previous app will show up (data will be reentered entirely) ''' conn = data.connectDB() c = conn.cursor() numOfFrames = 6 inputStage = 0 #initialize while inputStage != numOfFrames: if inputStage == 0: inputStage = inputCredits(c,inputStage) elif inputStage == 1: inputStage = inputUnitFees(c,inputStage) elif inputStage == 2: inputStage = inputBIU(c,inputStage) elif inputStage == 3: inputStage = inputFormulaFees(c,inputStage) elif inputStage == 4: inputStage = inputNormalUnits(c,inputStage) elif inputStage == 5: inputStage = inputProgWeights(c,inputStage) elif inputStage == -1: #when it is equal to -1 (go back on inputCredits) inputStage = 0 #makes them input credits again else: break try: c.execute('''INSERT INTO timeRecord(time_id,timeStam) VALUES (2,?);''',(dateTimeOutput.pythonTime(),)) except sqlite3.IntegrityError: c.execute('''UPDATE timeRecord SET timeStam = ? WHERE time_id = 2;''',(dateTimeOutput.pythonTime(),)) conn.commit() conn.close()
def runApp(): conn = data.connectDB() c = conn.cursor() c.execute("SELECT COUNT (*) FROM students") val = c.fetchone() numOfStudents = int(val[0]) grantGeneratedTotal = 0 for i in range(numOfStudents): grantGeneratedTotal = grantGeneratedTotal + studentGrant(c, i + 1) return grantGeneratedTotal
def runApp(): conn = extractData.connectDB() c = conn.cursor() c.execute("SELECT COUNT (*) FROM students") #find how many students are in the data base val = c.fetchone() numOfStudents = int(val[0]) revenueGeneratedTotal = 0 for i in range(numOfStudents): #loops through all the students and calculates money from each student revenueGeneratedTotal = revenueGeneratedTotal + studentTuition(c, i + 1) return revenueGeneratedTotal
def SQLTime(): #SQL time capabilities conn = extractData.connectDB() c = conn.cursor() c.execute("SELECT strftime('%s','now');") unixTime = c.fetchall() #grab the unix time string c.execute("SELECT datetime(?, 'unixepoch','localtime');", (unixTime[0])) #find the date time string from the unix time string timeString = c.fetchone() conn.commit() conn.close return (timeString[0])
def runAppCourse(course): conn = data.connectDB() c = conn.cursor() return courseGrant(c, course)
def DatabaseSetup(self): ''' Used every loop in the main menu loop ''' self.conn = data.connectDB() self.c = self.conn.cursor()
def runApp(): conn = data.connectDB() c = conn.cursor() sheetName = "DBMS Enrollment Data.xls" #name of the excel spreadsheet tuitionGrantSheetName = "Course Tuition and Grant Revenue Totals" programTotalsSheetName = "Course Breakdown Based on Program" programPercentTotalsSheetName = "Course Percentage Breakdown based on Faculty" planTotalsSheetName = "Course Breakdown Based on All Plans" sigPlanTotalsSheetName = "Course Breakdown Based on Plans (with >10 enrollments)" yearTotalsSheetName = "Course Breakdown Based on Year" planBreakdownSheetName = "Course Breakdown Based on Selected Plans" programYearSheetName = "Program Breakdown Based on Year" programInfoSheetName = "Program Info" sheetsOrderedDict = OrderedDict([ (tuitionGrantSheetName, 0), (programTotalsSheetName, 1), (planTotalsSheetName, 2), (sigPlanTotalsSheetName, 3), (yearTotalsSheetName, 4), (planBreakdownSheetName, 5), (programYearSheetName, 6), (programInfoSheetName, 7), ]) cdLocation = os.getcwd() excelLocation = cdLocation + "\\" + sheetName try: os.remove(excelLocation) #TESTING PURPOSES, REMOVES THE OLD SPREADSHEET EVERY TIME@@@@@@@@@@@@ except WindowsError: pass ''' Asks user for information that needs to be shown ''' selectedSheets = UI.sheetsOptionsCheckBox.runScrollingApp(sheetsOrderedDict) #UI module asks for sheets while not checkError(selectedSheets): UI.errorMessageBox.runApp(selectedSheets) selectedSheets = UI.sheetsOptionsCheckBox.runScrollingApp(sheetsOrderedDict) selectedSheetsKey = [] #used to store the keys of the selected sheets for name in selectedSheets: selectedSheetsKey.append(sheetsOrderedDict[name]) ''' Sheets that will be written to the outputted workbook ''' book = xlwt.Workbook() if sheetsOrderedDict[tuitionGrantSheetName] in selectedSheetsKey: ExcelOutput.tuitionGrantTotals.write(c,book) if sheetsOrderedDict[programTotalsSheetName] in selectedSheetsKey: ExcelOutput.programTotals.write(c,book) if sheetsOrderedDict[planTotalsSheetName] in selectedSheetsKey: ExcelOutput.planExpandedTotals.write(c,book) if sheetsOrderedDict[sigPlanTotalsSheetName] in selectedSheetsKey: ExcelOutput.planSignificantTotals.write(c,book) if sheetsOrderedDict[yearTotalsSheetName] in selectedSheetsKey: ExcelOutput.yearTotals.write(c,book) if sheetsOrderedDict[planBreakdownSheetName] in selectedSheetsKey: #Make list of plans with only the plan code e.g. "BCHM" rawPlanList = data.grabFullPlanList(c) checkPlanList = [] for plan in rawPlanList: plan = plan[0] #unpack the tuple breakPoint = plan.index('-') #find the first occurence of "-" that separates BCHM-M-BSH plan = plan[0:breakPoint] #splice the string to get just BCHM try: temp = checkPlanList.index(plan) #check if the course code BCHM exists in the list except ValueError: checkPlanList.append(plan) #if not, it is added to the list selectedPlans = UI.planOptionsCheckBox.runScrollingApp(checkPlanList) while not checkError(selectedPlans): #ensure plans are chosen to be output UI.errorMessageBox(selectedPlans) selectedPlans = UI.planOptionsCheckBox.runScrollingApp(checkPlanList) for plan in selectedPlans: ExcelOutput.planBreakdown.write(c,book,plan) if sheetsOrderedDict[programYearSheetName] in selectedSheetsKey: ExcelOutput.programYearTotals.write(c,book) if sheetsOrderedDict[programInfoSheetName] in selectedSheetsKey: ExcelOutput.programInfo.write(c,book) '''Save the file into a specific location. This uses the tkfiledialog module to select the save location. The default save name is "DBMS Enrollment Data " and the timestamp date. A location must be chosen for save location. ''' timeStam = dateTimeOutput.pythonTime() #only the date of the timestamp will be printed Tk().withdraw() filename = asksaveasfilename(defaultextension = '.xls', initialfile = 'DBMS Enrollment Data ' + timeStam[:10]) while filename == '': #a location must be saved #UI.errorMessageBox.runApp("File was not saved. Please enter valid name.") filename = asksaveasfilename(defaultextension = '.xls', initialfile = 'DBMS Enrollment Data ' + timeStam[:10]) try: book.save(filename) except IndexError: #exists if no sheets are printed (empty file) pass except IOError: UI.errorMessageBox.runApp("Error: Please close all Excel workbooks.")
def runAppCourse(course): conn = extractData.connectDB() c = conn.cursor() return courseTuition(c , course)