using System;
using System.Data;
using System.Data.SqlClient;
using Common;
namespace Business.System.Op.Vo
{
public class LmtVo
{
///
/// 根据userid获取用户权限
///
/// 用户ID
/// 用户不可操作代码
public string GetLmt(string userid)
{
string check = "select count(*) from SysLmt where userid=@userid ";
string result = SqlHelper.ExecSqlSc(check, new SqlParameter("userid", userid));
if (!SqlHelper.CheckSc(result))
{
return "**";
}
int count = Convert.ToInt32(result);
if (count <= 0)
{
return "**";
}
string sql = "select ops from SysLmt where userid=@userid ";
result=SqlHelper.ExecSqlSc(sql,new SqlParameter( "userid",userid));
if (!SqlHelper.CheckSc(result))
{
result = "**";
}
return result;
}
///
/// 修改用户权限
///
/// 用户id
/// 操作集合
/// 成功返回空字符串,失败返回错误信息
public string UpdateLmt(string userid,string ops)
{
string sql = "update SysLmt set ops=@ops where userid=@userid ";
return SqlHelper.ExecSql(sql, new SqlParameter("@userid", userid), new SqlParameter("@ops", ops));
}
///
/// 获取系统日志
///
/// 搜索字段
/// 搜索字段
/// 数据表
public DataTable GetSysLog(string searchTime,string searchText)
{
var sql =
"select top(500) l.time ,u.username,l.remark from SysLog l left join SysUser u on l.userid=u.userid ";
if (!string.IsNullOrEmpty(searchTime))
{
//根据查询字段 进行查询
sql +=
string.Format("where (l.time between '{0}' and '{0} 23:59:59') ", searchTime);
if (!string.IsNullOrEmpty(searchText))
{
//根据查询字段 进行查询
sql +=
string.Format("and (u.username like '%{0}%' or l.remark like '%{0}%')", searchText);
}
}
else
{
if (!string.IsNullOrEmpty(searchText))
{
//根据查询字段 进行查询
sql +=
string.Format("where ( u.username like '%{0}%' or l.remark like '%{0}%')", searchText);
}
}
sql += " order by l.time DESC";
return SqlHelper.ExecSqlDateTable(sql);
}
}
}