@ -22,6 +22,8 @@ using System.Text.RegularExpressions;
using System.Linq ;
using System.Data.Common ;
using DSWeb.MvcShipping.DAL.MsSysParamSet ;
using DSWeb.Common.DB ;
using DSWeb.MvcShipping.Helper ;
namespace DSWeb.MvcShipping.DAL.MsInfoClient
{
@ -110,19 +112,19 @@ namespace DSWeb.MvcShipping.DAL.MsInfoClient
//未作指定的单位全都能看
//指定过userid的单位 只有指定的人才能看到
//高级管理员任何时候不受限制
var InfoClintRange = MsSysParamSetDAL . GetData ( "PARAMNAME='ISENABLECUSTRANGE'" ) ;
if ( InfoClintRange . PARAMVALUE ! = "" )
{
if ( InfoClintRange . PARAMVALUE = = "1" & & userid ! = "1BEC90E1-9780-472F-90C2-0C6390C044A4" )
{
//var InfoClintRange = MsSysParamSetDAL.GetData("PARAMNAME='ISENABLECUSTRANGE'") ;
//if (InfoClintRange.PARAMVALUE != "" )
// {
// if (InfoClintRange.PARAMVALUE == "1" && userid!= "1BEC90E1-9780-472F-90C2-0C6390C044A4")
// {
strSql . Append ( "and (not exists(select 1 from info_client_range where SHORTNAME=info_Client.SHORTNAME )" ) ;
// strSql.Append("and (not exists(select 1 from info_client_range where SHORTNAME=info_Client.SHORTNAME )");
strSql . Append ( " or exists(select 1 from info_client_range where SHORTNAME=info_Client.SHORTNAME and userid='" + userid + "'))" ) ;
// strSql.Append(" or exists(select 1 from info_client_range where SHORTNAME=info_Client.SHORTNAME and userid='" + userid + "'))");
}
}
// }
// }
if ( ! string . IsNullOrEmpty ( strCondition ) )
@ -1741,7 +1743,11 @@ namespace DSWeb.MvcShipping.DAL.MsInfoClient
var cmddeletefeedo = db . GetSqlStringCommand ( "delete from info_client_range where userid in (select userid from VW_user where companyid IN (" + op + ")) and SHORTNAME='" + enumValue . SHORTNAME + "' " ) ;
db . ExecuteNonQuery ( cmddeletefeedo , tran ) ;
}
else if ( seltype = = "3" )
{
var cmddeletefeedo = db . GetSqlStringCommand ( "delete from info_client_range where SHORTNAME='" + enumValue . SHORTNAME + "' " ) ;
db . ExecuteNonQuery ( cmddeletefeedo , tran ) ;
}
}
result = new DBResult ( ) ;
result . Success = true ;
@ -1764,6 +1770,7 @@ namespace DSWeb.MvcShipping.DAL.MsInfoClient
return result ;
}
# endregion
@ -2507,7 +2514,6 @@ namespace DSWeb.MvcShipping.DAL.MsInfoClient
# endregion
#region 往来单位审核
public static DBResult IC_Start ( List < MsClient > _List , string USERID ) //申请签入
{
@ -2808,8 +2814,102 @@ namespace DSWeb.MvcShipping.DAL.MsInfoClient
# endregion
#region 独立版本功能 设定往来单位权限
public static DBResult SetRange ( string RANGETYPE , string data , string USERID )
{
//1集团 2分公司 3个人
//1集团 即清空所有往来单位人员权限
//2分公司 效果为选中所有该往来单位录入人的本公司人员
//3个人 效果为选中录入人本人 和他所在公司的操作部、财务
var dataList = JsonConvert . Deserialize < List < MsClient > > ( data ) ;
var result = new DBResult ( ) ;
//op为一串用逗号隔开的带单引号userid 形如 'aaaaa','bbbbb'
var op = "" ;
var seltype = "2" ;
var cdc = new CommonDataContext ( ) ;
if ( RANGETYPE = = "1" )
{
result = MsInfoClientDAL . DelClientRange ( dataList , op , seltype , USERID ) ;
}
if ( RANGETYPE = = "2" )
{
result = MsInfoClientDAL . DelClientRange ( dataList , op , seltype , USERID ) ;
//获取本公司的所有人gid
var 本 公 司 人 员 = new List < VW_user_md > ( ) ;
foreach ( var item in dataList )
{
本 公 司 人 员 = cdc . VW_user . Where ( x = > x . COMPANYID = = item . CORPID ) . ToList ( ) ;
op = GetUseridStr ( 本 公 司 人 员 ) ;
var templist = dataList . Where ( x = > x . GID = = item . GID ) . ToList ( ) ;
result = MsInfoClientDAL . InsertClientRange ( templist , op , seltype , USERID ) ;
if ( ! result . Success ) return result ;
}
}
if ( RANGETYPE = = "3" )
{
result = MsInfoClientDAL . DelClientRange ( dataList , op , "3" , USERID ) ;
//获取本公司非销售人员
//user_userattribute.userid属于本公司 且attri 3C91140E-6FB6-4B5A-B5AB-30E59E3CBBED
var 本 公 司 人 员 = new List < VW_user_md > ( ) ;
foreach ( var item in dataList )
{
本 公 司 人 员 = cdc . VW_user . Where ( x = > x . COMPANYID = = item . CORPID ) . ToList ( ) ;
var 本 人 = 本 公 司 人 员 . FirstOrDefault ( x = > x . SHOWNAME = = item . OPNAME ) ;
op = 获 取 非 销 售 人 员 str ( 本 公 司 人 员 ) ;
if ( op ! = "" ) op + = "," ;
op + = $"'{本人.USERID}'" ;
result = MsInfoClientDAL . InsertClientRange ( dataList , op , seltype , USERID ) ;
if ( ! result . Success ) return result ;
}
}
return result ;
}
private static string GetUseridStr ( List < VW_user_md > vwuserlist )
{
var result = "" ;
foreach ( var user in vwuserlist )
{
if ( result ! = "" ) result + = "," ;
result + = $"'{user.USERID}'" ;
}
return result ;
}
private static string 获 取 非 销 售 人 员 str ( List < VW_user_md > vwuserlist )
{
var cdc = new CommonDataContext ( ) ;
var useridlist = vwuserlist . Select ( s = > s . USERID ) . ToList ( ) ;
var 非 销 售 List = cdc . user_userattribute . Where ( x = > useridlist . Contains ( x . USERID ) & & x . ATTRIBUTEID = = "3C91140E-6FB6-4B5A-B5AB-30E59E3CBBED" & & x . VALUE = = "false" ) . ToList ( ) ;
var 非 销 售 UseridList = 非 销 售 List . Select ( s = > s . USERID ) . ToList ( ) ;
var result = "" ;
foreach ( var userid in 非 销 售 UseridList )
{
if ( result ! = "" ) result + = "," ;
result + = $"'{userid}'" ;
}
return result ;
}
# endregion
#region 参照部分