/******2.1******/
if exists (SELECT TOP 1 ID FROM TCWL_Tree where TextShow='日志管理' and parentID='187DA6B4-CDED-4BE5-BAEE-1FB5E098CC99')
begin
	update TCWL_Tree set parentID='7AC54B65-BAA6-4ABA-9782-B38A63A60800' where TextShow='日志管理'
end
if exists (SELECT TOP 1 ID FROM TCWL_Tree where TextShow='批注日志' and parentID='187DA6B4-CDED-4BE5-BAEE-1FB5E098CC99')
begin
	update TCWL_Tree set parentID='7AC54B65-BAA6-4ABA-9782-B38A63A60800'  where TextShow='批注日志'
end
if not exists (SELECT TOP 1 ID FROM TCWL_All_Dic_UnitOfProduct)
begin
INSERT [TCWL_All_Dic_UnitOfProduct] ([ID], [Familiar], [Complex], [English], [Name], [AddPeople], [Belong], [ServerID]) VALUES (N'1B42B5EE-5D12-44C6-BED9-7B22B16357A7', N'个', NULL, NULL, NULL, N'0', N'0', N'')
INSERT [TCWL_All_Dic_UnitOfProduct] ([ID], [Familiar], [Complex], [English], [Name], [AddPeople], [Belong], [ServerID]) VALUES (N'1FD298F5-339A-4C2B-82CD-6AA19AB15724', N'件', NULL, NULL, NULL, N'0', N'0', N'')
end
if not exists (SELECT TOP 1 ID FROM TCWL_All_Dic_Stock)
begin
INSERT [TCWL_All_Dic_Stock] ([ID], [Familiar],  [Belong], [ServerID]) VALUES (N'18134C6E-88FB-44EE-B1D8-56177D10FB10', N'郑州仓',  N'0', N'')
INSERT [TCWL_All_Dic_Stock] ([ID], [Familiar],  [Belong], [ServerID]) VALUES(N'1AC4860A-67BB-445B-956E-179B15B43941', N'厂仓库', N'0', N'')
end
if not exists (SELECT TOP 1 ID FROM TCWL_All_Dic_SalesStage)
begin
INSERT [TCWL_All_Dic_SalesStage] ([ID], [Familiar], [Complex], [English], [Name], [AddPeople], [ServerID], [Belong]) VALUES (N'05013C14-296B-42D0-AAC0-722332EF510D', N'合同签约', NULL, NULL, NULL, NULL, N'', N'0')
INSERT [TCWL_All_Dic_SalesStage] ([ID], [Familiar], [Complex], [English], [Name], [AddPeople], [ServerID], [Belong]) VALUES (N'1376847E-7B23-4A74-A388-99F4950D03B5', N'初期沟通', NULL, NULL, NULL, NULL, N'', N'0')
end
if not exists (SELECT TOP 1 ID FROM TCWL_All_Dic_Reimburse)
begin
INSERT [TCWL_All_Dic_Reimburse] ([ID], [Familiar],  [Belong], [ServerID]) VALUES (N'6FC6E195-5E7A-4CBB-A827-734086096AE6', N'管理费用',  N'0', N'')
INSERT [TCWL_All_Dic_Reimburse] ([ID], [Familiar],  [Belong], [ServerID]) VALUES (N'9A0659B1-A674-4D00-AA32-25F7CB09D089', N'办公费用',  N'0', N'')
end
if not exists (SELECT TOP 1 ID FROM TCWL_All_Dic_ProductCategories)
begin
INSERT [TCWL_All_Dic_ProductCategories] ([ID], [Familiar], [Complex], [English], [Name],  [AddPeople], [Belong], [ServerID]) VALUES (N'07AFE143-F6C4-40D0-86CE-39628A991E5D', N'衣服', NULL, NULL, NULL,N'0', N'0', N'')
INSERT [TCWL_All_Dic_ProductCategories] ([ID], [Familiar], [Complex], [English], [Name],  [AddPeople], [Belong], [ServerID]) VALUES (N'0B85662F-7BC3-47B8-877F-26D69C4E4362', N'裤子', NULL, NULL, NULL, N'0', N'0', N'')
end
if not exists (SELECT TOP 1 ID FROM TCWL_All_Dic_Position)
begin
INSERT [TCWL_All_Dic_Position] ([ID], [Familiar], [Name],  [Belong], [ServerID], [Complex], [English], [Paixu]) VALUES (N'0290D219-ED0A-42E3-9199-E93A5A49B342', N'总经理 ', NULL, N'0', N'', NULL, NULL, 0)
INSERT [TCWL_All_Dic_Position] ([ID], [Familiar], [Name], [Belong], [ServerID], [Complex], [English], [Paixu]) VALUES (N'05ABDB8E-E811-4F71-BB4D-2D3E554EC7F8', N'项目主管', NULL,  N'0', N'', NULL, NULL, 0)
end
if not exists (SELECT TOP 1 ID FROM TCWL_All_Dic_Overtime)
begin
INSERT [TCWL_All_Dic_Overtime] ([ID], [Familiar],  [Belong], [ServerID]) VALUES (N'50E5E8DE-97CE-4E2F-8BE5-75012B2CB55E', N'休息日', N'0', N'')
INSERT [TCWL_All_Dic_Overtime] ([ID], [Familiar],  [Belong], [ServerID]) VALUES (N'87BAC4C4-7565-4CF6-9514-CFB2346F37C5', N'工作日', N'0', N'')
end
if not exists (SELECT TOP 1 ID FROM TCWL_All_Dic_OpportunityType)
begin
INSERT [TCWL_All_Dic_OpportunityType] ([ID], [Familiar], [Complex], [English], [Name], [TimeStr], [AddPeople], [ServerID], [Belong]) VALUES (N'0F7C23A9-1EE8-4FA9-9244-FA87B85C26E1', N'重要', NULL, NULL, NULL, CAST(0x0000A3FB012325C9 AS DateTime), NULL, N'', N'0')
INSERT [TCWL_All_Dic_OpportunityType] ([ID], [Familiar], [Complex], [English], [Name], [TimeStr], [AddPeople], [ServerID], [Belong]) VALUES (N'2E329B2E-D9C6-4C46-A524-EF95BF4E2C50', N'一般', NULL, NULL, NULL, CAST(0x0000A45E0098C4AF AS DateTime), NULL, N'', N'0')
end
if not exists (SELECT TOP 1 ID FROM TCWL_All_Dic_GongGaoType)
begin
INSERT [TCWL_All_Dic_GongGaoType] ([ID], [Familiar], [AddPeople], [TimeStr], [Belong], [ServerID]) VALUES (N'0220CAF8-1913-44EC-90D5-CFCA8869785A', N'行业新闻', NULL, NULL, N'0', N'')
INSERT [TCWL_All_Dic_GongGaoType] ([ID], [Familiar], [AddPeople], [TimeStr], [Belong], [ServerID]) VALUES (N'04583662-6660-42ED-98FB-254ABD5DCC8B', N'公司新闻', NULL, NULL, N'0', N'')
end
if not exists (SELECT TOP 1 ID FROM TCWL_All_Dic_CustomerStatus)
begin
INSERT [TCWL_All_Dic_CustomerStatus] ([ID], [Familiar], [Complex], [English], [Name], [TimeStr], [AddPeople], [ServerID], [Belong]) VALUES (N'0076F192-FCC6-4E43-AE6E-1E602FBEE1B6', N'新客户', NULL, NULL, NULL, CAST(0x0000A46C013F5CD5 AS DateTime), NULL, N'', N'0')
INSERT [TCWL_All_Dic_CustomerStatus] ([ID], [Familiar], [Complex], [English], [Name], [TimeStr], [AddPeople], [ServerID], [Belong]) VALUES (N'018C914F-7814-4509-A8B8-1D31FF6F33E4', N'洽谈中', NULL, NULL, NULL, CAST(0x0000A4920004A593 AS DateTime), NULL, N'', N'0')
end
if not exists (SELECT TOP 1 ID FROM TCWL_All_Dic_CustomerPriority)
begin
INSERT [TCWL_All_Dic_CustomerPriority] ([ID], [Familiar], [Complex], [English], [Name], [TimeStr], [AddPeople], [Belong], [ServerID], [Paixu]) VALUES (N'0C9C046A-D990-4983-917D-3FC75D118CF6', N'高', NULL, NULL, NULL, CAST(0x0000A426009C013B AS DateTime), NULL, N'0', N'', 0)
INSERT [TCWL_All_Dic_CustomerPriority] ([ID], [Familiar], [Complex], [English], [Name], [TimeStr], [AddPeople], [Belong], [ServerID], [Paixu]) VALUES (N'0F3E9D07-2E3C-4B9B-9F7C-E33CDBB29298', N'中', NULL, NULL, NULL, CAST(0x0000A4620106A658 AS DateTime), NULL, N'0', N'', 0)
end
if not exists (SELECT TOP 1 ID FROM TCWL_All_Dic_CustomerLevel)
begin
INSERT [TCWL_All_Dic_CustomerLevel] ([ID], [Familiar], [Complex], [English], [Name], [TimeStr], [AddPeople], [Belong], [ServerID], [Paixu]) VALUES (N'013899E5-6D56-4CAB-818B-AA349C55C02C', N'优质客户', NULL, NULL, NULL, CAST(0x0000A46200DFAC73 AS DateTime), NULL, N'0', N'', 0)
INSERT [TCWL_All_Dic_CustomerLevel] ([ID], [Familiar], [Complex], [English], [Name], [TimeStr], [AddPeople], [Belong], [ServerID], [Paixu]) VALUES (N'107BB48E-ECFB-4776-B16E-304C5A9F5C09', N'普通客户', NULL, NULL, NULL, CAST(0x0000A3FB010F5F02 AS DateTime), NULL, N'0', N'', 0)
end
if not exists (SELECT TOP 1 ID FROM TCWL_All_Dic_CustomerCreditDegree)
begin
INSERT [TCWL_All_Dic_CustomerCreditDegree] ([ID], [Familiar], [Complex], [English], [Name], [TimeStr], [AddPeople], [ServerID], [Belong], [Paixu]) VALUES (N'03B88CBE-218E-4CF8-9480-A7BB6E049E51', N'★', NULL, NULL, NULL, CAST(0x0000A45800AE8415 AS DateTime), NULL, N'', N'0', 0)
INSERT [TCWL_All_Dic_CustomerCreditDegree] ([ID], [Familiar], [Complex], [English], [Name], [TimeStr], [AddPeople], [ServerID], [Belong], [Paixu]) VALUES (N'10720BC9-620C-4BC0-9F45-A76C561F6A9B', N'★★', NULL, NULL, NULL, CAST(0x0000A41000B0EDA6 AS DateTime), NULL, N'', N'0', 0)
end
if not exists (SELECT TOP 1 ID FROM TCWL_All_Dic_ComPosition)
begin
INSERT [TCWL_All_Dic_ComPosition] ([ID], [Familiar], [TimeStr], [AddPeople], [Complex], [English], [Belong], [ServerID], [Paixu]) VALUES (N'0244054D-C9FD-442E-BC6D-E71ED2CC5F16', N'总经理', NULL, NULL, NULL, NULL, N'0', N'', NULL)
INSERT [TCWL_All_Dic_ComPosition] ([ID], [Familiar], [TimeStr], [AddPeople], [Complex], [English], [Belong], [ServerID], [Paixu]) VALUES (N'07ED66C7-E5D3-4CE6-8A97-0D09E8336AE7', N'业务员', NULL, NULL, NULL, NULL, N'0', N'', NULL)
end
if not exists (SELECT TOP 1 ID FROM TCWL_All_Dic_ClientBase)
begin
INSERT [TCWL_All_Dic_ClientBase] ([ID], [Familiar], [Complex], [English], [Name], [TimeStr], [AddPeople], [ServerID], [Belong], [Paixu]) VALUES (N'0356F66D-E625-4D4F-8767-B02AC7075355', N'客户介绍', NULL, NULL, NULL, CAST(0x0000A3FB0113A871 AS DateTime), NULL, N'', N'0', 0)
INSERT [TCWL_All_Dic_ClientBase] ([ID], [Familiar], [Complex], [English], [Name], [TimeStr], [AddPeople], [ServerID], [Belong], [Paixu]) VALUES (N'06729348-08F7-4784-AC01-B7C72CF3FFB3', N'网络开发', NULL, NULL, NULL, CAST(0x0000A40200F3C253 AS DateTime), NULL, N'', N'0', 0)
end
if not exists (SELECT TOP 1 ID FROM TCWL_All_Dic_ChanceToGrade)
begin
INSERT [TCWL_All_Dic_ChanceToGrade] ([ID], [Familiar], [Complex], [English], [Name], [TimeStr], [AddPeople], [ServerID], [Belong]) VALUES (N'276F8321-8723-41DF-A176-9E69FFB24105', N'VIP2', NULL, NULL, NULL, CAST(0x0000A40201221016 AS DateTime), NULL, N'', N'0')
INSERT [TCWL_All_Dic_ChanceToGrade] ([ID], [Familiar], [Complex], [English], [Name], [TimeStr], [AddPeople], [ServerID], [Belong]) VALUES (N'5553A4FD-9651-4075-B2FB-152CC97AD53A', N'VIP1', NULL, NULL, NULL, CAST(0x0000A462010751E8 AS DateTime), NULL, N'', N'0')
end
if not exists (SELECT TOP 1 ID FROM TCWL_All_Dic_ChancesOf)
begin
INSERT [TCWL_All_Dic_ChancesOf] ([ID], [Familiar], [Complex], [English], [Name], [TimeStr], [AddPeople], [ServerID], [Belong]) VALUES (N'20C5285C-B66D-43FE-AAB3-437DA5BBD040', N'网络', NULL, NULL, NULL, CAST(0x0000A41000ADAF7E AS DateTime), NULL, N'', N'0')
INSERT [TCWL_All_Dic_ChancesOf] ([ID], [Familiar], [Complex], [English], [Name], [TimeStr], [AddPeople], [ServerID], [Belong]) VALUES (N'A194575B-6DDF-4F6A-B054-E38CB5AA3CCD', N'电话', NULL, NULL, NULL, CAST(0x0000A45E0098CC13 AS DateTime), NULL, N'', N'0')
end
if not exists (SELECT TOP 1 ID FROM TCWL_ALL_Dic_Absence)
begin
INSERT [TCWL_ALL_Dic_Absence] ([ID], [Familiar], [TimeStr], [Belong], [ServerID]) VALUES (N'38508227-4158-4E83-92A8-1461DA96B892', N'事假', CAST(0x0000A46900C1F87E AS DateTime), N'0', N'')
INSERT [TCWL_ALL_Dic_Absence] ([ID], [Familiar], [TimeStr], [Belong], [ServerID]) VALUES (N'43E8BB88-FEA6-4A1B-A620-8285A815932E', N'婚假', CAST(0x0000A473011B753B AS DateTime), N'0', N'')
end
if not exists (SELECT TOP 1 ID FROM TCWL_Acount_classification)
begin
INSERT [TCWL_Acount_classification] ([ID], [Familiar], [ServerID], [timestr], [Belong]) VALUES (N'66505003-A803-4109-A773-992950227F31', N'办公用品', N'', CAST(0x0000A45A010BD167 AS DateTime), N'0')
INSERT [TCWL_Acount_classification] ([ID], [Familiar], [ServerID], [timestr], [Belong]) VALUES (N'80FC6F94-86D4-4ED6-AAB7-FDF8F33CAF65', N'主营业务', N'', CAST(0x0000A45A010D00B3 AS DateTime), N'0')
end
/******2.1******/
if not exists(select name  FROM syscolumns where id=object_id('TCWL_KeHuXinXi') and name='Position')
begin
alter table TCWL_KeHuXinXi add Position nvarchar(50)
end
GO

if not exists(select name  FROM syscolumns where id=object_id('TCWL_KeHuXinXi') and name='Face')
begin
alter table TCWL_KeHuXinXi add Face nvarchar(100)
end
GO

if not exists(select name  FROM syscolumns where id=object_id('TCWL_KeHuXinXi') and name='State')
begin
alter table TCWL_KeHuXinXi add State nvarchar(1)
end
GO

if not exists(select name  FROM syscolumns where id=object_id('TCWL_KeHuXinXi') and name='Coordinate')
begin
alter table TCWL_KeHuXinXi add Coordinate nvarchar(200)
end
GO

if not exists (select name from sysobjects where object_id('TCWL_KeHuXinXi')=parent_obj and xtype='D' and name='DF_TCWL_KeHuXinXi_Face')
begin
ALTER TABLE [TCWL_KeHuXinXi] ADD  CONSTRAINT [DF_TCWL_KeHuXinXi_Face]  DEFAULT ('') FOR [Face]
end
GO

if not exists (select name from sysobjects where object_id('TCWL_KeHuXinXi')=parent_obj and xtype='D' and name='DF_TCWL_KeHuXinXi_State')
begin
ALTER TABLE [TCWL_KeHuXinXi] ADD  CONSTRAINT [DF_TCWL_KeHuXinXi_State]  DEFAULT ('0') FOR [State]
end
GO

if not exists (select name from sysobjects where object_id('TCWL_KeHuXinXi')=parent_obj and xtype='D' and name='DF_TCWL_KeHuXinXi_Coordinate')
begin
ALTER TABLE [TCWL_KeHuXinXi] ADD  CONSTRAINT [DF_TCWL_KeHuXinXi_Coordinate]  DEFAULT ('') FOR [Coordinate]
end
GO

update TCWL_KeHuXinXi set Position=''  where Position is null
update TCWL_KeHuXinXi set Face=''  where Face is null
update TCWL_KeHuXinXi set State=''  where State is null
update TCWL_KeHuXinXi set Coordinate=''  where Coordinate is null

if not exists(select name  FROM syscolumns where id=object_id('TCWL_Process') and name='HasAttach')
begin
alter table TCWL_Process add HasAttach nvarchar(400)
end
GO

GO
if not exists(select name  FROM syscolumns where id=object_id('TCWL_FileManagement') and name='AnnexType')
begin
alter table TCWL_FileManagement add AnnexType char(1)
end

GO
if not exists(select name  FROM syscolumns where id=object_id('TCWL_Daily') and name='AnnexType')
begin
alter table TCWL_Daily add AnnexType char(1)
end
GO

if not exists(select name  FROM syscolumns where id=object_id('TCWL_KHJiaoWangJiLu') and name='Img')
begin
alter table TCWL_KHJiaoWangJiLu add Img nvarchar(100)
end
GO

if not exists(select name  FROM syscolumns where id=object_id('TCWL_KHJiaoWangJiLu') and name='Position')
begin
alter table TCWL_KHJiaoWangJiLu add Position nvarchar(100)
end
GO


if not exists(select name  FROM syscolumns where id=object_id('TCWL_KHJiaoWangJiLu') and name='State')
begin
alter table TCWL_KHJiaoWangJiLu add State nvarchar(1)
end
GO


if not exists(select name  FROM syscolumns where id=object_id('TCWL_KHJiaoWangJiLu') and name='Coordinate')
begin
alter table TCWL_KHJiaoWangJiLu add Coordinate nvarchar(200)
end
GO

if not exists (select name from sysobjects where object_id('TCWL_KHJiaoWangJiLu')=parent_obj and xtype='D' and name='DF_TCWL_TCWL_KHJiaoWangJiLu_State')
begin
ALTER TABLE [TCWL_KHJiaoWangJiLu] ADD  CONSTRAINT [DF_TCWL_KHJiaoWangJiLut_State]  DEFAULT ('0') FOR [State]
end
GO

update TCWL_KHJiaoWangJiLu set State='0'  where  State is null or  State=''
GO

if not exists (select name from sysobjects where object_id('TCWL_FileManagement')=parent_obj and xtype='D' and name='DF_TCWL_FileManagement_AnnexType')
begin
ALTER TABLE [TCWL_FileManagement] ADD  CONSTRAINT [DF_TCWL_FileManagement_AnnexType]  DEFAULT ('0') FOR [AnnexType]
end
GO

if not exists (select name from sysobjects where object_id('TCWL_Daily')=parent_obj and xtype='D' and name='DF_TCWL_Daily_AnnexType')
begin
ALTER TABLE [TCWL_Daily] ADD  CONSTRAINT [DF_TCWL_Daily_AnnexType]  DEFAULT ('0') FOR [AnnexType]
end
GO

update TCWL_FileManagement set AnnexType='0'  where  AnnexType is null or  AnnexType=''
GO

update TCWL_Daily set AnnexType='0' where  AnnexType is null or  AnnexType=''
GO
GO

if not exists(select name  FROM syscolumns where id=object_id('TCWL_User') and name='Face')
begin
alter table TCWL_User add Face nvarchar(100)
end
GO

if not exists(select name  FROM syscolumns where id=object_id('TCWL_User') and name='Nickname' )
begin
alter table TCWL_User add Nickname nvarchar(10)
end
GO

if not exists (select name from sysobjects where object_id('TCWL_User')=parent_obj and xtype='D' and name='DF_TCWL_User_Face')
begin
ALTER TABLE [TCWL_User] ADD  CONSTRAINT [DF_TCWL_User_Face]  DEFAULT ('') FOR [Face]
end
GO

if not exists (select name from sysobjects where object_id('TCWL_User')=parent_obj and xtype='D' and name='DF_TCWL_User_Nickname')
begin
ALTER TABLE [TCWL_User] ADD  CONSTRAINT [DF_TCWL_User_Nickname]  DEFAULT ('') FOR [Nickname]
end
GO


if exists(select name  FROM syscolumns where id=object_id('TCWL_Order') and name='Annex')
begin
alter table TCWL_Order alter column Annex nvarchar(450)
end
GO

if exists (select top 1 Log_Img from TCWL_All_CompanyInformation)
begin
declare @id  nvarchar(40)
select top 1 @id=id from TCWL_All_CompanyInformation
update TCWL_All_CompanyInformation set Log_Img='../Scripts/Log/images/lg-img.png' where id=@id
end
GO

delete from TCWL_Tree_Fun where id='c9fe7333-4a90-4e00-8c1a-51d9a52b1fa0'

GO

delete from TCWL_Tree where id='c9fe7333-4a90-4e00-8c1a-51d9a52b1fa0'
GO

if not exists (select id from TCWL_Tree where id='B9D8F817-9763-43F1-ACD0-94C5E6EAA799')
begin
INSERT [TCWL_Tree] ([ID], [ValueStr], [TextShow], [navigateURL], [parentID], [functionList], [sorter], [serviceID], [frees], [money], [TorF], [icon], [period], [moneyTime], [state], [timeStr], [v]) VALUES (N'B9D8F817-9763-43F1-ACD0-94C5E6EAA799', N'M_180', N'考勤管理', N'', N'0', N'', N'050', N'SVR20150115120117', NULL, 0, N'1', N'fa-clock-o', 0, NULL, N'0', CAST(0x0000A45200FD444A AS DateTime), N'0')
end
GO

if not exists (select id from TCWL_Tree where id='82BA3A0D-545A-4A1B-B632-673AFFCA638A')
begin
INSERT [TCWL_Tree] ([ID], [ValueStr], [TextShow], [navigateURL], [parentID], [functionList], [sorter], [serviceID], [frees], [money], [TorF], [icon], [period], [moneyTime], [state], [timeStr], [v]) VALUES (N'82BA3A0D-545A-4A1B-B632-673AFFCA638A', N'M_184', N'我的考勤', N'../SetInfo/MyKaoQin.htm', N'B9D8F817-9763-43F1-ACD0-94C5E6EAA799', N'M_184', N'002', N'SVR20150115120117', NULL, 0, N'1', NULL, 0, NULL, N'0', CAST(0x0000A45701185C69 AS DateTime), N'0')
end
GO

if not exists (select id from TCWL_Tree where id='BEA38F8B-5ACA-4379-A862-05E1327E68AF')
begin
INSERT [TCWL_Tree] ([ID], [ValueStr], [TextShow], [navigateURL], [parentID], [functionList], [sorter], [serviceID], [frees], [money], [TorF], [icon], [period], [moneyTime], [state], [timeStr], [v]) VALUES (N'BEA38F8B-5ACA-4379-A862-05E1327E68AF', N'M_183', N'考勤明细', N'../SetInfo/KaoQinDetailed.htm', N'B9D8F817-9763-43F1-ACD0-94C5E6EAA799', N'M_183', N'003', N'SVR20150115120117', NULL, 0, N'1', NULL, 0, NULL, N'0', CAST(0x0000A45800C013D4 AS DateTime), N'0')
end
GO

if not exists (select id from TCWL_Tree where id='E7D70627-ECB6-47AA-86F8-FAAB47C35AE1')
begin
INSERT [TCWL_Tree] ([ID], [ValueStr], [TextShow], [navigateURL], [parentID], [functionList], [sorter], [serviceID], [frees], [money], [TorF], [icon], [period], [moneyTime], [state], [timeStr], [v]) VALUES (N'E7D70627-ECB6-47AA-86F8-FAAB47C35AE1', N'M_182', N'考勤汇总', N'../SetInfo/KaoQinSummary.htm', N'B9D8F817-9763-43F1-ACD0-94C5E6EAA799', N'M_182', N'004', N'SVR20150115120117', NULL, 0, N'1', NULL, 0, NULL, N'0', CAST(0x0000A45701185C69 AS DateTime), N'0')
end
GO

if not exists (select id from TCWL_Tree where id='65CEAC1B-173B-4FBE-8578-F5C88253F740')
begin
INSERT [TCWL_Tree] ([ID], [ValueStr], [TextShow], [navigateURL], [parentID], [functionList], [sorter], [serviceID], [frees], [money], [TorF], [icon], [period], [moneyTime], [state], [timeStr], [v]) VALUES (N'65CEAC1B-173B-4FBE-8578-F5C88253F740', N'M_181', N'考勤设置', N'../SetInfo/KaoqinSet.htm', N'B9D8F817-9763-43F1-ACD0-94C5E6EAA799', N'M_181', N'012', N'SVR20150115120117', NULL, 0, N'1', NULL, 0, NULL, N'0', CAST(0x0000A45800AA31D2 AS DateTime), N'0')
end
GO


if not exists (select id from TCWL_Tree_Fun where id='B9D8F817-9763-43F1-ACD0-94C5E6EAA799')
begin
INSERT [TCWL_Tree_Fun] ([ID], [ValueStr], [TextShow], [navigateURL], [parentID], [functionList], [sorter], [frees], [money], [TorF], [icon], [v]) VALUES (N'B9D8F817-9763-43F1-ACD0-94C5E6EAA799', N'M_180', N'考勤管理', N'', N'0', N'', N'050', NULL, NULL, N'0', N'fa-clock-o', N'0')
end
GO

if not exists (select id from TCWL_Tree_Fun where id='82BA3A0D-545A-4A1B-B632-673AFFCA638A')
begin
INSERT [TCWL_Tree_Fun] ([ID], [ValueStr], [TextShow], [navigateURL], [parentID], [functionList], [sorter], [frees], [money], [TorF], [icon], [v]) VALUES (N'82BA3A0D-545A-4A1B-B632-673AFFCA638A', N'M_184', N'我的考勤', N'../SetInfo/MyKaoQin.htm', N'B9D8F817-9763-43F1-ACD0-94C5E6EAA799', N'M_184', N'002', NULL, NULL, N'0', N'', N'0')
end
GO

if not exists (select id from TCWL_Tree_Fun where id='BEA38F8B-5ACA-4379-A862-05E1327E68AF')
begin
INSERT [TCWL_Tree_Fun] ([ID], [ValueStr], [TextShow], [navigateURL], [parentID], [functionList], [sorter], [frees], [money], [TorF], [icon], [v]) VALUES (N'BEA38F8B-5ACA-4379-A862-05E1327E68AF', N'M_183', N'考勤明细', N'../SetInfo/KaoQinDetailed.htm', N'B9D8F817-9763-43F1-ACD0-94C5E6EAA799', N'M_183', N'003', NULL, NULL, N'0', N'', N'0')
end
GO

if not exists (select id from TCWL_Tree_Fun where id='E7D70627-ECB6-47AA-86F8-FAAB47C35AE1')
begin
INSERT [TCWL_Tree_Fun] ([ID], [ValueStr], [TextShow], [navigateURL], [parentID], [functionList], [sorter], [frees], [money], [TorF], [icon], [v]) VALUES (N'E7D70627-ECB6-47AA-86F8-FAAB47C35AE1', N'M_182', N'考勤汇总', N'../SetInfo/KaoQinSummary.htm', N'B9D8F817-9763-43F1-ACD0-94C5E6EAA799', N'M_182', N'004', NULL, NULL, N'0', N'', N'0')
end
GO

if not exists (select id from TCWL_Tree_Fun where id='65CEAC1B-173B-4FBE-8578-F5C88253F740')
begin
INSERT [TCWL_Tree_Fun] ([ID], [ValueStr], [TextShow], [navigateURL], [parentID], [functionList], [sorter], [frees], [money], [TorF], [icon], [v]) VALUES (N'65CEAC1B-173B-4FBE-8578-F5C88253F740', N'M_181', N'考勤设置', N'../SetInfo/KaoqinSet.htm', N'B9D8F817-9763-43F1-ACD0-94C5E6EAA799', N'M_181', N'012', NULL, NULL, N'0', N'', N'0')
end
GO

if exists (select ID from  TCWL_Role where deleteYes=0)
begin
update TCWL_Role set permission=permission+',M_181,M_182,M_183,M_184' where deleteYes=0

end

GO

if not exists(SELECT * FROM sys.objects WHERE object_id = OBJECT_ID('TCWL_WorkingDay') AND type ='U')
begin
CREATE TABLE [TCWL_WorkingDay](
	[ID] [nvarchar](36) NOT NULL,
	[Years] [varchar](4) NULL,
	[Month] [varchar](2) NULL,
	[Days] [text] NULL,
	[UserName] [nvarchar](36) NULL,
	[ServiceID] [nvarchar](50) NULL,
	[TimeStr] [datetime] NULL,
	[TimeSet] [datetime] NULL,
	[WorkDays] [int] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

ALTER TABLE [TCWL_WorkingDay] ADD  CONSTRAINT [DF_TCWL_WorkingDay_ID]  DEFAULT (newid()) FOR [ID]
ALTER TABLE [TCWL_WorkingDay] ADD  CONSTRAINT [DF_TCWL_WorkingDay_TimeStr]  DEFAULT (getdate()) FOR [TimeStr]

ALTER TABLE [TCWL_WorkingDay] ADD  CONSTRAINT [DF_TCWL_WorkingDay_TimeSet]  DEFAULT (getdate()) FOR [TimeSet]

ALTER TABLE [TCWL_WorkingDay] ADD  CONSTRAINT [DF_TCWL_WorkingDay_WorkDays]  DEFAULT ((20)) FOR [WorkDays]
end

GO

if not exists(SELECT * FROM sys.objects WHERE object_id = OBJECT_ID('TCWL_KaoQinSheZhi') AND type ='U')
begin
CREATE TABLE [TCWL_KaoQinSheZhi](
	[ID] [nvarchar](36) NOT NULL,
	[KaoQinShiJian1] [varchar](50) NULL,
	[KaoQinShiJian2] [varchar](50) NULL,
	[KaoQinShiJian3] [varchar](50) NULL,
	[KaoQinShiJian4] [varchar](50) NULL,
	[ServiceID] [nvarchar](50) NULL,
	[TimeStr] [datetime] NULL,
	[Setting] [int] NULL,
	[AddUser] [nvarchar](36) NULL,
	[DiffTime] [int] NULL
) ON [PRIMARY]

INSERT [TCWL_KaoQinSheZhi] ([ID], [KaoQinShiJian1], [KaoQinShiJian2], [KaoQinShiJian3], [KaoQinShiJian4], [ServiceID], [TimeStr], [Setting], [AddUser], [DiffTime]) VALUES (N'0031F75B-61B9-46BF-A977-A6FCDE0ECED1', N'08:00', N'18:00', N'13:00', N'16:00', N'SVR20150826062714', CAST(0x0000A5220115A490 AS DateTime), 2, N'c', 0)
ALTER TABLE [TCWL_KaoQinSheZhi] ADD  CONSTRAINT [DF_ERP_KaoQinSheZhi_ID]  DEFAULT (newid()) FOR [ID]

ALTER TABLE [TCWL_KaoQinSheZhi] ADD  CONSTRAINT [DF_TCWL_KaoQinSheZhi_ServiceID]  DEFAULT ('') FOR [ServiceID]

ALTER TABLE [TCWL_KaoQinSheZhi] ADD  CONSTRAINT [DF_TCWL_KaoQinSheZhi_TimeStr]  DEFAULT (getdate()) FOR [TimeStr]
ALTER TABLE [TCWL_KaoQinSheZhi] ADD  CONSTRAINT [DF_TCWL_KaoQinSheZhi_Setting]  DEFAULT ((2)) FOR [Setting]
ALTER TABLE [TCWL_KaoQinSheZhi] ADD  CONSTRAINT [DF_TCWL_KaoQinSheZhi_DiffTime]  DEFAULT ((0)) FOR [DiffTime]
end

GO

if not exists(SELECT * FROM sys.objects WHERE object_id = OBJECT_ID('TCWL_KaoQinXiangXi') AND type ='U')
begin
CREATE TABLE [TCWL_KaoQinXiangXi](
	[ID] [nvarchar](36) NOT NULL,
	[DKShiJian1] [datetime] NULL,
	[DKDiDian1] [nvarchar](50) NULL,
	[DKZuoBiao1] [nvarchar](500) NULL,
	[DKStart1] [nvarchar](1) NULL,
	[DKShiJian2] [datetime] NULL,
	[DKDiDian2] [nvarchar](50) NULL,
	[DKZuoBiao2] [nvarchar](500) NULL,
	[DKStart2] [nvarchar](1) NULL,
	[DKShiJian3] [datetime] NULL,
	[DKDiDian3] [nvarchar](50) NULL,
	[DKZuoBiao3] [nvarchar](500) NULL,
	[DKStart3] [nvarchar](1) NULL,
	[DKShiJian4] [datetime] NULL,
	[DKDiDian4] [nvarchar](50) NULL,
	[DKZuoBiao4] [nvarchar](500) NULL,
	[DKStart4] [nvarchar](1) NULL,
	[Remarks] [text] NULL,
	[YongHuID] [nvarchar](50) NULL,
	[CheckNumber] [nvarchar](1) NULL,
	[AbnormalNumber] [nvarchar](1) NULL,
	[ServiceID] [nvarchar](50) NULL,
	[TimeStr] [datetime] NULL,
	[Remarks1] [nvarchar](200) NULL,
	[Remarks2] [nvarchar](200) NULL,
	[Remarks3] [nvarchar](200) NULL,
	[Remarks4] [nvarchar](200) NULL,
	[Pic1] [nvarchar](200) NULL,
	[Pic2] [nvarchar](200) NULL,
	[Pic3] [nvarchar](200) NULL,
	[Pic4] [nvarchar](200) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

ALTER TABLE [TCWL_KaoQinXiangXi] ADD  CONSTRAINT [DF_TCWL_KaoQinXiangXi_ID]  DEFAULT (newid()) FOR [ID]

ALTER TABLE [TCWL_KaoQinXiangXi] ADD  CONSTRAINT [DF_TCWL_KaoQinXiangXi_CheckNumber]  DEFAULT ((1)) FOR [CheckNumber]

ALTER TABLE [TCWL_KaoQinXiangXi] ADD  CONSTRAINT [DF_TCWL_KaoQinXiangXi_AbnormalNumber]  DEFAULT ((0)) FOR [AbnormalNumber]

ALTER TABLE [TCWL_KaoQinXiangXi] ADD  CONSTRAINT [DF_TCWL_KaoQinXiangXi_TimeStr]  DEFAULT (getdate()) FOR [TimeStr]

ALTER TABLE [TCWL_KaoQinXiangXi] ADD  CONSTRAINT [DF_TCWL_KaoQinXiangXi_Remarks1]  DEFAULT (N'') FOR [Remarks1]

ALTER TABLE [TCWL_KaoQinXiangXi] ADD  CONSTRAINT [DF_TCWL_KaoQinXiangXi_Remarks2]  DEFAULT (N'') FOR [Remarks2]

ALTER TABLE [TCWL_KaoQinXiangXi] ADD  CONSTRAINT [DF_TCWL_KaoQinXiangXi_Remarks3]  DEFAULT (N'') FOR [Remarks3]

ALTER TABLE [TCWL_KaoQinXiangXi] ADD  CONSTRAINT [DF_TCWL_KaoQinXiangXi_Remarks4]  DEFAULT (N'') FOR [Remarks4]

ALTER TABLE [TCWL_KaoQinXiangXi] ADD  CONSTRAINT [DF_TCWL_KaoQinXiangXi_Pic1]  DEFAULT (N'') FOR [Pic1]

ALTER TABLE [TCWL_KaoQinXiangXi] ADD  CONSTRAINT [DF_TCWL_KaoQinXiangXi_Pic2]  DEFAULT (N'') FOR [Pic2]

ALTER TABLE [TCWL_KaoQinXiangXi] ADD  CONSTRAINT [DF_TCWL_KaoQinXiangXi_Pi3]  DEFAULT (N'') FOR [Pic3]
ALTER TABLE [TCWL_KaoQinXiangXi] ADD  CONSTRAINT [DF_TCWL_KaoQinXiangXi_Pic4]  DEFAULT (N'') FOR [Pic4]
end

GO


if not exists(SELECT * FROM sys.objects WHERE object_id = OBJECT_ID('TCWL_LeaveRecords') AND type ='U')
begin
CREATE TABLE [TCWL_LeaveRecords](
	[ID] [nvarchar](36) NOT NULL,
	[UserName] [nvarchar](50) NULL,
	[State] [nvarchar](1) NULL,
	[ServiceID] [nvarchar](50) NULL,
	[TimeStr] [datetime] NULL
) ON [PRIMARY]

ALTER TABLE [TCWL_LeaveRecords] ADD  CONSTRAINT [DF_TCWL_LeaveRecords_ID]  DEFAULT (newid()) FOR [ID]

ALTER TABLE [TCWL_LeaveRecords] ADD  CONSTRAINT [DF_TCWL_LeaveRecords_State]  DEFAULT ((0)) FOR [State]
ALTER TABLE [TCWL_LeaveRecords] ADD  CONSTRAINT [DF_TCWL_LeaveRecords_TimeStr]  DEFAULT (getdate()) FOR [TimeStr]
end

GO

if not exists(SELECT * FROM sys.objects WHERE object_id = OBJECT_ID('TCWL_LocationSet') AND type ='U')
begin
CREATE TABLE [TCWL_LocationSet](
	[ID] [varchar](36) NOT NULL,
	[LocName] [nvarchar](50) NULL,
	[locDistrict] [nvarchar](100) NULL,
	[AddUser] [nvarchar](36) NULL,
	[locCdn] [varchar](100) NULL,
	[reMark] [nvarchar](100) NULL,
	[ServiceID] [varchar](50) NULL,
	[TimeStr] [datetime] NULL,
	[locDistance] [int] NULL
) ON [PRIMARY]

ALTER TABLE [TCWL_LocationSet] ADD  CONSTRAINT [DF_TCWL_LocationSet_ID]  DEFAULT (newid()) FOR [ID]

ALTER TABLE [TCWL_LocationSet] ADD  CONSTRAINT [DF_TCWL_LocationSet_TimeStr]  DEFAULT (getdate()) FOR [TimeStr]
end

GO
/*...........................*/

if not exists(SELECT * FROM sys.objects WHERE object_id = OBJECT_ID('TCWL_All_Dic_CSort') AND type ='U')
begin
CREATE TABLE [TCWL_All_Dic_CSort](
	[ID] [nvarchar](50) NOT NULL,
	[Familiar] [nvarchar](50) NULL,
	[Name] [nvarchar](50) NULL,
	[TimeStr] [datetime] NULL,
	[Belong] [varchar](1) NULL,
	[ServerID] [nvarchar](36) NULL,
	[Complex] [nvarchar](50) NULL,
	[English] [nchar](20) NULL,
	[Paixu] [int] NULL
) ON [PRIMARY]

ALTER TABLE [TCWL_All_Dic_CSort] ADD  CONSTRAINT [DF_TCWL_TCWL_All_Dic_CSort_ID]  DEFAULT (newid()) FOR [ID]

ALTER TABLE [TCWL_All_Dic_CSort] ADD  CONSTRAINT [DF_TCWL_ALL_Dic_CSort_TimeStr]  DEFAULT (getdate()) FOR [TimeStr]


ALTER TABLE [TCWL_All_Dic_CSort] ADD  CONSTRAINT [DF_TCWL_ALL_Dic_CSort_Belong]  DEFAULT ((0)) FOR [Belong]


ALTER TABLE [TCWL_All_Dic_CSort] ADD  CONSTRAINT [DF_TCWL_ALL_Dic_CSort_Paixu]  DEFAULT ((0)) FOR [Paixu]
end
GO


if not exists(select name  FROM syscolumns where id=object_id('TCWL_KeHuXinXi') and name='cSort')
begin
alter table TCWL_KeHuXinXi add cSort nvarchar(50)
end

GO

INSERT [TCWL_All_Dic_CSort] ([ID], [Familiar], [Name], [TimeStr], [Belong], [ServerID], [Complex], [English], [Paixu]) VALUES (N'0DE2C3CD-9A19-401E-89B0-A556C2DF14BD', N'电子行业', NULL, CAST(0x0000A56D00958D8D AS DateTime), N'0', NULL, NULL, NULL, 0)
INSERT [TCWL_All_Dic_CSort] ([ID], [Familiar], [Name], [TimeStr], [Belong], [ServerID], [Complex], [English], [Paixu]) VALUES (N'E324C0AD-5D2D-474D-8430-7BBB43DA1722', N'运输行业', NULL, CAST(0x0000A56D0095B498 AS DateTime), N'0', NULL, NULL, NULL, 0)
GO
INSERT [TCWL_Tree_Fun] ([ID], [ValueStr], [TextShow], [navigateURL], [parentID], [functionList], [sorter], [serviceID], [frees], [money], [TorF], [icon], [period], [moneyTime], [state], [timeStr], [v]) VALUES (N'9C4332FD-68F6-4FC9-9FC3-F220241B7E09', N'M_136', N'软件授权', N'../System/reg.htm', N'C5363EF2-F2C3-41D7-BDC0-0574D718825C', N'M_136', N'04', N'SVR20150115120117', NULL, 0, N'1', N'', 0, NULL, N'0', CAST(0x0000A45200FD444A AS DateTime), N'0')
INSERT [TCWL_Tree] ([ID], [ValueStr], [TextShow], [navigateURL], [parentID], [functionList], [sorter], [serviceID], [frees], [money], [TorF], [icon], [period], [moneyTime], [state], [timeStr], [v]) VALUES (N'9C4332FD-68F6-4FC9-9FC3-F220241B7E09', N'M_136', N'软件授权', N'../System/reg.htm', N'C5363EF2-F2C3-41D7-BDC0-0574D718825C', N'M_136', N'04', N'SVR20150115120117', NULL, 0, N'1', N'', 0, NULL, N'0', CAST(0x0000A45200FD444A AS DateTime), N'0')
GO
if exists (select ID from  TCWL_Role where deleteYes=0)
begin
update TCWL_Role set permission=permission+',|M_136' where deleteYes=0
end
GO

if not exists(SELECT * FROM sys.objects WHERE object_id = OBJECT_ID('TCWL_R') AND type ='U')
begin
CREATE TABLE [dbo].[TCWL_R](
	[s] [nvarchar](max) NULL
) ON [PRIMARY]
end
GO

