def pullClass(self, a): self.a = a cn = Db() students = cn.select('datas', '', '', {'subID': self.a}) arr = {} for j in students: arr[j[0]] = j[2] return arr
def pullClass(self): cn = Db() students = cn.select('session', '', '') arr = {} try: for j in students: arr[j[0]] = [j[1], j[2], j[3], j[4]] except: pass return arr
def pullClass(self, a): self.a = a cn = Db() cn.createData() datas = cn.select('datas', '' , '', {'subID':self.a}) arr = {} try: for j in datas: arr[j[0]] =[j[1], j[3], j[4], j[5]] except: pass return arr
def classRemoveStudent(self, session, students): session = session classtable = 'student_class'+str(session) arr = [] g = Db() for student in students: f = g.select(classtable, '', 1, {'studentID':student}) if f and int(f[0]) > 1: h = g.delete(classtable, {'studentID': student}) h = f[0] else: pass arr.append(h) return arr
def classMoveStudent(self, session, moveclass, students): session = session classtable = 'student_class'+str(session) arr = [] g = Db() for student in students: f = g.select(classtable, '', 1, {'studentID':student}) if f and int(f[0]) > 1: h = g.update(classtable, {'classID': moveclass}, {'id': f[0]}) h = f[0] else: h = g.insert(classtable, {'studentID': student, 'classID': moveclass,'active': 0}) arr.append(h) return arr
def pullDetails(self, a): self.a = a cn = Db() datas = cn.select('datas', '', 1, {'id': self.a}) return datas
def callData(self, a): # select a file self.a = a g = Db() return g.select('session', '', 1, {'id': self.a})
def pullSession(self, a): # select a file self.a = a g = Db() return g.select('session', '', 1, {'id': self.a})
def chkFunc(self, a, c, d, b): # checkbox select to make fuul payment self.a = a db_fee = 'student_fee' + str(self.term) db_pay = 'student_pay' + str(self.term) amount = self.payAmount.text() teller = self.teller.text() # get all paments made for that fee # get the check box g = Db() fee = g.selectn(db_fee, '', 1, {'id': a}) loc = self.holdfee[int(fee['feeID'])] poc = self.holdpaid[int(fee['feeID'])] pocc = self.holdcpaid[int(fee['feeID'])] try: ## fee was checked full pay ## confirm if money posted and its greater than or equals # confimr if teller number was provided ## if those conditions are met payment of fees is possible if (float(amount) >= float(d)) and len(str(teller)) > 0: # confirm if the checkbox was checked if loc.isChecked() == True: #if it was checked prepare to insert payment data pay = {} pay['studentID'] = self.student pay['accountID'] = self.payAmount.text() pay['amount'] = d pay['teller'] = teller pay['feeID'] = fee['feeID'] pay['datepaid'] = self.payDate.date().toPyDate() # however confirm if full payment had bee made b4 dat = g.select(db_pay, '', '', { 'studentID': self.student, 'feeID': fee['feeID'] }) if dat and len(dat) > 0 and float( dat[0]['amount']) > 0 and float( dat[0]['amount']) == float(d): # full payment made # dont post # keep part pay disabled poc.hide() pocc.hide() # inform user msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setWindowTitle("Info") msg.setText( "This fee has already been paid for. You cannot repay for it" ) msg.setStandardButtons(QMessageBox.Cancel) msg.exec_() else: # post payment h = g.insert(db_pay, pay) if int(h) > 0: # deduct from balance # keep part pay disabled] poc.hide() pocc.hide() # recalculate self.reCalFull() self.reCalSingleBal() else: poc.show() else: # money was not posted if len(str(self.teller.text())) > 0: pay = {} pay['studentID'] = self.student pay['teller'] = self.teller.text() pay['feeID'] = fee['feeID'] h = g.delete(db_pay, pay) poc.show() pocc.show() self.reCalFull() self.reCalSingleBal() else: msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setWindowTitle("Info") msg.setText( "Please provide the teller/receipt details before removing amount." ) msg.setStandardButtons(QMessageBox.Cancel) msg.exec_() #add to money ## if those conditions are not met # payment of fees is not possible # however user might want to revoke a payment # meaning checkbox was unchecked else: if loc.isChecked() == False: # prepare to remove payment pay = {} pay['studentID'] = self.student pay['teller'] = self.teller.text() pay['feeID'] = fee['feeID'] # remove payment h = g.delete(db_pay, pay) # confirm if removal was succesful if h == 1: # if successful poc.show() pocc.show() # refund balance # recalculate self.reCalFull() self.reCalSingleBal() else: # not sussefull # details not complete #restore it to check #loc.setChecked(True) poc.hide() pocc.hide() # inform user msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setWindowTitle("Safety Measure:") msg.setText( "You will need to enter the correct teller/receipt details for this payment before removing it" ) msg.setStandardButtons(QMessageBox.Cancel) msg.exec_() # user trying to make payment with no funds else: # uncheck user loc.setChecked(False) poc.show() pocc.show() #give info msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setWindowTitle(" Payment Error") msg.setText( "Please provide teller/receipt details or Insufficient funds to make full payments " ) msg.setStandardButtons(QMessageBox.Cancel) msg.exec_() except: if loc.isChecked() == False: # money was not posted if len(str(self.teller.text())) > 0: pay = {} pay['studentID'] = self.student pay['teller'] = self.teller.text() pay['feeID'] = fee['feeID'] h = g.delete(db_pay, pay) poc.show() pocc.show() self.reCalFull() self.reCalSingleBal() else: pass else: loc.setChecked(False) poc.show() pocc.show() msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setWindowTitle(" Payment Error:") msg.setText("Please insert amount and Teller/Receipt details ") msg.setStandardButtons(QMessageBox.Cancel) msg.exec_()