/*********************************************

 AppWizard 4.01 Database Create Code
      2008 (c) Gateway Software

   VERY IMPORTANT 

Before running this script, ensure that the file
location is set below for the new AppWizard database


**********************************************/
set NOCOUNT on

-- Create Database (you can do this through Enterprise Manager (2000) or Management Studio (2005+)
use master
go
create database AppWizard
on (Name = 'AppWizard_dat',  Filename = 'C:\MSSQL\Data\AppWizard.mdf', Size = 2MB, MaxSize = 100MB, FileGrowth = 2MB)
Log on (Name = 'AppWizard_log', Filename = 'C:\MSSQL\Data\AppWizard.ldf', Size = 2MB, MaxSize = 100MB, FileGrowth = 2MB)
go
if not exists (select * from sysdatabases where Name = 'AppWizard') begin
  Print 'Unable to create AppWizard database. Please check file location before you retry the installation.'
  Return
end
use AppWizard
go
-- Build AppWizard
create table awSystem (
  Version	decimal(18,2),
  UpdateSeq	int,
  Session	int
)

insert into awSystem values(4.01,0,1)
go

-- Function reference
create table awFunction (
 [Function]	varchar(20) primary key,
 Category	varchar(30),
 Description	varchar(200),
 TextList	varchar(300) default 'Text1,Text2,Text3,Text4,Text5,Text6,Memo1,Memo2,Memo3,Memo4',
 ValueList	varchar(300),
 Active		int default 0
)

insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('-NEW FUNCTION-','General','This is a place holder function that does nothing. It is used in the Application Builder application.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4',',,,,,,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('Button','Forms','Displays a submit button.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Button Text,,Name,,,,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('CheckBox','Forms','Use this function to show a checkbox.  The value 1 will be checked, NULL will be unchecked.  The value will be started with the given value.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Caption,,Name,Parameter,Query Field,Fixed Value,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('ComboBox','Forms','Displays a ComboBox (drop-down box) sourced from a table. The initial selected value will be set using the given value.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Caption,Source[SQL;0;Values;1;ComboSQL;2],Name,Parameter,Query Field,Fixed Value,2-10 for Multiple Selection,SQL Statement,Value List,Top Value,Top Text',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('ComboSQL','Forms','This will build an SQL statement to be used with a following <B>ComboBox</b> function using a fixed SQL statement where a field name is a given value, ordered by a set of fields.  The "WHERE" and "ORD','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Where name,Condition[=;=;>;>;<;<;<>;<>;>=;>=;<=;<=],,Parameter,Query Field,Fixed Value,,SQL Statement,Order By,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('Comment','General','Allows the placing of a comment in the code. This function has no effect.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4',',,,,,,,Comment,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('CSVExport','File','Export the SQL data to a file specified by the <B>CSVFile</b> function and columns given by the <B>CSVField</b> function.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Column Headings[No;0;Yes;1],,,,,,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('CSVField','File','Specify the field to be imported/exported in a file. Works with the <B>CSVFile</b>, <b>CSVExport</b> and <b>CSVImport</b> functions.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Heading,Format[General;0;String;1],@Name for Import,Parameter,Query Field,Fixed Value,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('CSVFile','File','Specify the filename for a file to be imorted or exported. Works with the <B>CSVField</b>, <b>CSVExport</b> and <b>CSVImport</b> functions.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4',',,,Parameter,Query Field,Fixed Value,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('CSVImport','File','Import the SQL data from a file specified by the <B>CSVFile</b> function and columns given by the <B>CSVField</b> function.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Headings[None;0;1st Row;1],,Stored Proc Name,,,,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('DataAdd','Data','Use this function to add a record to a table.  Use the <B>DataSetValue</B> function to set the field values and the <B>DataCommit</B> function to save the record.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Table Name,,,,,,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('DataClose','Data','This will close the open recordset and should follow either a Stored Procedure (if a value is returned) or SQL function.  It must be called before another recordset can be opened.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4',',,,,,,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('DataCommit','Data','Use this function to save the changes after the <B>DataSetValue</b> function was called.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4',',,,,,,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('DataDelete','Data','This function will delete a record in the table where the key field has the given value.  If more than 1 key is required, use a Stored Procedure.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Table Name,,Key Field,Parameter,Query Field,Fixed Value,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('DataNoRecords','Data','Checks to see if there are no records and responds with a message with an option to stop further functions.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Action[Continue;0;Stop;1;Goto;2],Goto SeqNo,,Parameter,Query Field,Fixed Value,,HTML Code,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('DataSetValue','Data','Use this function to change the value of an open recordset field to the given value.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Field Name,,,Parameter,Query Field,Fixed Value,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('DataUpdate','Data','Use this function to update an existing record in a table where the key field is the given value.  Use the <B>DataSetValue</B> function to set the field values and the <B>DataCommit</b> function to sa','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Table Name,,Key Field,Parameter,Query Field,Fixed Value,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('DateEdit','Forms','Displays an edit box with a date picker with date validation of the content.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Caption,,Name,Parameter,Query Field,Fixed Value,Required[Optional;0;Compulsory;1],1 for Focus,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('DynamicComboBox','Forms','Displays a combobox with values linked to the DynamicList box.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Caption,,Name,,,,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('DynamicList','Forms','Displays a ComboBox (drop-down box) sourced from a table with additional fields to be used to dynamically change text labels and <B>DynamicComboBox</b> options. The initial selected value will be set ','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Caption,,Name,Parameter,Query Field,Fixed Value,,SQL Statement,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('EditBox','Forms','Displays an edit box (one line text input).  The initial value will be set using the given value.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Caption,Width,Name,Parameter,Query Field,Fixed Value,Required[Optional;0;Compulsory;1;Numeric;2],1 for Focus,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('FileName','Forms','Allows the specifying of a filename for a file to upload','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Caption,Width,Name,Parameter,Query Field,Fixed Value,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('FileSave','Forms','Save an uploaded file','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','File Parameter,,,Parameter,Query Field,Fixed Value,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('Folder','General','Creates a dynamic open/close folder header.  The folder starts closed. The value supplied gives the indent (space from the left) of the folder header.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4',',Background Color,Indent,,,,,Caption,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('FolderClose','General','Closes a dynamic folder area.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4',',,,,,,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('Form','Forms','This initializes the form and should be placed before any of the Forms functions.  The key hidden field can be set in this function.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Style[Formatted;0;Unformatted;1],Application,Name,Parameter,Query Field,Fixed Value,URL,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('FormClose','Forms','Closes the current form.  This function must be called before another Form function is called.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4',',,,,,,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('ForSQL','General','This starts a loop that will process all the records in the cuurent SQL query one by one.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4',',,,,,,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('GraphBar','Graph','Draws a Bar graph','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Title,Series Names,Colours,Width,Height,Source[SQL;0;GraphSQL;1],,SQL,Y axis label,1 for Legend,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('GraphLine','Graph','Draws a line graph','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Title,Series Names,Colours,Width,Height,Source[SQL;0;GraphSQL;1],,SQL,Y axis label,1 for Legend,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('GraphMap','Graph','Draws a map and plotting using an XY graph','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Title,1 for Tag,Dot Colour,Width,Height,Source[SQL;0;GraphSQL;1],,SQL,Tag Colour,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('GraphSQL','Graph','Builds the SQL statement for the graphs','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4',',,,Parameter Name,Query Field,Fixed Value,,SQL,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('Hidden','Forms','Allocates a hidden form value','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4',',,Name,Parameter,Query Field,Fixed Value,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('Html','General','Normal HTML text to be displayed as is.  The text will be placed within the P and /P tags.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4',',,,Parameter,Query Field,Fixed Value,,HTML Code,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('IfGoto','General','If a condition is true it forwards to another sequence number','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Test Value,Condition[=;=;>;>;>=;>=;<>;<>;<;<;<=;<=],GotoNo,Parameter,Query Field,Fixed Value,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('IfStop','Genmeral','Stops the application if a specified text comparison condition is met.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Fixed Value,Condition[=;=;>;>;>=;>=;<>;<>;<;<;<=;<=],,Parameter,Query Field,Fixed Value,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('Link','General','Hyperlink to another application including an optional parameter value. Extra parameters can be included by calling the <B>LinkParameter</B> function first.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Application,,Name,Parameter,Query Field,Fixed Value,,Link Text,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('Menu','Menu','USE ONLY IN AppId = 1. Start of a drop down menu or shortcut menu. Must always have Public access.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Shortcut Title,Submenu Name,Width,Type[Drop Down;0;Shortcut;1],,,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('MenuClose','Menu','USE ONLY IN AppId = 1. End of a drop down menu or shortcut menu. Must always have Public access.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4',',,,,,,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('MenuItem','Menu','USE ONLY IN AppId = 1. A menu item pointing to an application or URL.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Display Text,Application,Name,Parameter,Query Field,Fixed Value,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('MenuMainClose','Menu','USE ONLY IN AppId = 1. Indicates the end of the main menu. All functions following will be within drop down or shortcut menus.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4',',,,,,,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('MenuSubMenu','Menu','USE ONLY IN AppId = 1. A menu item pointing to a sub menu (drop down or shortcut menu)','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Display Text,Submenu Name,Menu Level,Type[Drop Down;0;Shortcut;1],,,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('NextSQL','General','This function loops back to the ForSQL function if there are more records in the SQL query.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4',',,,,,,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('Parameter','General','An extra parameter to be added the the next <B>Link</b> or <B>Redirect</b> or <b>UploadRedirect</b>  function. This function can be called multiple times.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4',',,Name,Parameter,Query Field,Fixed Value,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('Password','Forms','Displays a Password box.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Caption,Width,Name,Parameter,Query Field,Fixed Value,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('PosixOpen','System','Opens the attached USB Posix drawer.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4',',,,,,,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('Redirect','General','This will redirect to another application using the given parameter value. Optionally only redirect if parameter = value.<U>IMPORTANT:</U> The <I><B>Can Redirect</B></I> value in the Application must ','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Application,,Name,Parameter,Query Field,Fixed Value,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('SetVariable','General','This will set a local variable value.  The value can be set using a calculation as well.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Name,Calculation,,Parameter,Query Field,Fixed Value,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('SQL','Data','This will set up a recordset using a fixed SQL statement where a field name is a given value, ordered by a set of fields.  The "WHERE" and "ORDER BY" usage is optional.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Where name,Condition[=;=;>;>;<;<;<>;<>;>=;>=;<=;<=],,Parameter,Query Field,Fixed Value,,SQL Statement,Order By,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('StoredProc','Data','This will set up a recordset using a stored procedure as source.  Use the <B>StoredProcParam</b> function to give parameters values and the <B>StoredProcExec</b> function to execure the procedure.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Proc Name,Action[Continue;0;Execute;1],@Name,Parameter,Query Field,Fixed Value,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('StoredProcParam','Data','This will give a stored procedure parameter the given value.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4',',Action[Continue;0;Execute;1],@Name,Parameter,Query Field,Fixed Value,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('Table','Table','Initializes a table to display sets of data. Use the <B>TableField</b> function to set up table columns and the <B>TableShow</b> function to display the table.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Border Type[None;0;Single;1;Compact;2],Border Color,Caption Color,Width,Totals[No;0;Yes;1],Colspan of Totals,Row Colors[Default;0;Odd Only;1;Even Only;2;None;3],Text of Totals,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('TableCheckBox','Table','This creates a check box within a table cell to allow for multiple capture.  The table must be inside a form. The data will be returned in a comma delimeted string.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Field name,Alignment,Parameter Name,,,,,Caption,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('TableComboBox','Table','This creates a Combo Box within a table cell to allow for multiple capture. The table must be inside a form. The data will be returned in a comma delimited string','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Field name,Alignment,Parameter Name,Source[SQL;0;Values;1;ComboSQL;2],Top Value,Top Text,,Caption,SQL Statement,Value List,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('TableEditBox','Table','This creates a Edit Box within a table cell to allow for multiple capture. The table must be inside a form. The data will be returned in a comma delimited string','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Field name,Alignment,Parameter Name,Width,,,,Caption,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('TableField','Table','Call this function for each field you would like to display within the Data Table.  You must call the <B>Table</b> function first for this function to have any meaning.  Use the <B>TableShow</b> funct','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Display Field,Application,Name,Parameter Field,Format[Text;0;0 000.00;1;0 000;2],Summary[None;0;GROUP;GROUP;SUM;SUM],BackGround Field,Caption,Alignment,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('TableHidden','Table','Include a hidden value into an editable field.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Field name,,Parameter Name,,,,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('TableShow','Table','This is called to display the contents of the Data Table.  Call this function after all the <B>DataField</b> functions are complete.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4',',,,,,,,,,,',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('TextBox','Forms','This will display text box for large text entries (similar to a memo entry box)','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4','Caption,Width,Name,Parameter,Query Field,Fixed Value,Required[Optional;0;Compulsory;1;Numeric;2],Rows,,2nd Name,2nd Query Field',1)
insert into awFunction ([Function], Category, Description, TextList, ValueList, Active)
 values ('TreeView','General','Displays a tree view of a record set.','Text1,Text2,Text3,Text4,Text5,Text6,Text7,Memo1,Memo2,Memo3,Memo4',',,,,,,,,,,',1)

-- Default Applications
create table awApplication (
 AppId		int identity(1,1) primary key,
 Name		varchar(30),
 Title		varchar(50),
 Description	varchar(200),
 [Public]	int,
 NavBack	int default 0,
 PrintView	int
)

-- aw Applications
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values ('awMenu','Main Menu','This is the default Main Menu',0,0,0)                                                                                                                                                                                                                         
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values ('awHelp','Online Help','This is the default online help system',1,0,0)
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values('awHelpFilter','','Pass the category',1,2,0) 
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values('awHelpView','Topic','Show the help topic',1,0,0) 
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values ('awHome','AppWizard Home','AppWizard Home Page',1,0,0)
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values ('awBackup','Backup Database','Back up the database',1,0,0)
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values('awHelpBuilder','Help Category','Maintain help categories',1,0,0) 
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values('awHelpBuilderCat','Category','Edit the category',1,0,0) 
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values('awHelpBuilderCatAdd','','Add the category',1,2,0) 
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values('awHelpBuilderCatDelete','','Delete the category',1,3,0) 
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values('awHelpBuilderCatUpdate','','Save changes',1,2,0) 
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values('awHelpBuilderTopic','Topic','Topic Editor',1,0,0) 
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values('awHelpBuilderTopicAdd','','Add the new topic',1,2,0) 
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values('awHelpBuilderTopicDelete','','Delete the topic',1,3,0) 
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values('awHelpBuilderTopicUpdate','','Save the changes',1,2,0) 

-- dev Applications
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values ('devFuncRenumber','','Renumber the function',1,2,0)
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values ('devAppBuilder','App Builder','Application Builder',1,0,0)
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values ('devAppAdd','','Add a new application',1,2,0)
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values ('devAppEdit','Function List','The list of functions in the selected Application',1,0,0)
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values ('devFuncAdd','','Add a new function',1,1,0)
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values ('devFuncEdit','Editor','Edit the function parameters',1,0,0)
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values ('devAppFuncDelete','','Delete the range of functions',0,2,0)                                                                                                                                                                                                                         
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values ('devFuncUpdate','','Update the function details',1,3,0)
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values ('devAppDelete','','Delete the application',1,3,0)
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values ('devFuncDelete','','Delete the function',1,3,0)
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values ('devAppUpdate','','Updates the application properties',1,2,0)
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values ('devAppFilter','','Pass the filter parameter',1,2,0)
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values ('devFuncGroupAdd','','Add or remove the selected group',1,2,0)
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values ('devAppCopy','','Copy all the functions of another application',1,2,0)
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values ('devStoredProc','Stored Procedures','Load an existing stored procedure or create a new one',1,0,0)                                                                                                                                                                                                      
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values ('devStoredProcFilter','Send Id','Send the selected ID back to the devStoredProc app',1,2,0)                                                                                                                                                                                                             
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values ('devStoredProcSave','Saving','Save the stored procedure and return any results',1,2,0)
insert into awApplication (Name, Title, Description, NavBack, PrintView, [Public])
 values('devTableViewer','View Tables','View table structures',0,0,1)                                             
insert into awApplication (Name, Title, Description, NavBack, PrintView, [Public])
 values('devTableFilter','','Send selected ID back to devTableView',2,0,1)                                             
insert into awApplication (Name, Title, Description, NavBack, PrintView, [Public])
 values('devSQL','SQL Query Tool','View the results of an SQL query',1,0,1)                                             
insert into awApplication (Name, Title, Description, NavBack, PrintView, [Public])
 values('devImportApp','Import Application','Allows the user to enter the Application info to be uploaded',0,0,1)                                             
insert into awApplication (Name, Title, Description, NavBack, PrintView, [Public])
 values('devImportAppUpdate','Import the Application','Import the Application using stored procedure devImportAppUpdate',2,0,1)                               
insert into awApplication (Name, Title, Description, NavBack, PrintView, [Public])
 values('devExportApp','Export Application','Allows the user to Export an Application',1,0,1)                                                                 
insert into awApplication (Name, Title, Description, NavBack, PrintView, [Public])
 values('devExportAppFilter','Send Application ID','Send the Application ID back to devExportApp',1,0,1)                                                      
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values('devAppSQLFilter','','Pass the AppId',1,2,0) 
insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)
 values('devAppSQL','Application SQL','Return the Application in SQL format',1,0,0) 


-- Default Application Details
create table awDetail (
 FuncId		int identity(1,1) primary key,
 AppId		int,
 SeqNo		int,
 [Function]	varchar(20),
 Memo1		varchar(3000),
 Memo2		varchar(1500),
 Memo3		varchar(1000),
 Memo4		varchar(1000),
 Text1		varchar(200),
 Text2		varchar(200),
 Text3		varchar(200),
 Text4		varchar(200),
 Text5		varchar(200),
 Text6		varchar(200),
 Text7		varchar(50),
 GotoFuncId	int
)

declare
 @AppId  int,
 @CatId  int

-- awMenu                                                                                                                                                             
select @AppId=AppId from awApplication where Name='awMenu'

insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,10,'MenuSubMenu','','','','0','Programs','PROGRAMS','0','0','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,20,'MenuSubMenu','','','','0','Utilities','UTILITIES','0','0','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,30,'MenuItem','','','','','Help','awHelp','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,40,'MenuMainClose','','','','','','','0','0','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,50,'Menu','','','','','','UTILITIES','160','0','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,60,'MenuItem','','','','','App Builder','devAppBuilder','Filter=-&OpenFolder=1','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,65,'MenuItem','','','','','Help Builder','awHelpBuilder','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,70,'MenuItem','','','','','Stored Procedures','devStoredProc','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,80,'MenuItem','','','','','Table Structure','devTableViewer','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,90,'MenuItem','','','','','SQL Query Tool','devSQL','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,95,'MenuItem','','','','','Application SQL','devAppSQL','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,100,'MenuItem','','','','','Import Applications','devImportApp','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,110,'MenuItem','','','','','Export Applications','devExportApp','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,120,'MenuItem','','','','','Admin Menu','awAdmin','sLogin','','','1')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,130,'MenuItem','','','','','Backup Database','awBackup','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,140,'MenuClose','','','','','','','0','0','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,150,'Menu','','','','','','PROGRAMS','180','0','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,160,'MenuClose','','','','','','','','','','')

-- awBackup
select @AppId=AppId from awApplication where Name='awBackup'

insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,10,'StoredProc','','','','','awBackup','1','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,20,'Html','<B>Database Backup Complete</b>','','','','','','','','','')

-- awHome
select @AppId=AppId from awApplication where Name='awHome'

insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,10,'Html','<center><h3>Welcome to AppWizard</h3><b>Your application provider.<P>This demonstration site will illustrate some of AppWizard''s capabilities.<br>AppWizard''s abilities are only limited by your imagination...</b></center>','','','','','','','','','')

-- awHelp
select @AppId = AppId from awApplication where Name='awHelp' 

insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,10,'Html','<B>Select a Category to View Help Topics</b>','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,20,'Form','','','','','0','awHelpFilter','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,30,'ComboBox','select CatId as Value, Category as Text from awHelpCategory order by Category','','0','- Select a Help Category -','Category','0','CatId','CatId','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,40,'Button','','','','','Show Topics','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,50,'FormClose','','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,60,'Html','<hr><B>Select a Topic to View</b>','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,70,'StoredProc','','','','','awHelpFilter','0','@CatId','CatId','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,80,'StoredProcParam','','','','','','1','@UserId','@UserId','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,90,'Table','','','','','','','','','0','','0') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,100,'TableField','Topic','','','','Topic','awHelpView','DetId','DetId','0','0','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,110,'TableShow','','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,120,'DataClose','','','','',' ','','','','','','') 

-- awHelpFilter
select @AppId = AppId from awApplication where Name='awHelpFilter' 

insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,10,'Redirect','','','','','awHelp','','CatId','CatId','','','') 

-- awHelpView
select @AppId = AppId from awApplication where Name='awHelpView' 

insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,10,'SQL','select * from awHelpDetail','','','','DetId','','','DetId','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,20,'Html','<B>','','','','','','','','Topic','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,30,'Html','</b><P>','','','','','','','','Content','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,40,'DataClose','','','','','','','','','','','') 

-- awHelpBuilder
select @AppId = AppId from awApplication where Name='awHelpBuilder'

insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,10,'Folder','Add a New Help Category','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,20,'Form','','','','','0','awHelpBuilderCatAdd','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,30,'EditBox','','','','','Help Category','40','Category','','','','1') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,40,'Button','','','','','Add Category','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,50,'FormClose','','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,60,'Html','<hr>','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,70,'FolderClose','','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,80,'Html','<B>Select a Category to Edit</b>','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,90,'SQL','select * from awHelpCategory order by Category','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,100,'Table','','','','','','','','','0','','0') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,110,'TableField','Category','','','','Category','awHelpBuilderCat','CatId','CatId','0','0','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,120,'TableShow','','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,130,'DataClose','','','','','','','','','','','') 

-- awHelpBuilderCat
select @AppId = AppId from awApplication where Name='awHelpBuilderCat'

insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,10,'SQL','select * from awHelpCategory','','','','CatId','','','CatId','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,20,'Html','<B>Edit the Help Category Name</b>','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,30,'Form','','','','','0','awHelpBuilderCatUpdate','CatId','CatId','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,40,'EditBox','1','','','','Category','40','Category','','Category','','1') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,50,'Button','','','','','Save Changes','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,60,'FormClose','','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,70,'DataClose','','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,80,'Html','<hr><B>Maintain Help Topics in this Category</b>','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,90,'Folder','Add a New Help Topic','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,100,'Html','<B>Note:</b> Use HTML tag to format the content.<br>The content cannot exceed 7000 characters.','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,110,'Form','','','','','0','awHelpBuilderTopicAdd','CatId','CatId','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,120,'EditBox','','','','','Topic','70','Topic','','','','1') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,130,'TextBox','5','','','','Content','70','Content','','','','1') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,135,'CheckBox','','','','','Admin Only Access','','AdminOnly','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,140,'Button','','','','','Add Topic','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,150,'FormClose','','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,160,'Html','<hr>','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,170,'FolderClose','','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,180,'SQL','select count(*) as Cnt from awHelpDetail','','','','CatId','','','CatId','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,190,'IfGoto','','','','','0','=','300','','Cnt','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,200,'DataClose','','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,210,'Html','<B>Select a Topic to Edit</b>','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,220,'SQL','select DetId, Topic, case when isnull(AdminOnly,0)=0 then ''Public'' else ''<B>Admin Only</b>'' end as IsAdmin from awHelpDetail','Topic','','','CatId','','','CatId','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,230,'Table','','','','','','','','','0','','0') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,240,'TableField','Topic','','','','Topic','awHelpBuilderTopic','DetId','DetId','0','0','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,250,'Parameter','','','','','','','CatId','CatId','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,260,'TableField','Access','','','','IsAdmin','','','','0','0','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,270,'TableShow','','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,280,'DataClose','','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,290,'IfStop','','','','','1','=','','','','1','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,300,'Html','<hr><hr>','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,310,'Folder','Delete this Category','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,320,'Link','Permananetly DELETE this Category','','','','awHelpBuilderCatDelete','','CatId','CatId','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,330,'FolderClose','','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,340,'DataClose','','','','','','','','','','','') 

-- awHelpBuilderCatAdd
select @AppId = AppId from awApplication where Name='awHelpBuilderCatAdd'

insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,10,'DataAdd','','','','','awHelpCategory','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,20,'DataSetValue','','','','','Category','','','Category','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,30,'DataCommit','','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,40,'Redirect','','','','','awHelpBuilder','','','','','','') 

-- awHelpBuilderCatDelete
select @AppId = AppId from awApplication where Name='awHelpBuilderCatDelete'

insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,10,'DataDelete','','','','','awHelpCategory','','CatId','CatId','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,20,'Redirect','','','','','awHelpBuilder','','','','','','') 

-- awHelpBuildetCatUpdate
select @AppId = AppId from awApplication where Name='awHelpBuilderCatUpdate'

insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,10,'DataUpdate','','','','','awHelpCategory','','CatId','CatId','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,20,'DataSetValue','','','','','Category','','','Category','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,30,'DataCommit','','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,40,'Redirect','','','','','awHelpBuilderCat','','CatId','CatId','','','') 

-- awHelpBuilderTopic
select @AppId = AppId from awApplication where Name='awHelpBuilderTopic'

insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,10,'Html','<B>Edit the Topic</b>','','','','','','','','','',' ') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,20,'SQL','select * from awHelpDetail','','','','DetId','','','DetId','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,30,'Form','','','','','0','awHelpBuilderTopicUpdate','DetId','DetId','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,40,'Hidden','','','','','','','CatId','CatId','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,50,'EditBox','1','','','','Topic','70','Topic','','Topic','','1') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,60,'TextBox','4','','','','Content','70','Content','','Content','','1') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,65,'CheckBox','','','','','Admin Only Access','','AdminOnly','','AdminOnly','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,70,'Button','','','','','Save Changes','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,80,'FormClose','','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,90,'Folder','Delete this Topic','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,100,'Parameter','','','','','','','CatId','CatId','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,110,'Link','Permanently DELETE this Topic','','','','awHelpBuilderTopicDelete','','DetId','DetId','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,120,'FolderClose','','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,130,'Html','<hr><B><i> - Preview of Topic in Help - </i></b><hr>','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,140,'Html','<B>','','','','','','','','Topic','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,150,'Html','</b><P>','','','','','','','','Content','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,160,'DataClose','','','','','','','','','','','') 

-- awHelpBuilderTopicAdd
select @AppId = AppId from awApplication where Name='awHelpBuilderTopicAdd'

insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,10,'DataAdd','','','','','awHelpDetail','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,20,'DataSetValue','','','','','CatId','','','CatId','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,30,'DataSetValue','','','','','Topic','','','Topic','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,40,'DataSetValue','','','','','AdminOnly','','','AdminOnly','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,50,'DataSetValue','','','','','Content','','','Content','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,60,'DataCommit','','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,70,'Redirect','','','','','awHelpBuilderCat','','CatId','CatId','','','') 

-- awHelpBuilderTopicDelete
select @AppId = AppId from awApplication where Name='awHelpBuilderTopicDelete'

insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,10,'DataDelete','','','','','awHelpDetail','','DetId','DetId','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,20,'Redirect','','','','','awHelpBuilderCat','','CatId','CatId','','','') 

-- awHelpBuilderTopicUpdate
select @AppId = AppId from awApplication where Name='awHelpBuilderTopicUpdate'

insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,10,'DataUpdate','','','','','awHelpDetail','','DetId','DetId','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,20,'DataSetValue','','','','','Topic','','','Topic','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,30,'DataSetValue','','','','','AdminOnly','','','AdminOnly','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,40,'DataSetValue','','','','','Content','','','Content','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,50,'DataCommit','','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,60,'Parameter','','','','','','','CatId','CatId','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,70,'Redirect','','','','','awHelpBuilderTopic','','DetId','DetId','','','') 

--devAppAdd
select @AppId=AppId from awApplication where Name='devAppAdd'

insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,10,'DataAdd','','','','','awApplication','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,20,'DataSetValue','','','','','Name','','','Name','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,30,'DataSetValue','','','','','Public','','','','','1')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,40,'DataCommit','','','','','','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,50,'Redirect','','','','','devAppBuilder','','Filter','Filter','','')

--devAppBuilder
select @AppId=AppId from awApplication where Name='devAppBuilder'

insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,10,'Folder','<B>Add new Application</b>','','','','','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,20,'Form','','','','','','devAppAdd','Filter','Filter','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,30,'EditBox','','','','','Application Name:','','Name','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,40,'Button','','','','','Add Application','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,50,'FormClose','','','','','','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,60,'Html','<hr>','','','','','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,70,'FolderClose','','','','','','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,80,'Folder','<b>Application Filter</b>','','','','','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,90,'Form','','','','','','devAppFilter','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,100,'EditBox','','','','','Filter','15','Filter','Filter','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,110,'Button','','','','','Filter Applications','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,120,'FormClose','','','','','','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,130,'FolderClose','','','','','','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,140,'StoredProc','','','','','awAppFilter','1','@Filter','Filter','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,150,'Html','<B>Select an application to Edit</b>','','','','','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,160,'Table','','','','','0','','#c0c0c0','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,170,'Parameter','','','','','','','Filter','Filter','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,180,'TableField','Application','','','','Name','devAppEdit','AppId','AppId','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,190,'TableField','Description','','','','Description','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,200,'TableShow','','','','','','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,210,'DataClose','','','','','','','','','','')

--devAppCopy
select @AppId=AppId from awApplication where Name='devAppCopy'

insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,10,'StoredProc','','','','','devAppCopy','','@AppId','AppId','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,20,'StoredProcParam','','','','','','','@All','All','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,30,'StoredProcParam','','','','','','','@FromSeq','FromSeq','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,40,'StoredProcParam','','','','','','','@ToSeq','ToSeq','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,50,'StoredProcParam','','','','','','','@Start','Start','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,60,'StoredProcParam','','','','','','','@Inc','Inc','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,70,'StoredProcParam','','','','','','1','@CopyId','CopyId','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,80,'Parameter','','','','','','','Filter','Filter','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,90,'Redirect','','','','','devAppEdit','','AppId','AppId','','')

--devAppDelete
select @AppId=AppId from awApplication where Name='devAppDelete'

insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,10,'DataDelete','','','','','awDetail','','AppId','AppId','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,20,'DataDelete','','','','','awApplication','','AppId','AppId','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,30,'Redirect','','','','','devAppBuilder','','Filter','Filter','','')

--devAppEdit
select @AppId=AppId from awApplication where Name='devAppEdit'

insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,10,'IfGoto','','','','','1','=','30','NewFunction','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,20,'IfGoto','','','','','1','=','50','','','1')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,30,'Parameter','','','','','','','Filter','Filter','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,40,'Redirect','','','','','devFuncAdd','','AppId','AppId','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,50,'SQL','select * from awApplication','','','','AppId','','','AppId','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,60,'Html','<B>Application Name: ','','','','','','','','Name','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,70,'Html','</b><br>','','','','','','','','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,80,'Folder','<B>Update Application Properties</b>','','','','','','','','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,90,'Form','','','','','','devAppUpdate','AppId','AppId','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,100,'Hidden','','','','','','','Filter','Filter','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,110,'EditBox','','','','','App Name','20','Name','','Name','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,120,'EditBox','','','','','Title','20','Title','','Title','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,130,'TextBox','2','','','','Description','60','Description','','Description','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,140,'CheckBox','','','','','Public Access','','Public','','Public','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,150,'ComboBox','','0,0,1,1,2,2,3,3,4,4','','','Nav Back','1','NavBack','','NavBack','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,160,'ComboBox','','-None-,0,Portrait,1,Landscape,2','','','Print View','1','PrintView','','PrintView','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,170,'Button','','','','','Update Properties','','','','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,180,'FormClose','','','','','','','','','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,190,'Html','<hr>','','','','','','','','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,200,'FolderClose','','','','','','','','','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,210,'Folder','Copy/Delete Parts of Application','','','','','','','','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,220,'Form','','','','','','devAppCopy','AppId','AppId','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,230,'Hidden','','','','','','','Filter','Filter','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,240,'ComboBox','select AppId as Value, Name as Text from awApplication order by Name','','','','Select Application','','CopyId','AppId','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,250,'CheckBox','','','','','Copy ALL','','All','','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,260,'EditBox','','','','','Copy from Seq No','5','FromSeq','','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,270,'EditBox','','','','','Copy to Seq No','5','ToSeq','','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,280,'EditBox','','','','','New Start Seq No','5','Start','','','10')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,290,'EditBox','','','','','Seq No Increment','5','Inc','','','10')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,300,'Button','','','','','Copy Application','','','','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,310,'FormClose','','','','','','','','','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,320,'Html','<hr><b>Delete the range of Functions</b>','','','','','','','','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,330,'Form','','','','','','devAppFuncDelete','AppId','AppId','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,340,'EditBox','','1','','','From SeqNo','5','FromSeq','','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,350,'EditBox','','1','','','To SeqNo','5','ToSeq','','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,360,'Hidden','','','','','','','Filter','Filter','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,370,'Button','','','','','DELETE Functions','','','','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,380,'FormClose','','','','','','','','','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,390,'Html','<hr>','','','','','','','','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,400,'FolderClose','','','','','','','','','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,410,'DataClose','','','','','','','','','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,420,'Parameter','','','','','','','Filter','Filter','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,430,'Link','Add a new Function','','','','devFuncAdd','','AppId','AppId','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,440,'Parameter','','','','','','','AppId','AppId','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,450,'Parameter','','','','','','','Filter','Filter','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,460,'StoredProc','','','','','devAppEdit','1','@AppId','AppId','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,470,'Table','','','','','1','','#c0c0c0','','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,480,'TableField','SeqNo','','','','SeqNo','devFuncEdit','FuncId','FuncId','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,490,'TableField','Function','','','','Function','','','','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,500,'TableField','Text1','','','','Text1','','','','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,510,'TableField','Text2','','','','Text2','','','','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,520,'TableField','Text3','','','','Text3','','','','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,530,'TableField','Text4','','','','Text4','','','','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,540,'TableField','Memo1','','','','Memo1','','','','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,545,'TableField','Groups','','','','Groups','','','','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,550,'TableShow','','','','','','','','','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,560,'Parameter','','','','','','','Filter','Filter','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,570,'Link','Add a new Function','','','','devFuncAdd','','AppId','AppId','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,580,'DataClose','','','','','','','','','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,590,'Html','<br>','','','','','','','','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,600,'Parameter','','','','','','','Filter','Filter','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,610,'Link','Renumber the Sequence','','','','devFuncRenumber','','AppId','AppId','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,620,'Html','<hr><hr>','','','','','','','','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,630,'Folder','DELETE this Application','','','','','','','','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,640,'Parameter','','','','','','','Filter','Filter','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,650,'Link','Permanently DELETE this application','','','','devAppDelete','','AppId','AppId','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,660,'FolderClose','','','','','','','','','','')

--devAppFilter
select @AppId=AppId from awApplication where Name='devAppFilter'

insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,10,'Redirect','','','','','devAppBuilder','','Filter','Filter','','')

--devAppFuncDelete
select @AppId=AppId from awApplication where Name='devAppFuncDelete'

insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,10,'StoredProc','','','','','devFuncDelete','','@AppId','AppId','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,20,'StoredProcParam','','','','','','','@From','FromSeq','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,30,'StoredProcParam','','','','','','1','@To','ToSeq','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,40,'Parameter','','','','','','','Filter','Filter','','')
insert into awDetail(AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,50,'Redirect','','','','','devAppEdit','','AppId','AppId','','')

--devAppUpdate
select @AppId=AppId from awApplication where Name='devAppUpdate'

insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,10,'DataUpdate','','','','','awApplication','','AppId','AppId','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,20,'DataSetValue','','','','','Name','','','Name','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,30,'DataSetValue','','','','','Title','','','Title','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,40,'DataSetValue','','','','','Description','','','Description','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,50,'DataSetValue','','','','','Public','','','Public','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,60,'DataSetValue','','','','','NavBack','','','NavBack','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,70,'DataSetValue','','','','','PrintView','','','PrintView','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,80,'DataCommit','','','','','','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,90,'Parameter','','','','','','','AppId','AppId','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,100,'Redirect','','','','','devAppEdit','','Filter','Filter','','')

--devFuncAdd
select @AppId=AppId from awApplication where Name='devFuncAdd'

insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,10,'StoredProc','','','','','devGetNextSeqNo','1','@AppId','AppId','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,20,'DataAdd','','','','','awDetail','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,30,'DataSetValue','','','','','AppId','','','AppId','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,40,'DataSetValue','','','','','SeqNo','','','','NextSeqNo','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,50,'DataCommit','','','','','','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,60,'DataClose','','','','','','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,70,'Parameter','','','','','','','AppId','AppId','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,80,'SQL','select max(FuncId) as FuncId from awDetail','','','','AppId','','','AppId','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,90,'Parameter','','','','','','','Filter','Filter','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,100,'Redirect','','','','','devFuncEdit','','FuncId','','FuncId','')

--devFuncDelete
select @AppId=AppId from awApplication where Name='devFuncDelete'

insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,10,'DataDelete','','','','','awDetail','','FuncId','FuncId','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,20,'Parameter','','','','','','','Filter','Filter','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,30,'Redirect','','','','','devAppEdit','','AppId','AppId','','')

--devFuncEdit
select @AppId=AppId from awApplication where Name='devFuncEdit'

insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,10,'SQL','select * from awDetail','','','','FuncId','','','FuncId','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,20,'Form','','','','','','devFuncUpdate','FuncId','FuncId','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,30,'Hidden','','','','','','','AppId','AppId','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,40,'Hidden','','','','','','','Filter','Filter','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,50,'Html','<tr><td width="170"></td><td></td></tr><tr><td colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="0"><tr><td width="50%"><table border="0" width="100%"><tr><td width="170"></td><td></td></tr>','','','','','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,60,'EditBox','1','','','','Sequence Number','','SeqNo','','SeqNo','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,70,'DynamicList','select [Function] as Text, [Function] as Value, TextList, ValueList from awFunction where Active = 1 order by [Function]','','','','Function','','Function','','Function','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,80,'EditBox','','','','','@Text1','','Text1','','Text1','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,90,'EditBox','','','','','@Text2','','Text2','','Text2','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,100,'EditBox','','','','','@Text3','','Text3','','Text3','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,110,'Html','</table></td><td><table border="0" width="100%"><tr><td width="170"></td><td></td></tr>','','','','','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,120,'CheckBox','','','','','Add new Function','','NewFunction','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,130,'EditBox','','','','','@Text7','','Text7','','Text7','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,140,'EditBox','','','','','@Text4','','Text4','','Text4','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,150,'EditBox','','','','','@Text5','','Text5','','Text5','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,160,'EditBox','','','','','@Text6','','Text6','','Text6','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,170,'Html','</table></td></tr></table></td></tr>','','','','','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,180,'TextBox','3','','','','@Memo1','70','Memo1','','Memo1','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,190,'TextBox','2','','','','@Memo2','50','Memo2','','Memo2','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,200,'TextBox','2','','','','@Memo3','50','Memo3','','Memo3','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,210,'TextBox','2','','','','@Memo4','50','Memo4','','Memo4','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,220,'Button','','','','','Update Function','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,230,'FormClose','','','','','','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,240,'DataClose','','','','','','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,250,'Folder','Security Groups','','','','','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,260,'Html','<B>Add group access</b>','','','','','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,270,'Form','','','','','','devFuncGroupAdd','FuncId','FuncId','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,280,'Hidden','','','','','','','AppId','AppId','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,290,'Hidden','','','','','','','Action','','','1')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,300,'Hidden','','','','','','','Filter','Filter','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,310,'ComboBox','select Name as Text, GroupId as Value from awGroup order by Name','','','','Group','','GroupId','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,320,'Button','','','','','Add Group','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,330,'FormClose','','','','','','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,340,'Html','<hr><b>Select a group to remove</b>','','','','','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,350,'SQL','select awGroup.* from awGroup join awGroupDetail on awGroup.GroupId = awGroupDetail.GroupId','Name','','','FuncId','','','FuncId','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,360,'Parameter','','','','','','','AppId','AppId','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,370,'Parameter','','','','','','','Filter','Filter','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,380,'Parameter','','','','','','','Action','','','2')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,390,'Parameter','','','','','','','FuncId','FuncId','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,400,'Table','','','','','','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,410,'TableField','Group','','','','Name','devFuncGroupAdd','GroupId','GroupId','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,420,'TableShow','','','','','','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,430,'DataClose','','','','','','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,440,'FolderClose','','','','','','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,450,'Html','<hr>','','','','','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,460,'Parameter','','','','','','','AppId','AppId','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,470,'Parameter','','','','','','','Filter','Filter','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,480,'Link','Delete the Function','','','','devFuncDelete','','FuncId','FuncId','','')

--devFuncGroupAdd
select @AppId=AppId from awApplication where Name='devFuncGroupAdd'

insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,10,'StoredProc','','','','','devFuncGroupAdd','','@GroupId','GroupId','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,20,'StoredProcParam','','','','','','','@Action','Action','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,30,'StoredProcParam','','','','','','1','@FuncId','FuncId','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,40,'Parameter','','','','','','','AppId','AppId','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,50,'Parameter','','','','','','','FuncId','FuncId','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,60,'Redirect','','','','','devFuncEdit','','OpenFolder=0&Filter','Filter','','')

-- devFuncRenumber
select @AppId=AppId from awApplication where Name='devFuncRenumber'

insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,10,'StoredProc','','','','','devFuncRenumber','1','@AppId','AppId','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,20,'Parameter','','','','','','','Filter','Filter','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,30,'Redirect','','','','','devAppEdit','','AppId','AppId','','')

--devFuncUpdate
select @AppId=AppId from awApplication where Name='devFuncUpdate'

insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,10,'DataUpdate','','','','','awDetail','','FuncId','FuncId','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,20,'DataSetValue','','','','','SeqNo','','','SeqNo','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,30,'DataSetValue','','','','','Function','','','Function','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,40,'DataSetValue','','','','','Text1','','','Text1','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,50,'DataSetValue','','','','','Text2','','','Text2','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,60,'DataSetValue','','','','','Text3','','','Text3','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,70,'DataSetValue','','','','','Text4','','','Text4','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,80,'DataSetValue','','','','','Text5','','','Text5','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,90,'DataSetValue','','','','','Text6','','','Text6','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,100,'DataSetValue','','','','','Text7','','','Text7','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,110,'DataSetValue','','','','','Memo1','','','Memo1','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,120,'DataSetValue','','','','','Memo2','','','Memo2','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,130,'DataSetValue','','','','','Memo3','','','Memo3','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,140,'DataSetValue','','','','','Memo4','','','Memo4','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,150,'DataCommit','','','','','','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,160,'Parameter','','','','','','','Filter','Filter','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,170,'Parameter','','','','','','','NewFunction','NewFunction','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values(@AppId,180,'Redirect','','','','','devAppEdit','','AppId','AppId','','')

--devStoredProc
select @AppId=AppId from awApplication where Name='devStoredProc'

insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,10,'Form','','','','','','devStoredProcFilter','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,20,'ComboBox','select Id as Value, Name as Text from sysobjects where xtype=''P'' order by Name','','0','- New Procedure -','Load Stored Procedure','','ProcId','ProcId','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,30,'Button','','','','','Load','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,40,'FormClose','','','','','','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,50,'Html','<B>Edit the Stored Procedure</b>','','','','','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,60,'StoredProc','','','','','devGetProcedure','1','@ProcId','ProcId','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,70,'Form','','','','','0','devStoredProcSave','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,80,'TextBox','25','','Text2','Text2','','115','Text','','Text','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,90,'Button','','','','','Save Changes','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,100,'FormClose','','','','','','','','','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,110,'DataClose','','','','','','','','','','')

--devStoredProcFilter
select @AppId=AppId from awApplication where Name='devStoredProcFilter'

insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,10,'Redirect','','','','','devStoredProc','','ProcId','ProcId','','')

--devStoredProcSave
select @AppId=AppId from awApplication where Name='devStoredProcSave'

insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,10,'StoredProc','','','','','devStoredProc','','@Name','Name','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,20,'StoredProcParam','','','','','','','@Text2','Text2','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,30,'StoredProcParam','','','','','','1','@Text','Text','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,40,'Html','','','','','','','','Result','','')
insert into awDetail (AppId,SeqNo,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6)
 values (@AppId,50,'Redirect','','','','','devStoredProc','','','','','')

-- devTableViewer
select @AppId=AppId from awApplication where Name='devTableViewer'

insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,10,'Html','<B>View the Table Structure</b>','','','','','','','','','')
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,20,'Form','','','','','','devTableFilter','','','','')
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,30,'ComboBox','Select Id as Value, Name as Text from sysobjects where xtype in (''U'') order by Name','','0','- Select Table -','Load Table Structure','','TableId','TableId','','')
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,40,'Button','','','','','Select Table','','','','','')
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,50,'FormClose','','','','','','','','','','')
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,60,'Table','','','','','0','','','','','')
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,70,'SQL','Select Name, case Type when 56 then ''Int Identity'' when 39 then ''Varchar('' + cast(length as varchar(10)) + '')'' when 38 then ''Int'' when 106 then ''Decimal('' + cast(prec as varchar(10)) + '','' + cast(scale as varchar(10)) + '')'' when 111 then ''DateTime'' end as Type from sysColumns','ColOrder','','','Id','','','TableId','','')
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,80,'TableField','Field Name','','','','Name','','Name','Name','','')
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,90,'TableField','Field Type','','','','Type','','Type','Type','','')
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,100,'TableShow','','','','','','','','','','')

--devTableFilter
select @AppId = AppId from awApplication where Name = 'devTableFilter'

insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,10,'Redirect','','','','','devTableViewer','','TableId','TableId','','')

-- devSQL
select @AppId = AppId from awApplication where Name = 'devSQL'

insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,10,'Html','<B>SQL Query Utility</b>','','','','','','','','','')
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,20,'Form','','','','','','devSQL','','','','')
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,30,'TextBox','3','','','','SQL','60','SQL','SQL','','','1')
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,40,'Button','','','','','Execute','','','','','')
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,50,'FormClose','','','','','','','','','','')
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,60,'Html','<hr><B>Result</b><P><pre>','','','','','','','','','')
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,70,'StoredProc','','','','','devSQL','1','@SQL','SQL','','')
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,80,'ForSQL','','','','','','','','','','')
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,90,'Html','','','','','','','','','output','')
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,100,'NextSQL','','','','','','','','','','')
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,110,'DataClose','','','','','','','','','','')

-- devImportApp
select @AppId = AppId from awApplication where Name = 'devImportApp'

insert into awDetail (AppId, [Function], Memo1, Memo2, Memo3, Memo4, SeqNo, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,'Form','','','','',10,'','devImportAppUpdate','','','','')                                                 
insert into awDetail (AppId, [Function], Memo1, Memo2, Memo3, Memo4, SeqNo, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,'TextBox','25','','','',20,'Enter Information','110','Import','','','')                                    
insert into awDetail (AppId, [Function], Memo1, Memo2, Memo3, Memo4, SeqNo, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,'Button','','','','',30,'Import','','','','','')                                                           
insert into awDetail (AppId, [Function], Memo1, Memo2, Memo3, Memo4, SeqNo, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,'FormClose','','','','',40,'','','','','','')          

-- devImportAppUpdate
select @AppId = AppId from awApplication where Name = 'devImportAppUpdate'

insert into awDetail (AppId, [Function], Memo1, Memo2, Memo3, Memo4, SeqNo, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,'StoredProc','','','','',10,'devImportAppUpdate','1','@Import','Import','','')                             
insert into awDetail (AppId, [Function], Memo1, Memo2, Memo3, Memo4, SeqNo, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,'Redirect','','','','',20,'devImportApp','','','','','')    

-- devExportApp
select @AppId = AppId from awApplication where Name = 'devExportApp'

insert into awDetail (AppId, [Function], Memo1, Memo2, Memo3, Memo4, SeqNo, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,'Html','<B>Applications</B>','','','',10,'','','','','','')                                                
insert into awDetail (AppId, [Function], Memo1, Memo2, Memo3, Memo4, SeqNo, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,'Form','','','','',20,'','devExportAppFilter','','','','')                                                 
insert into awDetail (AppId, [Function], Memo1, Memo2, Memo3, Memo4, SeqNo, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,'ComboBox','select Name as Text, AppId as Value from awApplication','','','',30,'Select an Application','','AppId','AppId','','') 
insert into awDetail (AppId, [Function], Memo1, Memo2, Memo3, Memo4, SeqNo, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,'Button','','','','',40,'Select','','','','','')                                                           
insert into awDetail (AppId, [Function], Memo1, Memo2, Memo3, Memo4, SeqNo, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,'FormClose','','','','',50,'','','','','','')                                                              
insert into awDetail (AppId, [Function], Memo1, Memo2, Memo3, Memo4, SeqNo, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,'DataClose','','','','',60,'','','','','','')                                                              
insert into awDetail (AppId, [Function], Memo1, Memo2, Memo3, Memo4, SeqNo, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,'StoredProc','','','','',70,'devExportApp','1','@AppId','AppId','','')                                     
insert into awDetail (AppId, [Function], Memo1, Memo2, Memo3, Memo4, SeqNo, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,'Html','<hr>','','','',80,'','','','','','')                                                               
insert into awDetail (AppId, [Function], Memo1, Memo2, Memo3, Memo4, SeqNo, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,'TextBox','20','','','',90,'Application Information','120','Result','','Result','')  

-- devExportAppFilter
select @AppId = AppId from awApplication where Name = 'devExportAppFilter'

insert into awDetail (AppId, [Function], Memo1, Memo2, Memo3, Memo4, SeqNo, Text1, Text2, Text3, Text4, Text5, Text6)
 values (@AppId,'Redirect','','','','',10,'devExportApp','','AppId','AppId','','')                                         

-- devAppSQL
select @AppId = AppId from awApplication where Name='devAppSQL' 

insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,10,'Html','<B>Show the SQL to load the selected Application</b>','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,20,'Form','','','','','0','devAppSQLFilter','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,30,'ComboBox','select Name as Text, AppId as Value from awApplication order by Name','','','','Application','0','AppId','AppId','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,40,'Button','','','','','Show SQL','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,50,'FormClose','','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,60,'Html','<hr>','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,70,'StoredProc','','','','','devApplicationSQL','1','@AppId','AppId','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,80,'ForSQL','','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,90,'Html','<br>','','','','','','','','Text','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,100,'NextSQL','','','','','','','','','','','') 
insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,110,'DataClose','','','','','','','','','','','') 

-- devAppSQLFilter
select @AppId = AppId from awApplication where Name='devAppSQLFilter' 

insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)
 values (@AppId,10,'Redirect','','','','','devAppSQL','','AppId','AppId','','','') 

-- Default Groups
create table awGroup (
 GroupId		int identity(1,1) primary key,
 Name		varchar(20)
)

insert into awGroup (Name)
 values('Admin')
insert into awGroup (Name)
 values('Public')

-- User Table
create table awUser (
 UserId		int identity(1,1) primary key,
 Name		varchar(30),
 Surname	varchar(50),
 UserCount	int,
 AuthUser	varchar(50),
 Email		varchar(100),
 Password	varchar(50) default '',
 Session	int,
 LastDate	DateTime,
 Inactive	int,
 Note           varchar(200)
)

-- User Groups
create table awUserGroup (
 UserId		int,
 GroupId		int
)

-- User Nav
create table awUserNav (
 UserId		int,
 NavNo		int,
 URL		varchar(300),
 Title		varchar(100)
)

-- Group Details
create table awGroupDetail (
 GroupId		int,
 FuncId		int
)

-- awDebug
create table awDebug (
 LastFuncId	int
)

insert into awDebug 
 values (0)

-- awMail
create table awMail (
  MailId     int identity(1,1) primary key,
  Recipients varchar(1000),
  Subject    varchar(200),
  Message    varchar(8000),
  Source     varchar(100),
  UserId     int,
  Date       datetime
)

-- awHelp
create table awHelpCategory (
  CatId      int identity(1,1) primary key,
  Category   varchar(100)
)

create table awHelpDetail (
  DetId      int identity(1,1) primary key,
  CatId      int,
  Topic      varchar(200),
  Content    varchar(7000),
  AdminOnly  int
)

insert into awHelpCategory (Category) values ('AppWizard System Admin')

select @CatId = CatId
  from awHelpCategory
 where Category = 'AppWizard System Admin'



-- awApplicationStats
create table awApplicationStats (
  HitDate	DateTime,
  AppId		int,
  Cnt		int
)

-- Default Stored Procedures
go
------------------------------------------------------------------------------------
-- awAppFilter                                                                    --
--  2008 (c) Gateway Software                                                     --
--                                                                                --
-- This is a default AppWizard Stored Procedure and it could be affected by any   --
--  future updates or upgrades without notice.                                    --
--                                                                                --
-- WARNING!                                                                       --
--   Updates to this procedure could cause AppWizard to stop working as expected. --
------------------------------------------------------------------------------------
create procedure awAppFilter
 @Filter varchar(20)
 as
begin
 set NOCOUNT on

 select *
   from awApplication
  where Name like @Filter + '%'
 order by Name

 return 0
end

go
------------------------------------------------------------------------------------
-- awBackup                                                                       --
--  2008 (c) Gateway Software                                                     --
--                                                                                --
-- This is a default AppWizard Stored Procedure and it could be affected by any   --
--  future updates or upgrades without notice.                                    --
--                                                                                --
-- WARNING!                                                                       --
--   Updates to this procedure could cause AppWizard to stop working as expected. --
------------------------------------------------------------------------------------
create procedure awBackup
 as
begin
 set NOCOUNT on

 declare
  @File varchar(100)

 set @File = 'c:\mssql\AppWizard' + cast(Year(getdate()) as varchar(10)) 
              + Case when Month(getdate())<10 then '0' else '' end + cast(Month(getdate()) as varchar(10))
              + Case when Day(getdate())<10 then '0' else '' end + cast(Day(getdate()) as varchar(10))
              + Case when datepart(Hour,getdate())<10 then '0' else '' end + cast(datepart(Hour,getdate()) as varchar(10))
              + Case when datepart(Minute,getdate())<10 then '0' else '' end + cast(Datepart(Minute,getdate()) as varchar(10)) + '.bak'

 backup database Bthru to disk = @File with INIT, SKIP

 select 'OK' as Result

 return 0
end

go
------------------------------------------------------------------------------------
-- awGetApp                                                                       --
--  2008 (c) Gateway Software                                                     --
--                                                                                --
-- This is a default AppWizard Stored Procedure and it could be affected by any   --
--  future updates or upgrades without notice.                                    --
--                                                                                --
-- WARNING!                                                                       --
--   Updates to this procedure could cause AppWizard to stop working as expected. --
------------------------------------------------------------------------------------
create procedure awGetApp
 @AppId  int,
 @UserId int,
 @Goto int=-10000
 as
begin
 set NOCOUNT on

 -- Update Stats
 declare
   @HitDate datetime

 set @HitDate = convert(varchar(10),getdate(),120)

 if exists (select * from awApplicationStats where AppId = @Appid and HitDate = @HitDate)
   update awApplicationStats
      set Cnt = Cnt + 1
    where AppId = @AppId
      and HitDate = @HitDate
 else
   insert into awApplicationStats (HitDate, AppId, Cnt)
    values (@HitDate, @AppId, 1)

 -- Admin user or public app
 if exists (select * from awUserGroup where UserId = @UserId and GroupId = 1)
   or exists (select * from awApplication where AppId = @AppId and [Public] = 1)
 begin
  select awDetail.*
    from awDetail
   where AppId = @AppId
     and SeqNo >= @Goto
   order by SeqNo
 end else begin
 --Other users
  select distinct awDetail.*
    from awDetail
    join awGroupDetail
      on awDetail.FuncId = awGroupDetail.FuncId
     and awDetail.AppId = @AppId
     and awDetail.SeqNo >= @Goto
    left join awUserGroup
      on awUserGroup.GroupId = awGroupDetail.GroupId
     and awUserGroup.UserId = @UserId
   where awGroupDetail.GroupId = 2
      or awUserGroup.GroupId is not null
   order by SeqNo
 end
 return 0
end

go
------------------------------------------------------------------------------------
-- awUserRenumber                                                                 --
--  2008 (c) Gateway Software                                                     --
--                                                                                --
-- This is a default AppWizard Stored Procedure and it could be affected by any   --
--  future updates or upgrades without notice.                                    --
--                                                                                --
-- WARNING!                                                                       --
--   Updates to this procedure could cause AppWizard to stop working as expected. --
------------------------------------------------------------------------------------
create procedure awUserRenumber
as
begin
 set NOCOUNT on

 declare 
   @Cnt int,
   @UserId int

 set @Cnt = 10

 update awUser
    set UserCount = 100000
  where isnull(Inactive,0) = 1

 declare curNum cursor for
  select UserId
    from awUser
   order by isnull(UserCount,50000)

 open curNum
 while (1=1) begin
  fetch next from curNum into @UserId
  if @@fetch_status <> 0 break

  update awUser
     set UserCount = @Cnt
   where UserId = @UserId

  set @Cnt = @Cnt + 10
 end
 close curNum
 deallocate curNum

 return 0
end
go
------------------------------------------------------------------------------------
-- devAppCopy                                                                     --
--  2008 (c) Gateway Software                                                     --
--                                                                                --
-- This is a default AppWizard Stored Procedure and it could be affected by any   --
--  future updates or upgrades without notice.                                    --
--                                                                                --
-- WARNING!                                                                       --
--   Updates to this procedure could cause AppWizard to stop working as expected. --
------------------------------------------------------------------------------------
CREATE procedure devAppCopy
 @AppId   int,
 @CopyId  int,
 @All     int,
 @FromSeq int,
 @ToSeq   int,
 @Start   int,
 @Inc     int
 as
begin
 set NOCOUNT on

 declare
   @FuncId  int,
   @SeqNo   int

 declare curAppCopy cursor for
   select FuncId, SeqNo
     from awDetail
    where Appid  = @CopyId
    order by SeqNo

 open curAppCopy
 while (1=1) begin
   fetch next from curAppCopy into @FuncId, @SeqNo
   if @@fetch_Status <> 0 break

   if (@All = 1) or ((@SeqNo >= @FromSeq) and (@SeqNo <= @ToSeq)) begin

   insert into awDetail (AppId,SeqNo,  [Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6,Text7)
  select @AppId,
        @Start,[Function],Memo1,Memo2,Memo3,Memo4,Text1,Text2,Text3,Text4,Text5,Text6,Text7
    from awDetail
   where FuncId = @FuncId

   set @Start = @Start + @Inc
  end

 end
 close curAppCopy
 deallocate curAppCopy

 select 'OK' as result

 return 0
end

go
------------------------------------------------------------------------------------
-- devFuncGroupAdd                                                                --
--  2008 (c) Gateway Software                                                     --
--                                                                                --
-- This is a default AppWizard Stored Procedure and it could be affected by any   --
--  future updates or upgrades without notice.                                    --
--                                                                                --
-- WARNING!                                                                       --
--   Updates to this procedure could cause AppWizard to stop working as expected. --
------------------------------------------------------------------------------------
create procedure devFuncGroupAdd
 @FuncId  int,
 @GroupId int,
 @Action  int
 as
begin
 set NOCOUNT on

 if @Action = 1 begin
   if not exists (select * from awGroupDetail where GroupId = @GroupId and FuncId = @FuncId)
     insert into awGroupDetail (GroupId, FuncId) values (@GroupId, @FuncId)
 end else
   delete from awGroupDetail
    where GroupId = @GroupId
      and FuncId  = @FuncId

 select 'OK' as Result

 return 0
end

go
------------------------------------------------------------------------------------
-- devGetNextSeqNo                                                                --
--  2008 (c) Gateway Software                                                     --
--                                                                                --
-- This is a default AppWizard Stored Procedure and it could be affected by any   --
--  future updates or upgrades without notice.                                    --
--                                                                                --
-- WARNING!                                                                       --
--   Updates to this procedure could cause AppWizard to stop working as expected. --
------------------------------------------------------------------------------------
create procedure devGetNextSeqNo
 @AppId int
 as
begin
 set NOCOUNT on

 declare
  @SeqNo int

 select @SeqNo = max(SeqNo)
   from awDetail
  where AppId = @AppId

 set @SeqNo = isnull(@SeqNo,0)/10
 set @SeqNo = @SeqNo * 10 + 10

 select isnull(@SeqNo,10) as NextSeqNo

 return 0
end

go
------------------------------------------------------------------------------------
-- devGetProcedure                                                                --
--  2008 (c) Gateway Software                                                     --
--                                                                                --
-- This is a default AppWizard Stored Procedure and it could be affected by any   --
--  future updates or upgrades without notice.                                    --
--                                                                                --
-- WARNING!                                                                       --
--   Updates to this procedure could cause AppWizard to stop working as expected. --
------------------------------------------------------------------------------------
create procedure devGetProcedure
 @ProcId int
as
begin
 set NOCOUNT on

 declare
  @Name varchar(100),
  @Text varchar(8000),
  @Text2 varchar(8000),
  @Text3 varchar(8000),
  @Text4 varchar(8000)

 select @Text = C.Text, 
        @Name = O.Name 
  from syscomments C 
  join sysobjects O 
    on C.Id = O.Id
   and C.Id = @ProcId
   and ColId = 1

 set @Text = replace(@Text,'create procedure','alter procedure')

 select @Text2 = Text
   from syscomments
  where ColId = 2 
    and Id = @ProcId

 select @Text3 = Text
   from syscomments
  where ColId = 3 
    and Id = @ProcId

 select @Text4 = Text
   from syscomments
  where ColId = 4 
    and Id = @ProcId

 select @Text+isnull(@Text2,'') as Text, @Name as Name, @ProcId as Id, isnull(@Text3,'') + isnull(@Text4,'') as Text2

 return 0
end
go
------------------------------------------------------------------------------------
-- devStoredProc                                                                  --
--  2008 (c) Gateway Software                                                     --
--                                                                                --
-- This is a default AppWizard Stored Procedure and it could be affected by any   --
--  future updates or upgrades without notice.                                    --
--                                                                                --
-- WARNING!                                                                       --
--   Updates to this procedure could cause AppWizard to stop working as expected. --
------------------------------------------------------------------------------------
create procedure devStoredProc
 @Name	varchar(100),
 @Text	varchar(8000),
 @Text2 varchar(8000)
as
begin
 set NOCOUNT on

 declare @Var varchar(200)

 if @Name <> '' begin
   set @Var = 'drop procedure ' + @Name
   exec (@Var)
 end

 set @Text = isnull(@Text,'')
 set @Text2 = isnull(@Text2,'')

 if @Text <> ''
   exec (@Text + @Text2)

 select @@Error as Result

 return 0
end
go
------------------------------------------------------------------------------------
-- devFuncDelete                                                                  --
--  2008 (c) Gateway Software                                                     --
--                                                                                --
-- This is a default AppWizard Stored Procedure and it could be affected by any   --
--  future updates or upgrades without notice.                                    --
--                                                                                --
-- WARNING!                                                                       --
--   Updates to this procedure could cause AppWizard to stop working as expected. --
------------------------------------------------------------------------------------
create procedure devFuncDelete
 @AppId int,
 @From  int,
 @To    int
as
begin
 set NOCOUNT on

 delete from awDetail
  where AppId = @AppId
    and SeqNo >= @From
    and SeqNo <= @To

 select 'OK' as Result

 return 0
end
go
------------------------------------------------------------------------------------
-- devFuncRenumber                                                                --
--  2008 (c) Gateway Software                                                     --
--                                                                                --
-- This is a default AppWizard Stored Procedure and it could be affected by any   --
--  future updates or upgrades without notice.                                    --
--                                                                                --
-- WARNING!                                                                       --
--   Updates to this procedure could cause AppWizard to stop working as expected. --
------------------------------------------------------------------------------------
create procedure devFuncRenumber
 @AppId int
as
begin
 set NOCOUNT on
 
 declare
  @Cnt int,
  @FuncId int

 create table #Detail (
  FuncId int,
  SeqNo int
 )

 insert into #Detail
  select FuncId,SeqNo
    from awDetail
   where AppId = @AppId

 set @Cnt = 10

 update awDetail
    set GotoFuncId = D2.FuncId
   from awDetail D
   join #Detail D2
     on D.[Function] = 'IfGoto'
    and cast(D.Text3 as int) = D2.SeqNo
    and D.AppId = @AppId

 declare curDet cursor for
  select FuncId
    from awDetail
   where AppId = @AppId
   order by SeqNo
 open curDet
 while (1=1) begin
  fetch next from curDet into @FuncId
  if @@fetch_status <> 0 break
  update awDetail
     set SeqNo = @Cnt
   where FuncId = @FuncId

  set @Cnt = @Cnt + 10
 end
 close curDet
 deallocate curDet

 truncate table #Detail
 insert into #Detail
  select FuncId,SeqNo
    from awDetail
   where AppId = @AppId

 update awDetail
    set Text3 = cast(D2.SeqNo as varchar(10))
   from awDetail D
   join #Detail D2
     on D.[Function] = 'IfGoto'
    and D.GotoFuncId = D2.FuncId
    and D.AppId = @AppId

 select 'OK' as Result

 return 0
end
go
------------------------------------------------------------------------------------
-- devAppEdit                                                                     --
--  2008 (c) Gateway Software                                                     --
--                                                                                --
-- This is a default AppWizard Stored Procedure and it could be affected by any   --
--  future updates or upgrades without notice.                                    --
--                                                                                --
-- WARNING!                                                                       --
--   Updates to this procedure could cause AppWizard to stop working as expected. --
------------------------------------------------------------------------------------
create procedure devAppEdit
 @AppId int
as
begin
 set NOCOUNT on

 create table #SecNames (
  FuncId int,
  Groups varchar(2000)
 )

 insert into #SecNames
  select FuncId, '' 
    from awDetail 
   where AppId = @AppId

 declare
  @FuncId int,
  @Name varchar(50)

 declare curFuncs cursor for
  select S.FuncId, G.Name
    from #SecNames S
    join awGroupDetail D
      on S.FuncId = D.FuncId
    join awGroup G
      on G.GroupId = D.GroupId
   order by S.FuncId, G.Name

 open curFuncs
 while (1=1) begin
  fetch next from curFuncs into @FuncId, @Name
  if @@fetch_status <> 0 break

  update #SecNames
     set Groups = Groups + case when Groups <> '' then ', ' else '' end + @Name
   where FuncId = @FuncId
 end
 close curFuncs
 deallocate curFuncs

 select D.*, isnull(S.Groups,'') as Groups
   from awDetail D
   join #SecNames S
     on D.FuncId = S.FuncId
  order by D.SeqNo

 return 0
end
go
------------------------------------------------------------------------------------
-- devExportApp                                                                   --
--  2008 (c) Gateway Software                                                     --
--                                                                                --
-- This is a default AppWizard Stored Procedure and it could be affected by any   --
--  future updates or upgrades without notice.                                    --
--                                                                                --
-- WARNING!                                                                       --
--   Updates to this procedure could cause AppWizard to stop working as expected. --
------------------------------------------------------------------------------------
create procedure devExportApp
  @AppId int
 as
begin
  set nocount on

  create table #Result (
    SeqNo int identity(1,1),
    Text varchar(1000)
  )

  insert into #Result (Text)
    select '"'+Name+'","'+isnull(Title,'')+'","'+isnull(Description,'')+'",'+cast([Public] as varchar(10))+
           ','+cast(NavBack as varchar(10))+','+cast(isnull(PrintView,0) as varchar(10))
      from awApplication
     where AppId = @AppId

  insert into #Result (Text)
  select cast(SeqNo as varchar(10))+',"'+[Function]+'","'+Memo1+'","'+Memo2+'","'+Memo3+'","'+Memo4+'","'+
              Text1+'","'+Text2+'","'+Text3+'","'+Text4+'","'+Text5+'","'+Text6+'"'
    from awDetail
   where AppId = @AppId
   order by SeqNo

  while exists (select * from #Result where charindex(char(13),Text)>0) begin
    update #Result
       set Text = substring(Text,1,charindex(char(13),Text)-1) + ' ' + substring(Text,charindex(char(13),Text)+1,1000)
     where charindex(char(13),Text)>0
  end

  while exists (select * from #Result where charindex(char(10),Text)>0) begin
    update #Result
       set Text = substring(Text,1,charindex(char(10),Text)-1) + ' ' + substring(Text,charindex(char(10),Text)+1,1000)
     where charindex(char(10),Text)>0
  end

  while exists (select * from #Result where charindex(char(8),Text)>0) begin
    update #Result
       set Text = substring(Text,1,charindex(char(8),Text)-1) + ' ' + substring(Text,charindex(char(8),Text)+1,1000)
     where charindex(char(8),Text)>0
  end

  while exists (select * from #Result where charindex('  ',Text)>0) begin
    update #Result
       set Text = substring(Text,1,charindex('  ',Text)-1) + ' ' + substring(Text,charindex('  ',Text)+2,1000)
     where charindex('  ',Text)>0
  end

  declare @Result varchar(8000), @Text varchar(1000)

  declare curTable cursor for
    select Text
      from #Result
     order by SeqNo

  set @Result = ''

  open curTable

  while (1=1) begin
    fetch next from curTable
      into @Text

    if @@fetch_status<>0
      break

    set @Result = @Result + @Text + char(13) + char(10)
    
  end

  close curTable
  deallocate curTable

  select @Result as Result

  return 0
end
go
------------------------------------------------------------------------------------
-- devImportAppUpdate                                                             --
--  2008 (c) Gateway Software                                                     --
--                                                                                --
-- This is a default AppWizard Stored Procedure and it could be affected by any   --
--  future updates or upgrades without notice.                                    --
--                                                                                --
-- WARNING!                                                                       --
--   Updates to this procedure could cause AppWizard to stop working as expected. --
------------------------------------------------------------------------------------
create procedure devImportAppUpdate
  @Import varchar(8000)
  as
begin
  set nocount on

  declare
    @Sub varchar(1000),
    @AppId int,
    @Name varchar(50),
    @Title varchar(50),
    @Description varchar(200),
    @Public varchar(10),
    @NavBack varchar(10),
    @PrintView varchar(10),
    @SeqNo varchar(10),
    @Function varchar(20),
    @Memo1 varchar(3000),
    @Memo2 varchar(1500),
    @Memo3 varchar(1000),
    @Memo4 varchar(1000),
    @Text1 varchar(200),
    @Text2 varchar(200),
    @Text3 varchar(200),
    @Text4 varchar(200),
    @Text5 varchar(200),
    @Text6 varchar(200)

  set @Sub = substring(@Import,2,charindex(char(13),@Import)-2)
  set @Import = substring(@Import,charindex(char(13),@Import)+2,8000)

  set @Name = substring(@Sub,1,charindex('","',@Sub)-1)
  set @Sub = substring(@Sub,charindex('","',@Sub)+3,1000)
  set @Title = substring(@Sub,1,charindex('","',@Sub)-1)
  set @Sub = substring(@Sub,charindex('","',@Sub)+3,1000)
  set @Description = substring(@Sub,1,charindex('",',@Sub)-1)
  set @Sub = substring(@Sub,charindex('",',@Sub)+2,1000)
  set @Public = substring(@Sub,1,charindex(',',@Sub)-1)
  set @Sub = substring(@Sub,charindex(',',@Sub)+1,1000)
  set @NavBack = substring(@Sub,1,charindex(',',@Sub)-1)
  set @PrintView = rtrim(substring(@Sub,charindex(',',@Sub)+1,1000))

  if exists (select * from awApplication where Name = @Name) begin
    update awApplication
       set Title = @Title,
           Description = @Description,
           [Public] = @Public,
           [NavBack] = @NavBack,
           PrintView = @PrintView
     where Name = @Name
    
  end else begin
    insert into awApplication (Name, Title, Description, [Public], [NavBack], PrintView)
      values (@Name, @Title, @Description, @Public, @NavBack, @PrintView)
  end

  select @AppId = AppId
    from awApplication
   where Name = @Name

  delete from awDetail
   where AppId = @AppId

  while (charindex(char(13),@Import)>0) begin
    set @Sub = substring(@Import,1,charindex(char(13),@Import)-2)
    set @Import = substring(@Import,charindex(char(13),@Import)+2,8000)

    set @SeqNo = substring(@Sub,1,charindex(',',@Sub)-1)
    set @Sub = substring(@Sub,charindex(',"',@Sub)+2,1000)
    set @Function = substring(@Sub,1,charindex('","',@Sub)-1)
    set @Sub = substring(@Sub,charindex('","',@Sub)+3,1000)
    set @Memo1 = substring(@Sub,1,charindex('","',@Sub)-1)
    set @Sub = substring(@Sub,charindex('","',@Sub)+3,1000)
    set @Memo2 = substring(@Sub,1,charindex('","',@Sub)-1)
    set @Sub = substring(@Sub,charindex('","',@Sub)+3,1000)
    set @Memo3 = substring(@Sub,1,charindex('","',@Sub)-1)
    set @Sub = substring(@Sub,charindex('","',@Sub)+3,1000)
    set @Memo4 = substring(@Sub,1,charindex('","',@Sub)-1)
    set @Sub = substring(@Sub,charindex('","',@Sub)+3,1000)
    set @Text1 = substring(@Sub,1,charindex('","',@Sub)-1)
    set @Sub = substring(@Sub,charindex('","',@Sub)+3,1000)
    set @Text2 = substring(@Sub,1,charindex('","',@Sub)-1)
    set @Sub = substring(@Sub,charindex('","',@Sub)+3,1000)
    set @Text3 = substring(@Sub,1,charindex('","',@Sub)-1)
    set @Sub = substring(@Sub,charindex('","',@Sub)+3,1000)
    set @Text4 = substring(@Sub,1,charindex('","',@Sub)-1)
    set @Sub = substring(@Sub,charindex('","',@Sub)+3,1000)
    set @Text5 = substring(@Sub,1,charindex('","',@Sub)-1)
    set @Text6 = substring(@Sub,charindex('","',@Sub)+3,1000)

    insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6)
      values (@AppId, @SeqNo, @Function, @Memo1, @Memo2, @Memo3, @Memo4, @Text1, @Text2, @Text3, @Text4, @Text5, @Text6)

  end

  select 'OK' as Result
  return 0
end
go
------------------------------------------------------------------------------------
-- devSQL                                                                         --
--  2008 (c) Gateway Software                                                     --
--                                                                                --
-- This is a default AppWizard Stored Procedure and it could be affected by any   --
--  future updates or upgrades without notice.                                    --
--                                                                                --
-- WARNING!                                                                       --
--   Updates to this procedure could cause AppWizard to stop working as expected. --
------------------------------------------------------------------------------------
create procedure devSQL
 @SQL varchar(1000)
as
begin
 set NOCOUNT on

 declare
  @Cmd varchar(2000)

 create table #Output (
  seqNo int identity(1,1),
  output varchar(5000)
 )

 set @Cmd = 'osql -U sa -P sa -d AppWizard -w 200 -m-1 -Q "exit(' + @SQL + ')"'

 insert into #output (output)
  exec master.dbo.xp_cmdshell @Cmd

 select rtrim(output) as output
   from #Output
  order by SeqNo

 return 0
end
go
------------------------------------------------------------------------------------
-- devApplicationSQL                                                              --
--  2008 (c) Gateway Software                                                     --
--                                                                                --
-- This is a default AppWizard Stored Procedure and it could be affected by any   --
--  future updates or upgrades without notice.                                    --
--                                                                                --
-- WARNING!                                                                       --
--   Updates to this procedure could cause AppWizard to stop working as expected. --
------------------------------------------------------------------------------------
create procedure devApplicationSQL
 @AppId int
as
begin
 set NOCOUNT on
 
 create table #App (
   SeqNo int identity(1,1),
   Text varchar(2000)
 )

 insert into #App (Text)
  values ('-- Declare');
 
 insert into #App (Text)
  values ('--  @AppId int');

 insert into #App (Text)
  select 'if exists (select * from awApplication where Name=''' + Name + ''') begin'
    from awApplication
   where AppId = @AppId

 insert into #App (Text)
  select '&nbsp;update awApplication<br>'
         + '&nbsp;&nbsp;&nbsp;&nbsp;set Title=''' + replace(Title,'''','''''') + ''',<br>'
         + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Description=''' + replace(Description,'''','''''') + ''',<br>'
         + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[Public]=' + cast([Public] as varchar(10)) + ',<br>'
         + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NavBack=' + cast(NavBack as varchar(10)) + ',<br>'
         + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PrintView=' + cast(PrintView as varchar(10)) + '<br>'
         + '&nbsp;&nbsp;where Name=''' + Name + ''''
    from awApplication
   where AppId = @AppId
 
 insert into #App (Text)
  values ('end else begin');
 
 insert into #App (Text)
  select '&nbsp;insert into awApplication (Name, Title, Description, [Public], NavBack, PrintView)<br>&nbsp;&nbsp;values(''' 
         + Name + ''',''' + replace(Title,'''','''''') + ''',''' + replace(Description,'''','''''') + ''','
         + cast([Public] as varchar(10)) + ',' + cast(NavBack as varchar(10)) + ','
         + cast(PrintView as varchar(10)) + ')'
    from awApplication
   where AppId = @AppId

 insert into #App (Text)
  values ('end<br>');

 insert into #App (Text)
  select 'select @AppId = AppId from awApplication where Name=''' + Name + '''<br>'
    from awApplication
   where AppId = @AppId

 insert into #App (Text)
  values ('delete from awDetail where AppId = @AppId<br>');

 insert into #App (Text)
  select 'insert into awDetail (AppId, SeqNo, [Function], Memo1, Memo2, Memo3, Memo4, Text1, Text2, Text3, Text4, Text5, Text6, Text7)<br>&nbsp;values (@AppId,' + cast(SeqNo as varchar(10)) + ',''' + [Function] + ''','''
      + isnull(Replace(Replace(Memo1,'''',''''''),'<','&lt;'),'') + ''','''
      + isnull(Replace(Replace(Memo2,'''',''''''),'<','&lt;'),'') + ''','''
      + isnull(Replace(Replace(Memo3,'''',''''''),'<','&lt;'),'') + ''','''
      + isnull(Replace(Replace(Memo4,'''',''''''),'<','&lt;'),'') + ''','''
      + isnull(Replace(Replace(Text1,'''',''''''),'<','&lt;'),'') + ''','''
      + isnull(Replace(Replace(Text2,'''',''''''),'<','&lt;'),'') + ''','''
      + isnull(Replace(Replace(Text3,'''',''''''),'<','&lt;'),'') + ''','''
      + isnull(Replace(Replace(Text4,'''',''''''),'<','&lt;'),'') + ''','''
      + isnull(Replace(Replace(Text5,'''',''''''),'<','&lt;'),'') + ''','''
      + isnull(Replace(Replace(Text6,'''',''''''),'<','&lt;'),'') + ''','''
      + isnull(Replace(Replace(Text7,'''',''''''),'<','&lt;'),'') + ''')'
    from awDetail
   where AppId = @AppId
   order by SeqNo


 select Text
   from #App
  order by SeqNo 

 return 0
end
go
------------------------------------------------------------------------------------
-- awHelpFilter                                                                   --
--  2008 (c) Gateway Software                                                     --
--                                                                                --
-- This is a default AppWizard Stored Procedure and it could be affected by any   --
--  future updates or upgrades without notice.                                    --
--                                                                                --
-- WARNING!                                                                       --
--   Updates to this procedure could cause AppWizard to stop working as expected. --
------------------------------------------------------------------------------------
create procedure awHelpFilter
 @CatId int,
 @UserId int
as
begin
 set NOCOUNT on

 declare
  @IsAdmin int

 set @IsAdmin = 0
 
 if exists (select * from awUserGroup where UserId = @UserId and GroupId = 1)
  set @IsAdmin = 1

 select DetId, Topic
   from awHelpDetail
  where CatId = @CatId
    and 1 = case when isnull(AdminOnly,0) = 1 AND @IsAdmin = 0 then 0 else 1 end
  order by Topic

 return 0
end
go
------------------------------------------------------------------------------------
-- awSendMail                                                                     --
--  2008 (c) Gateway Software                                                     --
--                                                                                --
-- This is a default AppWizard Stored Procedure and it could be affected by any   --
--  future updates or upgrades without notice.                                    --
--                                                                                --
-- WARNING!                                                                       --
--   Updates to this procedure could cause AppWizard to stop working as expected. --
------------------------------------------------------------------------------------
create procedure awSendMail
 @To   varchar(1000),
 @Name varchar(100) = 'AppWizard',
 @Subject varchar(200),
 @Message varchar(7000),
 @Source  varchar(100),
 @UserId int
as
begin
 set NOCOUNT on

 insert into awMail (Recipients, Subject, Message, Source, UserId, Date)
  values (@To, @Subject, @Message, @Source, @UserId, getdate())

 -- Install the xp_smtp_sendmail procedure before enabling the section below
 /*
  exec master.dbo.xp_smtp_sendmail
        @From = 'SQLService@company.co.za',  -- Change to the correct from address
        @From_Name = @Name,
        @To = @To,
        @Subject = @Subject,
        @Message = @Message,
        @Type = 'text/html',
        @Server = '123.123.123.123'          -- Change to the correct routing server
        
 */

 select 'OK' as Result

 return 0
end
go

print 'Installation of AppWizard 4.01 completed.'