def removeRow(self, row: int, parent: QModelIndex = ...): try: cursor = self.mysql_db.cursor() cursor.execute(self.Remove_Query % self.current_indexes_list[row]) except: error_dialog = ErrorDialogView("Участок используется, удаление невозможно") error_dialog.setModal(True) error_dialog.setWindowTitle("Ошибка") error_dialog.exec_()
def validate_data(self, col, value): if (col <= 1 or col == 2) and not validate_number(value): error_dialog = ErrorDialogView( "Ширина,длина,количество посеянного может быть только числом") error_dialog.setModal(True) error_dialog.setWindowTitle("Ошибка") error_dialog.exec_() return False return True
def add_to_db(self): if self.model.validate_amount(self.view.amount_line.text()) == 1: self.model.insert_to_db(self.view.id, self.view.amount_line.text(), self.view.session_id) self.view.close_window() else: error_dialog = ErrorDialogView("Проверьте количество") error_dialog.setModal(True) error_dialog.setWindowTitle("Ошибка") error_dialog.exec_()
def removeRow(self, row: int, parent: QModelIndex = ...): try: cursor = self.mysql_db.cursor() cursor.execute(self.Remove_Roles % self.current_indexes_list[row]) cursor.execute(self.Remove_Query % self.current_indexes_list[row]) except: error_dialog = ErrorDialogView("Произошла ошибка, попробуйте позже") error_dialog.setModal(True) error_dialog.setWindowTitle("Ошибка") error_dialog.exec_()
def check(self): if self.model.check(self.view.login.text(), self.view.password.text()) == 1: self.view.close_window() self.view.show_stacked_widgets() else: error_dialog = ErrorDialogView("Логин или пароль неверны") error_dialog.setModal(True) error_dialog.setWindowTitle("Ошибка") error_dialog.exec_()
def add_to_db(self): if not self.view.login.text() and self.view.password.text(): error_dialog = ErrorDialogView("Имя не может быть пустым") error_dialog.setModal(True) error_dialog.setWindowTitle("Ошибка") error_dialog.exec_() return self.model.insert_to_users(self.view.login.text(), self.view.password.text(), self.view.role.currentData()) self.view.close_window()
def add_to_db(self): if self.model.validate_time(self.view.time_line.text()) == 1: self.model.insert_to_rig( self.view.technique_combo_box.currentData(), self.view.location_combo_box.currentData(), self.view.time_line.text()) self.view.close_window() else: error_dialog = ErrorDialogView("Проверьте время") error_dialog.setModal(True) error_dialog.setWindowTitle("Ошибка") error_dialog.exec_()
def check(self): if self.model.check(self.view.login.text(), self.view.password.text()) == 1: self.view.close_window() roles = self.model.selectRoles(self.view.login.text()) view = MenuView(roles) view.setWindowTitle("Меню") view.show() else: error_dialog = ErrorDialogView("Логин или пароль неверны") error_dialog.setModal(True) error_dialog.setWindowTitle("Ошибка") error_dialog.exec_()
def add_to_db(self): if not self.view.name.text(): error_dialog = ErrorDialogView("Поля не могут быть пустыми") error_dialog.setModal(True) error_dialog.setWindowTitle("Ошибка") error_dialog.exec_() return self.model.insert_to_technique(self.view.name.text(), self.view.production_date.text(), self.view.capital_date.text(), self.view.next_repair.text(), self.view.state.currentData()) self.view.close_window()
def add_to_db(self): if validate_number(self.view.start_year.text()) == 1: for i in range(5): if validate_number(self.view.amount_seed[i].text()) != 1: return for i in range(5): self.model.insert_crop_rotation(self.view.location_combo_box[i].currentData(), self.view.culture_combo_box[i].currentData(), int(self.view.amount_seed[i].text()), int(self.view.start_year.text()) + i) self.view.close_window() else: error_dialog = ErrorDialogView("Проверьте год") error_dialog.setModal(True) error_dialog.setWindowTitle("Ошибка") error_dialog.exec_()
def key_input_form_event(self, event): if event.key() == Qt.Key_Return: if validate_number(self.view.q_line_edit.text()) == 1: self.model.update(self.view.q_line_edit.text()) if len(self.model.get_crop_rotation()) != 0: self.view.clear_layout() self.view.init_input_form() self.view.show_table() self.view.year = int(self.view.q_line_edit.text()) else: self.view.clear_layout() self.view.init_input_form() self.view.show_nothing() else: error_dialog = ErrorDialogView("Проверьте год") error_dialog.setModal(True) error_dialog.setWindowTitle("Ошибка") error_dialog.exec_()
def add_to_db(self): if not self.view.amount.text() and not self.view.culture.text() and not self.view.price.text(): error_dialog = ErrorDialogView("Поля не могут быть пустыми") error_dialog.setModal(True) error_dialog.setWindowTitle("Ошибка") error_dialog.exec_() return if validate_number(self.view.amount.text()) and validate_number(self.view.price.text()): self.model.insert_culture(self.view.culture.text(), self.view.amount.text(),self.view.price.text()) self.view.close_window() else: error_dialog = ErrorDialogView("Проверьте количество и ценну") error_dialog.setModal(True) error_dialog.setWindowTitle("Ошибка") error_dialog.exec_()
def add_to_db(self): if self.view.technique_combo_box.currentData() is None or \ self.view.location_combo_box.currentData() is None or self.view.user_combo_box.currentData() is None \ or not self.view.time_line.text() or not self.view.date.text(): error_dialog = ErrorDialogView("Поля не могут быть пустыми") error_dialog.setModal(True) error_dialog.setWindowTitle("Ошибка") error_dialog.exec_() return if validate_time(self.view.time_line.text()) == 1: self.model.insert_to_rig( self.view.technique_combo_box.currentData(), self.view.location_combo_box.currentData(), self.view.user_combo_box.currentData(), self.view.time_line.text(), self.view.date.text()) self.view.close_window() else: error_dialog = ErrorDialogView("Проверьте время") error_dialog.setModal(True) error_dialog.setWindowTitle("Ошибка") error_dialog.exec_()
def show_message(self, message): error_dialog = ErrorDialogView(message) error_dialog.setModal(True) error_dialog.setWindowTitle("Ошибка") error_dialog.exec_()
def add_to_db(self): if not self.view.width.text() and not self.view.height.text(): error_dialog = ErrorDialogView("Поля не могут быть пустыми") error_dialog.setModal(True) error_dialog.setWindowTitle("Ошибка") error_dialog.exec_() return if validate_number(self.view.width.text()) and validate_number(self.view.height.text()): self.model.insert_culture(self.view.width.text(), self.view.height.text()) self.view.close_window() else: error_dialog = ErrorDialogView("Длина и ширина должны быть числом") error_dialog.setModal(True) error_dialog.setWindowTitle("Ошибка") error_dialog.exec_()
def add_to_db(self): if self.model.valid_phone_number(self.view.phone_number.text()) == 1: if self.view.delivery_condition.text() \ or self.view.payment_condition.text() \ or self.view.name.text() \ or self.view.requisites.text() \ or self.view.email.text() \ or self.view.head.text() \ or self.view.post_address.text() \ or self.view.legal_address.text() \ or self.view.site.text(): self.model.insert_treaty(self.view.delivery_condition.text(), self.view.payment_condition.text(), self.view.name.text(), self.view.requisites.text(), self.view.email.text(), self.view.head.text(), self.view.post_address.text(), self.view.legal_address.text(), self.view.site.text(), self.view.phone_number.text(), self.view.session_id) self.view.close_window() else: error_dialog = ErrorDialogView("Не все поля зхаполнены") error_dialog.setModal(True) error_dialog.setWindowTitle("Ошибка") error_dialog.exec_() else: error_dialog = ErrorDialogView("Неверный телефонный номер") error_dialog.setModal(True) error_dialog.setWindowTitle("Ошибка") error_dialog.exec_()
def no_table_selected(self): error_dialog = ErrorDialogView("Ни одной таблицы не выбрано") error_dialog.setModal(True) error_dialog.setWindowTitle("Ошибка") error_dialog.exec_()
def add_to_db(self): if not self.view.delivery_date.text() \ or not self.view.payment_condition.text() \ or not self.view.culture_amount.text() \ or not self.view.organization_name.text() \ or not self.view.requisites.text() \ or not self.view.email.text() \ or not self.view.head.text() \ or not self.view.post_address.text() \ or not self.view.legal_address.text() \ or not self.view.site.text(): error_dialog = ErrorDialogView("Имя не может быть пустым") error_dialog.setModal(True) error_dialog.setWindowTitle("Ошибка") error_dialog.exec_() return if not validate_phone_number(self.view.phone_number.text()): error_dialog = ErrorDialogView( "Неверный формат телефонного номера") error_dialog.setModal(True) error_dialog.setWindowTitle("Ошибка") error_dialog.exec_() return if not validate_email(self.view.email.text()): error_dialog = ErrorDialogView("Проверьте email") error_dialog.setModal(True) error_dialog.setWindowTitle("Ошибка") error_dialog.exec_() return if not validate_requisites(self.view.requisites.text()): error_dialog = ErrorDialogView("Реквизиты должны быть числом") error_dialog.setModal(True) error_dialog.setWindowTitle("Ошибка") error_dialog.exec_() return self.model.insert_to_treaty(self.view.delivery_date.text(), self.view.delivery_condition.text(), self.view.payment_condition.text(), self.view.culture_name.currentData(), self.view.culture_amount.text(), self.view.organization_name.text(), self.view.requisites.text(), self.view.email.text(), self.view.head.text(), self.view.post_address.text(), self.view.legal_address.text(), self.view.site.text(), self.view.phone_number.text()) self.view.close_window()