1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #include "QFDAlert.h"
- #include <dbService/ClassSet.h>
- #include <Widgets/InfoBar.h>
- void QFDAlert::showAlertWithCode(int code, QWidget *w)
- {
- if (code == QF_CODE_SUCCEEDED) {
- return;
- }
- QString msg;
- QFDAlertType type = Alert;
- if (code == QF_CODE_EMPTY_ACCOUNT) {
- msg = "账号不能为空";
- } else if (code == QF_CODE_EMPTY_PASSWORD) {
- msg = "密码不能为空";
- } else if (code == QF_CODE_USER_NOT_EXISTS) {
- msg = "用户不存在";
- } else if (code == QF_CODE_WRONG_PASSWORD) {
- msg = "密码错误";
- } else if (code == QF_CODE_PASSWORD_NOT_SAME) {
- msg = "两次输入密码不一致,请修改后重试";
- } else if (code == QF_CODE_PASSWORD_UNCHANGED) {
- msg = "不能与旧密码相同,请修改后重试";
- } else if (code == QF_CODE_DATA_ERROR) {
- msg = "数据异常";
- } else if (code == QF_CODE_EMPTY_USERNAME) {
- msg = "专家名不能为空";
- } else if (code == QF_CODE_ACCOUNT_OCCUPIED) {
- msg = "用户名已存在或者数据库存储异常!";
- } else if (code == QF_CODE_ADD_USER_SUCCEEDED) {
- msg = "已添加";
- type = Success;
- } else if (code == QF_CODE_DELETE_USER_FAILED) {
- msg = "删除用户失败";
- }
- if (!msg.isEmpty()) {
- switch (type) {
- case None:
- break;
- case Info:
- InfoBar::info("提示", msg, Qt::Horizontal, false, 2000, InfoBarPosition::TOP_RIGHT, w);
- break;
- case Success:
- InfoBar::success("提示", msg, Qt::Horizontal, false, 2000, InfoBarPosition::TOP_RIGHT, w);
- break;
- case Alert:
- InfoBar::warning("提示", msg, Qt::Horizontal, false, 2000, InfoBarPosition::TOP_RIGHT, w);
- break;
- case Error:
- InfoBar::error("提示", msg, Qt::Horizontal, false, 2000, InfoBarPosition::TOP_RIGHT, w);
- break;
- }
- }
- }
|