23bf40a8f14b4b840a64c213d70f667d884cc4be.svn-base 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Windows.Forms;
  5. namespace Core.Mes.ClientPurviewManager
  6. {
  7. public sealed class RightsComm
  8. {
  9. private static string _ChildDpt = "";
  10. public static string GetChildDpt()
  11. {
  12. string err = "";
  13. object obj = Core.Mes.ClientFrameWork.ClientCommon._RemotingHelp.ExecuteMethod("PurviewManager", "Core.Mes.PurviewManager.UAM_DEPARTMENT",
  14. "GetAllChildDpt", new object[] { Core.Mes.ClientFrameWork.ClientCommon._UserInfo.UserDepID }, out err);
  15. _ChildDpt = CheckNullStr(obj);
  16. return _ChildDpt;
  17. }
  18. public static string CheckNullStr(object obj)
  19. {
  20. if (obj == null || obj.GetType() == typeof(System.DBNull))
  21. {
  22. return "";
  23. }
  24. else
  25. {
  26. return Convert.ToString(obj);
  27. }
  28. }
  29. public static bool CheckRole(string OpDptID)
  30. {
  31. OpDptID = "'" + OpDptID + "'";
  32. string UserID = Core.Mes.ClientFrameWork.ClientCommon._UserInfo.UserID;
  33. string LoginID = Core.Mes.ClientFrameWork.ClientCommon._UserInfo.LoginID;
  34. string UserRoleID = Core.Mes.ClientFrameWork.ClientCommon._UserInfo.UserRoleID;
  35. string UserChildDpt = GetChildDpt();
  36. if (UserID.ToUpper() == "ROOT" || UserRoleID.ToUpper() == "ADMIN001" || LoginID.ToUpper() == "ROOT")
  37. return true;
  38. if (UserRoleID.IndexOf("Admin") < 0)
  39. {
  40. MessageBox.Show("执行该命令需要管理员权限,请与管理员联系", "系统提示");
  41. return false;
  42. }
  43. if (UserChildDpt.Length == 0)
  44. {
  45. MessageBox.Show("权限不够,不能执行该命令,请与系统管理员联系", "系统提示");
  46. return false;
  47. }
  48. if (UserChildDpt.IndexOf(OpDptID) < 0)
  49. {
  50. MessageBox.Show("权限不够,不能执行该命令,请与系统管理员联系", "系统提示");
  51. return false;
  52. }
  53. return true;
  54. }
  55. }
  56. }