示例#1
0
 def button_delete(self):
     item = self.mySelectTable()
     _session = self.session
     g = Db()
     db = 'school_stores' + str(_session)
     for j in item:
         g.delete(db, {'id': j})
     self.reloadTable(1)
 def removeSubject(self, a, b):
     session = self.session
     db = 'student_subject' + str(session)
     g = Db()
     for i in a:
         for j in b:
             f = g.selectn(db, '', 1, {'studentID': i, 'subjectID': j})
             if f and f['id'] > 0:
                 g.delete(db, {'id': f['id']})
    def button_click(self):
        subject = self.getValue()
        #clasz = self.classCombo.itemData(self.classCombo.currentIndex())
        clasz = self.class_arr[self.classCombo.currentIndex()]
        ## set class
        g = Db()
        sel = g.selectn(self.db_class, '', 1, {'studentID': self.student})

        if sel and sel['id'] > 0:
            if int(sel['classID']) == clasz:
                pass
            else:
                g.update(self.db_class, {'classID': clasz}, {'id': sel['id']})
        else:
            g.insert(self.db_class, {
                'studentID': self.student,
                'classID': clasz
            })

        if len(subject[0]) > 0:
            for a in subject[0]:
                sel = g.selectn(self.db_subject, '', 1, {
                    'studentID': self.student,
                    'subjectID': a
                })
                if sel and int(sel['id']) > 0:
                    pass
                else:
                    g.insert(self.db_subject, {
                        'studentID': self.student,
                        'subjectID': a
                    })

        if len(subject[1]) > 0:
            for a in subject[1]:
                g.delete(self.db_subject, {
                    'studentID': self.student,
                    'subjectID': a
                })

        ## set subject
        self.accept()
示例#4
0
 def button_click(self):
     arr = {}
     arr['namex'] = self.schoolNameData.text()
     arr['alias'] = self.schoolAliasData.text()
     arr['motto'] = self.schoolMottoData.text()
     arr['address'] = self.schoolAddressData.text()
     arr['city'] = self.schoolCityData.text()
     arr['country'] = self.schoolCountryData.text()
     arr['state'] = self.schoolStateData.text()
     arr['email1'] = self.schoolEmail1Data.text()
     arr['email2'] = self.schoolEmail2Data.text()
     arr['phone1'] = self.schoolPhone1Data.text()
     arr['phone2'] = self.schoolPhone2Data.text()
     arr['zip'] = self.schoolZipData.text()
     arr['pmb'] = self.schoolPmbData.text()
     arr['color1'] = self.colorPrimaryLbl.text()
     arr['color2'] = self.colorSecondaryLbl.text()
     
     #print(arr)
     db = 'datas'
     g = Db()
     
     for a in arr:
         s = g.selectn(db , '', 1, {'pubID':'datas', 'name':a})
         if s and s['id'] > 0:
             if arr[a] and len(arr[a]) > 0:
                 g.update(db, {'description': arr[a]}, {'id':s['id']})
             else:
                 g.delete(db, {'id':s['id']})
         else:
             if arr[a] and len(arr[a]) > 0:
                 print(arr[a])
                 g.insert(db, {'pubID': 'datas', 'name':a, 'description': arr[a]})
     
 
     self.button_close(self)
示例#5
0
 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
示例#6
0
    def chkFunc1(self, a, b, c):
        # 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[b]
        payfull = self.holdtextfee[b]
        pocc = self.holdpaid[b]
        poc = self.holdcpaid[b]

        d = pocc.text()

        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 poc.isChecked() == True:
                    #if it was checked prepare to insert payment data
                    pay = {}
                    pay['studentID'] = self.student
                    pay['accountID'] = self.payAmount.text()
                    pay['teller'] = teller
                    pay['feeID'] = fee['feeID']
                    pay['datepaid'] = self.payDate.date().toPyDate()
                    # however confirm if full payment had bee made b4
                    dat = g.selectn(db_pay, '', '', {
                        'studentID': self.student,
                        'feeID': fee['feeID']
                    })

                    if dat and len(dat) > 0:
                        mon = list()
                        for dd in dat:
                            mon.append(float(dd['amount']))
                        # full payment made
                        # dont post
                        # keep part pay disabled
                        total_money_paid = sum(mon)
                        #no payments required
                        if float(total_money_paid) >= float(payfull):
                            pass
                        #payment required
                        elif float(total_money_paid) < float(payfull):
                            if float(amount) >= float(d):
                                pay['amount'] = d
                                #post
                                h = g.insert(db_pay, pay)
                                if int(h) > 0:
                                    # deduct from balance

                                    # keep part pay disabled]
                                    loc.hide()
                                    pocc.setDisabled(True)
                                    # recalculate
                                    self.reCalFull()
                                    self.reCalPart()
                                    self.reCalSingleBal()
                                else:
                                    poc.show()
                            else:
                                msg = QMessageBox()
                                msg.setIcon(QMessageBox.Information)
                                msg.setWindowTitle("Info")
                                msg.setText("Insufficient funds.")
                                msg.setStandardButtons(QMessageBox.Cancel)
                                msg.exec_()

                        loc.hide()
                        pocc.setDisabled(True)
                        # inform user

                    else:
                        # post payment
                        if float(amount) >= float(d):
                            pay['amount'] = d

                            #post
                            h = g.insert(db_pay, pay)

                            if int(h) > 0:
                                # deduct from balance

                                # keep part pay disabled]
                                loc.hide()
                                pocc.setDisabled(True)
                                # recalculate
                                self.reCalFull()
                                self.reCalSingleBal()
                            else:
                                poc.show()

                    # 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_()