--1.水控子系统初始菜单表
INSERT INTO dbo.ST_MenuInfo(Menu_ID,System_No,Menu_No,Menu_Name,Menu_Hint,Para_ID,Call_Mode,Form_Name,ShortKey,
                        Menu_Index,Image_Index,Separator,InToolBar,Remark)
SELECT * FROM (SELECT 143[Menu_ID],'SK'[System_No],'SK_04'[Menu_No],'系统管理'[Menu_Name],NULL[Menu_Hint],-1[Para_ID],NULL[Call_Mode],
                      NULL[Form_Name],NULL[ShortKey],'1'[Menu_Index],NULL[Image_Index],NULL[Separator],0[InToolBar],NULL[Remark]
                UNION ALL SELECT 144,'SK','SK_0401','退出系统','退出系统',143,'5','Exit',NULL,'1',0,'0',0,NULL
                UNION ALL SELECT 137,'SK','SK_01','应用场合',NULL,-1,NULL,NULL,NULL,'2',NULL,NULL,0,NULL
                UNION ALL SELECT 138,'SK','SK_0101','消费场合','消费场合',137,'2','TfrmConsumeArea',NULL,'1',7,'0',0,NULL
                UNION ALL SELECT 213,'SK','SK_0102','水控补贴机','水控补贴机',137,1,'TfrmSKSubsidyMocSet',NULL,1,8,'0',0,NULL
                UNION ALL SELECT 139,'SK','SK_02','特殊卡管理',NULL,-1,NULL,NULL,NULL,'3',NULL,NULL,0,NULL
                UNION ALL SELECT 140,'SK','SK_0201','特殊卡管理','特殊卡管理',139,'2','TfrmSpecificCard',NULL,'1',9,'0',0,NULL
                UNION ALL SELECT 141,'SK','SK_03','汇总报表',NULL,-1,NULL,NULL,NULL,'4',NULL,NULL,0,NULL
                UNION ALL SELECT 142,'SK','SK_0301','采集数据汇总表','采集数据汇总表',141,'1','TfrmGetConsumeSumRpt',NULL,'1',10,'0',0,NULL
							) A
 WHERE A.Menu_ID NOT IN (SELECT Menu_ID FROM dbo.ST_MenuInfo)
GO

--新版水控机所需要使用的菜单
INSERT INTO dbo.ST_MenuInfo(Menu_ID,System_No,Menu_No,Menu_Name,Menu_Hint,Para_ID,Call_Mode,Form_Name,ShortKey,
                        Menu_Index,Image_Index,Separator,InToolBar,Remark)
SELECT * FROM (SELECT 201[Menu_ID],'SK'[System_No],'SK_0400'[Menu_No],'系统参数'[Menu_Name],'系统参数'[Menu_Hint],143[Para_ID],2[Call_Mode],
                      'TfrmSKSysParams'[Form_Name],NULL[ShortKey],0[Menu_Index],11[Image_Index],1[Separator],0[InToolBar],NULL[Remark]
                UNION ALL SELECT 202,'SK','SK_10','业务功能',NULL,-1,NULL,NULL,NULL,2,-1,0,0,NULL
                UNION ALL SELECT 203,'SK','SK_1001','卡类设置','卡类设置',202,2,'TfrmSKCardType',NULL,1,12,0,0,NULL
                UNION ALL SELECT 204,'SK','SK_1002','终端机设置','终端机设置',202,2,'TfrmSKMocSet',NULL,2,13,1,0,NULL
                UNION ALL SELECT 205,'SK','SK_1003','采集记录','采集记录',202,2,'TfrmSKDownload',NULL,3,14,1,0,NULL
                UNION ALL SELECT 206,'SK','SK_1004','统计报表',NULL,202,9,NULL,NULL,3,-1,0,0,NULL
                UNION ALL SELECT 207,'SK','SK_100401','消费明细表','消费明细表',206,1,'TfrmSKConsume',NULL,1,15,1,0,NULL
                UNION ALL SELECT 208,'SK','SK_100402','人员消费汇总表','人员消费汇总表',206,1,'TfrmSKPsnTotal',NULL,2,-1,0,0,NULL
                UNION ALL SELECT 209,'SK','SK_100403','机器消费汇总表','机器消费汇总表',206,1,'TfrmSKMocTotal',NULL,3,-1,0,0,NULL
                UNION ALL SELECT 210,'SK','SK_100404','用途消费汇总表','用途消费汇总表',206,1,'TfrmSKUseTotal',NULL,4,-1,0,0,NULL
                UNION ALL SELECT 211,'SK','SK_1005','打折时段设置','打折时段设置',202,2,'TfrmDiscountInfo',NULL,2,16,1,0,NULL
                UNION ALL SELECT 212,'SK','SK_1006','水控补贴机','水控补贴机',202,1,'TfrmSKSubsidyMocSet',Null,2,8,1,0,NULL
							) A
 WHERE A.Menu_ID NOT IN (SELECT Menu_ID FROM dbo.ST_MenuInfo)
GO

--1.1.初始化小金额应用场合用途编码
INSERT INTO dbo.ST_Dictionary(Table_Name,Table_ChsName,Dict_Id,Dict_Value,Is_SysCol)
SELECT * FROM (SELECT 'BM_AREAUSE'[Table_Name],'水控场合用途'[Table_ChsName],'1'[Dict_Id],'洗澡堂(水控)'[Dict_Value],1[Is_SysCol]
                UNION ALL SELECT 'BM_AREAUSE','水控场合用途','2','洗衣房',1
                UNION ALL SELECT 'BM_AREAUSE','水控场合用途','3','开水房',1
                UNION ALL SELECT 'BM_AREAUSE','水控场合用途','4','饮水机',1
                UNION ALL SELECT 'BM_AREAUSE','水控场合用途','5','绿化草地',1
                UNION ALL SELECT 'BM_AREAUSE','水控场合用途','6','工业用水',1
                --UNION ALL SELECT 'BM_AREAUSE','水控场合用途','7','小卖部(商品)',1
                --UNION ALL SELECT 'BM_AREAUSE','水控场合用途','8','机房',1
                --UNION ALL SELECT 'BM_AREAUSE','水控场合用途','9','卡拉OK(各种娱乐场所)',1
                --UNION ALL SELECT 'BM_AREAUSE','水控场合用途','10','美食城',1
              ) A
 WHERE A.Dict_ID NOT IN (SELECT Dict_ID FROM dbo.ST_Dictionary WHERE Table_Name='BM_AREAUSE')
GO

--2.增加系统权限值列表
--2.1增加每个模块的默认权限值

--3.增加角色权限默认管理员组


--初始化水控参数
INSERT INTO dbo.SK_SysParam(Param_Code,Param_Name,Param_Value)
SELECT * FROM (SELECT 'MocType'[Param_Code],'硬件类型'[Param_Name],'1'[Param_Value]
                UNION ALL SELECT 'COM','通讯串口','COM1'
                UNION ALL SELECT 'BaudRate','通讯波特率','9600'
                UNION ALL SELECT 'MOCUse','水控机用途','0-娱乐;1-开水;2-洗浴;3-机房;4-洗衣;5-用电'
                UNION ALL SELECT 'MOCUnit','水控机计量单位','0-秒;1-分;2-小时;3-天;4-次;5-脉冲'
                UNION ALL SELECT 'MOCMode','水控机计费模式','1-计时;2-计次;3-计流量'
                UNION ALL SELECT 'SetSubsidyMode','设置补贴发放模式',''
                UNION ALL SELECT 'CommMode','通讯方式','0'
              ) A
WHERE A.Param_Code NOT IN (SELECT Param_Code FROM dbo.SK_SysParam)
GO

--更新子系统创建日期
UPDATE dbo.ST_SubSystem SET DBCreateDate=CONVERT(VARCHAR(10),GETDATE(),121),DBVersion = '3.2.0'
WHERE  System_No = 'SK'
GO
