def displayData(self, student_id): loadCmb.courses_forYear(self.choice_rereg_course, gVar.schYr) self.student_id = student_id #rint'displayData', student_id lastMonthPaid = self.lastMonthPaid() if lastMonthPaid==12: self.panel_rereg.Show() self.panel_fees.Hide() else: self.monthFrom = lastMonthPaid + 1 if lastMonthPaid: txt = "%s" % fetch.monthName(self.monthFrom) self.text_ctrl_fee_description.SetValue(txt) self.text_ctrl_months.SetMax(12-lastMonthPaid) sql = "SELECT monthly_fee \ FROM students_by_form \ WHERE student_id = %d" % self.student_id self.monthly_fee = fetch.getDig(sql) fee = "{:,}".format(self.monthly_fee) self.text_ctrl_monthly_fee.SetValue(fee) self.OnMonthsChange(wx.Event) self.Layout
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 OnCourse(self, evt): #rint'OnCourse' course_id = fetch.cmbID(self.choice_course) sql = "SELECT course_fee_monthly \ FROM courses_by_year \ WHERE id =%d" % course_id res = fetch.getDig(sql) #rint'course_fee_monthly', res self.text_ctrl_course_fee.SetValue(str(res)) self.calcFeeTotal()
def lastMonthPaid(self): sql = "SELECT MAX(ii.month_to) \ FROM acc_invoices i \ JOIN acc_invoice_items ii ON i.id = ii.invoice_id \ JOIN acc_products p ON p.id = ii.product_id \ WHERE student_id =%d \ AND i.schYr =%d \ AND p.type = 1 " % (self.student_id, gVar.schYr) res = fetch.getDig(sql) #rintres return res
def courseNameAvailable(self, course_name): sql = 'SELECT id \ FROM courses \ WHERE name = %s \ AND schYr =%d' % (course_name, gVar.schYr) if self.editMode: sql += " AND NOT id = %d" % self.course_id #rint sql if fetch.getDig(sql): fetch.msg("Duplicate course name for this year, please try another") return False else: return True
def updateAddressIDs(): sql = "SELECT id, aiID, nextItemID FROM address_items" res = fetch.getAllCol(sql) i = 0 for row in res: iid, aiID, nextItemID = row sql = "SELECT id FROM address_items WHERE aiID = %d" % nextItemID ##rintsql next_item_id = fetch.getDig(sql) sql = "UPDATE address_items \ SET next_item_id = %d \ WHERE id = %d" % (next_item_id, iid) ##rintsql fetch.updateDB(sql)
def moveSiswaPerKelas(): sql = "TRUNCATE students_by_form" fetch.updateDB(sql) sql = "SELECT KKelas, NoInduk FROM SiswaPerKelas WHERE TahunAjaran > 2013" res = getAllDict(sql) #rintsql, res for row in res: form_id = row['KKelas'] NoInduk = row['NoInduk'] sql = "SELECT id FROM students WHERE NoInduk = '%s'" % NoInduk student_id = fetch.getDig(sql) sql = "INSERT INTO students_by_form (form_id, student_id) VALUES (%d, %d)" % (form_id, student_id) #rintsql fetch.updateDB(sql)
def getStaff_id(NoIndukStaf): sql = "SELECT id FROM staff WHERE NoInduk = '%s'" % NoIndukStaf res = fetch.getDig(sql) return res