Declare @prodCount As int = 0

Set @prodCount = (Select Count(*) FROM pal_Product)
Truncate Table  [dbo].[pal_Module]

SET IDENTITY_INSERT [dbo].[pal_Module] ON 

INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar]) VALUES (1, N'Content', 1, N'Admin_Content.aspx', N'module/content.ascx', 1, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar]) VALUES (3, N'Users', 3, N'Admin_Users.aspx', NULL, 1, 0, NULL, NULL, NULL, NULL, 1)
IF @prodCount > 0
BEGIN
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar]) VALUES (4, N'Products', 4, N'Admin_Products.aspx', N'module/featuredProducts.ascx', 1, 1, NULL, NULL, NULL, NULL, NULL)
END
Else
BEGIN
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar]) VALUES (4, N'Products', 4, N'Admin_Products.aspx', N'module/featuredProducts.ascx', 0, 1, NULL, NULL, NULL, NULL, NULL)
END


INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar]) VALUES (5, N'Product Categories', 5, N'Admin_ProductCategories.aspx', NULL, 1, 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar]) VALUES (6, N'Product Brands', 6, N'Admin_ProductBrands.aspx', NULL, 1, 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar]) VALUES (7, N'Banners', 7, N'Admin_Banners.aspx', NULL, 1, 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar]) VALUES (8, N'Templates', 8, N'Admin_Templates.aspx', NULL, 1, 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar]) VALUES (9, N'Gallery', 9, N'Admin_Gallery.aspx', NULL, 1, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar]) VALUES (10, N'Surface', 10, N'Admin_Surface.aspx', N'surface/surface.ascx', 1, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar]) VALUES (11, N'Canvas', 11, N'Admin_Canvas.aspx', NULL, 1, 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar]) VALUES (12, N'Practices', 12, N'Debtors_Practices.aspx', NULL, 1, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar]) VALUES (13, N'Doctors', 13, N'Debtors_Doctors.aspx', NULL, 1, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar]) VALUES (14, N'Tariffs', 14, N'Debtors_Tariffs.aspx', N'debtors/tariffs.ascx', 1, 1, 1, N'oTariffPlan', N'name', N'code', NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar]) VALUES (15, N'Procedures', 15, N'Debtors_Procedures.aspx', N'debtors/procedures.ascx', 1, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar]) VALUES (16, N'Medical Schemes', 16, N'Debtors_Schemes.aspx', N'debtors/schemes.ascx', 1, 1, 1, N'oMedicalScheme', N'name', N'code', NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar]) VALUES (17, N'Notes', 17, N'', NULL, 0, 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar]) VALUES (18, N'Debtors Reports', 18, N'', N'module/debtorsReports.ascx', 0, 1, 0, N'', N'', N'', NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar]) VALUES (19, N'Tasks', 19, N'Admin_Tasks.aspx', N'module/task.ascx', 1, 0, 0, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar]) VALUES (20, N'FAQ', 20, N'Admin_FAQ.aspx', N'module/faq.ascx', 0, 1, 0, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar]) VALUES (21, N'Medical Administrators', 21, N'Debtors_MedAdmins.aspx', NULL, 1, 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar]) VALUES (22, N'Calendar', 22, N'Admin_Calendar.aspx', N'module/calendar.ascx', 1, 1, 0, NULL, NULL, NULL, 0)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar]) VALUES (23, N'ICD10', 23, N'Debtors_ICD10.aspx', N'debtors/icd10.ascx', 1, 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar]) VALUES (24, N'Enquiry', 24, N'', N'module/enquiry.ascx', 1, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar]) VALUES (25, N'Promotions', 25, N'Admin_Promotions.aspx', NULL, 1, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar]) VALUES (26, N'Sales', 26, N'', N'module/sales.ascx', 1, 1, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar]) VALUES (27, N'Products and Services', 27, N'Sales_SalesItems.aspx', N'sales/items.ascx', 1, 1, 0, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar]) VALUES (28, N'Company Setup', 28, N'Admin_Setup.aspx', N'admin/setup.ascx', 1, 1, 0, NULL, NULL, NULL, NULL)
SET IDENTITY_INSERT [dbo].[pal_Module] OFF
