def _remove_second_service(self): service_id = get_table_current_index_info(self.second_service_table, 2) if service_id: service_name = get_table_current_index_info(self.second_service_table, 3) reply = QtWidgets.QMessageBox.question(self.remove_second_service, 'Message', "是否删除此服务项目:" + service_name + "?", QtWidgets.QMessageBox.Yes, QtWidgets.QMessageBox.No) if reply == QtWidgets.QMessageBox.Yes: if stock_handler.get_count_by_service(service_id): QtWidgets.QMessageBox.information(self.remove_second_service, "提示", "该服务项目存在库存信息,不允许删除!") return else: try: db_transaction_util.begin() service_handler.delete_service_all_attribute(service_id) service_handler.delete_service(service_id) db_transaction_util.commit() QtWidgets.QMessageBox.information(self.remove_second_service, "提示", "删除成功!") self._refresh_second_service() except Exception as e: print(e) db_transaction_util.rollback() QtWidgets.QMessageBox.information(self.remove_second_service, "提示", "删除失败,请重试!") else: QtWidgets.QMessageBox.information(self.remove_second_service, "提示", "请选择二级服务项目")
def show_detail(self, index: QModelIndex): if index.column() != 14: return self.sale_id = table_utils.get_table_cell(self.write_off_table, index.row(), 0) self.stock_id = table_utils.get_table_current_index_info( self.write_off_table, 9) self.brand_id = table_utils.get_table_current_index_info( self.write_off_table, 7) self.model_id = table_utils.get_table_current_index_info( self.write_off_table, 8) self.buy_date.setDateTime( QDateTime.fromString(time_utils.get_now(), 'yyyy-MM-dd hh:mm:ss')) self.brand.setText( table_utils.get_table_current_index_info(self.write_off_table, 2)) self.model.setText( table_utils.get_table_current_index_info(self.write_off_table, 3)) self.sale_number.setText( table_utils.get_table_current_index_info(self.write_off_table, 4)) balance = int( table_utils.get_table_current_index_info(self.write_off_table, 5)) self.buy_number.setValue(abs(balance)) self.unit.setText( table_utils.get_table_current_index_info(self.write_off_table, 6)) self.service.setText( table_utils.get_table_current_index_info(self.write_off_table, 10) + '-' + table_utils.get_table_current_index_info(self.write_off_table, 12)) self.price.setText('0.0') self.total.setText('0.0') self.paid.setText('0.0') self.unpaid.setText('0.0') self.balance = balance
def do_remove(self): attr_id = table_utils.get_table_current_index_info(self.tableView, 0) message = QMessageBox.information(self.remove, '提示', '是否要删除该属性?', QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes) if message == QMessageBox.No: return if not attr_id: QMessageBox.information(self.remove, '提示', '请选择一条属性进行修改!') return is_required = int( table_utils.get_table_current_index_info(self.tableView, 3)) if is_required: QMessageBox.information(self.remove, '提示', '必填属性不允许删除!') return service_count = service_handler.get_count_by_attribute(attr_id) if service_count and service_count[0]: QMessageBox.information(self.remove, '提示', '该属性已经关联到服务项目上,不允许删除!') return try: attribute_handler.delete_attribute_logical(int(attr_id)) QMessageBox.information(self.remove, '提示', '删除成功') self._init_table() except Exception as e: print(e) QMessageBox.information(self.remove, '提示', '该属性删除失败,请重新尝试!')
def _update_first_service(self): service_id = get_table_current_index_info(self.first_service_table, 0) if not service_id: QtWidgets.QMessageBox.information(self.update_first_service, "提示", "请选择一级服务项目") return service_name = get_table_current_index_info(self.first_service_table, 1) service = FirstLevelServiceInfo('修改一级服务项目', service_id=service_id, service_name=service_name) service.exec() self._refresh_all_table()
def _update_staff(self): record_id = get_table_current_index_info(self.staff_table, 0) staff_name = get_table_current_index_info(self.staff_table, 1) sex = get_table_current_index_info(self.staff_table, 2) id_card_no = get_table_current_index_info(self.staff_table, 3) if record_id: staff = StaffInfo(staff_table=self.staff_table, window_title="修改员工信息", table_tile=self.table_title, staff_id=record_id, name=staff_name, id_card_no=id_card_no, sex=sex) staff.exec() else: QtWidgets.QMessageBox.information(self.update_staff, "提示", "请选择员工")
def _update_second_service(self): service_id = get_table_current_index_info(self.second_service_table, 2) if not service_id: QtWidgets.QMessageBox.information(self.add_second_service, "提示", "请选择二级服务项目") else: father_id = get_table_current_index_info(self.second_service_table, 0) service_name = get_table_current_index_info(self.second_service_table, 3) service = SecondServiceInfo('修改二级服务项目', service_id=service_id, father_id=father_id, service_name=service_name) service.exec() self._refresh_second_service() self.attribute_table.model().removeRows(0, self.attribute_table.model().rowCount())
def do_update(self): attr_id = table_utils.get_table_current_index_info(self.tableView, 0) if not attr_id: QMessageBox.information(self.add, '提示', '请选择一条属性进行修改!') return attr_id = int(attr_id) old_attr_name = table_utils.get_table_current_index_info( self.tableView, 1) new_attr_name, ok = QInputDialog.getText(self.edit, '修改属性', '请修改属性名称', QLineEdit.Normal, old_attr_name) if new_attr_name and ok: exists_info = attribute_handler.get_count_by_name(new_attr_name) if exists_info: if not exists_info[1]: QMessageBox.information(self.edit, '提示', '该属性已经存在,请重新输入') return else: try: db_transaction_util.begin() # 将原来的属性对应的销售信息更新到当前的属性ID上 sale_item_handler.update_item_id( exists_info[2], attr_id) # 物理删除原来的属性 attribute_handler.delete_attribute_physical( exists_info[2]) # 修改新的属性名称 attribute_handler.update_attribute( attr_id, new_attr_name) db_transaction_util.commit() except Exception as e: print(e) db_transaction_util.rollback() QMessageBox.information(self.edit, '提示', '该属性名称修改失败,请重新提交!') else: try: attribute_handler.update_attribute(attr_id, new_attr_name) QMessageBox.information(self.edit, '提示', '新增成功') self._init_table() except Exception as e: print(e) QMessageBox.information(self.edit, '提示', '该属性名称修改失败,请重新提交!')
def _change_sys_user(self): user_id = get_table_current_index_info(self.sys_user_table, 0) if user_id: sys_user = ChangePassword(user_id) sys_user.exec() else: QtWidgets.QMessageBox.information(self.change_sys_user, "提示", "请选择管理员")
def _stop(self): device_id = get_table_current_index_info(self.device_table, 0) if not device_id: QtWidgets.QMessageBox.information(self.stop, "提示", "请选择设备") else: update_device_state(device_id, self.stop_state) QtWidgets.QMessageBox.information(self.stop, "提示", "设备已禁用") self._update_device_table()
def _add_second_service(self): father_id = get_table_current_index_info(self.first_service_table, 0) if not father_id: QtWidgets.QMessageBox.information(self.add_second_service, "提示", "请选择一级服务项目") else: service = SecondServiceInfo('新增二级服务项目', father_id=father_id) service.exec() self._refresh_second_service()
def _remove_first_service(self): service_id = get_table_current_index_info(self.first_service_table, 0) if service_id: service_name = get_table_current_index_info(self.first_service_table, 1) reply = QtWidgets.QMessageBox.question(self.remove_first_service, 'Message', "是否删除此服务项目:" + service_name + "?", QtWidgets.QMessageBox.Yes, QtWidgets.QMessageBox.No) if reply == QtWidgets.QMessageBox.Yes: if not service_handler.get_second_service_count_by_father(service_id): service_handler.delete_service(service_id) QtWidgets.QMessageBox.information(self.remove_first_service, "提示", "删除成功!") self._refresh_all_table() else: QtWidgets.QMessageBox.information(self.remove_first_service, "提示", "该一级服务项目下存在二级服务项目,不能删除!") else: QtWidgets.QMessageBox.information(self.remove_first_service, "提示", "请选择一级服务项目")
def _return_visit_process(self): record_id = get_table_current_index_info(self.return_visit_table, 0) username = get_table_current_index_info(self.return_visit_table, 1) car_id = get_table_current_index_info(self.return_visit_table, 2) car_phone = get_table_current_index_info(self.return_visit_table, 3) return_visit_date = get_table_current_index_info( self.return_visit_table, 4) print(return_visit_date) if record_id: msg = "您于 <b>{}</b> 要回访用户 : <b>{}</b><br>联系方式为 : <b>{}</b><br>车牌号为 : <b>{}</b>".format( return_visit_date[:10], username, car_phone, car_id) ui = ReturnVisitSetting(msg, record_id, car_phone, car_id, username) ui.exec_() self.return_visit_setting() else: QtWidgets.QMessageBox.information(self.return_visit_button, "提示", "请选择未回访记录")
def _delete_staff(self): staff_id = get_table_current_index_info(self.staff_table, 0) if staff_id: reply = QtWidgets.QMessageBox.question(self.delete_staff, 'Message', "是否删除此员工?", QtWidgets.QMessageBox.Yes, QtWidgets.QMessageBox.No) if reply == QtWidgets.QMessageBox.Yes: delete_staff_by_id(staff_id) set_table_content(self.staff_table, get_all_staff(), self.table_title) else: QtWidgets.QMessageBox.information(self.delete_staff, "提示", "请选择员工")
def _refresh_second_service(self): father_id = get_table_current_index_info(self.first_service_table, 0) if not father_id: return set_table_content(self.second_service_table, service_handler.get_second_service_by_father(father_id), self.second_service_title) self.second_service_table.setColumnHidden(0, True) self.second_service_table.setColumnHidden(1, True) self.second_service_table.setColumnHidden(2, True) self.second_service_table.setColumnHidden(4, True) self.second_service_table.setColumnHidden(5, True)
def single_pay(self): buy_id = table_utils.get_table_current_index_info(self.detail_table, 10) if not buy_id: QMessageBox.information(self.single_button, '提示', '请选择一条明细!') return buy_info = BuyInfo() buy_info.buy_id(int(buy_id)) unpaid = Decimal(table_utils.get_table_current_index_info(self.detail_table, 9)) paid = Decimal(table_utils.get_table_current_index_info(self.detail_table, 8)) buy_info.paid(paid) buy_info.unpaid(unpaid) buy_info.note(self.supplier_name) dialog = PayOffArrearsDialog(buy_info) dialog.exec() self._init_table()
def _remove_sys_user(self): id = get_table_current_index_info(self.sys_user_table, 0) if id: reply = QtWidgets.QMessageBox.question(self.remove_sys_user, 'Message', "是否删除此管理员?", QtWidgets.QMessageBox.Yes, QtWidgets.QMessageBox.No) if reply == QtWidgets.QMessageBox.Yes: delete_sys_user_by_id(id) set_table_content(self.sys_user_table, get_all_sys_user(), self.table_title) else: QtWidgets.QMessageBox.information(self.remove_sys_user, "提示", "请选择一条记录")
def _clear_detail(self): self.buy_date.setDateTime( QDateTime.fromString(time_utils.get_now(), 'yyyy-MM-dd hh:mm:ss')) self.brand.clear() self.model.clear() self.sale_number.clear() self.buy_number.setValue( abs( int( table_utils.get_table_current_index_info( self.write_off_table, 5)))) self.unit.clear() self.service.clear() self.price.setText('0.0') self.total.setText('0.0') self.paid.setText('0.0') self.unpaid.setText('0.0') self.sale_id = 0 self.stock_id = 0 self.brand_id = 0 self.model_id = 0 self.balance = 0
def _refresh_detail_table(self, index): second_srv_id = table_utils.get_table_current_index_info(self.summary_table, 1) if second_srv_id: record = buy_handler.get_detail_info(second_srv_id, self.start_time_str, self.end_time_str) self._init_detail_table(record)
def _refresh_compare_table(self, index: int): model_id = table_utils.get_table_current_index_info( self.history_table, 0) if model_id: record = buy_handler.get_compare_info(model_id) self._init_compare_table(record)
def _get_attribute_list(self): service_id = get_table_current_index_info(self.second_service_table, 2) attribute = service_handler.get_attribute_by_service(service_id) return attribute