def ConnTest(self, tabno, wait=None, messages=True): def FindWindow(name): l = [x for x in self.nbServer.GetChildren()[tabno].GetChildren() if ('_%s' % name) in x.GetName()] if l: out = l[0] else: out = None return out host, port, user, pswd, = map(lambda x: FindWindow(x).GetValue(), ('host', 'port', 'user', 'pswd')) if not host or not port or not user or not pswd: if wait: wait.Hide() aw.awu.MsgDialog(self, 'Definire tutti i parametri') return False test = adb.DB(dbType='mysql', globalConnection=False) ok = test.Connect(host=host, user=user, passwd=pswd, db=None)#, db='x4') if ok: test.Close() msg = 'Connessione riuscita' icon = wx.ICON_INFORMATION out = True else: msg = 'Connessione fallita:\n%s' % test.dbError.description icon = wx.ICON_ERROR out = False if wait: wait.Hide() if messages or not out: aw.awu.MsgDialog(self, msg, style=icon) return out
def existSupervisor(self, id): lEsito = False db = adb.DB() db._dbCon = self.db_conn db.connected = True ute = adb.DbTable('utenti', db=db, writable=False) if not ute.Retrieve("amministratore='X' and not id=%s" % id): util.MsgDialog(None,\ "Impossibile accedere alla tabella Utenti:\n"\ % repr(ute.GetError())) else: if ute.RowsCount() > 0: lEsito = True return lEsito
def existUser(self, code, user, lNew): lEsito = False db = adb.DB() db._dbCon = self.db_conn db.connected = True ute = adb.DbTable('utenti', db=db, writable=False) if not ute.Retrieve("codice='%s' or descriz='%s'" % (code, user)): util.MsgDialog(None,\ "Impossibile accedere alla tabella Utenti:\n"\ % repr(ute.GetError())) else: if ute.RowsCount() > 0 and lNew: lEsito = True elif ute.RowsCount() > 1 and not lNew: lEsito = True return lEsito
def __init__(self, *args, **kwargs): wx.Panel.__init__(self, *args, **kwargs) self.pm = adb.DbTable(bt.TABNAME_PROMEM, "promem", writable=True) self.pm.AddMultiJoin(bt.TABNAME_PROMEMU, "users", idLeft="id", idRight="id_promem", writable=True) dbu = adb.DB(globalConnection=False, openMode=adb.OPENMODE_READONLY) dbu.Connect(host=Env.Azienda.DB.servername, user=Env.Azienda.DB.username, passwd=Env.Azienda.DB.password, db='x4') self.utenti = adb.DbTable("utenti", fields="id,codice,descriz", writable=False, db=dbu) self.utenti.AddOrder("descriz") self.ucod = [] wdr.PromemPanelFunc(self) cn = lambda x: self.FindWindowByName(x) for name, flags in ( ('globale', { True: 1, False: 0 }), ('avvisa', { True: 1, False: 0 }), ('status', { True: 1, False: 0 }), ): cn(name).SetDataLink(name, flags) cn('_save').Bind(wx.EVT_BUTTON, self.OnSave) cn('_delete').Bind(wx.EVT_BUTTON, self.OnDelete) cn('globale').Bind(wx.EVT_CHECKBOX, self.OnGlobale) cn('avvisa').Bind(wx.EVT_CHECKBOX, self.OnAvviso) self._evtAvviso = False
def AppLoaded(self): self.SetJob("Inizializzazione terminata. Buon lavoro!", True) wx.Sleep(1) if self.splash is not None: self.splash.Hide() out = False self.TestUpdates() from selazienda import SelAziendaDialog aziDialog = SelAziendaDialog() if aziDialog.ShowModal() == 1: if self.db is None: self.db = adb.DB() else: self.db.Close() self.db.Connect(host = Env.Azienda.DB.servername, user = Env.Azienda.DB.username, passwd = Env.Azienda.DB.password, db = Env.Azienda.DB.schema) out = True aziDialog.Destroy() return out
class CatForDialog(ga._AnagDialog): """ Dialog Gestione tabella Categorie fornitori. """ def __init__(self, *args, **kwargs): if not kwargs.has_key('title') and len(args) < 3: kwargs['title'] = FRAME_TITLE ga._AnagDialog.__init__(self, *args, **kwargs) self.LoadAnagPanel(CatForPanel(self, -1)) # --------------------------------------------------------------------------- def runTest(frame, nb, log): win = CatForDialog() win.Show() return win # ------------------------------------------------------------------------------ if __name__ == '__main__': import sys,os import runtest import stormdb as adb db = adb.DB() db.Connect() runtest.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])