def createAccountCallback(self): if len(self.firstNameTextInput.text.strip()) == 0 \ or len(self.lastNameTextInput.text.strip()) == 0\ or len(self.phoneNumberTextInput.text.strip()) == 0\ or len(self.nationalCodeTextInput.text.strip()) == 0: Alert(title="Input Error", text='Empty Fields are not Allowed Here! Try Again') return try: resultCode = createAccount(readToken(), \ self.firstNameTextInput.text.strip(), \ self.lastNameTextInput.text.strip(), \ self.phoneNumberTextInput.text.strip(), \ self.nationalCodeTextInput.text.strip()) if resultCode == INVALID_TOKEN_CODE: removeToken() self.app.screenManager.current = LOGIN_SCREEN Alert(title="Authentication Error", text='Please Login Again') elif resultCode == DUPLICATE_CODE: Alert(title="Input Error", text='Owner with this ID Already Exists!') elif resultCode == POST_SUCCESS_CODE: self.app.screenManager.current = MENU_SCREEN Alert(title="Success", text='New Account Successfully Created') else: self.app.screenManager.current = MENU_SCREEN Alert(title="Create Account Error", text='Please Try Again Later') except Exception: Alert(title="Connection Error", text='Connection Error, Try Again Later')
def signUpCallback(self): if len(self.usernameTextInput.text.strip()) == 0 \ or len(self.passwordTextInput.text.strip()) == 0\ or len(self.repeatPasswordTextInput.text.strip()) == 0: Alert(title="Input Error", text='Empty Fields are not Allowed Here! Try Again') return if not self.passwordTextInput.text.strip() ==\ self.repeatPasswordTextInput.text.strip(): Alert(title="Input Error", text='Passwords do not match! Try Again') return try: resultCode = signUp(readToken(), self.usernameTextInput.text.strip(), self.passwordTextInput.text.strip()) if resultCode == INVALID_TOKEN_CODE: removeToken() self.app.screenManager.current = LOGIN_SCREEN Alert(title="Authentication Error", text='Please Login Again') elif resultCode == INVALID_CODE: Alert(title="Input Error", text='User with this Username Already Exists!') elif resultCode == POST_SUCCESS_CODE: self.app.screenManager.current = MENU_SCREEN Alert(title="Success", text='New Clerk Successfully Registered') else: self.app.screenManager.current = MENU_SCREEN Alert(title="Register Error", text='Please Try Again Later') except Exception: Alert(title="Connection Error", text='Connection Error, Try Again Later')
def blockAccountCallback(self): try: result = changeAccountStatus(readToken(), self.accountNumberTextInput.text.strip(), BLOCKED) if result == None: raise Exception self.app.screenManager.current = MENU_SCREEN Alert(title="Success", text='Account Successfully Blocked') except Exception: Alert(title="Input Error", text='Invalid Account Number! Try Again')
def __init__(self, app, **kwargs): super(TransactionsListScreen, self).__init__(**kwargs) self.app = app self.ids.rv.data = [] result = getAllTransactions(readToken()) self.allResults = [] if result == None: removeToken() self.app.screenManager.current = LOGIN_SCREEN Alert(title="Authentication Error", text='Please Login Again') else: self.allResults = result[:]
def build(self): self.title = 'Watson Bank Client' self.screenManager = ScreenManager() self.loginScreen = LoginScreen(self) screenLogin = Screen(name=LOGIN_SCREEN) screenLogin.add_widget(self.loginScreen) self.menuScreen = MenuScreen(self) screenMenu = Screen(name=MENU_SCREEN) screenMenu.add_widget(self.menuScreen) if not readToken() == None: self.screenManager.add_widget(screenMenu) self.screenManager.add_widget(screenLogin) else: self.screenManager.add_widget(screenLogin) self.screenManager.add_widget(screenMenu) self.signupScreen = SignUpScreen(self) screen = Screen(name=SIGNUP_SCREEN) screen.add_widget(self.signupScreen) self.screenManager.add_widget(screen) self.createAccountScreen = CreateAccountScreen(self) screen = Screen(name=CREATE_ACCOUNT_SCREEN) screen.add_widget(self.createAccountScreen) self.screenManager.add_widget(screen) self.addAccountScreen = AddAccountScreen(self) screen = Screen(name=ADD_ACCOUNT_SCREEN) screen.add_widget(self.addAccountScreen) self.screenManager.add_widget(screen) self.changeAccountStatus = ChangeStatusScreen(self) screen = Screen(name=CHANGE_ACCOUNT_STATUS) screen.add_widget(self.changeAccountStatus) self.screenManager.add_widget(screen) self.allTransactionsScreen = None self.allTransactionsScreenChild = None self.allAccountsScreen = None self.allAccountsScreenChild = None self.transactionScreen = None self.transactionScreenChild = None return self.screenManager
def addAccountCallback(self): if len(self.nationalCodeTextInput.text.strip()) == 0: Alert(title="Input Error", text='Empty Field! Try Again') return try: result = addAccount(readToken(), self.nationalCodeTextInput.text.strip()) if result == None: raise Exception self.app.screenManager.current = MENU_SCREEN Alert(title="Success", text='Account<%s> Successfully Created' % result['accountNumber']) except Exception: Alert(title="Input Error", text='Invalid National Code! Try Again')
def showLogsCallback(self, accountID, ownerName): logs = getAccountLogs(readToken(), int(accountID)) if logs == None: removeToken() self.app.screenManager.current = LOGIN_SCREEN Alert(title="Authentication Error", text='Please Login Again') return currentCredit = logs['currentCredit'] logs = logs['logs'] if len(logs) == 0: Alert(title="Account Logs", text='There are no logs to show!', time=3, linesNumber=1) return logsPopup = ShowLogsPopUp(logs, currentCredit, accountID, ownerName) popUpWindow = Popup(title="Logs", content=logsPopup, size_hint = (None, None), size=(400,400)) popUpWindow.open() return
def createTransactionCallback(self): fromAccount = self.fromAccountTextInput.text.strip() toAccount = self.toAccountTextInput.text.strip() if len(fromAccount) == 0 and len(toAccount) == 0: Alert(title="Input Error", text='Both Account Fields can not be Empty') return if fromAccount == '': fromAccount = None if toAccount == '': toAccount = None amount = self.transactionAmountTextInput.text.strip() if len(amount) == 0: Alert(title="Input Error", text='Amount Field can not be Empty') return cash = False if fromAccount == None or toAccount == None: cash = True try: result = createTransaction( readToken(), float(amount), fromAccount, toAccount, self.transactionDescribtionTextInput.text.strip(), cash) if type(result) == str: Alert(title="Input Error(s)", text=result, time=3) return if result == None: removeToken() self.app.screenManager.current = LOGIN_SCREEN Alert(title="Authentication Error", text='Please Login Again') return self.app.screenManager.current = MENU_SCREEN Alert(title="Success", text='Transaction Successfully Created With ID: ' + str(result['id']), time=3) except Exception: Alert(title="Connection Error", text='Connection Error, Try Again Later')