d53703b7b384192908c99f6df4846dc126fd7e83.svn-base 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 UserRoleName = Core.Mes.ClientFrameWork.ClientCommon._UserInfo.UserRoleName;
  36. string UserChildDpt = GetChildDpt();
  37. if (UserID.ToUpper() == "ROOT" || UserRoleID.ToUpper() == "ADMIN001" || LoginID.ToUpper() == "ROOT" || LoginID.ToUpper() == "ZH017" || LoginID.ToUpper() == "OY")
  38. return true;
  39. if (UserRoleID.IndexOf("Admin") < 0 && UserRoleName.IndexOf("管理员") < 0 )
  40. {
  41. MessageBox.Show("执行该命令需要管理员权限,请与管理员联系", "系统提示");
  42. return false;
  43. }
  44. if (UserChildDpt.Length == 0)
  45. {
  46. MessageBox.Show("权限不够,不能执行该命令,请与系统管理员联系", "系统提示");
  47. return false;
  48. }
  49. if (UserChildDpt.IndexOf(OpDptID) < 0)
  50. {
  51. MessageBox.Show("权限不够,不能执行该命令,请与系统管理员联系", "系统提示");
  52. return false;
  53. }
  54. return true;
  55. }
  56. }
  57. }