登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

忆风的博客

http://www.cnblogs.com/dhjdhja

 
 
 

日志

 
 
 
 

添加团队时将用户加入团队  

2009-05-04 15:02:37|  分类: CRM学习 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

-------------添加分销代表团队

--select SystemUserid from SystemUser a where a.FullName='白玉国'
--select * from SystemUserRoles where SystemUserId='A456A3CC-EC07-DE11-8365-00155D000309'
--select * from RoleBase where RoleId='62D9DCAC-61DB-4588-A3C0-76F46E3FE3D6'

--insert into TeamMembership(SystemUserId,teamid) values(@uid,@teamid)
--   insert into SystemUserPrincipals(SystemUserPrincipalId,PrincipalId,SystemUserId)
-- values(NEWID(),@teamid,@uid)
 
select teamid from TeamBase where [name]='分销代表'
292FBD6F-F532-DE11-98C7-000C29A68834

drop table #t1
drop table #t2
select newid() as nid,
'292FBD6F-F532-DE11-98C7-000C29A68834' as teamid,a.SystemUserId
into #t1
from SystemUser a
join SystemUserRoles b on a.SystemUserId=b.SystemUserId
join RoleBase c on c.RoleId=b.RoleId
where c.Name='销售代表-分销'

select *
into #t2
from #t1
where nid not in(
select a.nid from #t1 a
join TeamMembership b on a.SystemUserId=b.SystemUserId and a.teamid=b.TeamId)

insert into TeamMembership(SystemUserId,teamid)
select SystemUserid,teamid from #t2

insert into SystemUserPrincipals(SystemUserPrincipalId,PrincipalId,SystemUserId)
select nid,teamid,SystemUserid from #t2

select a.FullName from SystemUser a
where a.SystemUserId in (select SystemUserId from #t1)


-------------添加分销经理团队

select teamid from TeamBase where [name]='分销地区经理'
AEC35E95-F532-DE11-98C7-000C29A68834

drop table #t1
drop table #t2
select newid() as nid,
'AEC35E95-F532-DE11-98C7-000C29A68834' as teamid,a.SystemUserId
into #t1
from SystemUser a
join SystemUserRoles b on a.SystemUserId=b.SystemUserId
join RoleBase c on c.RoleId=b.RoleId
where c.Name='地区经理-分销'

select *
into #t2
from #t1
where nid not in(
select a.nid from #t1 a
join TeamMembership b on a.SystemUserId=b.SystemUserId and a.teamid=b.TeamId)

insert into TeamMembership(SystemUserId,teamid)
select SystemUserid,teamid from #t2

insert into SystemUserPrincipals(SystemUserPrincipalId,PrincipalId,SystemUserId)
select nid,teamid,SystemUserid from #t2

select a.FullName from SystemUser a
where a.SystemUserId in (select SystemUserId from #t1)

  评论这张
 
阅读(364)| 评论(0)

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018