/**更改子系统的名称**/
Update ST_SubSystem Set System_Name=
  Case System_No 
   when 'ST' then '卡务中心'
   when 'KQ' then '考勤管理'
   when 'SF' then '食堂管理'
   when 'KQ' then '考勤管理'
   when 'MJ' then '门禁管理'
   when 'DC' then '订餐管理'
   when 'SK' then '水控管理'
   else System_Name
  End
GO

DELETE FROM ST_Subsystem WHERE CHARINDEX(System_No,'ST,KQ,MJ,SF,DC,SK')<=0
GO

/**1 更改安装系统为KQ_JJ系统**/ 
if not Exists(Select * from st_sysparam where Param_code='SystemType')
  insert into st_sysparam(Param_Code,Param_Name,Param_Value) 
    Values('SystemType','SystemType','11')
else
  Update st_sysparam set Param_Value='11' where Param_code='SystemType'

GO

--2.在用户自定义表ST_SelfMenu插入考勤精简版的Menu_ID
INSERT INTO ST_SelfMenu(User_NO,Menu_ID)
SELECT * FROM ( SELECT 'Admin'[User_NO],1[Menu_ID] 
                  UNION ALL SELECT 'Admin',2
                  UNION ALL SELECT 'Admin',3
                  UNION ALL SELECT 'Admin',4
                  UNION ALL SELECT 'Admin',5
                  UNION ALL SELECT 'Admin',6
                  UNION ALL SELECT 'Admin',7
                  UNION ALL SELECT 'Admin',8
--                  UNION ALL SELECT 'Admin',9
                  UNION ALL SELECT 'Admin',10
                  UNION ALL SELECT 'Admin',11
                  UNION ALL SELECT 'Admin',12
                  UNION ALL SELECT 'Admin',13
                  UNION ALL SELECT 'Admin',14
--                  UNION ALL SELECT 'Admin',15
                  UNION ALL SELECT 'Admin',16
                  UNION ALL SELECT 'Admin',17
                  UNION ALL SELECT 'Admin',18
                  UNION ALL SELECT 'Admin',19
--                  UNION ALL SELECT 'Admin',20
--                  UNION ALL SELECT 'Admin',21
--                  UNION ALL SELECT 'Admin',22
--                  UNION ALL SELECT 'Admin',23
                  UNION ALL SELECT 'Admin',24
--                  UNION ALL SELECT 'Admin',25
--                  UNION ALL SELECT 'Admin',26
--                  UNION ALL SELECT 'Admin',27
--                  UNION ALL SELECT 'Admin',28
--                  UNION ALL SELECT 'Admin',29
                  UNION ALL SELECT 'Admin',30
                  UNION ALL SELECT 'Admin',31
                  UNION ALL SELECT 'Admin',32
                  UNION ALL SELECT 'Admin',33
                  UNION ALL SELECT 'Admin',34
                  UNION ALL SELECT 'Admin',35
                  UNION ALL SELECT 'Admin',36
                  UNION ALL SELECT 'Admin',37
                  UNION ALL SELECT 'Admin',38
--                  UNION ALL SELECT 'Admin',39
--                  UNION ALL SELECT 'Admin',40
--                  UNION ALL SELECT 'Admin',41
--                  UNION ALL SELECT 'Admin',42
                  UNION ALL SELECT 'Admin',43
                  UNION ALL SELECT 'Admin',44
--                  UNION ALL SELECT 'Admin',45
--                  UNION ALL SELECT 'Admin',46
                  UNION ALL SELECT 'Admin',47
--                  UNION ALL SELECT 'Admin',48
--                  UNION ALL SELECT 'Admin',133
                  UNION ALL SELECT 'Admin',191
--以下是考勤子系统
                  UNION ALL SELECT 'Admin',50
                  UNION ALL SELECT 'Admin',53
                  UNION ALL SELECT 'Admin',54
                  UNION ALL SELECT 'Admin',55
                  UNION ALL SELECT 'Admin',56
                  UNION ALL SELECT 'Admin',57
                  UNION ALL SELECT 'Admin',58
                  UNION ALL SELECT 'Admin',59
                  UNION ALL SELECT 'Admin',60
                  UNION ALL SELECT 'Admin',61
                  UNION ALL SELECT 'Admin',62
                  UNION ALL SELECT 'Admin',63
                  UNION ALL SELECT 'Admin',64
                  UNION ALL SELECT 'Admin',65
                  UNION ALL SELECT 'Admin',66
                  UNION ALL SELECT 'Admin',67
                  UNION ALL SELECT 'Admin',68
                  UNION ALL SELECT 'Admin',69
                  UNION ALL SELECT 'Admin',70
                  UNION ALL SELECT 'Admin',71
                  UNION ALL SELECT 'Admin',72
                  UNION ALL SELECT 'Admin',73
                  UNION ALL SELECT 'Admin',74
                  UNION ALL SELECT 'Admin',75
                  UNION ALL SELECT 'Admin',76
                  UNION ALL SELECT 'Admin',77
--                  UNION ALL SELECT 'Admin',78
                  UNION ALL SELECT 'Admin',79
                  UNION ALL SELECT 'Admin',700
                  UNION ALL SELECT 'Admin',701
                  UNION ALL SELECT 'Admin',702
                  UNION ALL SELECT 'Admin',703
              )A
 WHERE A.User_NO='Admin' AND A.Menu_ID NOT IN (SELECT Menu_ID FROM dbo.ST_SelfMenu)
GO

--3、更新用户当前使用子系统标致
UPDATE ST_UserInfo SET Current_Menu='SD'