def userlogin(self): try: login_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) pwd = self.get_password() if ((self.cb_user.currentIndex() == 0) and (self.le_pwd.text() == pwd)): #log.loginfo.process_log('Administrator login') UserManager.username = '******' self.loginsignal.emit(['Administrator']) self.save_user('Administrator', login_time) UserManager.loginok = True self.accept() elif (self.cb_user.currentIndex() == 1): if (self.le_pwd.text() == ''): QMessageBox.information( self, ("Warning!"), ("Invalid operator!"), QMessageBox.StandardButton(QMessageBox.Ok)) else: #log.loginfo.process_log('Operator ' + self.le_pwd.text() + ' login') UserManager.username = self.le_pwd.text() self.loginsignal.emit([self.le_pwd.text()]) self.save_user(UserManager.username, login_time) UserManager.loginok = True self.accept() else: # 除了information还有warning、about等 QMessageBox.information( self, ("Warning!"), ("Password Error!"), QMessageBox.StandardButton(QMessageBox.Ok)) #log.loginfo.process_log('wrong password') except Exception as e: log.loginfo.process_log('userlogin' + str(e))
def login(self): self.usr=self.UserName.text() self.pw=self.Passwd.text() print(self.usr, self.pw) cursor = self.conn.cursor() ################### try: command = "select PassWD from UandP where StaffID ='" + self.usr + "'" print(command) cursor.execute(command) data = cursor.fetchone()[0] if data == self.pw: print('密码正确') self.hide() self.newWin = ClientM(self.usr, self.conn) self.newWin.show() else: OK = QMessageBox.critical(self, ("反馈"), ("""密码或账号有误,请重新确认"""), QMessageBox.StandardButton(QMessageBox.Yes )) print('密码错误') except: OK = QMessageBox.critical(self, ("反馈"), ("""密码或账号有误,请重新确认"""), QMessageBox.StandardButton(QMessageBox.Yes)) print('密码错误') finally: cursor.close()
def export(self): tempInfo=self.YGGZ_Info.copy() title=['工号','姓名','部门','基本工资','津贴','扣罚','总工资'] tempInfo.append(title) tempInfo[0],tempInfo[-1]=tempInfo[-1],tempInfo[0] try: wrt2xl(tempInfo,self.Name) OK=QMessageBox.information(self, ("反馈"), ("""导出完成"""), QMessageBox.StandardButton(QMessageBox.Yes)) except: wrong = QMessageBox.critical(self, ("反馈"), ("""导出失败"""), QMessageBox.StandardButton(QMessageBox.Yes))
def SC_Fun(self): cursor=self.conn.cursor() try: ID = "'" + self.GH_L.text() + "'" command = "Delete from StaffInfo WHERE StaffID ="+ID+";" print(command) cursor.execute(command) self.conn.commit() OK = QMessageBox.information(self, ("反馈"), ("""职员已被下岗"""), QMessageBox.StandardButton(QMessageBox.Yes)) self.close() except: wrong = QMessageBox.critical(self, ("反馈"), ("""删除失败"""), QMessageBox.StandardButton(QMessageBox.Yes)) finally: cursor.close()
def Verify_Reset(self): MSG = QMessageBox( QMessageBox.Question, "Alerta", "Deseja mesmo Resetar os Dados?", QMessageBox.StandardButton(QMessageBox.Yes | QMessageBox.No)) button = MSG.exec_() if button == QMessageBox.Yes: SQDB().Reset()
def check_volume_run(self): path = self.edit_autovolume_file_name.text() if not os.path.exists(path): QMessageBox.information( main_window, app.translate('file_not_found', 'Plik nie istnieje'), app.translate('file_not_found', 'Plik {path!r} nie istnieje').format(path=path), buttons=QMessageBox.StandardButton(0)) return task = self.executor.submit(self._really_check_volume, path) task.add_done_callback(self._update_volume_output)
def ask_user_to_confirm(question: str, icon: QMessageBox.Icon = ICON_QUESTION, parent: QObject = None, title="Please Confirm") -> bool: """ A simple dialog box that displays a yes/no question. question -- the question to ask icon -- the icon on the left (default is ICON_QUESTION) parent -- the parenrt window, or None title -- title for the dialog frame (default is "Please Confirm") returns -- True if yes (confirmed); otherwise False """ buttons = QMessageBox.StandardButton(QMessageBox.Yes | QMessageBox.No) box = QMessageBox(icon, title, question, buttons, parent, STD_DIALOG_OPTS) box.setDefaultButton(QMessageBox.No) box.show() QCoreApplication.processEvents() box.raise_() return box.exec_() == QMessageBox.Yes
def on_action_insert_image_triggered(self): filename = QFileDialog.getOpenFileName( self, 'Insert image', QDir.homePath(), 'Images ({})'.format(' '.join( map('*.{}'.format, self.text_edit_editor.supported_image_formats))))[0] if not filename: return if not os.path.isfile(filename) or QImage(filename).isNull(): QMessageBox.critical(None, None, 'Could\'t open Image', QMessageBox.StandardButton(QMessageBox.Ok)) else: filename_mime_data: QMimeData = QMimeData() filename_mime_data.setUrls([QUrl().fromUserInput(filename)]) self.text_edit_editor.insertFromMimeData(filename_mime_data)
def check_name_and_ID(self): self.Name = self.XM_L.text() self.GH = self.GH_L.text() command = "Select * from StaffInfo WHERE StaffID='" + self.GH + "' and Name='" + self.Name + "' and Leader='" + self.UserInfo + "';" print(command) cursor = self.conn.cursor() try: cursor.execute(command) data = cursor.fetchall() if len(data) == 0: NameWrong = QMessageBox.critical( self, ("反馈"), ("""您输入的员工及工号有错误,或者您无权为该员工添加加班记录,请重新确认"""), QMessageBox.StandardButton(QMessageBox.Yes)) return False else: return True except: print('加班记录添加名字检查错误') return False
def account_test_finished(self, account_valid: bool, message: str): if account_valid: self.line_edit_username.setEnabled(False) self.line_edit_password.setEnabled(False) self.line_edit_server_address.setEnabled(False) self.push_button_test.setEnabled(False) self.push_button_test.setText('') self.push_button_test.setIcon(qta.icon('fa.check')) self.push_button_start.setEnabled(True) else: self.push_button_start.setEnabled(False) self.line_edit_username.setEnabled(True) self.line_edit_password.setEnabled(True) self.line_edit_server_address.setEnabled(True) self.push_button_test.setEnabled(True) self.push_button_test.setText('Test') self.push_button_test.setIcon(QIcon()) QMessageBox.warning(None, None, message, QMessageBox.StandardButton(QMessageBox.Ok))
def check_reInsert(self): self.Name = self.XM_L.text() self.GH = self.GH_L.text() self.date = self.RQ_E.text() command = "select * from Attendence where StaffID='" + self.GH + "' and OccurDate=str_to_date('" + self.date + "','%Y/%m/%d') and Behavior='加班';" print(command) cursor = self.conn.cursor() try: cursor.execute(command) data = cursor.fetchall() if len(data) != 0: DateWrong = QMessageBox.critical( self, ("反馈"), ("""您输入的加班信息与数据库中的信息有冲突,请重新确认"""), QMessageBox.StandardButton(QMessageBox.Yes)) return False else: return True except: print('加班记录添加时间检查错误') return False
def inform_user(message: str, icon: QMessageBox.Icon = ICON_INFO, parent: QObject = None, title="", timeout=0): """ Simple dialog box to display some info to the user. message -- the info to display icon -- the icon on the left (default is ICON_INFO) parent -- the parenrt window, or None title -- title for the dialog frame timeout -- automatically close after a number of miliseconds (0 = remain open) """ if title == "": title = "Warning" if (icon == ICON_WARN) else "Error" if timeout: message += f"\n\n(This warning will automatically close in {int(timeout/1000)} seconds.)" buttons = QMessageBox.StandardButton(QMessageBox.Ok) box = QMessageBox(icon, title, message, buttons, parent, STD_DIALOG_OPTS) box.show() QCoreApplication.processEvents() box.raise_() if timeout: QTimer.singleShot(timeout, box.close) box.exec_()
def on_action_about_oxnote_triggered(self): QMessageBox.information(None, None, 'About', QMessageBox.StandardButton(QMessageBox.Ok))
def msg(self): OK = QMessageBox.information( self, ("这是标题"), ("""这是信息框"""), QMessageBox.StandardButton(QMessageBox.Yes | QMessageBox.No))
def Queren(self): ID="'"+self.GH_L.text()+"'" Name="'"+self.XM_L.text()+"'" Age=self.NL_Box.text() Sex="'"+self.XB_Box.currentText()+"'" Department="'"+self.BM_Box.currentText()+"'" DepartmentID="" Leader="'"+self.LD_L.text()+"'" LeaderID='' Position="'"+self.ZW_Box.currentText()+"'" PositionID='' RZ=self.RZ_L.text() print (RZ) RZ="str_to_date('"+RZ+"','%Y/%m/%d')" doubao="," photo=None cursor = self.conn.cursor() try: command = "Select DepartmentID from DepartmentInfo where Department =" + Department + ";" cursor.execute(command) DepartmentID = "'" + cursor.fetchone()[0] + "'" except: print("查询部门出错") print(command) return finally: cursor.close() del cursor cursor = self.conn.cursor() try: command = "Select PositionID from WageInfo where Position =" + Position + ";" cursor.execute(command) PositionID = "'" + cursor.fetchone()[0] + "'" except: print("查询职位出错") print(command) return finally: cursor.close() del cursor cursor = self.conn.cursor() try: command = "Select StaffID from StaffInfo where Name =" + Leader + ";" cursor.execute(command) LeaderID = "'" + cursor.fetchone()[0] + "'" cursor.close() except: print("查询领导出错") print(command) OK = QMessageBox.critical(self, ("反馈"), ("""您输入的领导名字有误,请重新确认"""), QMessageBox.StandardButton(QMessageBox.Yes)) return finally: cursor.close() del cursor if self.File_Path!="": print (self.File_Path) file=open(self.File_Path,'rb') photo=file.read() file.close() try: cursor = self.conn.cursor() command = "INSERT INTO `StaffInfo` (StaffID,Name,WorkDay,Position,PositionID,Age,Department,DepartmentID,Leader,Sex) VALUES (" + ID + doubao + Name + doubao + RZ + doubao + Position + doubao + PositionID + doubao + Age + doubao + Department + doubao + DepartmentID + doubao + LeaderID + doubao + Sex + ");" cursor.execute(command) command = "UPDATE StaffInfo SET Photo=%s where StaffID=" + ID + ";" cursor.execute(command, (photo)) self.conn.commit() except: print("有照片情况插入数据错误") somethingwrong = QMessageBox.critical(self, ("反馈"), ("""您输入的原始信息有误,请重新确认"""), QMessageBox.StandardButton(QMessageBox.Yes)) return finally: cursor.close() else: try: cursor = self.conn.cursor() command="INSERT INTO `StaffInfo` (StaffID,Name,WorkDay,Position,PositionID,Age,Department,DepartmentID,Leader,Sex) VALUES ("+ID+doubao+Name+doubao+RZ+doubao+Position+doubao+PositionID+doubao+Age+doubao+Department+doubao+DepartmentID+doubao+LeaderID+doubao+Sex+");" print(command) cursor.execute(command) self.conn.commit() print(command) except: print("无照片情况插入数据错误") somethingwrong = QMessageBox.critical(self, ("反馈"), ("""您输入的原始信息有误,请重新确认"""), QMessageBox.StandardButton(QMessageBox.Yes)) return finally: cursor.close() self.close()
def showinfoMsg(self, msg): OK = QMessageBox.information( self, (self.tr("Redeem")), ("%s" % msg), QMessageBox.StandardButton(QMessageBox.Yes))