QFDAlert.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #include "QFDAlert.h"
  2. #include <dbService/ClassSet.h>
  3. #include <Widgets/InfoBar.h>
  4. void QFDAlert::showAlertWithCode(int code, QWidget *w)
  5. {
  6. if (code == QF_CODE_SUCCEEDED) {
  7. return;
  8. }
  9. QString msg;
  10. QFDAlertType type = Alert;
  11. if (code == QF_CODE_EMPTY_ACCOUNT) {
  12. msg = "账号不能为空";
  13. } else if (code == QF_CODE_EMPTY_PASSWORD) {
  14. msg = "密码不能为空";
  15. } else if (code == QF_CODE_USER_NOT_EXISTS) {
  16. msg = "用户不存在";
  17. } else if (code == QF_CODE_WRONG_PASSWORD) {
  18. msg = "密码错误";
  19. } else if (code == QF_CODE_PASSWORD_NOT_SAME) {
  20. msg = "两次输入密码不一致,请修改后重试";
  21. } else if (code == QF_CODE_PASSWORD_UNCHANGED) {
  22. msg = "不能与旧密码相同,请修改后重试";
  23. } else if (code == QF_CODE_DATA_ERROR) {
  24. msg = "数据异常";
  25. } else if (code == QF_CODE_EMPTY_USERNAME) {
  26. msg = "专家名不能为空";
  27. } else if (code == QF_CODE_ACCOUNT_OCCUPIED) {
  28. msg = "用户名已存在或者数据库存储异常!";
  29. } else if (code == QF_CODE_ADD_USER_SUCCEEDED) {
  30. msg = "已添加";
  31. type = Success;
  32. } else if (code == QF_CODE_DELETE_USER_FAILED) {
  33. msg = "删除用户失败";
  34. }
  35. if (!msg.isEmpty()) {
  36. switch (type) {
  37. case None:
  38. break;
  39. case Info:
  40. InfoBar::info("提示", msg, Qt::Horizontal, false, 2000, InfoBarPosition::TOP_RIGHT, w);
  41. break;
  42. case Success:
  43. InfoBar::success("提示", msg, Qt::Horizontal, false, 2000, InfoBarPosition::TOP_RIGHT, w);
  44. break;
  45. case Alert:
  46. InfoBar::warning("提示", msg, Qt::Horizontal, false, 2000, InfoBarPosition::TOP_RIGHT, w);
  47. break;
  48. case Error:
  49. InfoBar::error("提示", msg, Qt::Horizontal, false, 2000, InfoBarPosition::TOP_RIGHT, w);
  50. break;
  51. }
  52. }
  53. }