def read_worker_card_update_input(self): worker_card_entity = WorkerCardScheme() worker_card_entity.id = input("enter id: ") if CheckInput.check_worker_card_existence(worker_card_entity.id): worker_card_entity.worker_id = input("enter worker_id: ") while not CheckInput.check_worker_existence( worker_card_entity.worker_id): input_str = input( "There is no such worker!\nWanna add?\n(y/n): ") for case in switch(input_str): if case('y'): worker_entity = self.read_worker_input() worker_card_entity.worker_id = worker_entity.id db.insert_worker(worker_entity) break if case('n'): print("can't insert worker card ") return else: print("____________________") print("no such option, try again!") worker_card_entity.is_active = input("enter is active: ") while worker_card_entity.is_active != "True" and worker_card_entity.is_active != "False": worker_card_entity.is_active = input( "Wrong input!\nTry again: ") return worker_card_entity else: print("There is no such worker card in db!") return None
def delete_entity(db_name): if db_name == "worker": worker_id = user_input.get_id() if not CheckInput.check_worker_existence(worker_id): print("There is no such worker in db!\n") else: db.delete_worker(worker_id) elif db_name == "journal": journal_id = user_input.get_id() if not CheckInput.check_journal_existence(journal_id): print("There is no such journal in db!\n") else: db.delete_journal(journal_id) elif db_name == "department": department_id = user_input.get_id() if not CheckInput.check_department_existence(department_id): print("There is no such department in db!\n") else: db.delete_department(department_id) elif db_name == "worker_card": worker_card_id = user_input.get_id() if not CheckInput.check_worker_card_existence(worker_card_id): print("There is no such worker card in db!\n") else: db.delete_worker_card(worker_card_id)