LmtVo.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. using System;
  2. using System.Data;
  3. using System.Data.SqlClient;
  4. using Common;
  5. namespace Business.System.Op.Vo
  6. {
  7. public class LmtVo
  8. {
  9. /// <summary>
  10. /// 根据userid获取用户权限
  11. /// </summary>
  12. /// <param name="userid">用户ID</param>
  13. /// <returns>用户不可操作代码</returns>
  14. public string GetLmt(string userid)
  15. {
  16. string check = "select count(*) from SysLmt where userid=@userid ";
  17. string result = SqlHelper.ExecSqlSc(check, new SqlParameter("userid", userid));
  18. if (!SqlHelper.CheckSc(result))
  19. {
  20. return "**";
  21. }
  22. int count = Convert.ToInt32(result);
  23. if (count <= 0)
  24. {
  25. return "**";
  26. }
  27. string sql = "select ops from SysLmt where userid=@userid ";
  28. result=SqlHelper.ExecSqlSc(sql,new SqlParameter( "userid",userid));
  29. if (!SqlHelper.CheckSc(result))
  30. {
  31. result = "**";
  32. }
  33. return result;
  34. }
  35. /// <summary>
  36. /// 修改用户权限
  37. /// </summary>
  38. /// <param name="userid">用户id</param>
  39. /// <param name="ops">操作集合</param>
  40. /// <returns>成功返回空字符串,失败返回错误信息</returns>
  41. public string UpdateLmt(string userid,string ops)
  42. {
  43. string sql = "update SysLmt set ops=@ops where userid=@userid ";
  44. return SqlHelper.ExecSql(sql, new SqlParameter("@userid", userid), new SqlParameter("@ops", ops));
  45. }
  46. /// <summary>
  47. /// 获取系统日志
  48. /// </summary>
  49. /// <param name="searchTime">搜索字段</param>
  50. /// <param name="searchText">搜索字段</param>
  51. /// <returns>数据表</returns>
  52. public DataTable GetSysLog(string searchTime,string searchText)
  53. {
  54. var sql =
  55. "select top(500) l.time ,u.username,l.remark from SysLog l left join SysUser u on l.userid=u.userid ";
  56. if (!string.IsNullOrEmpty(searchTime))
  57. {
  58. //根据查询字段 进行查询
  59. sql +=
  60. string.Format("where (l.time between '{0}' and '{0} 23:59:59') ", searchTime);
  61. if (!string.IsNullOrEmpty(searchText))
  62. {
  63. //根据查询字段 进行查询
  64. sql +=
  65. string.Format("and (u.username like '%{0}%' or l.remark like '%{0}%')", searchText);
  66. }
  67. }
  68. else
  69. {
  70. if (!string.IsNullOrEmpty(searchText))
  71. {
  72. //根据查询字段 进行查询
  73. sql +=
  74. string.Format("where ( u.username like '%{0}%' or l.remark like '%{0}%')", searchText);
  75. }
  76. }
  77. sql += " order by l.time DESC";
  78. return SqlHelper.ExecSqlDateTable(sql);
  79. }
  80. }
  81. }