insert into Sys_Const values('716C3A9E-A88C-4D4B-81D5-5C84EE24357F','Menu_PGJSX','关键事项',7,'MenuType_P',NULL) GO update Sys_Const set SortIndex=8 where ID='CF2CA03F-84B3-432E-AEAC-4ECF7890D6D7' update Sys_Const set SortIndex=9 where ID='85CF0BBF-A3F3-42DF-89DC-CE9A4886BCA1' update Sys_Const set SortIndex=10 where ID='0B13D4A9-E047-4C18-AD68-8D3724D4F0A8' GO INSERT INTO dbo.Sys_Menu(MenuId,MenuName,Url,SortIndex,SuperMenu,MenuType,IsOffice,IsEnd,IsUsed) VALUES('2344465A-F43E-495E-98E7-9AC1C6484F5C','工程量清单设置','JDGL/Check/QuantityList.aspx',60,'0','Menu_JDGL',0,1,1) GO INSERT INTO dbo.Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,SortIndex) VALUES('35BBBD54-29F1-4D46-9745-3500B6B00267','2344465A-F43E-495E-98E7-9AC1C6484F5C','增加',1) INSERT INTO dbo.Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,SortIndex) VALUES('52B28F04-AECA-4FDD-B5FA-45EC22CAC50B','2344465A-F43E-495E-98E7-9AC1C6484F5C','修改',2) INSERT INTO dbo.Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,SortIndex) VALUES('FC4DAA4C-7E3A-4627-A2A8-1286018C4B30','2344465A-F43E-495E-98E7-9AC1C6484F5C','删除',3) INSERT INTO dbo.Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,SortIndex) VALUES('4705582D-0389-4226-9D44-D906691F3310','2344465A-F43E-495E-98E7-9AC1C6484F5C','保存',4) GO INSERT INTO dbo.Sys_Menu(MenuId,MenuName,Url,SortIndex,SuperMenu,MenuType,IsOffice,IsEnd,IsUsed) VALUES('2AE9D982-A499-497F-8F54-ADDA5856887E','工程量完成情况','JDGL/Check/QuantityCompletion.aspx',70,'0','Menu_JDGL',0,1,1) GO INSERT INTO dbo.Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,SortIndex) VALUES('0EF989CE-B113-40A2-A8B1-52DBDB69A5E0','2AE9D982-A499-497F-8F54-ADDA5856887E','增加',1) INSERT INTO dbo.Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,SortIndex) VALUES('31F3236C-16E9-438A-810F-FDBA5776470D','2AE9D982-A499-497F-8F54-ADDA5856887E','修改',2) INSERT INTO dbo.Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,SortIndex) VALUES('C3260DE0-748A-4D5E-A30D-F886BC2385D2','2AE9D982-A499-497F-8F54-ADDA5856887E','删除',3) INSERT INTO dbo.Sys_ButtonToMenu(ButtonToMenuId,MenuId,ButtonName,SortIndex) VALUES('BDBABEE5-DE52-47BA-9799-ACB7EE76F3FA','2AE9D982-A499-497F-8F54-ADDA5856887E','保存',4) GO CREATE TABLE [dbo].[JDGL_QuantityList]( [QuantityListId] [nvarchar](50) NOT NULL, [ProjectId] [nvarchar](50) NULL, [CNProfessionalId] [nvarchar](50) NULL, [Name] [nvarchar](50) NULL, [Unit] [nvarchar](20) NULL, [DesignNum] [decimal](9, 2) NULL, CONSTRAINT [PK_JDGL_QuantityList] PRIMARY KEY CLUSTERED ( [QuantityListId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO ALTER TABLE [dbo].[JDGL_QuantityList] WITH CHECK ADD CONSTRAINT [FK_JDGL_QuantityList_Base_CNProfessional] FOREIGN KEY([CNProfessionalId]) REFERENCES [dbo].[Base_CNProfessional] ([CNProfessionalId]) GO ALTER TABLE [dbo].[JDGL_QuantityList] CHECK CONSTRAINT [FK_JDGL_QuantityList_Base_CNProfessional] GO ALTER TABLE [dbo].[JDGL_QuantityList] WITH CHECK ADD CONSTRAINT [FK_JDGL_QuantityList_Base_Project] FOREIGN KEY([ProjectId]) REFERENCES [dbo].[Base_Project] ([ProjectId]) GO ALTER TABLE [dbo].[JDGL_QuantityList] CHECK CONSTRAINT [FK_JDGL_QuantityList_Base_Project] GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'主键' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'JDGL_QuantityList', @level2type=N'COLUMN',@level2name=N'QuantityListId' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'项目Id' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'JDGL_QuantityList', @level2type=N'COLUMN',@level2name=N'ProjectId' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'专业Id' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'JDGL_QuantityList', @level2type=N'COLUMN',@level2name=N'CNProfessionalId' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'JDGL_QuantityList', @level2type=N'COLUMN',@level2name=N'Name' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'单位' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'JDGL_QuantityList', @level2type=N'COLUMN',@level2name=N'Unit' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'设计数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'JDGL_QuantityList', @level2type=N'COLUMN',@level2name=N'DesignNum' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'工程量清单设置表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'JDGL_QuantityList' GO CREATE TABLE [dbo].[JDGL_QuantityCompletion]( [QuantityCompletionId] [nvarchar](50) NOT NULL, [ProjectId] [nvarchar](50) NULL, [QuantityListId] [nvarchar](50) NULL, [Months] [datetime] NULL, [PlanNum] [decimal](9, 2) NULL, [RealNum] [decimal](9, 2) NULL, [CompileMan] [nvarchar](50) NULL, [CompileDate] [datetime] NULL, CONSTRAINT [PK_JDGL_QuantityCompletion] PRIMARY KEY CLUSTERED ( [QuantityCompletionId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO ALTER TABLE [dbo].[JDGL_QuantityCompletion] WITH CHECK ADD CONSTRAINT [FK_JDGL_QuantityCompletion_Base_Project] FOREIGN KEY([ProjectId]) REFERENCES [dbo].[Base_Project] ([ProjectId]) GO ALTER TABLE [dbo].[JDGL_QuantityCompletion] CHECK CONSTRAINT [FK_JDGL_QuantityCompletion_Base_Project] GO ALTER TABLE [dbo].[JDGL_QuantityCompletion] WITH CHECK ADD CONSTRAINT [FK_JDGL_QuantityCompletion_JDGL_QuantityList] FOREIGN KEY([QuantityListId]) REFERENCES [dbo].[JDGL_QuantityList] ([QuantityListId]) GO ALTER TABLE [dbo].[JDGL_QuantityCompletion] CHECK CONSTRAINT [FK_JDGL_QuantityCompletion_JDGL_QuantityList] GO ALTER TABLE [dbo].[JDGL_QuantityCompletion] WITH CHECK ADD CONSTRAINT [FK_JDGL_QuantityCompletion_Sys_User] FOREIGN KEY([CompileMan]) REFERENCES [dbo].[Sys_User] ([UserId]) GO ALTER TABLE [dbo].[JDGL_QuantityCompletion] CHECK CONSTRAINT [FK_JDGL_QuantityCompletion_Sys_User] GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'主键' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'JDGL_QuantityCompletion', @level2type=N'COLUMN',@level2name=N'QuantityCompletionId' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'项目Id' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'JDGL_QuantityCompletion', @level2type=N'COLUMN',@level2name=N'ProjectId' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'月份' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'JDGL_QuantityCompletion', @level2type=N'COLUMN',@level2name=N'Months' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'本月计划完成' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'JDGL_QuantityCompletion', @level2type=N'COLUMN',@level2name=N'PlanNum' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'本月实际完成' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'JDGL_QuantityCompletion', @level2type=N'COLUMN',@level2name=N'RealNum' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'编制人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'JDGL_QuantityCompletion', @level2type=N'COLUMN',@level2name=N'CompileMan' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'编制日期' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'JDGL_QuantityCompletion', @level2type=N'COLUMN',@level2name=N'CompileDate' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'工程量完成情况表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'JDGL_QuantityCompletion' GO CREATE VIEW [dbo].[View_JDGL_QuantityCompletion] AS select qc.*,ql.DesignNum,ql.Name,ql.Unit,cn.ProfessionalName,cn.SortIndex, CONVERT(FLOAT,(select sum(ISNULL(PlanNum,0)) from JDGL_QuantityCompletion where QuantityListId=qc.QuantityListId and Months<=qc.Months)) as TotalPlanNum, CONVERT(FLOAT,(select sum(ISNULL(RealNum,0)) from JDGL_QuantityCompletion where QuantityListId=qc.QuantityListId and Months<=qc.Months)) as TotalRealNum, CONVERT(NVARCHAR(10),((CAST(CASE ISNULL(qc.PlanNum,0) WHEN 0 THEN 0 ELSE 1.0*ISNULL(qc.RealNum,0) / (1.0 *qc.PlanNum) END AS DECIMAL(9,2)))*100))+'%' AS Rate, CONVERT(NVARCHAR(10),((CAST(CASE (select sum(ISNULL(PlanNum,0)) from JDGL_QuantityCompletion where QuantityListId=qc.QuantityListId and Months<=qc.Months) WHEN 0 THEN 0 ELSE 1.0*(select sum(ISNULL(RealNum,0)) from JDGL_QuantityCompletion where QuantityListId=qc.QuantityListId and Months<=qc.Months) / (1.0 *(select sum(ISNULL(PlanNum,0)) from JDGL_QuantityCompletion where QuantityListId=qc.QuantityListId and Months<=qc.Months)) END AS DECIMAL(9,2)))*100))+'%' AS TotalRate, CONVERT(NVARCHAR(10),((CAST(CASE ISNULL(ql.DesignNum,0) WHEN 0 THEN 0 ELSE 1.0*(select sum(ISNULL(RealNum,0)) from JDGL_QuantityCompletion where QuantityListId=qc.QuantityListId and Months<=qc.Months) / (1.0 *ql.DesignNum) END AS DECIMAL(9,2)))*100))+'%' AS SumRate, CONVERT(FLOAT,(select sum(ISNULL(PlanNum,0)) from JDGL_QuantityCompletion where QuantityListId=qc.QuantityListId and Months