IF NOT EXISTS (SELECT 1 FROM pal_Surface
WHERE name = 'WholesalerDataItems')
BEGIN
SET IDENTITY_INSERT [dbo].[pal_Surface] ON 

INSERT INTO [dbo].[pal_Surface]
([recId]
,[name]
,[surface]
,[dateCreated]
,[isActive]
,[isModal]
,[isPublished]
,[isDefaultToForm]
,[isWizzard]
,[isComparable]
,[linkUser]
,[surfaceActionId]
,[columnCount]
,[isCapitalizeInput]
,[isLinkedSurface]
,[isDisableRequired])
VALUES
(4113
,'WholesalerDataItems'
,'Wholesaler Data Items'	
,GETDATE()
,1
,0
,1
,0
,0
,0
,0
,0
,0
,0
,0
,0);
SET IDENTITY_INSERT [dbo].[pal_Surface] OFF 

INSERT INTO [dbo].[pal_SurfaceGridOptions]
([surfaceId]
,[allowAdd]
,[allowEdit]
,[allowRemove]
,[allowView]
,[allowSort]
,[allowFilter]
,[pagingCount]
,[surfaceGridEditTypeId]
,[isTabbed]
,[viewIcon]
,[allowExport]
,[allowColVis]
,[defaultSort]
,[allowClone]
,[editIcon]
,[showWizardStatus]
,[addAccessType]
,[editAccessType]
,[viewAccessType]
,[removeAccessType]
,[cloneAccessType]
,[showAggregate]
,[aggregateTitle]
,[allowBulkUpdate]
,[allowScroll]
,[fixedColumns]
,[useFooTable]
,[noBorders]
,[freezeHeader]
,[iconsAsText]
,[allowImport])
VALUES
(4113
,0
,0
,0
,0
,0
,0
,25
,1
,0
,'eye'
,0
,0	
,''
,0
,'edit'	
,0
,4
,4
,0
,4
,0
,0
,''
,0
,0
,0
,0
,0
,0
,0,
0);

SET IDENTITY_INSERT [dbo].[pal_SurfaceField] ON 

INSERT [dbo].[pal_SurfaceField] ([recId], [surfaceId], [surfaceFieldName], [surfaceFieldDisplay], [surfaceFieldTypeId], [length], [required], [lookupCategory], [relationalFields], [relationalValues], [relationalOrderBy], [relationalSurface], [relationalObject], [parentId], [sequence], [isActive], [isGrid], [isFilter], [colSequence], [contentId], [defaultToCurrent], [isControlled], [controlledValue], [controlText], [isAutoPostback], [isHidden], [isReadOnly], [placeholder], [isUnique], [actionType], [action], [actionSource], [isComparable], [alternateView], [isHiddenFromWizzard], [surfaceDateTypeId], [isHiddenFromView], [actionValue], [surfaceFieldSize], [isLabelHidden], [isOnNewLine], [labelSize], [isHiddenFromForm], [accessLevel], [hasBottomBorder], [hasFullBorder], [defaultValue], [validationType], [enableBulkUpdate], [isCurrency], [isVerticalHeader], [gridSequence], [isGrouped], [isCloneable], [isCustomSource], [relationalWhere], [groupedDisplayCount]) VALUES (3247, 4113, N'WholesalerDataItems', N'Wholesaler Data Items', 1, 0, 0, 0, N'', N'', N'', N'', N'', 0, 1, 1, 0, 0, 0, 0, 0, 0, N'', N'', 0, 0, 0, N'', 0, 0, 0, 0, 0, 0, 0, 0, 0, N'', 6, 0, 0, 4, 0, 1, 0, 0, N'', 0, 0, 0, 0, 1, 0, 0, 0, N'', 0)
INSERT [dbo].[pal_SurfaceField] ([recId], [surfaceId], [surfaceFieldName], [surfaceFieldDisplay], [surfaceFieldTypeId], [length], [required], [lookupCategory], [relationalFields], [relationalValues], [relationalOrderBy], [relationalSurface], [relationalObject], [parentId], [sequence], [isActive], [isGrid], [isFilter], [colSequence], [contentId], [defaultToCurrent], [isControlled], [controlledValue], [controlText], [isAutoPostback], [isHidden], [isReadOnly], [placeholder], [isUnique], [actionType], [action], [actionSource], [isComparable], [alternateView], [isHiddenFromWizzard], [surfaceDateTypeId], [isHiddenFromView], [actionValue], [surfaceFieldSize], [isLabelHidden], [isOnNewLine], [labelSize], [isHiddenFromForm], [accessLevel], [hasBottomBorder], [hasFullBorder], [defaultValue], [validationType], [enableBulkUpdate], [isCurrency], [isVerticalHeader], [gridSequence], [isGrouped], [isCloneable], [isCustomSource], [relationalWhere], [groupedDisplayCount]) VALUES (3248, 4113, N'WholesalerDataItems_WholesalerDataItems', N'Wholesaler Data Items', 2, 0, 0, 0, N'', N'', N'', N'', N'', 3247, 1, 1, 0, 0, 0, 0, 0, 0, N'', N'', 0, 0, 0, N'', 0, 0, 0, 0, 0, 0, 0, 0, 0, N'', 6, 0, 0, 4, 0, 1, 0, 0, N'', 0, 0, 0, 0, 1, 0, 0, 0, N'', 0)
INSERT [dbo].[pal_SurfaceField] ([recId], [surfaceId], [surfaceFieldName], [surfaceFieldDisplay], [surfaceFieldTypeId], [length], [required], [lookupCategory], [relationalFields], [relationalValues], [relationalOrderBy], [relationalSurface], [relationalObject], [parentId], [sequence], [isActive], [isGrid], [isFilter], [colSequence], [contentId], [defaultToCurrent], [isControlled], [controlledValue], [controlText], [isAutoPostback], [isHidden], [isReadOnly], [placeholder], [isUnique], [actionType], [action], [actionSource], [isComparable], [alternateView], [isHiddenFromWizzard], [surfaceDateTypeId], [isHiddenFromView], [actionValue], [surfaceFieldSize], [isLabelHidden], [isOnNewLine], [labelSize], [isHiddenFromForm], [accessLevel], [hasBottomBorder], [hasFullBorder], [defaultValue], [validationType], [enableBulkUpdate], [isCurrency], [isVerticalHeader], [gridSequence], [isGrouped], [isCloneable], [isCustomSource], [relationalWhere], [groupedDisplayCount]) VALUES (3249, 4113, N'WholesalerDataItems_WholesalerDataItems_Barcode', N'Barcode', 3, 0, 0, 0, N'', N'', N'', N'', N'', 3248, 1, 1, 1, 0, 0, 0, 0, 0, N'', N'', 0, 0, 0, N'', 0, 0, 0, 0, 0, 0, 0, 0, 0, N'', 3, 0, 0, 12, 0, 1, 0, 0, N'', 0, 0, 0, 0, 1, 0, 1, 0, N'', 0)
INSERT [dbo].[pal_SurfaceField] ([recId], [surfaceId], [surfaceFieldName], [surfaceFieldDisplay], [surfaceFieldTypeId], [length], [required], [lookupCategory], [relationalFields], [relationalValues], [relationalOrderBy], [relationalSurface], [relationalObject], [parentId], [sequence], [isActive], [isGrid], [isFilter], [colSequence], [contentId], [defaultToCurrent], [isControlled], [controlledValue], [controlText], [isAutoPostback], [isHidden], [isReadOnly], [placeholder], [isUnique], [actionType], [action], [actionSource], [isComparable], [alternateView], [isHiddenFromWizzard], [surfaceDateTypeId], [isHiddenFromView], [actionValue], [surfaceFieldSize], [isLabelHidden], [isOnNewLine], [labelSize], [isHiddenFromForm], [accessLevel], [hasBottomBorder], [hasFullBorder], [defaultValue], [validationType], [enableBulkUpdate], [isCurrency], [isVerticalHeader], [gridSequence], [isGrouped], [isCloneable], [isCustomSource], [relationalWhere], [groupedDisplayCount]) VALUES (3250, 4113, N'WholesalerDataItems_WholesalerDataItems_WholesalerUniqueName', N'Wholesaler Unique Name', 29, 0, 0, 0, N'1855', N'', N'', N'3036', N'', 3248, 1, 1, 0, 0, 0, 0, 0, 0, N'', N'', 0, 0, 1, N'', 0, 0, 0, 0, 0, 0, 0, 0, 0, N'', 3, 0, 0, 12, 0, 1, 0, 0, N'', 0, 0, 0, 0, 1, 0, 0, 0, N'', 0)
INSERT [dbo].[pal_SurfaceField] ([recId], [surfaceId], [surfaceFieldName], [surfaceFieldDisplay], [surfaceFieldTypeId], [length], [required], [lookupCategory], [relationalFields], [relationalValues], [relationalOrderBy], [relationalSurface], [relationalObject], [parentId], [sequence], [isActive], [isGrid], [isFilter], [colSequence], [contentId], [defaultToCurrent], [isControlled], [controlledValue], [controlText], [isAutoPostback], [isHidden], [isReadOnly], [placeholder], [isUnique], [actionType], [action], [actionSource], [isComparable], [alternateView], [isHiddenFromWizzard], [surfaceDateTypeId], [isHiddenFromView], [actionValue], [surfaceFieldSize], [isLabelHidden], [isOnNewLine], [labelSize], [isHiddenFromForm], [accessLevel], [hasBottomBorder], [hasFullBorder], [defaultValue], [validationType], [enableBulkUpdate], [isCurrency], [isVerticalHeader], [gridSequence], [isGrouped], [isCloneable], [isCustomSource], [relationalWhere], [groupedDisplayCount]) VALUES (3251, 4113, N'WholesalerDataItems_WholesalerDataItems_WholesalerCode', N'Wholesaler Code', 29, 0, 0, 0, N'3074', N'', N'', N'0', N'', 3248, 1, 1, 0, 0, 0, 0, 0, 0, N'', N'', 0, 0, 1, N'', 0, 0, 0, 0, 0, 0, 0, 0, 0, N'', 3, 0, 0, 12, 0, 1, 0, 0, N'', 0, 0, 0, 0, 1, 0, 0, 0, N'', 0)
INSERT [dbo].[pal_SurfaceField] ([recId], [surfaceId], [surfaceFieldName], [surfaceFieldDisplay], [surfaceFieldTypeId], [length], [required], [lookupCategory], [relationalFields], [relationalValues], [relationalOrderBy], [relationalSurface], [relationalObject], [parentId], [sequence], [isActive], [isGrid], [isFilter], [colSequence], [contentId], [defaultToCurrent], [isControlled], [controlledValue], [controlText], [isAutoPostback], [isHidden], [isReadOnly], [placeholder], [isUnique], [actionType], [action], [actionSource], [isComparable], [alternateView], [isHiddenFromWizzard], [surfaceDateTypeId], [isHiddenFromView], [actionValue], [surfaceFieldSize], [isLabelHidden], [isOnNewLine], [labelSize], [isHiddenFromForm], [accessLevel], [hasBottomBorder], [hasFullBorder], [defaultValue], [validationType], [enableBulkUpdate], [isCurrency], [isVerticalHeader], [gridSequence], [isGrouped], [isCloneable], [isCustomSource], [relationalWhere], [groupedDisplayCount]) VALUES (3252, 4113, N'WholesalerDataItems_WholesalerDataItems_CostPrice', N'Cost Price', 5, 0, 0, 0, N'', N'', N'', N'', N'', 3248, 2, 1, 1, 0, 0, 0, 0, 0, N'', N'', 0, 0, 0, N'', 0, 0, 0, 0, 0, 0, 0, 0, 0, N'', 3, 0, 0, 12, 0, 1, 0, 0, N'', 0, 0, 0, 0, 2, 0, 1, 0, N'', 0)
INSERT [dbo].[pal_SurfaceField] ([recId], [surfaceId], [surfaceFieldName], [surfaceFieldDisplay], [surfaceFieldTypeId], [length], [required], [lookupCategory], [relationalFields], [relationalValues], [relationalOrderBy], [relationalSurface], [relationalObject], [parentId], [sequence], [isActive], [isGrid], [isFilter], [colSequence], [contentId], [defaultToCurrent], [isControlled], [controlledValue], [controlText], [isAutoPostback], [isHidden], [isReadOnly], [placeholder], [isUnique], [actionType], [action], [actionSource], [isComparable], [alternateView], [isHiddenFromWizzard], [surfaceDateTypeId], [isHiddenFromView], [actionValue], [surfaceFieldSize], [isLabelHidden], [isOnNewLine], [labelSize], [isHiddenFromForm], [accessLevel], [hasBottomBorder], [hasFullBorder], [defaultValue], [validationType], [enableBulkUpdate], [isCurrency], [isVerticalHeader], [gridSequence], [isGrouped], [isCloneable], [isCustomSource], [relationalWhere], [groupedDisplayCount]) VALUES (3253, 4113, N'WholesalerDataItems_WholesalerDataItems_LastUpdated', N'Last Updated', 29, 0, 0, 0, N'3239', N'', N'', N'4112', N'', 3248, 3, 1, 1, 0, 0, 0, 0, 0, N'', N'', 0, 0, 1, N'', 0, 0, 0, 0, 0, 0, 0, 0, 0, N'', 3, 0, 0, 12, 0, 1, 0, 0, N'', 0, 0, 0, 0, 3, 0, 0, 0, N'', 0)
INSERT [dbo].[pal_SurfaceField] ([recId], [surfaceId], [surfaceFieldName], [surfaceFieldDisplay], [surfaceFieldTypeId], [length], [required], [lookupCategory], [relationalFields], [relationalValues], [relationalOrderBy], [relationalSurface], [relationalObject], [parentId], [sequence], [isActive], [isGrid], [isFilter], [colSequence], [contentId], [defaultToCurrent], [isControlled], [controlledValue], [controlText], [isAutoPostback], [isHidden], [isReadOnly], [placeholder], [isUnique], [actionType], [action], [actionSource], [isComparable], [alternateView], [isHiddenFromWizzard], [surfaceDateTypeId], [isHiddenFromView], [actionValue], [surfaceFieldSize], [isLabelHidden], [isOnNewLine], [labelSize], [isHiddenFromForm], [accessLevel], [hasBottomBorder], [hasFullBorder], [defaultValue], [validationType], [enableBulkUpdate], [isCurrency], [isVerticalHeader], [gridSequence], [isGrouped], [isCloneable], [isCustomSource], [relationalWhere], [groupedDisplayCount]) VALUES (3254, 4113, N'WholesalerDataItems_WholesalerDataItems_UpdatedBy', N'Updated By', 29, 0, 0, 0, N'3080', N'', N'', N'user', N'', 3248, 4, 1, 1, 0, 0, 0, 0, 0, N'', N'', 0, 0, 1, N'', 0, 0, 0, 0, 0, 0, 0, 0, 0, N'', 3, 0, 0, 12, 0, 1, 0, 0, N'', 0, 0, 0, 0, 4, 0, 0, 0, N'', 0)
INSERT [dbo].[pal_SurfaceField] ([recId], [surfaceId], [surfaceFieldName], [surfaceFieldDisplay], [surfaceFieldTypeId], [length], [required], [lookupCategory], [relationalFields], [relationalValues], [relationalOrderBy], [relationalSurface], [relationalObject], [parentId], [sequence], [isActive], [isGrid], [isFilter], [colSequence], [contentId], [defaultToCurrent], [isControlled], [controlledValue], [controlText], [isAutoPostback], [isHidden], [isReadOnly], [placeholder], [isUnique], [actionType], [action], [actionSource], [isComparable], [alternateView], [isHiddenFromWizzard], [surfaceDateTypeId], [isHiddenFromView], [actionValue], [surfaceFieldSize], [isLabelHidden], [isOnNewLine], [labelSize], [isHiddenFromForm], [accessLevel], [hasBottomBorder], [hasFullBorder], [defaultValue], [validationType], [enableBulkUpdate], [isCurrency], [isVerticalHeader], [gridSequence], [isGrouped], [isCloneable], [isCustomSource], [relationalWhere], [groupedDisplayCount]) VALUES (3255, 4113, N'WholesalerDataItems_WholesalerDataItems_ImportFileName', N'Import File Name', 29, 0, 0, 0, N'3238', N'', N'', N'4112', N'', 3248, 5, 1, 1, 0, 0, 0, 0, 0, N'', N'', 0, 0, 1, N'', 0, 0, 0, 0, 0, 0, 0, 0, 0, N'', 3, 0, 0, 12, 0, 1, 0, 0, N'', 0, 0, 0, 0, 5, 0, 0, 0, N'', 0)
INSERT [dbo].[pal_SurfaceField] ([recId], [surfaceId], [surfaceFieldName], [surfaceFieldDisplay], [surfaceFieldTypeId], [length], [required], [lookupCategory], [relationalFields], [relationalValues], [relationalOrderBy], [relationalSurface], [relationalObject], [parentId], [sequence], [isActive], [isGrid], [isFilter], [colSequence], [contentId], [defaultToCurrent], [isControlled], [controlledValue], [controlText], [isAutoPostback], [isHidden], [isReadOnly], [placeholder], [isUnique], [actionType], [action], [actionSource], [isComparable], [alternateView], [isHiddenFromWizzard], [surfaceDateTypeId], [isHiddenFromView], [actionValue], [surfaceFieldSize], [isLabelHidden], [isOnNewLine], [labelSize], [isHiddenFromForm], [accessLevel], [hasBottomBorder], [hasFullBorder], [defaultValue], [validationType], [enableBulkUpdate], [isCurrency], [isVerticalHeader], [gridSequence], [isGrouped], [isCloneable], [isCustomSource], [relationalWhere], [groupedDisplayCount]) VALUES (3256, 4113, N'ParentSurfaceItemId', N'ParentSurfaceItemId', 4, 0, 0, 0, N'', N'', N'', N'WholesalerData', N'', 3248, 0, 1, 0, 0, 0, 0, 0, 0, N'', N'', 0, 1, 1, N'', 0, 0, 0, 0, 0, 0, 0, 0, 0, N'', 0, 0, 0, 0, 0, 0, 0, 0, N'', 0, 0, 0, 0, 0, 0, 0, 0, N'', 0)

SET IDENTITY_INSERT [dbo].[pal_SurfaceField] OFF 

CREATE TABLE [dbo].[publ_WholesalerDataItems](
	[itemID] [int] NOT NULL,
	[isActive] [bit] NULL,
	[surfaceId] [int] NOT NULL,
	[ParentSurfaceItemId] [int] NULL,
	[WholesalerDataItems_WholesalerDataItems_Barcode] [varchar](max) NULL,
	[WholesalerDataItems_WholesalerDataItems_WholesalerUniqueName] [varchar](max) NULL,
	[WholesalerDataItems_WholesalerDataItems_WholesalerCode] [varchar](max) NULL,
	[WholesalerDataItems_WholesalerDataItems_CostPrice] [decimal](18, 2) NULL,
	[WholesalerDataItems_WholesalerDataItems_LastUpdated] [varchar](max) NULL,
	[WholesalerDataItems_WholesalerDataItems_UpdatedBy] [varchar](max) NULL,
	[WholesalerDataItems_WholesalerDataItems_ImportFileName] [varchar](max) NULL,
	[recId] [int] IDENTITY(1,1) NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[recId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

END;

