SVN-Revision: r499
This commit is contained in:
wyf
2025-04-18 08:28:35 +00:00
parent 7d064e9555
commit 006deaa14c
3 changed files with 86 additions and 97 deletions
+20 -27
View File
@@ -1201,8 +1201,26 @@ namespace Lskj.Business.Impl
{ {
try try
{ {
string sqlValue = "select * from p_systemDlltabDetail where tab=@tab and (charindex('," + ERPInfo.Instance.UserName + ",',','+privilegeOper+',')>0 or isnull(privilegeOper,'')='') and ISNULL(isVisible,0)=0 order by orderid"; string sqlTemplate = @"WITH UserRoles AS (
return SqlHelper.ExecuteDataTable(sqlValue, new SqlParameter[] { new SqlParameter("@tab", menuCode) }); SELECT r.roleName
FROM p_systemRoleOperSetTab AS ro
JOIN p_systemRoleSetTab AS r ON r.id = ro.roleId
WHERE ro.operatorname = '{0}'
)
SELECT pm.*
FROM p_systemDlltabDetail AS pm WITH (NOLOCK)
WHERE ISNULL(pm.isvisible, 0) = 0
AND pm.tab = '{1}'
AND (
ISNULL(pm.privilegeOper, '') = ''
OR CHARINDEX(',' + '{0}' + ',', ',' + pm.privilegeOper + ',') > 0
OR EXISTS (
SELECT 1
FROM UserRoles AS ur
WHERE CHARINDEX('{{&' + ur.roleName + '&}}', pm.privilegeOper) > 0)
) ORDER BY pm.orderid;";
string sqlValue = string.Format(sqlTemplate, ERPInfo.Instance.UserName, menuCode);
return SqlHelper.ExecuteDataTable(sqlValue);
} }
catch (Exception) catch (Exception)
{ {
@@ -1260,29 +1278,4 @@ namespace Lskj.Business.Impl
/// <param name="comfirmAdvice">确认意见.</param> /// <param name="comfirmAdvice">确认意见.</param>
/// <returns>System.Int32.</returns> /// <returns>System.Int32.</returns>
public static bool isParamComplete(string storedName, string[] Param) public static bool isParamComplete(string storedName, string[] Param)
{
string whereConfig = string.Empty;
for (int i = 0; i < Param.Length; i++)
{
whereConfig += string.Format(" LOWER(PARAMETER_NAME)=LOWER('{0}') or", Param[i]);
}
string sql = string.Format("SELECT PARAMETER_NAME AS [参数名称] FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_NAME='{1}' and ({0})", whereConfig.Substring(0, whereConfig.Length - 2), storedName);
return SqlHelper.ExecuteDataTable(sql).Rows.Count == Param.Length;
}
/// <summary>
/// 创建只读列
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static DataTable getDetail_Details(string key)
{
string sql = string.Format("select * from p_systembillsourcedetail where sourceid=0 and sourcekey='{0}' and mxflag=1 and isnull(isVisible,0)=0 order by orderid", key);
return GetDataTableResult(sql);
}
}
}
+19 -4
View File
@@ -54,7 +54,7 @@ namespace Lskj.Business.Impl
int result = ExecSqlValue(detailSql, true); int result = ExecSqlValue(detailSql, true);
if (result > 0) if (result > 0)
{ {
SqlParameter pMsg = ERPInfo.Instance.ChangeParameterType ? new SqlParameter("@msg", SqlDbType.NVarChar, 4000) :new SqlParameter("@msg", SqlDbType.VarChar, 2000); SqlParameter pMsg = ERPInfo.Instance.ChangeParameterType ? new SqlParameter("@msg", SqlDbType.NVarChar, 4000) : new SqlParameter("@msg", SqlDbType.VarChar, 2000);
pMsg.Direction = ParameterDirection.Output; pMsg.Direction = ParameterDirection.Output;
SqlParameter returnValue = new SqlParameter("@return", SqlDbType.Int, 4); SqlParameter returnValue = new SqlParameter("@return", SqlDbType.Int, 4);
returnValue.Direction = ParameterDirection.ReturnValue; returnValue.Direction = ParameterDirection.ReturnValue;
@@ -590,15 +590,30 @@ namespace Lskj.Business.Impl
conditions = "and isnull(mxflag,0)=0"; conditions = "and isnull(mxflag,0)=0";
} }
string cond = !string.IsNullOrEmpty(sourceCond) ? string.Format(" and id in ({0})", sourceCond.Trim(',')) : string.Empty; string cond = !string.IsNullOrEmpty(sourceCond) ? string.Format(" and id in ({0})", sourceCond.Trim(',')) : string.Empty;
string sqlValue = string.Format("select * from p_systembillsource where typeCode=@typeCode" + cond + " and isnull(isVisible,0)=0 and (isnull(viewOper,'')='' or CHARINDEX(',' + '{0}' + ',', ',' + viewOper + ',')>0) order by orderid", ERPInfo.Instance.UserName); string sqlValue = string.Format(@"WITH UserRoles AS (
string sqlDetail = string.Format(@"SELECT id,sourceId,fieldName,sysName,userName,orderid,isVisible,sourceKey,privilegeView,DataFormat,isSum,ifmerge,{2} SELECT r.roleName
FROM p_systemRoleOperSetTab AS ro
JOIN p_systemRoleSetTab AS r ON r.id = ro.roleId
WHERE ro.operatorname = '{0}'
)
select * from p_systembillsource where typeCode=@typeCode" + cond +
@" and isnull(isVisible,0)=0 and (isnull(viewOper,'')='' or CHARINDEX(',' + '{0}' + ',', ',' + viewOper + ',')>0 OR EXISTS (
SELECT 1 FROM UserRoles AS ur WHERE CHARINDEX('{{&' + ur.roleName + '&}}', viewOper) > 0)) order by orderid", ERPInfo.Instance.UserName);
string sqlDetail = string.Format(@"WITH UserRoles AS (
SELECT r.roleName
FROM p_systemRoleOperSetTab AS ro
JOIN p_systemRoleSetTab AS r ON r.id = ro.roleId
WHERE ro.operatorname = '{0}'
)
SELECT id,sourceId,fieldName,sysName,userName,orderid,isVisible,sourceKey,privilegeView,DataFormat,isSum,ifmerge,{2}
isnull(CASE WHEN isVisible=1 OR (ISNULL(b.userList,'')='' AND ISNULL(a.PrivilegeView,'')<>'') THEN 0 ELSE width END,0) width isnull(CASE WHEN isVisible=1 OR (ISNULL(b.userList,'')='' AND ISNULL(a.PrivilegeView,'')<>'') THEN 0 ELSE width END,0) width
FROM p_systembillsourcedetail a FROM p_systembillsourcedetail a
LEFT JOIN ( LEFT JOIN (
SELECT userList,privTypeId from p_systemPrivilege b where modId = '{0}' SELECT userList,privTypeId from p_systemPrivilege b where modId = '{0}'
AND CHARINDEX(',' + '{1}' + ',', ',' + userList + ',') > 0 AND CHARINDEX(',' + '{1}' + ',', ',' + userList + ',') > 0
) b on CHARINDEX(',' + CAST(b.privTypeId AS VARCHAR(5)) + ',',',' + PrivilegeView + ',') > 0 ) b on CHARINDEX(',' + CAST(b.privTypeId AS VARCHAR(5)) + ',',',' + PrivilegeView + ',') > 0
where sourceId in (select id from p_systembillsource where typeCode=@typeCode" + cond + " and isnull(isVisible,0)=0 and (isnull(viewOper,'')='' or CHARINDEX(',' + '{1}' + ',', ',' + viewOper + ',')>0)) {3} order by sourceId,orderid", menuCode, ERPInfo.Instance.UserName, otherfield, conditions); where sourceId in (select id from p_systembillsource where typeCode=@typeCode" + cond + @" and isnull(isVisible,0)=0 and (isnull(viewOper,'')='' or CHARINDEX(',' + '{1}' + ',', ',' + viewOper + ',')>0) OR EXISTS (
SELECT 1 FROM UserRoles AS ur WHERE CHARINDEX('{{&' + ur.roleName + '&}}', viewOper) > 0)) {3} order by sourceId,orderid", menuCode, ERPInfo.Instance.UserName, otherfield, conditions);
htTable["master"] = SqlHelper.ExecuteDataTable(sqlValue, new SqlParameter[] { new SqlParameter("@typeCode", menuCode) }); htTable["master"] = SqlHelper.ExecuteDataTable(sqlValue, new SqlParameter[] { new SqlParameter("@typeCode", menuCode) });
htTable["detail"] = SqlHelper.ExecuteDataTable(sqlDetail, new SqlParameter[] { new SqlParameter("@typeCode", menuCode) }); htTable["detail"] = SqlHelper.ExecuteDataTable(sqlDetail, new SqlParameter[] { new SqlParameter("@typeCode", menuCode) });
+28 -47
View File
@@ -23,7 +23,8 @@ namespace Lskj.Business.Impl
/// <returns>DataTable.</returns> /// <returns>DataTable.</returns>
public static DataTable GetPurview(string condition) public static DataTable GetPurview(string condition)
{ {
if (string.IsNullOrWhiteSpace(condition)) { if (string.IsNullOrWhiteSpace(condition))
{
string allSql = string.Format("select * from p_formmenuconfigtab where len(MenuStruct)>2"); string allSql = string.Format("select * from p_formmenuconfigtab where len(MenuStruct)>2");
return GetDataTableResult(allSql); return GetDataTableResult(allSql);
} }
@@ -57,9 +58,9 @@ namespace Lskj.Business.Impl
/// <para>版本:1.0</para> /// <para>版本:1.0</para>
/// </summary> /// </summary>
/// <returns>DataTable.</returns> /// <returns>DataTable.</returns>
public static DataTable GetSystemsTable(string way,bool isChildren) public static DataTable GetSystemsTable(string way, bool isChildren)
{ {
string sqlValue = isChildren ? "select * from p_formmenuconfigtab where " + way:"select * from p_formmenuconfigtab where ParentMenuId='-1' and LEN(MenuStruct)=2 " + way; string sqlValue = isChildren ? "select * from p_formmenuconfigtab where " + way : "select * from p_formmenuconfigtab where ParentMenuId='-1' and LEN(MenuStruct)=2 " + way;
return GetDataTableResult(sqlValue); return GetDataTableResult(sqlValue);
} }
/// <summary> /// <summary>
@@ -108,7 +109,7 @@ namespace Lskj.Business.Impl
{ {
string where = string.Empty; string where = string.Empty;
if (!string.IsNullOrEmpty(depid)) if (!string.IsNullOrEmpty(depid))
where = string.Format(" where operatorid='{0}'",depid); where = string.Format(" where operatorid='{0}'", depid);
if (!string.IsNullOrEmpty(mf)) if (!string.IsNullOrEmpty(mf))
where = string.Format(" and (loginaccount like '%{0}%' or employeename like '%{0}%' or dbo.P_getpy(employeename) like '%{0}%')", mf); where = string.Format(" and (loginaccount like '%{0}%' or employeename like '%{0}%' or dbo.P_getpy(employeename) like '%{0}%')", mf);
@@ -215,13 +216,15 @@ namespace Lskj.Business.Impl
/// <para>版本:1.0</para> /// <para>版本:1.0</para>
/// </summary> /// </summary>
/// <returns>System.Int32.</returns> /// <returns>System.Int32.</returns>
public static bool SaveRoleOperDate(string OperId, string OperName, string departemnt, string readdate, string editdate,bool IsBrowse) public static bool SaveRoleOperDate(string OperId, string OperName, string departemnt, string readdate, string editdate, bool IsBrowse)
{ {
string sqlValue = string.Empty; string sqlValue = string.Empty;
if (IsBrowse) { if (IsBrowse)
{
sqlValue = string.Format(" if exists (select * from p_systemRoleOperSetTab s where s.operatorid='{0}') update p_systemRoleOperSetTab set ReadPurview='{4}' where operatorid = '{0}' ELSE insert into p_systemRoleOperSetTab (roleId,roleOperatorId,operatorid,operatorname,operatedate,department,ReadPurview,EditPurview) values ('0','{0}','{0}','{1}','{2}','{3}','{4}','{5}')", OperId, OperName, DateTime.Now, departemnt, readdate, ""); sqlValue = string.Format(" if exists (select * from p_systemRoleOperSetTab s where s.operatorid='{0}') update p_systemRoleOperSetTab set ReadPurview='{4}' where operatorid = '{0}' ELSE insert into p_systemRoleOperSetTab (roleId,roleOperatorId,operatorid,operatorname,operatedate,department,ReadPurview,EditPurview) values ('0','{0}','{0}','{1}','{2}','{3}','{4}','{5}')", OperId, OperName, DateTime.Now, departemnt, readdate, "");
} }
else { else
{
sqlValue = string.Format(" if exists (select * from p_systemRoleOperSetTab s where s.operatorid='{0}') update p_systemRoleOperSetTab set EditPurview='{5}' where operatorid = '{0}' ELSE insert into p_systemRoleOperSetTab (roleId,roleOperatorId,operatorid,operatorname,operatedate,department,ReadPurview,EditPurview) values ('0','{0}','{0}','{1}','{2}','{3}','{4}','{5}')", OperId, OperName, DateTime.Now, departemnt, "", editdate); sqlValue = string.Format(" if exists (select * from p_systemRoleOperSetTab s where s.operatorid='{0}') update p_systemRoleOperSetTab set EditPurview='{5}' where operatorid = '{0}' ELSE insert into p_systemRoleOperSetTab (roleId,roleOperatorId,operatorid,operatorname,operatedate,department,ReadPurview,EditPurview) values ('0','{0}','{0}','{1}','{2}','{3}','{4}','{5}')", OperId, OperName, DateTime.Now, departemnt, "", editdate);
} }
@@ -281,10 +284,10 @@ namespace Lskj.Business.Impl
/// <para>版本:1.0</para> /// <para>版本:1.0</para>
/// </summary> /// </summary>
/// <returns>System.Int32.</returns> /// <returns>System.Int32.</returns>
public static bool DropDate(int OperId,string JobNumber,string OperName, string departemnt, string id) public static bool DropDate(int OperId, string JobNumber, string OperName, string departemnt, string id)
{ {
string sqlValue = string.Format("INSERT INTO p_systemRoleOperSetTab (roleId, roleOperatorId,operatorid,operatorname,department,operatedate,JobNumber) VALUES ('{0}','{1}','{1}','{2}','{3}','{4}','{5}')", id, OperId, OperName, departemnt, DateTime.Now,JobNumber); string sqlValue = string.Format("INSERT INTO p_systemRoleOperSetTab (roleId, roleOperatorId,operatorid,operatorname,department,operatedate,JobNumber) VALUES ('{0}','{1}','{1}','{2}','{3}','{4}','{5}')", id, OperId, OperName, departemnt, DateTime.Now, JobNumber);
return ExecSqlValue(sqlValue) > 0; return ExecSqlValue(sqlValue) > 0;
} }
/// <summary> /// <summary>
@@ -312,7 +315,7 @@ namespace Lskj.Business.Impl
/// <para>版本:1.0</para> /// <para>版本:1.0</para>
/// </summary> /// </summary>
/// <returns>System.Int32.</returns> /// <returns>System.Int32.</returns>
public static bool deletRoleDate(string id,string roleId) public static bool deletRoleDate(string id, string roleId)
{ {
string sqlValue = string.Format("DELETE FROM p_systemRoleOperSetTab WHERE operatorid = '{0}' and roleId='{1}'", id, roleId); string sqlValue = string.Format("DELETE FROM p_systemRoleOperSetTab WHERE operatorid = '{0}' and roleId='{1}'", id, roleId);
return ExecSqlValue(sqlValue) > 0; return ExecSqlValue(sqlValue) > 0;
@@ -349,7 +352,7 @@ namespace Lskj.Business.Impl
where = string.Format(" where (员工姓名 like '%{0}%' or dbo.P_getpy(员工姓名) like '%{0}%')", mc); where = string.Format(" where (员工姓名 like '%{0}%' or dbo.P_getpy(员工姓名) like '%{0}%')", mc);
if (!string.IsNullOrEmpty(dc)) if (!string.IsNullOrEmpty(dc))
{ {
where +=string.IsNullOrWhiteSpace(mc)?string.Format(" where 员工工号 like '%{0}%'",dc):string.Format(" and 员工工号 like '%{0}%'",dc); where += string.IsNullOrWhiteSpace(mc) ? string.Format(" where 员工工号 like '%{0}%'", dc) : string.Format(" and 员工工号 like '%{0}%'", dc);
} }
string sqlValue = "select 员工ID,员工工号,员工姓名,所属部门 from P_employeeBaseView " + where; string sqlValue = "select 员工ID,员工工号,员工姓名,所属部门 from P_employeeBaseView " + where;
return GetDataTableResult(sqlValue); return GetDataTableResult(sqlValue);
@@ -366,7 +369,7 @@ namespace Lskj.Business.Impl
/// <returns>System.Int32.</returns> /// <returns>System.Int32.</returns>
public static bool intnewOper(string OperName) public static bool intnewOper(string OperName)
{ {
string sqlValue = string.Format("INSERT INTO p_systemRoleSetTab (roleName,operatedate) VALUES ('{0}','{1}')", OperName,DateTime.Now); string sqlValue = string.Format("INSERT INTO p_systemRoleSetTab (roleName,operatedate) VALUES ('{0}','{1}')", OperName, DateTime.Now);
return ExecSqlValue(sqlValue) > 0; return ExecSqlValue(sqlValue) > 0;
} }
/// <summary> /// <summary>
@@ -379,9 +382,9 @@ namespace Lskj.Business.Impl
/// <para>版本:1.0</para> /// <para>版本:1.0</para>
/// </summary> /// </summary>
/// <returns>System.Int32.</returns> /// <returns>System.Int32.</returns>
public static bool UpdOper(string OperName,string id) public static bool UpdOper(string OperName, string id)
{ {
string sqlValue = string.Format("Update p_systemRoleSetTab set roleName='{0}',operatedate='{1}' where id={2} ", OperName, DateTime.Now,id); string sqlValue = string.Format("Update p_systemRoleSetTab set roleName='{0}',operatedate='{1}' where id={2} ", OperName, DateTime.Now, id);
return ExecSqlValue(sqlValue) > 0; return ExecSqlValue(sqlValue) > 0;
} }
@@ -499,25 +502,26 @@ namespace Lskj.Business.Impl
//获得全部权限人员 //获得全部权限人员
public static string getAllPersonnel(string name) public static string getAllPersonnel(string name)
{ {
if(string.IsNullOrWhiteSpace(name)) return ""; if (string.IsNullOrWhiteSpace(name)) return "";
//获得所有角色 //获得所有角色
List<string> condition = ReplaceHelper.GetParamFields(name); List<string> condition = ReplaceHelper.GetParamFields(name);
DataTable dataTable=GetWorkRole("", ""); DataTable dataTable = GetWorkRole("", "");
foreach (string role in condition) foreach (string role in condition)
{ {
string newName = string.Empty; string newName = string.Empty;
string roleName = role.Replace("{&", "").Replace("&}", ""); string roleName = role.Replace("{&", "").Replace("&}", "");
DataRow[] drs = dataTable.Select("roleName='"+ roleName + "'"); DataRow[] drs = dataTable.Select("roleName='" + roleName + "'");
if (drs.Length < 1) continue; if (drs.Length < 1) continue;
string id = drs[0]["id"] + ""; string id = drs[0]["id"] + "";
DataTable PersonnelDt = GetWorkUsers(id); DataTable PersonnelDt = GetWorkUsers(id);
foreach (DataRow dr in PersonnelDt.Rows) { foreach (DataRow dr in PersonnelDt.Rows)
{
newName += dr["员工姓名"] + ","; newName += dr["员工姓名"] + ",";
} }
name=name.Replace(role, newName.TrimEnd(','));// name = name.Replace(role, newName.TrimEnd(','));
} }
@@ -650,7 +654,7 @@ namespace Lskj.Business.Impl
/// <param name="roleid"></param> /// <param name="roleid"></param>
/// <param name="roleName"></param> /// <param name="roleName"></param>
/// <param name="moduleCodes"></param> /// <param name="moduleCodes"></param>
public static void SetRolePermissionclassification(string roleid,string roleName, DataTable Module) public static void SetRolePermissionclassification(string roleid, string roleName, DataTable Module)
{ {
BaseImpl.HasExistsColumn("p_systemPrivilege", "roleid", "int"); BaseImpl.HasExistsColumn("p_systemPrivilege", "roleid", "int");
@@ -676,7 +680,7 @@ namespace Lskj.Business.Impl
NewModule.Add(PurviewId); NewModule.Add(PurviewId);
} }
} }
DataTable dataTable= GetDataTableResult(string.Format("select * from p_systemPrivilege where roleid='{0}'", roleid)); DataTable dataTable = GetDataTableResult(string.Format("select * from p_systemPrivilege where roleid='{0}'", roleid));
foreach (DataRow item in dataTable.Rows) foreach (DataRow item in dataTable.Rows)
{ {
string PurviewId = item["modId"] + ""; string PurviewId = item["modId"] + "";
@@ -687,7 +691,7 @@ namespace Lskj.Business.Impl
} }
string Sql = string.Empty; string Sql = string.Empty;
List<string> AddList= NewModule.Except(OldModule).ToList(); List<string> AddList = NewModule.Except(OldModule).ToList();
List<string> DeleteList = OldModule.Except(NewModule).ToList(); List<string> DeleteList = OldModule.Except(NewModule).ToList();
//添加新增的权限模块 //添加新增的权限模块
@@ -698,7 +702,7 @@ namespace Lskj.Business.Impl
if (dr != null) privTypeId = int.Parse(dr["privTypeId"] + "") + 1; if (dr != null) privTypeId = int.Parse(dr["privTypeId"] + "") + 1;
Sql += string.Format(" insert into p_systemPrivilege(privTypeId,privTypeName,modId,userList,remark,roleid) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}'); ", Sql += string.Format(" insert into p_systemPrivilege(privTypeId,privTypeName,modId,userList,remark,roleid) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}'); ",
privTypeId + "", roleName, item, text,"", roleid); privTypeId + "", roleName, item, text, "", roleid);
} }
//删除移除的权限模块 //删除移除的权限模块
foreach (string item in DeleteList) foreach (string item in DeleteList)
@@ -709,27 +713,4 @@ namespace Lskj.Business.Impl
//拼接添加权限分类sql //拼接添加权限分类sql
//List<string> moduleNumbers = new List<string>(); //List<string> moduleNumbers = new List<string>();
//string Sql = string.Format("delete p_systemPrivilege where roleid='{0}';", roleid); //string Sql = string.Format("delete p_sy
//foreach (DataRow item in Module.Rows)
//{
// string PurviewId = item["PurviewId"] + "";
// if (!string.IsNullOrWhiteSpace(PurviewId) && !moduleNumbers.Contains(PurviewId))
// {
// moduleNumbers.Add(PurviewId);
// DataRow dr= GetDataRowResult(string.Format("select top 1 privTypeId from p_systemPrivilege where modId='{0}' order by privTypeId desc ", PurviewId));
// int privTypeId =1;
// if (dr != null) privTypeId = int.Parse(dr["privTypeId"] + "") + 1;
// Sql += string.Format(" insert into p_systemPrivilege(privTypeId,privTypeName,modId,userList,remark,roleid) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}'); ",
// privTypeId+"", roleName, PurviewId, text,"", roleid);
// }
//}
//ExecSqlValue(Sql);
}
}
}