def update_father_mother_guardian_id_into_students(): sql = " SELECT id, KOrangTua, KWali FROM students" res = fetch.getAllDict(sql) for row in res: sid = row['id'] KOrangTua = row['KOrangTua'] KWali = row['KWali'] #rint'Student:', sid, 'KOrangTua:', KOrangTua, ' KWali:', KWali if KWali: sql = "SELECT new_id FROM Wali WHERE Kode = %d" % KWali #rintsql new_id = fetch.getDig(sql) sql = "UPDATE students SET guardian_id = %d WHERE id =%d" % (new_id, sid) fetch.updateDB(sql) if KOrangTua: sql = "SELECT father_id, mother_id FROM OrangTua WHERE Kode = %d" % KOrangTua #rintsql res = fetch.getOneDict(sql) father_id = res['father_id'] mother_id = res['mother_id'] sql = "UPDATE students \ SET father_id = %d, mother_id =%d \ WHERE id = %d" % (father_id, mother_id, sid) fetch.updateDB(sql)
def displayData(self, jid=0): self.journal_id = jid self.loadSuppliers() self.loadDivisions() self.loadAccounts() if self.journal_id: txt = 'Edit Transaction No. %d' % self.journal_id self.SetTitle(txt) sql = "SELECT id, date, name + description AS description, \ ck_ref, supplier_ref, suppier_id, division_id \ FROM acc_journal \ WHERE id = %d" % self.journal_id res = fetch.getOneDict(sql) #rintsql, res self.text_ctrl_ckrefno.SetValue(res['ck_ref']) self.datepicker_ctrl_1.SetValue(res['date']) self.text_ctrl_description.SetValue(res['description']) self.text_ctrl_supplierrefno.SetValue(res['supplier_ref']) loadCmb.restore(self.choice_supplier, res['suppier_id']) loadCmb.restore(self.choice_division, res['division_id']) self.listDebitItems() self.listCreditItems()
def getMonthFrom(self, ): sql = "SELECT MAX(ii.month_from) AS monthFrom, \ MAX(ii.month_to) AS monthTo \ FROM acc_invoices i \ JOIN acc_invoice_items ii ON i.id = ii.invoice_id \ WHERE ii.product_id = %d \ AND i.student_id ='%s' \ AND i.schYr = %d " % (1, self.student_id, gVar.schYr) res = fetch.getOneDict(sql) #rintsql, res if res: monthFrom = res['monthFrom'] monthTo = res['monthTo'] if monthTo: self.monthFrom = monthTo + 1 else: self.monthFrom = monthFrom + 1 else: self.monthFrom = 1 return self.monthFrom
def showData(self): """ TYPE CLASSNAME CURRENT_POPULATION LEAVING RETAKE CONTINUE TOTAL CLASS_SIZE CLASSES PENDING_BOOKINGS notes heading CLASSNAME CURRENT_POPULATION LEAVING RETAKE CONTINUE kelas ClassName CurrentPopulation Leaving Retake Continue kelas ClassName CurrentPopulation Leaving Retake Continue tot Totals CurrentPopulation Leaving Retake Continue heading NEXTCLASSNAME NEW CONTINUE TOTAL CLASS_SIZE CLASSES PENDING_BOOKINGS course nextclassname New Continue tot Pending_Bookings course nextclassname New Continue tot Pending_Bookings space """ mylist = [] mylist.append(("TYPE", "FORM NAME", "POP.NOW", "OUT", "RETAKE", "CONT.", "TOTAL", "FORM SIZE", "FORMS", "PENDING BOOKINGS", "NOTES") ) # list of course ids for year sql ="SELECT courses \ FROM courses_by_year \ WHERE schYr = %s" % gVar.schYr course_ids = fetch.getList(sql) sql ="SELECT level \ FROM courses_levels \ ORDER BY course_level" course_levels = fetch.getList(sql) for level in course_levels: for course_id in course_ids: sql ="SELECT id, name, school_id \ FROM courses \ WHERE level=%d AND id =%d" % (int(level), int(course_id)) res = fetch.getAllDict(sql) for row in res: mylist.append(row) #rintmylist for level in range(3,20): # show last years classes & students sql ="SELECT id, name, school_id \ FROM forms \ WHERE level=%d AND schYr =%d" % (level, gVar.schYr-1) forms = fetch.getAllDict(sql) level_totals =[0,0,0,0,0] for myForm in forms: form_id = myForm[0] now = fetch.formPopulation(form_id) #GetClassPopulation level_totals[0]+=now cont = 4 #GetRereg level_totals[1]+=cont out = 2 #GetStudentsLeaving level_totals[2]+=out redo = 1 #GetStudentsRetaking level_totals[3]+=redo subtot = cont-out+redo level_totals[4]+=subtot index = self.listCtrl.Append((myForm[1], now, cont, out, redo, subtot)) self.listCtrl.SetItemData(index, form_id) self.listCtrl.Append(('Totals', str(level_totals[0]), str(level_totals[1]), str(level_totals[2]), str(level_totals[3]), str(level_totals[4]))) # list of Kelas for this sch yr sql ="SELECT c.id, c.name \ FROM courses c \ JOIN students ON s.join_course_id = c.id) \ WHERE s.register_schYr = %d AND c.level=%d" % (gVar.schYr, level ) res2 = fetch.getAllDict(sql) for row in res2: self.listCtrl.Append(('New reg','','','')) #sql ="SELECT * FROM cSiswa WHERE TahunAjaran = %d AND Kelas =%d" % (gVar.schYr, ) return for course_id in results: sql ="SELECT id, school_id, level, name \ FROM courses \ WHERE id =%d" % int(course_id) course = fetch.getOneDict(sql) mylist.append(course) mylist.sort(key=lambda tup: tup[1]) mylist = [(tup[1], tup) for tup in mylist] school_ids = list(set(mylist)) sql ="SELECT level, name \ FROM courses \ ORDER BY level, name" results = fetch.getAllDict(sql)