def add_user(self): ''' delete a user from the database and show a success popup ''' # get new parameters from entry widgets in the dictionaries new_role = self.entry_fields["Role"].get() new_name = self.entry_fields["Name"].get() new_email = self.entry_fields["Email"].get() # add new user to databse and save his id number uid = db.add_user(new_role, new_name, new_email, "", conn) # show popup self.refresh() # clear entries self.entry_fields["Role"].set('') self.entry_fields["Name"].set('') self.entry_fields["Email"].set('') showinfo("Success", "User #" + str(uid ) + " has been added to database")
def add_user(self): ''' delete a user from the database and show a success popup ''' # get new parameters from entry widgets in the dictionaries new_role = self.entry_fields[self.labels[0]].get() new_name = self.entry_fields[self.labels[1]].get() new_email = self.entry_fields[self.labels[2]].get() # check if any of the entries is blank verified = self.verify_user_input(new_role, new_name, new_email) # add new user to databse and save his id number if (verified): uid = db.add_user(new_role, new_name, new_email, "", conn) user_string = self.string_uid(uid) # clear entries self.clear_entries() lb = self.list_box["users"] lb.insert(END, user_string) # show popup showinfo("Success", "User #" + str(uid ) + " has been added to database")
def add_user(self): ''' delete a user from the database and show a success popup ''' # get new parameters from entry widgets in the dictionaries new_role = self.entry_fields["Role"].get() new_name = self.entry_fields["Name"].get() new_email = self.entry_fields["Email"].get() # check if any of the entries is blank if ((new_role == '') or (new_name == '') or (new_email == '')) : self.clear_entries() return "blank entry" # if role is invalid return a msg if ((new_role != 'student') and (new_role != 'admin')) : self.clear_entries() return "invalid role" # add new user to databse and save his id number uid = db.add_user(new_role, new_name, new_email, "", conn) # show popup self.refresh() # clear entries self.clear_entries() showinfo("Success", "User #" + str(uid ) + " has been added to database")