Exemplo n.º 1
0
    def OnSave(self, evt):
	street    = str(self.text_ctrl_street.GetValue()).strip()
	house     = str(self.text_ctrl_house.GetValue()).strip()
	estate    = str(fetch.cmbValue(self.combo_box_estate))
	block     = str(self.text_ctrl_block.GetValue()).strip()
	road      = str(self.text_ctrl_road.GetValue()).strip()
	kelurahan = str(fetch.cmbValue(self.combo_kelurahan))
	kecamatan = str(fetch.cmbValue(self.combo_kecamatan))
	kabupaten = str(fetch.cmbValue(self.combo_kabupaten))
	postcode  = str(self.num_ctrl_postcode.GetValue())
	province  = str(fetch.cmbValue(self.combo_province))
	country   = str(fetch.cmbValue(self.combo_country))
			    
	if not street or not house or not province:
	    fetch.msg('At least houseNo, street & province are needed')
	    return
	
	address =','.join((street,house,estate,block,road,kelurahan,kecamatan,kabupaten,postcode,province,country))
        #rintgVar.table, gVar.column, address, gVar.guardian_id
	sql = "UPDATE %s \
                  SET %s= '%s' \
                WHERE id = %d" %(gVar.table, gVar.column, address, gVar.guardian_id)
        #rintsql
        fetch.updateDB(sql)
	gVar.editedFlag = True
	#rint'set gVar.editedFlag to True'
	self.GetTopLevelParent().goBack()
Exemplo n.º 2
0
    def OnSave(self, evt):
        # aim to make this generic
        
	table  = 'guardians' 
	column = 'address'
	
	street    = str(self.text_ctrl_street.GetValue())
	house     = str(self.text_ctrl_house.GetValue())
	estate    = str(fetch.cmbValue(self.combo_estate))
	block     = str(self.text_ctrl_block.GetValue())
	road      = str(self.text_ctrl_road.GetValue())
	kelurahan = str(fetch.cmbValue(self.combo_kelurahan))
	kecamatan = self.combo_kecamatan.GetStringSelection()
	kabupaten = str(fetch.cmbValue(self.combo_kabupaten))
	postcode  = str(self.num_ctrl_postcode.GetValue())
	province  = str(fetch.cmbValue(self.combo_province))
	country   = str(fetch.cmbValue(self.combo_country))
			    
	if not street or not house or not province:
	    fetch.msg('At least houseNo, street & province are needed')
	    return
	
	address =','.join((street,house,estate,block,road,kelurahan,kecamatan,kabupaten,postcode,province,country))
        sql = "UPDATE %s \
                  SET address = '%s' \
                WHERE id =%d" %(table, address, self.guardian_id)
        #rintsql
        fetch.updateDB(sql)
Exemplo n.º 3
0
 def insertNewStudent(self):
     name    = self.text_ctrl_student_name.GetValue()
     gender    = fetch.cmbID(self.choice_gender)
     register_course_id   = fetch.cmbID(self.choice_joining_course)
     registration_status  = self.choice_status.GetCurrentSelection()
     
     sql = "SELECT MAX (student_id) \
              FROM students"
     student_id = fetch.getDig(sql)+1
     try:     dob = self.date_dob.caldate
     except:  dob = 0
         
     if name and register_course_id and registration_status and dob and gender <2:
         sql = "INSERT INTO students (student_id, name, dob, schYr, \
                                      registration_status, register_course_id, gender) \
                              VALUES (%d, '%s', '%s', %d, %d, %d, %d)" % (
                                      student_id, name, dob,  gVar.schYr,
                                      registration_status, register_course_id, gender)
         return sql, []
     
         """
         sql = "INSERT INTO students (student_id, name, dob, schYr, registration_status, register_course_id, gender) \
                            VALUES (?, ?, ?, ?, ?, ?, ?)"
         return sql, (student_id, name, dob,  gVar.schYr, registration_status, register_course_id, gender)"""
         
     else:
         fetch.msg('Fields Name, Course, DOB, registration_status & Gender need to be filled')
         return 'fail', []
Exemplo n.º 4
0
 def deleteRow(self, grid):
     rows = grid.GetSelectedRows()
     #rint'GetSelectedRows', rows
     if len(rows)==1:
         grid.deleteRow(rows[0])
         grid.calcTotal()
     else:
         fetch.msg('select one row only')
Exemplo n.º 5
0
 def edit(self, cmb1, cmb2, itemType):
     #rint'edit   type:',itemType
     
     nextItem = ''
     
     self.restore_id = self.cmbID(cmb1)
     restoreString = fetch.cmbValue(cmb1)
     if not self.restore_id:
         # prepare data for new entry
         if itemType=='country':
             self.next_item_id = 0
         else:
             if cmb2:
                 next_item_id = self.cmbID(cmb2)
                 #rintcmb2.GetName(), 'next_item_id', next_item_id
                 nextItem   = fetch.cmbValue(cmb2)
                 if not next_item_id:
                     fetch.msg('Please Select A Follow On Item')
                     return
     
     dlg = DlgAddrItemEditor.create(None)
     try:
         dlg.displayData(self.restore_id, itemType, nextItem)
         if dlg.ShowModal() == wx.ID_OK:
             itemName = dlg.itemName
             if not itemName: return
             
             # prevent duplicate name if country
             # prevent duplicate name where next item same
             # warning of other duplicate names -if not kelurahan
             
             if self.restore_id: # editing an item
                 if itemName == restoreString:
                     return
                 else:
                     sql = "UPDATE address_items \
                               SET name ='%s' \
                             WHERE %id = %d" % (itemName, self.restore_id)
                     #rint sql
                     cmb1.SetValue(itemName)
                     
             else: # insert a new item
                 if self.next_item_id: 
                     sql = "INSERT INTO address_items \
                                   (name, type, next_item_id) \
                            VALUES ('%s', '%s', '%s')" % (
                                    itemName, itemType, self.next_item_id)
                 else:
                     sql = "INSERT INTO address_items \
                                   (name, type) \
                            VALUES ('%s', '%s')" % (
                                    itemName, itemType)
                 #rintsql
                 fetch.updateDB(sql)
                   
     finally:    
         dlg.Destroy()
Exemplo n.º 6
0
 def OnAddYear(self, evt):
     if not self.new_year:
         res = fetch.getDig( "SELECT MAX(schYr) FROM schYrs" )
         yid = fetch.nextID('schYrs')
         if res :
             self.new_year = res + 1
             self.choice_schYr.Append(str(self.new_year), yid)
             loadCmb.restore(self.choice_schYr, yid)
     else:
         fetch.msg('A new year has already been added. Save First')
Exemplo n.º 7
0
 def setGen(self, selectedItemID, aList, cmb):
     if aList:
         r = aList[0]
         if len(r) != 2:
             fetch.msg('list error')
         
         if len(aList)  > 1: selectedItemID = self.setComboItems(cmb, aList)
         elif len(aList)==1:
             selectedItemID =  aList[0][0]
             loadCmb.restore(cmb, selectedItemID)
         else:               self.clearPostcodeCtrls((cmb,))
     return selectedItemID
Exemplo n.º 8
0
 def OnSave(self, evt):
     print
     print
     #rint'OnSave--------------'
     
     division_id  = fetch.cmbID(self.choice_divisioan)
     date         = self.datepicker_ctrl_1.GetDbReadyValue()
     tran_description  = self.text_ctrl_tans_descript.GetValue()
     #ckRef        = self.text_ctrl_ckrefno.GetValue()
     supplierRef  = self.text_ctrl_supplierrefno.GetValue()
     
     supplier_id = fetch.cmbID(self.choice_supplier)
     
     pettycash = self.checkbox_pettycash.GetValue()
     
     debit_items_count  = self.grid_debits.getItemCount()
     credit_items_count = self.grid_credits.getItemCount()
     msg = ''
     
     if not division_id:
         msg += '- division\n'
         
     if not tran_description:
         msg += '-transaction description\n'
         
     if not supplier_id:
          msg += '-supplier\n'
     
     if not date:
         msg += '-transaction date\n'
     
     if not ckRef:
         msg += '-ck ref missing\n'
     
     if debit_items_count + credit_items_count == 0:
         msg += '-credit or debit entries\n'
         
     if msg:
         msg = 'Missing Items:\n' + msg
         fetch.msg(msg)
         return
     
     if self.debit_total != self.credit_total:
         fetch.msg('transaction totals do not match')
     
     data = (supplier_id, date, tran_description,  supplier_id, supplierRef, pettycash)
     if self.jurnal_id:
         self.updateEntries(data)
     else:
         self.newEntry(data)
Exemplo n.º 9
0
   def OnAddCredit(self, evt):
       #rint'Add credit'
       gVar.listCtrl = 'c'
       account_id=fetch.cmbID(self.choice_credits)
 
       if self.id_in_grid(account_id, self.grid_credits): return
       
       if self.id_in_grid(account_id, self.grid_debits):
           fetch.msg('can add this account, already in debits')
       
       account = fetch.cmbValue(self.choice_credits)
       #rint'OnAddCredit', account
       
       self.grid_credits.appendItem((account_id, account, 0))
       self.grid_credits.calcTotal()
Exemplo n.º 10
0
    def OnNewSupplier(self, evt):
        #rint"open dlgTextEntry 'new supplier' "
        dlg = wx.TextEntryDialog(self, 'Supplier Name', 'New Supplier Name', '')
 
        if dlg.ShowModal() == wx.ID_OK:
            new_name = dlg.GetValue().strip()
            if new_name:
                sql = "SELECT Nama FROM Suplier WHERE Nama = '%s'" % new_name
                if fetch.getCount(sql):
                    msg = "Sorry supplier '%s' already exists" % new_name
                    fetch.msg(msg)
                else:
                    sql = "INSERT INTO Suplier (Nama) VALUES ('%s')" % new_name
                    fetch.updateDB(sql)
                    self.loadSuppliers()
                    loadCmb.restore_str(self.choice_supplier, new_name)
Exemplo n.º 11
0
 def OnEnter(self, event):
     activity_id = fetch.cmbID(self.choice_activity)
     
     if not activity_id:
         fetch.msg("! Must have an activity selected !")
         return
     
     teacher_id  = fetch.cmbID(self.choice_teacher)
     
     if self.editMode:
         self.update(activity_id, teacher_id)
         self.EndModal(wx.ID_OK)
         
     else:
         if self.insertNewActivity(activity_id, teacher_id):
             self.EndModal(wx.ID_OK)
Exemplo n.º 12
0
    def schoolNameAvailable(self, school_name):
        sql = (
            "SELECT id FROM schools \
                WHERE name = %s "
            % (school_name)
        )

        if self.editMode:
            sql += " AND NOT id = %d" % gVar.school_id

        # rint sql
        if fetch.getDig(sql):
            fetch.msg("Duplicate name, please try another")
            return False

        else:
            return True
Exemplo n.º 13
0
 def OnNewDivision(self, evt):
     dlg = wx.TextEntryDialog(self, 'Division Name', 'New Division Name', '')
     if dlg.ShowModal() == wx.ID_OK:
         new_name = dlg.GetValue().strip()
         if new_name:
             sql = "SELECT Nama FROM Divisi WHERE Nama = '%s'" % new_name
             if fetch.getCount(sql):
                 msg = "Sorry division '%s' already exists" % new_name
                 fetch.msg(msg)
             else:
                 next_id = fetch.nextID('Divisi')
                 sql = "INSERT INTO Divisi (Kode, Nama) VALUES (%d, '%s')" % (next_id, new_name)
                 #rintsql
                 fetch.updateDB(sql)
                 self.loadDivisions()
                 loadCmb.restore_str(self.choice_division, new_name)
     dlg.Destroy()
Exemplo n.º 14
0
    def OnEditAddress(self, evt):
	#rint'panel_guardian_data    OnEditAddress'
	if not self.guardian_id:
	    fetch.msg('can not enter address before guardian has been created')
	    return
	
	gVar.guardian_id = self.guardian_id
	gVar.address     = self.address
	
	#self.GetTopLevelParent().goTo('edit_address')
	dlg = DlgEditAddress.create(None)
        try:
            dlg.ShowModal()
            gVar.address = dlg.getEditedAddress()
	    if address == gVar.address:
		pass
	    else:
		pass
		#rint'update g'
        finally:
            dlg.Destroy()
Exemplo n.º 15
0
 def setGen(self, selectedItemID, aList, cmb):
     #rint'set gen'
     if aList:
         #rint' we have a list'
         r = aList[0]
         if len(r) != 2:
             fetch.msg('list error')
         
         if len(aList)  > 1:
             selectedItemID = self.setComboItems(cmb, aList)
             
         elif len(aList)==1:
             ##rint'aList on one: ', aList
             selectedItemID =  int(aList[0][0])
             ##rint'selectedItem>ID>', selectedItemID, cmb, cmb.GetName()
             if selectedItemID:
                 self.restore(cmb, selectedItemID)
                 
         else:
             self.clearPostcodeCtrls((cmb,))
     ##rint'setCmn return id', selectedItemID
     return selectedItemID
Exemplo n.º 16
0
    def OnSave(self, event):
        self.course_name  = self.text_ctrl_course_name.GetValue()
        self.course_level = int(self.choice_levels.GetStringSelection())
        self.school_id    = fetch.cmbID(self.choice_schools)

        if self.course_name:
            if self.course_id:
                #rint"Update course id:", self.course_id
                self.updateCourse()
                self.EndModal(wx.ID_OK)
            else:
                if self.courseNameAvailable(self.course_name):
                    #rint"Add new course:" , self.course_name
                    self.insertNewCourse()
                    self.EndModal(wx.ID_OK)
                else:
                    txt = "Course Name Must Be Unique"
                    fetch.msg(txt)
                    return
        else:
            txt = "Must have course title"
            fetch.msg(txt)
Exemplo n.º 17
0
 def OnSave(self, evt):
     #rint'OnSave'
     name =    self.text_ctrl_supplier_name.GetValue().strip()
     address = self.text_ctrl_supplier_address.GetValue()
     telp =    self.text_ctrl_supplier_telp.GetValue()
     if not name:
         fetch.msg('Name required')
         return
     
     if self.editing == True:
         sql = "UPDATE acc_suppliers \
                   SET name='%s', address = '%s', telp='%s' \
                 WHERE id = %d" % (name, address, telp, self.sid)
         # update list
         
     else:
         sql = "INSERT INTO acc_suppliers \
                       (name, address, telp) \
                VALUES ('%s', '%s' ,'%s')" % (name, address, telp)
         
     fetch.updateDB(sql)
     self.displayData()
     self.OnCancel(wx.Event)
Exemplo n.º 18
0
    def OnSave(self, evt):
        pass
        #rint'OnSave'
               
        acc_catagory_id = fetch.cmbID(self.choice_account_catagory)
        code_2 = self.text_ctrl_acc_code_2.GetValue()
        code_3 = self.text_ctrl_acc_code_3.GetValue()
        code_4 = self.text_ctrl_acc_code_4.GetValue()
        
        acc_code = "%s%s%s%s" % (acc_catagory_id, code_2, code_3, code_4)
        acc_code = acc_code.strip()
  
        if len(acc_code)<7:
            fetch.msg('Account code incomplete')
            return
        
        account_name = self.text_ctrl_section_name.GetValue()
        if not account_name:
            fetch.msg('Name required') 
            return
        
        if not self.editing: 
            if fetch.acc_code_exists(acc_code):
                fetch.msg('Account code already in use')
                return

            if fetch.acc_name_exists(account_name):
                fetch.msg('Account name in use - please try another')
                return
            
        start_ballance = self.text_ctrl_balance.GetValue()

        if self.editing:
            sql = "UPDATE acc_accounts \
                      SET name, balance=%d ='%s', acc_catagory_id = %d \
                    WHERE code = %d" % (account_name, start_ballance, acc_code, acc_catagory_id)
                
        else:
            sql = "INSERT INTO acc_accounts \
                              (name, balance, code, acc_catagory_id) \
                       VALUES('%s', %d, %d)" % ( 
                               account_name, int(start_ballance), int(acc_code), acc_catagory_id)
        #rintsql
        #fetch.updateDB(sql)
        
        self.OnCancel(wx.Event)
        self.displayDetails()
Exemplo n.º 19
0
 def OnSave(self, evt):
     description  = self.text_ctrl_description.GetValue()
     price        = self.text_ctrl_price.GetValue()
     is_recurring = self.checkbox_is_recurring.GetValue()
     monthly      = self.checkbox_monthly.GetValue()
     valid_from   = self.datectrl_from.GetDbReadyValue()
     valid_to     = self.datectrl_to.GetDbReadyValue()
     product_type = fetch.cmbID(self.choice_type)
     if not price or not description:
         fetch.msg('Not all fields complete')
     
 
     #rint"values",  description, price, is_recurring, monthly, valid_from, valid_to, product_type
     
     if fetch.is_unique_product(description):
         sql = "INSERT INTO acc_products \
                           (description, price, is_recurring, \
                            recurring_monthly, valid_from, valid_to, type) \
                     VALUES ('%s', %d, %d, %d, '%s', '%s', %d) " % (
                             description, int(price), is_recurring,
                             monthly, valid_from, valid_to, product_type)
         #rintsql
         fetch.updateDB(sql)
     self.Close()
Exemplo n.º 20
0
 def updateEntries(self, data):
     supplier_id, date, tran_description, ckRef, supplier_id, supplierRef, pettycash = data
     
     debit_items  = self.grid_debits.getItemCount()
     credit_items = self.grid_credits.getItemCount()
     
     print
     #rint'updateEntries'
     
     print
     #rint'remove existing entries'
     sql = "DELETE FROM JurnalD WHERE KJurnal = %d" % self.jurnal_id
     #rintsql
         
     sql = "DELETE FROM JurnalD WHERE KJurnal = %d" % self.jurnal_id
     #rint"remove all credit & debit items", sql
     
     if not (debit_items + credit_items)> 0:
         sql1 = "DELETE FROM Jurnal WHERE Kode = %d" % self.jurnal_id
         msg =  'No debit items or credit items. Please edit'
         fetch.msg(msg)
         return
         
     else:
         # update jurnal details
         sql = "UPDATE Jurnal \
                   SET KSuplier=%d, Tanggal='%s', Transaksi='%s', \
                       Keterangan='%s', NoBuktiKantor='%s', NoBuktiSuplier='%s', PettyCash = %s \
                 WHERE Kode = %d" % (
                       supplier_id, date, tran_description,
                       tran_description[255:], ckRef, supplierRef, pettycash, 
                       self.jurnal_id)
         #rint'\nUpdate jurnal details'
         #rintsql
         
         # 'insert each debit item'
         if debit_items:
             pass
             #rint'insert each debit item'
         for x in range(0, debit_items):
             account_id = int(self.grid_debits.GetCellValue(x, 0))
             amount = self.grid_debits.GetCellValue(x, 2)
             amount = float(amount.replace(',',''))
             sql = "INSERT INTO JurnalD \
                       SET (KJurnal, KPerkiraan, Debet, Jumlah) \
                    VALUES (%d, %d, %d, %d)" % (self.jurnal_id, account_id, True, amount)
             
             #rintsql
         
         # 'insert each debit item'
         if credit_items:
             pass
             #rint'insert each debit item'
         for x in range(0, credit_items):
             account_id = int(self.grid_credits.GetCellValue(x, 0))
             amount = self.grid_credits.GetCellValue(x, 2)
             amount = float(amount.replace(',',''))
             sql = "INSERT INTO JurnalD \
                       SET (KJurnal, KPerkiraan, Debet, Jumlah) \
                    VALUES (%d, %d, %d, %d)" % (self.jurnal_id, account_id, False, amount)
             
             #rintsql
     
     self.EndModal(wx.ID_OK)