def add_examiner(self, surn, name, patr, salary, listbox): Examiner.create(surn.get(), name.get(), patr.get(), int(salary.get())) surn.delete(0, END) name.delete(0, END) patr.delete(0, END) salary.delete(0, END) self.update_all(listbox)
def add_examiner(): try: surname = input("Enter surname: ") name = input("Enter name: ") patronymic = input("Enter patronymic: ") payment = int(input("Enter payment: ")) Examiner.create(surname, name, patronymic, payment) except: print("Error")
def updateAllList(self): self.allExaminersList.setEditTriggers(QAbstractItemView.NoEditTriggers) model = QStandardItemModel(self.allExaminersList) for i in Examiner.all(): item = QStandardItem(i.to_string()) model.appendRow(item) self.allExaminersList.setModel(model)
def add_exam(): try: pass_time = datetime.strptime( input("Enter time of pass(DD.MM.YYYY HH:MM): "), '%d.%m.%Y %H:%M').strftime('%d.%m.%Y %H:%M') exam_name = input("Enter name of exam: ") score = input("Enter score of exam: ") enrollee_id = 0 examiner_id = 0 score = None if score != "": score = int(score) while True: #select enrollee by surname enrollee_surn = input("Enter surname of enrollee: ") if enrollee_surn == "-1": return enrollees = Enrollee.findBySurname(enrollee_surn) if len(enrollees) == 0: print( "No results. Enter '-1' to stop adding exam ornew surname to try again: " ) else: print_arr(enrollees) user_input = int( input( "Enter number of selected enrollee, or '-1' to stop adding exam: " )) if user_input >= 0 or user_input < len(enrollees): enrollee_id = enrollees[user_input - 1].id break elif user_input == -1: return else: print("Incorrect input") while True: #select examiner by surname examiner_surn = input("Enter surname of examiner: ") if examiner_surn == "-1": return examiners = Examiner.findBySurname(examiner_surn) if len(examiners) == 0: print( "No results. Enter '-1' to stop adding exam or new surname to try again: " ) else: print_arr(examiners) user_input = int( input( "Enter number of selected examiner, or '-1' to stop adding exam: " )) if user_input >= 0 or user_input < len(examiners): examiner_id = examiners[user_input - 1].id break elif user_input == -1: return else: print("Incorrect input") Exam.create(pass_time, exam_name, score, enrollee_id, examiner_id) except: print("Error")
def __init__(self, id): super().__init__() uic.loadUi("layouts\\manipulateExaminer.ui", self) self.examiner = Examiner.get_by_id(id) self.newSal.setValue(self.examiner.payment) self.changeSal.clicked.connect(self.changeSalaryClick) self.deleteExaminer.clicked.connect(self.deleteExaminerClick) self.exportBtn.clicked.connect(self.exportExaminerClick) self.updateAllList()
def find_examiner(): try: sur = input("Enter surname to search: ") examiners = Examiner.findBySurname(sur) print_arr(examiners) if len(examiners) == 0: print("No results") else: res = int(input("Enter number of selected examiner or '-1' to go back: ")) if res > 0 and res <= len(examiners): manipulate_examiner(examiners[res - 1]) elif res == -1: return else: print("Incorrect input") except: print("Error")
def all_examiners(): try: examiners = Examiner.all() print_arr(examiners) if len(examiners) == 0: print("No results") else: res = int(input("Enter number of selected examiner or '-1' to go back: ")) if res > 0 and res <= len(examiners): manipulate_examiner(examiners[res - 1]) return elif res == -1: return else: print("Incorrect input") except: print("Error")
def exportXlsxClick(self): wb = openpyxl.load_workbook('..\\..\\Reports\\All.xlsx') if 'Examiners' not in wb.sheetnames: wb.create_sheet('Examiners') ws = wb['Examiners'] ws.delete_cols(1, 6) ws.delete_rows(1, 100) all_list = Examiner.all() for i in range(len(all_list)): ws.cell(row=i + 1, column=1).value = all_list[i].id ws.cell(row=i + 1, column=2).value = all_list[i].surname ws.cell(row=i + 1, column=3).value = all_list[i].name ws.cell(row=i + 1, column=4).value = all_list[i].patronymic ws.cell(row=i + 1, column=5).value = all_list[i].payment wb.save('..\\..\\Reports\\All.xlsx') # app = QApplication(sys.argv) # w = ExaminerWindow() # w.show() # app.exec_()
def find_examiner(self, listbox, find_label): listbox.delete(0, END) self.find_examiner_list = Examiner.findBySurname(find_label.get()) for elem in self.find_examiner_list: listbox.insert(END, elem.to_string()) return
def update_all(self, listbox): listbox.delete(0, END) self.all_list = Examiner.all() for elem in self.all_list: listbox.insert(END, elem.to_string()) return
def __init__(self, *args, **kwargs): Page.__init__(self, *args, **kwargs) all = Frame(self) all.pack(side=LEFT, fill=Y) Label(all, text="All examiners").pack() self.all_listbox = Listbox(all, width=100) self.all_listbox.bind('<Double-1>', self.all_list_on_click) self.all_list = Examiner.all() for person in self.all_list: self.all_listbox.insert(END, person.to_string()) self.all_listbox.pack(side="top", fill="both", expand=True) all_report = Button( all, text="Export info about all examiners in docx files", command=self.all_docx_export) all_report.pack(side="top") xlsx_report = Button(all, text="Export info about all examiners in Excel", command=self.xlsx_export) xlsx_report.pack(side="top") ################################################################################################# find = Frame(self) find.pack(side=LEFT, fill=Y) Label(find, text="Find examiner").pack() find_entry = Entry(find) find_entry.pack() self.find_listbox = Listbox(find, width=100) self.find_listbox.bind('<Double-1>', self.find_list_on_click) find_examiner = partial(self.find_examiner, self.find_listbox, find_entry) find_btn = Button(find, text="Find", command=find_examiner).pack() self.find_listbox.pack(side="top", fill="both", expand=True) ######################################################################################################## add = Frame(self) add.pack() Label(add, text="Add examiner", font="Helvetica -14 bold").grid(columnspan=2) Label(add, text="Surname: ").grid(row=1, column=0) surn = Entry(add, width=50) surn.grid(row=1, column=1) Label(add, text="Name: ").grid(row=2, column=0) name = Entry(add, width=50) name.grid(row=2, column=1) Label(add, text="Patronymic: ").grid(row=3, column=0) patr = Entry(add, width=50) patr.grid(row=3, column=1) Label(add, text="Salary: ").grid(row=4, column=0) salary = Entry(add, width=50) salary.grid(row=4, column=1) add_examiner = partial(self.add_examiner, surn, name, patr, salary, self.all_listbox) add_btn = Button(add, text="Add examiner", command=add_examiner) add_btn.grid(columnspan=2)
def findExaminerClick(self): model = QStandardItemModel(self.findExaminerList) for i in Examiner.findBySurname(self.findExaminerInput.text()): item = QStandardItem(i.to_string()) model.appendRow(item) self.findExaminerList.setModel(model)
def exportDocxClick(self): for i in Examiner.all(): examiner_export(i)
def addExaminerOnClick(self): Examiner.create(self.surnameEdit.text(), self.nameEdit.text(), self.patronymicEdit.text(), self.salaryEdit.value()) self.updateAllList()