HOME
User:
Anonymous
search for
in
Template Archives
Templates
Articles
Users
Login
Username:
Password:
Navigation
Registered User Functions:
Register New Account
Anonymous Functions:
Home
Users
Archives
Templates
Articles
MyGeneration Website
MyGeneration Forums
Categories
Application Type
Command Line
Graphical User Interface
Library
Sample
Web Application
Architecture Type
Client-Server
Distributed Computing
Multi-Tier
Peer-to-peer
Operating System
Linux
Win32
Programming Language
ASP
ASP.Net
C#
C++
Firebird SQL
J#
Java
Jet SQL
JScript
JSP
MySQL
Perl
PHP
PL/SQL
PostgreSQL
SQL
Transact-SQL
VB.Net
VBScript
XSLT
Template: Firebird With Enterprise Library - 2.0
Download Count:
439
View Count:
991
Template Properties
Unique ID:
f6e0ddfc-8d06-4f67-86e6-2f6275bfc9bf
Title:
Firebird With Enterprise Library - 2.0
Namespace:
RobertoSistemas
Output Language:
VB.Net
Mode:
Markup
Start Tag:
<%
End Tag:
%>
Template Body
Engine:
Microsoft Script
Language:
VBScript
<% '----------------------------------------------------------------------------- ' Developer: Roberto Carlos ' E-Mail: robertosistemas@gmail.com '----------------------------------------------------------------------------- Dim bFirst Dim name Dim pname Dim objTable Dim objColumn Dim tableNames Dim language Dim databaseName Dim database Dim Namespace Dim NamespaceDAL Dim Imports Dim ImportsDAL Dim props Dim bOtherColumns Dim IDbCommand Dim IDataParameter Dim ParameterPrefix Dim prefix Dim dialect Dim PosicionalParameter Dim LevelCode Dim exportPath Dim exportPathDAL Dim exportfileName LevelCode = 0 ' Grab the Namespace Namespace = input.Item("txtNamespace") NamespaceDAL = input.Item("txtNamespaceDAL") Imports = input.Item("txtImports") ImportsDAL = input.Item("txtImportsDAL") prefix = input.Item("prefix") dialect = 1 If input.Item("ckDialect3") Then dialect = 3 End If PosicionalParameter = input.Item("chkPosicional") ' Set the Language for our column data types ' Grab the choices the user made in our UI Script (see Interface Code tab) Set tableNames = input.Item("lstTables") databaseName = input.Item("cmbDatabase") Set database = MyMeta.Databases(databaseName) exportPath = input.item("txtPath") If InStrRev(exportPath, "\") <> Len(exportPath) Then exportPath = exportPath & "\" End If exportPathDAL = input.item("txtPathDAL") If InStrRev(exportPathDAL, "\") <> Len(exportPathDAL) Then exportPathDAL = exportPathDAL & "\" End If LevelCode = 0 output.tabLevel = LevelCode %>Option Explicit On Option Strict On Imports System.Collections.Generic <% if ImportsDAL <> "" then LevelCode = 0 output.tabLevel = LevelCode output.autoTabLn "Imports " & ImportsDAL end if if NamespaceDAL <> "" then LevelCode = 0 output.tabLevel = LevelCode output.autoTabLn "Namespace " & NamespaceDAL LevelCode = 1 output.tabLevel = LevelCode end if %> Partial Public Class MethodResult Private _Messages As List(Of String) Public Sub New() _Messages = New List(Of String) End Sub Public Property Messages() As List(Of String) Get Return _Messages End Get Set(ByVal value As List(Of String)) _Messages = value End Set End Property End Class <% if NamespaceDAL <> "" then LevelCode = 0 output.tabLevel = LevelCode output.autoTabLn "End Namespace" end if exportfileName = "MethodResult.vb" output.save exportPathDAL & exportfileName, false buffer = buffer & output.text output.clear %>Option Explicit On Option Strict On Imports System.Configuration <% 'if NamespaceDAL <> "" then ' LevelCode = 0 ' output.tabLevel = LevelCode ' output.autoTabLn "Namespace " & NamespaceDAL ' LevelCode = 1 ' output.tabLevel = LevelCode 'end if LevelCode = 0 output.tabLevel = LevelCode output.autoTabLn "Namespace Config" %> Public Class DalConfig Private Shared _Instancia As DalConfig Private Shared _ConnectionName As String = String.Empty Private Shared _ProviderName As String = String.Empty Private Shared _ConnectionString As String = String.Empty Private Shared _LockObject As New Object Private Sub New() Carrega() End Sub Private Sub Carrega() Dim mConfig As New Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings mConfig = CType(ConfigurationManager.GetSection("dataConfiguration"), Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings) Me.ConnectionName = mConfig.DefaultDatabase Me.ProviderName = ConfigurationManager.ConnectionStrings(Me.ConnectionName).ProviderName Me.ConnectionString = ConfigurationManager.ConnectionStrings(Me.ConnectionName).ConnectionString End Sub Public Shared ReadOnly Property Instancia() As DalConfig Get SyncLock _LockObject If _Instancia Is Nothing Then _Instancia = New DalConfig() End If Return _Instancia End SyncLock End Get End Property Public Property ConnectionName() As String Get Return _ConnectionName End Get Set(ByVal value As String) _ConnectionName = value End Set End Property Public Property ProviderName() As String Get Return _ProviderName End Get Set(ByVal value As String) _ProviderName = value End Set End Property Public Property ConnectionString() As String Get Return _ConnectionString End Get Set(ByVal value As String) _ConnectionString = value End Set End Property End Class <% LevelCode = 0 output.tabLevel = LevelCode output.autoTabLn "End Namespace" 'if NamespaceDAL <> "" then ' LevelCode = 0 ' output.tabLevel = LevelCode ' output.autoTabLn "End Namespace" 'end if exportfileName = "DalConfig.vb" output.save exportPathDAL & exportfileName, false buffer = buffer & output.text output.clear '----------------------------------------------------------------------------- ' Loop through the tables the user selected and generate the business entities For intLp = 0 To tableNames.Count - 1 Set objTable = database.Tables(tablenames.item(intLp)) Set props = objTable.Properties bOtherColumns = (objTable.Columns.Count > objTable.PrimaryKeys.Count) LevelCode = 0 output.tabLevel = LevelCode %>Option Explicit On Option Strict On Imports System.ComponentModel <% LevelCode = 0 output.tabLevel = LevelCode if Imports <> "" then LevelCode = 0 output.tabLevel = LevelCode output.autoTabLn "Imports " & Imports end if if Namespace <> "" then output.autoTabLn "Namespace " & Namespace LevelCode = 1 output.tabLevel = LevelCode end if if prefix then output.autoTabLn "Public Interface _I" & GetObjectName(objTable) else output.autoTabLn "Public Interface I" & GetObjectName(objTable) End If %>#Region "Properties" <% For mColIndex = 0 to objTable.Columns.Count - 1 Set objColumn = objTable.Columns(mColIndex) output.tabLevel = LevelCode + 1 output.autoTabLn "" output.autoTab "<DataObjectField(" if objColumn.IsInPrimaryKey then output.write "True, True" Else output.write "False, False" End If if objColumn.IsNullable then output.write ", True" Else output.write ", False" End If if objColumn.CharacterMaxLength > 0 then output.write ", " & objColumn.CharacterMaxLength End If output.writeln ")> _" '& vbcrlf output.autoTab "Property " & GetPublicName(objColumn) & "() As " if objColumn.IsNullable then if objColumn.LanguageType = "String" then output.writeln objColumn.LanguageType Elseif objColumn.LanguageType = "Byte()" then output.writeln objColumn.LanguageType else output.writeln "Nullable(Of " & objColumn.LanguageType & ")" end if else output.writeln objColumn.LanguageType end if Next %> #End Region <% ' finaliazar entidade output.tabLevel = LevelCode output.autoTabLn "End Interface" output.writeln "" if prefix then output.autoTabLn "Partial Public Class _" & GetObjectName(objTable) output.tabLevel = LevelCode + 1 output.autoTabLn "Implements _I" & GetObjectName(objTable) else output.autoTabLn "Partial Public Class " & GetObjectName(objTable) output.tabLevel = LevelCode + 1 output.autoTabLn "Implements I" & GetObjectName(objTable) End If %> #Region "Table Name" <% output.tabLevel = LevelCode + 1 output.autoTabLn "Public Shared ReadOnly c" & GetObjectName(objTable) & " As String = """ & GetObjectName(objTable) & """" %>#End Region #Region "Column Names" <% output.tabLevel = LevelCode + 1 For mColIndex = 0 to objTable.Columns.Count - 1 Set objColumn = objTable.Columns(mColIndex) output.autoTabLn "Public Shared ReadOnly c" & GetDbName(objColumn) & " As String = """ & GetDbName(objColumn) & """" Next %>#End Region #Region "Private Members" <% output.tabLevel = LevelCode + 1 For mColIndex = 0 to objTable.Columns.Count - 1 Set objColumn = objTable.Columns(mColIndex) if objColumn.IsNullable then if objColumn.LanguageType = "String" then output.autoTabLn "Private " & GetPrivateName(objColumn) & " As " & objColumn.LanguageType Elseif objColumn.LanguageType = "Byte()" then output.autoTabLn "Private " & GetPrivateName(objColumn) & " As " & objColumn.LanguageType else output.autoTabLn "Private " & GetPrivateName(objColumn) & " As Nullable(Of " & objColumn.LanguageType & ")" End If else output.autoTabLn "Private " & GetPrivateName(objColumn) & " As " & objColumn.LanguageType end if Next %>#End Region #Region "Public Properties" <% For mColIndex = 0 to objTable.Columns.Count - 1 Set objColumn = objTable.Columns(mColIndex) output.tabLevel = LevelCode + 1 output.autoTabLn "" output.autoTab "<DataObjectField(" if objColumn.IsInPrimaryKey then output.write "True, True" Else output.write "False, False" End If if objColumn.IsNullable then output.write ", True" Else output.write ", False" End If if objColumn.CharacterMaxLength > 0 then output.write ", " & objColumn.CharacterMaxLength End If output.write ")> _" & vbcrlf output.autoTab "Public " If objColumn.IsComputed OR (lcase(objColumn.Name) = "createdate") OR (lcase(objColumn.Name) = "modifydate") Then output.write "ReadOnly " End If output.write "Property " & GetPublicName(objColumn) & "() As " if objColumn.IsNullable then if objColumn.LanguageType = "String" then output.write objColumn.LanguageType Elseif objColumn.LanguageType = "Byte()" then output.write objColumn.LanguageType else output.write "Nullable(Of " & objColumn.LanguageType & ")" end if else output.write objColumn.LanguageType end if if prefix then output.writeln " Implements _I" & GetObjectName(objTable) & "." & GetPublicName(objColumn) else output.writeln " Implements I" & GetObjectName(objTable) & "." & GetPublicName(objColumn) End If output.tabLevel = LevelCode + 2 output.autoTabLn "Get" output.tabLevel = LevelCode + 3 output.autoTabLn "Return " & GetPrivateName(objColumn) output.tabLevel = LevelCode + 2 output.autoTabLn "End Get" If NOT ((objColumn.IsComputed) OR ((lcase(objColumn.Name) = "createdate")) OR ((lcase(objColumn.Name) = "modifydate"))) Then output.tabLevel = LevelCode + 2 if objColumn.IsNullable then if objColumn.LanguageType = "String" then output.autoTabLn "Set(ByVal Value As " & objColumn.LanguageType & ")" Elseif objColumn.LanguageType = "Byte()" then output.autoTabLn "Set(ByVal Value As " & objColumn.LanguageType & ")" else output.autoTabLn "Set(ByVal Value As " & "Nullable(Of " & objColumn.LanguageType & ")" & ")" end if else output.autoTabLn "Set(ByVal Value As " & objColumn.LanguageType & ")" end if output.tabLevel = LevelCode + 3 output.autoTabLn GetPrivateName(objColumn) & " = Value" output.tabLevel = LevelCode + 2 output.autoTabLn "End Set" End If output.tabLevel = LevelCode + 1 output.autoTabLn "End Property" Next %> #End Region #Region "Construct" <% output.tabLevel = LevelCode + 1 output.autoTabLn "Public Sub New()" output.tabLevel = LevelCode + 2 if prefix then output.autoTabLn "_" & GetObjectName(objTable) & ".AtribuiValoresPadrao(Me)" else output.autoTabLn GetObjectName(objTable) & ".AtribuiValoresPadrao(Me)" End If output.tabLevel = LevelCode + 1 output.autoTabLn "End Sub" %> #End Region #Region "Public Methods" <% output.tabLevel = LevelCode + 1 if prefix then output.autoTabLn "Public Shared Sub AtribuiValoresPadrao(ByVal p" & GetObjectName(objTable) & " As _I" & GetObjectName(objTable) & ")" else output.autoTabLn "Public Shared Sub AtribuiValoresPadrao(ByVal p" & GetObjectName(objTable) & " As I" & GetObjectName(objTable) & ")" End If output.tabLevel = LevelCode + 2 'Aqui tem que ser implementado os valores padrão For mColIndex = 0 to objTable.Columns.Count - 1 Set objColumn = objTable.Columns(mColIndex) if objColumn.IsNullable then output.autoTabLn "p" & GetObjectName(objTable) & "." & objColumn.Name & " = Nothing" else If objColumn.LanguageType = "String" Then output.autoTabLn "p" & GetObjectName(objTable) & "." & objColumn.Name & " = String.Empty" ElseIf objColumn.LanguageType = "Byte()" Then output.autoTabLn "p" & GetObjectName(objTable) & "." & objColumn.Name & " = Nothing" else output.autoTabLn "p" & GetObjectName(objTable) & "." & objColumn.Name & " = New " & objColumn.LanguageType & "()" End If End If Next output.tabLevel = LevelCode + 1 output.autoTabLn "End Sub" %> #End Region <% ' finaliazar entidade output.tabLevel = LevelCode output.autoTabLn "End Class" if Namespace <> "" then LevelCode = 0 output.tabLevel = LevelCode output.autoTabLn "End Namespace" end if If prefix = True Then exportfileName = "_" & GetObjectName(objTable) & ".vb" Else exportfileName = GetObjectName(objTable) & ".vb" End If output.save exportPath & exportfileName, false buffer = buffer & output.text output.clear '----------------------------------------------------------------------------- %>Option Explicit On Option Strict On Imports System.ComponentModel Imports System.Collections.Generic Imports System.Text Imports System.Data Imports System.Data.Common Imports Microsoft.Practices.EnterpriseLibrary.Data <% LevelCode = 0 output.tabLevel = LevelCode if ImportsDAL <> "" then LevelCode = 0 output.tabLevel = LevelCode output.autoTabLn "Imports " & ImportsDAL end if if NamespaceDAL <> "" then LevelCode = 0 output.tabLevel = LevelCode output.autoTabLn "Namespace " & NamespaceDAL LevelCode = 1 output.tabLevel = LevelCode end if output.writeln "" output.tabLevel = LevelCode output.autoTabLn "<DataObject(True)> _" if prefix then output.autoTabLn "Partial Public Class _" & GetObjectName(objTable) & "DAL" else output.autoTabLn "Partial Public Class " & GetObjectName(objTable) & "DAL" End If output.tabLevel = LevelCode + 1 output.autoTabLn "Implements IDisposable" %> #Region "Public Methods" Private _Database As Microsoft.Practices.EnterpriseLibrary.Data.Database Private _Transaction As System.Data.Common.DbTransaction Private _InternalDatabase As Boolean = True Private _InternalTransaction As Boolean = True Private Sub InitDatabase() _Database = Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.CreateDatabase(Config.DalConfig.Instancia.ConnectionName) _InternalDatabase = True End Sub Private Property Database() As Microsoft.Practices.EnterpriseLibrary.Data.Database Get If _Database Is Nothing Then Me.InitDatabase() End If Return _Database End Get Set(ByVal value As Microsoft.Practices.EnterpriseLibrary.Data.Database) _Database = value _InternalDatabase = False End Set End Property Public Property Transaction() As System.Data.Common.DbTransaction Get Return _Transaction End Get Set(ByVal value As System.Data.Common.DbTransaction) _Transaction = value _InternalTransaction = False End Set End Property <% output.tabLevel = LevelCode + 1 output.autoTabLn "" output.autoTabLn "Private mCountRecords As Integer = 0" output.tabLevel = LevelCode + 1 output.autoTabLn "" output.autoTabLn "Public Sub CountRecords(ByVal pageSize As Integer, _" output.autoTabLn " ByRef totalRecords As Integer, _" output.autoTabLn " ByRef totalPages As Integer, _" output.autoTabLn " Optional ByVal filterExpression As String = """")" output.tabLevel = LevelCode + 2 output.autoTabLn "Dim _Mod As Double = 0" output.autoTabLn "Dim msql As New StringBuilder" output.autoTabLn "msql.AppendLine(""Select count(*) From " & objTable.Alias & """)" output.autoTabLn "If Not String.IsNullOrEmpty(filterExpression) Then" output.tabLevel = LevelCode + 3 output.autoTabLn "msql.AppendLine(String.Concat("" WHERE "", filterExpression))" output.tabLevel = LevelCode + 2 output.autoTabLn "End If" output.autoTabLn "Using dbCmd As DbCommand = Me.Database.GetSqlStringCommand(msql.ToString)" output.tabLevel = LevelCode + 3 output.autoTabLn "If Me.Transaction Is Nothing Then" output.tabLevel = LevelCode + 4 output.autoTabLn "totalRecords = CInt(Me.Database.ExecuteScalar(dbCmd))" output.tabLevel = LevelCode + 3 output.autoTabLn "Else" output.tabLevel = LevelCode + 4 output.autoTabLn "totalRecords = CInt(Me.Database.ExecuteScalar(dbCmd, Me.Transaction))" output.tabLevel = LevelCode + 3 output.autoTabLn "End If" output.tabLevel = LevelCode + 2 output.autoTabLn "End Using" output.autoTabLn "_Mod = (totalRecords Mod pageSize)" output.autoTabLn "If _Mod > 0 Then" output.tabLevel = LevelCode + 3 output.autoTabLn "totalPages = CInt((((totalRecords - _Mod) / pageSize) + 1))" output.tabLevel = LevelCode + 2 output.autoTabLn "Else" output.tabLevel = LevelCode + 3 output.autoTabLn "totalPages = CInt((totalRecords / pageSize))" output.tabLevel = LevelCode + 2 output.autoTabLn "End If" output.tabLevel = LevelCode + 1 output.autoTabLn "End Sub" output.autoTabLn "" output.tabLevel = LevelCode + 1 output.autoTabLn "" output.autoTabLn "Public Function GetCount(ByVal startRowIndex As Integer, _" output.autoTabLn " ByVal maximumRows As Integer, _" output.autoTabLn " Optional ByVal filterExpression As String = """", _" output.autoTabLn " Optional ByVal sortExpression As String = """") As Integer" output.tabLevel = LevelCode + 2 output.autoTabLn "If mCountRecords <= 0 Then" output.tabLevel = LevelCode + 3 output.autoTabLn "Dim msql As New StringBuilder" output.autoTabLn "msql.AppendLine(""Select count(*) From " & objTable.Alias & """)" output.autoTabLn "If Not String.IsNullOrEmpty(filterExpression) Then" output.tabLevel = LevelCode + 4 output.autoTabLn "msql.AppendLine(String.Concat("" WHERE "", filterExpression))" output.tabLevel = LevelCode + 3 output.autoTabLn "End If" output.autoTabLn "Using dbCmd As DbCommand = Me.Database.GetSqlStringCommand(msql.ToString)" output.tabLevel = LevelCode + 4 output.autoTabLn "If Me.Transaction Is Nothing Then" output.tabLevel = LevelCode + 5 output.autoTabLn "mCountRecords = CInt(Me.Database.ExecuteScalar(dbCmd))" output.tabLevel = LevelCode + 4 output.autoTabLn "Else" output.tabLevel = LevelCode + 5 output.autoTabLn "mCountRecords = CInt(Me.Database.ExecuteScalar(dbCmd, Me.Transaction))" output.tabLevel = LevelCode + 4 output.autoTabLn "End If" output.tabLevel = LevelCode + 3 output.autoTabLn "End Using" output.tabLevel = LevelCode + 2 output.autoTabLn "End If" output.autoTabLn "Return mCountRecords" output.tabLevel = LevelCode + 1 output.autoTabLn "End Function" output.autoTabLn "" If objTable.PrimaryKeys.Count > 0 Then output.tabLevel = LevelCode + 1 output.autoTabLn "<DataObjectMethod(DataObjectMethodType.Select, False)> _" output.autoTab "Public Function GetByKey(" bFirst = true For mColIndex = 0 to objTable.PrimaryKeys.Count - 1 Set objColumn = objTable.PrimaryKeys(mColIndex) If Not bFirst Then output.write ", " End If output.write "ByVal in" & objColumn.Name & " As " & objColumn.LanguageType bFirst = false Next output.write ") As " if prefix then output.writeln "Global." & ImportsDAL & "._" & GetObjectName(objTable) else output.writeln "Global." & ImportsDAL & "." & GetObjectName(objTable) End If output.tabLevel = LevelCode + 2 output.autoTab "Dim oResultList As List(Of " if prefix then output.writeln "Global." & ImportsDAL & "._" & GetObjectName(objTable) & ")" else output.writeln "Global." & ImportsDAL & "." & GetObjectName(objTable) & ")" End If output.autoTab "Using dbCmd As DbCommand = Me.Database.GetSqlStringCommand(""Select * From " & objTable.Alias & " Where " bFirst = true For mColIndex = 0 to objTable.PrimaryKeys.Count - 1 Set objColumn = objTable.PrimaryKeys(mColIndex) If Not bFirst Then output.write " AND " End If if PosicionalParameter then output.write objColumn.Name & " = ?" else output.write objColumn.Name & " = @" & objColumn.Name end if bFirst = false Next output.writeln """)" For mColIndex = 0 to objTable.PrimaryKeys.Count - 1 Set objColumn = objTable.PrimaryKeys(mColIndex) output.tabLevel = LevelCode + 3 if PosicionalParameter then output.autoTabLn "Me.Database.AddInParameter(dbCmd, """ & GetDbName(objColumn) & """, " & GetDbType(objColumn) & ", in" & GetDbName(objColumn) & ")" else output.autoTabLn "Me.Database.AddInParameter(dbCmd, ""@" & GetDbName(objColumn) & """, " & GetDbType(objColumn) & ", in" & GetDbName(objColumn) & ")" end if Next output.tabLevel = LevelCode + 3 output.autoTabLn "If Me.Transaction Is Nothing Then" output.tabLevel = LevelCode + 4 output.autoTabLn "Using rdr As IDataReader = Me.Database.ExecuteReader(dbCmd)" output.tabLevel = LevelCode + 5 output.autoTabLn "oResultList = LoadFromReader(rdr)" output.tabLevel = LevelCode + 4 output.autoTabLn "End Using" output.tabLevel = LevelCode + 3 output.autoTabLn "Else" output.tabLevel = LevelCode + 4 output.autoTabLn "Using rdr As IDataReader = Me.Database.ExecuteReader(dbCmd, Me.Transaction)" output.tabLevel = LevelCode + 5 output.autoTabLn "oResultList = LoadFromReader(rdr)" output.tabLevel = LevelCode + 4 output.autoTabLn "End Using" output.tabLevel = LevelCode + 3 output.autoTabLn "End If" output.tabLevel = LevelCode + 2 output.autoTabLn "End Using" output.autoTabLn "If oResultList.Count = 0 Then" output.tabLevel = LevelCode + 3 output.autoTabLn "Return Nothing" output.tabLevel = LevelCode + 2 output.autoTabLn "Else" output.tabLevel = LevelCode + 3 output.autoTabLn "Return oResultList.Item(0)" output.tabLevel = LevelCode + 2 output.autoTabLn "End If" output.tabLevel = LevelCode + 1 output.autoTabLn "End Function" End If output.tabLevel = LevelCode + 1 output.autoTabLn "" output.autoTabLn "<DataObjectMethod(DataObjectMethodType.Select, True)> _" output.autoTabLn "Public Function GetAll(ByVal startRowIndex As Integer, _" output.autoTabLn " ByVal maximumRows As Integer, _" output.autoTabLn " Optional ByVal filterExpression As String = """", _" output.autoTab " Optional ByVal sortExpression As String = """") As List(Of " if prefix then output.writeln "Global." & ImportsDAL & "._" & GetObjectName(objTable) & ")" else output.writeln "Global." & ImportsDAL & "." & GetObjectName(objTable) & ")" End If output.tabLevel = LevelCode + 2 output.autoTab "Dim oResultList As List(Of " if prefix then output.writeln "Global." & ImportsDAL & "._" & GetObjectName(objTable) & ")" else output.writeln "Global." & ImportsDAL & "." & GetObjectName(objTable) & ")" End If output.autoTabLn "Dim msql As New StringBuilder" output.autoTabLn "msql.AppendLine("" Select "")" output.autoTabLn "If maximumRows > 0 Then" output.tabLevel = LevelCode + 3 output.autoTabLn "msql.AppendLine(String.Format("" first({0}) "", maximumRows))" output.tabLevel = LevelCode + 2 output.autoTabLn "End If" output.autoTabLn "If startRowIndex > 0 Then" output.tabLevel = LevelCode + 3 output.autoTabLn "msql.AppendLine(String.Format("" skip({0}) "", startRowIndex))" output.tabLevel = LevelCode + 2 output.autoTabLn "End If" output.autoTabLn "msql.AppendLine("" * From " & objTable.Alias & " "")" output.autoTabLn "If Not String.IsNullOrEmpty(filterExpression) Then" output.tabLevel = LevelCode + 3 output.autoTabLn "msql.AppendLine(String.Concat("" WHERE "", filterExpression))" output.tabLevel = LevelCode + 2 output.autoTabLn "End If" output.autoTabLn "If Not String.IsNullOrEmpty(sortExpression) Then" output.tabLevel = LevelCode + 3 output.autoTabLn "msql.AppendLine(String.Concat("" ORDER BY "", sortExpression))" output.tabLevel = LevelCode + 2 output.autoTabLn "End If" output.autoTabLn "Using dbCmd As DbCommand = Me.Database.GetSqlStringCommand(msql.ToString)" output.tabLevel = LevelCode + 3 output.autoTabLn "If Me.Transaction Is Nothing Then" output.tabLevel = LevelCode + 4 output.autoTabLn "Using rdr As IDataReader = Me.Database.ExecuteReader(dbCmd)" output.tabLevel = LevelCode + 5 output.autoTabLn "oResultList = LoadFromReader(rdr)" output.tabLevel = LevelCode + 4 output.autoTabLn "End Using" output.tabLevel = LevelCode + 3 output.autoTabLn "Else" output.tabLevel = LevelCode + 4 output.autoTabLn "Using rdr As IDataReader = Me.Database.ExecuteReader(dbCmd, Me.Transaction)" output.tabLevel = LevelCode + 5 output.autoTabLn "oResultList = LoadFromReader(rdr)" output.tabLevel = LevelCode + 4 output.autoTabLn "End Using" output.tabLevel = LevelCode + 3 output.autoTabLn "End If" output.tabLevel = LevelCode + 2 output.autoTabLn "End Using" output.autoTabLn "Return oResultList" output.tabLevel = LevelCode + 1 output.autoTabLn "End Function" %> <DataObjectMethod(DataObjectMethodType.Insert, True)> _ Public Function Insert(ByVal <% output.write "p" & GetObjectName(objTable) & " As " if prefix then output.write "Global." & ImportsDAL & "._I" & GetObjectName(objTable) else output.write "Global." & ImportsDAL & ".I" & GetObjectName(objTable) End If %>) As MethodResult Dim oResult As New MethodResult() Using dbCmd As Common.DbCommand = Me.Database.GetSqlStringCommand("Insert Into <%= objTable.Alias %> (<% bFirst = True If TableHasIntegerPrimaryKey(objTable) Then For mColIndex = 0 to objTable.Columns.Count - 1 Set objColumn = objTable.Columns(mColIndex) If Not objColumn.IsInPrimaryKey Then If Not bFirst Then output.write ", " End If output.write GetDbName(objColumn) bFirst = False End If Next Else For mColIndex = 0 to objTable.Columns.Count - 1 Set objColumn = objTable.Columns(mColIndex) If Not bFirst Then output.write ", " End If output.write GetDbName(objColumn) bFirst = False Next End If %>) Values (<% bFirst = True If TableHasIntegerPrimaryKey(objTable) Then For mColIndex = 0 to objTable.Columns.Count - 1 Set objColumn = objTable.Columns(mColIndex) If Not objColumn.IsInPrimaryKey Then If Not bFirst Then output.write ", " End If if PosicionalParameter then output.write "?" else output.write "@" & GetDbName(objColumn) end if bFirst = False End If Next Else For mColIndex = 0 to objTable.Columns.Count - 1 Set objColumn = objTable.Columns(mColIndex) If Not bFirst Then output.write ", " End If if PosicionalParameter then output.write "?" else output.write "@" & GetDbName(objColumn) end if bFirst = False Next End If Output.Write ")" If TableHasIntegerPrimaryKey(objTable) Then 'output.write " Select SCOPE_IDENTITY()" output.write " RETURNING " bFirst = true For mColIndex = 0 to objTable.PrimaryKeys.Count - 1 Set objColumn = objTable.PrimaryKeys(mColIndex) If Not bFirst Then output.write ", " End If output.write objColumn.Name bFirst = false Next End If Output.Write """)" %> <% For mColIndex = 0 to objTable.Columns.Count - 1 Set objColumn = objTable.Columns(mColIndex) output.tabLevel = LevelCode + 3 If objColumn.IsComputed Or objColumn.IsInPrimaryKey Then Else if objColumn.IsNullable then if (objColumn.LanguageType = "String") then output.autoTabLn "If Not String.IsNullOrEmpty(" & "p" & GetObjectName(objTable) & "." & objColumn.Name & ") Then" Elseif (objColumn.LanguageType = "Byte()") then output.autoTabLn "If Not p" & GetObjectName(objTable) & "." & objColumn.Name & " Is Nothing Then" Else output.autoTabLn "If p" & GetObjectName(objTable) & "." & objColumn.Name & ".HasValue Then" End If output.tabLevel = LevelCode + 4 if PosicionalParameter then output.autoTab "Me.Database.AddInParameter(dbCmd, """ & objColumn.Name & """, " & GetDbType(objColumn) & ", " else output.autoTab "Me.Database.AddInParameter(dbCmd, ""@" & objColumn.Name & """, " & GetDbType(objColumn) & ", " end if If (lcase(objColumn.Name) = "createdate") Or (lcase(objColumn.Name) = "modifydate") Then output.write "DateTime.Now()" Else if ((objColumn.LanguageType = "String") or (objColumn.LanguageType = "Byte()")) then output.write "p" & GetObjectName(objTable) & "." & objColumn.Name else output.write "p" & GetObjectName(objTable) & "." & objColumn.Name & ".Value" End If End If output.write ")" & vbcrlf output.tabLevel = LevelCode + 3 output.autoTabLn "Else" output.tabLevel = LevelCode + 4 if PosicionalParameter then output.autoTabLn "Me.Database.AddInParameter(dbCmd, """ & objColumn.Name & """, " & GetDbType(objColumn) & ", System.DBNull.Value)" else output.autoTabLn "Me.Database.AddInParameter(dbCmd, ""@" & objColumn.Name & """, " & GetDbType(objColumn) & ", System.DBNull.Value)" end if output.tabLevel = LevelCode + 3 output.autoTabLn "End If" else output.tabLevel = LevelCode + 3 if PosicionalParameter then output.autoTab "Me.Database.AddInParameter(dbCmd, """ & objColumn.Name & """, " & GetDbType(objColumn) & ", " else output.autoTab "Me.Database.AddInParameter(dbCmd, ""@" & objColumn.Name & """, " & GetDbType(objColumn) & ", " end if If (lcase(objColumn.Name) = "createdate") Or (lcase(objColumn.Name) = "modifydate") Then output.write "DateTime.Now()" Else output.write "p" & GetObjectName(objTable) & "." & objColumn.Name End If output.write ")" & vbcrlf end if End If Next If TableHasIntegerPrimaryKey(objTable) Then%> If Me.Transaction Is Nothing Then <%= "p" & GetObjectName(objTable) & "." & GetDbName(objTable.PrimaryKeys(0))%> = CInt(Me.Database.ExecuteScalar(dbCmd)) Else <%= "p" & GetObjectName(objTable) & "." & GetDbName(objTable.PrimaryKeys(0))%> = CInt(Me.Database.ExecuteScalar(dbCmd, Me.Transaction)) End If If <%= "p" & GetObjectName(objTable) & "." & GetDbName(objTable.PrimaryKeys(0))%> <= 0 Then oResult.Messages.Add("Insert Failed") End If <%Else%> If Me.Transaction Is Nothing Then Me.Database.ExecuteScalar(dbCmd) Else Me.Database.ExecuteScalar(dbCmd, Me.Transaction) End If<% End If %> End Using Return oResult End Function<% If objTable.PrimaryKeys.Count > 0 Then%> <DataObjectMethod(DataObjectMethodType.Update, True)> _ Public Function Update(ByVal <% output.write "p" & GetObjectName(objTable) & " As " if prefix then output.write "Global." & ImportsDAL & "._I" & GetObjectName(objTable) else output.write "Global." & ImportsDAL & ".I" & GetObjectName(objTable) End If %>) As MethodResult Dim oResult As New MethodResult() Using dbCmd As Common.DbCommand = Me.Database.GetSqlStringCommand("Update <%= objTable.Alias %> Set <% bFirst = True For mColIndex = 0 to objTable.Columns.Count - 1 Set objColumn = objTable.Columns(mColIndex) If ((Not objColumn.IsInPrimaryKey) And (Not (lcase(objColumn.Name) = "createdate"))) Then If Not bFirst Then output.write ", " End If if PosicionalParameter then output.write GetDbName(objColumn) & " = ?" else output.write GetDbName(objColumn) & " = @" & GetDbName(objColumn) end if bFirst=false End if Next %> Where <% bFirst = true For mColIndex = 0 to objTable.PrimaryKeys.Count - 1 Set objColumn = objTable.PrimaryKeys(mColIndex) If Not bFirst Then output.write " AND " End If if PosicionalParameter then output.write GetDbName(objColumn) & " = ?" else output.write GetDbName(objColumn) & " = @" & GetDbName(objColumn) end if bFirst = false Next %>") <% For mColIndex = 0 to objTable.Columns.Count - 1 Set objColumn = objTable.Columns(mColIndex) output.tabLevel = LevelCode + 3 'need to include primary keys for updates because of the where clause If objColumn.IsComputed or objColumn.IsInPrimaryKey or (lcase(objColumn.Name) = "createdate") Then Else if objColumn.IsNullable then if (objColumn.LanguageType = "String") then output.autoTabLn "If Not String.IsNullOrEmpty(" & "p" & GetObjectName(objTable) & "." & objColumn.Name & ") Then" Elseif (objColumn.LanguageType = "Byte()") then output.autoTabLn "If Not p" & GetObjectName(objTable) & "." & objColumn.Name & " Is Nothing Then" Else output.autoTabLn "If p" & GetObjectName(objTable) & "." & objColumn.Name & ".HasValue Then" End If output.tabLevel = LevelCode + 4 if PosicionalParameter then output.autoTab "Me.Database.AddInParameter(dbCmd, """ & objColumn.Name & """, " & GetDbType(objColumn) & ", " else output.autoTab "Me.Database.AddInParameter(dbCmd, ""@" & objColumn.Name & """, " & GetDbType(objColumn) & ", " end if If (lcase(objColumn.Name) = "createdate") Or (lcase(objColumn.Name) = "modifydate") Then output.write "DateTime.Now()" Else if ((objColumn.LanguageType = "String") or (objColumn.LanguageType = "Byte()")) then output.write "p" & GetObjectName(objTable) & "." & objColumn.Name else output.write "p" & GetObjectName(objTable) & "." & objColumn.Name & ".Value" End If End If output.write ")" & vbcrlf output.tabLevel = LevelCode + 3 output.autoTabLn "Else" output.tabLevel = LevelCode + 4 if PosicionalParameter then output.autoTabLn "Me.Database.AddInParameter(dbCmd, """ & objColumn.Name & """, " & GetDbType(objColumn) & ", System.DBNull.Value)" else output.autoTabLn "Me.Database.AddInParameter(dbCmd, ""@" & objColumn.Name & """, " & GetDbType(objColumn) & ", System.DBNull.Value)" end if output.tabLevel = LevelCode + 3 output.autoTabLn "End If" else output.tabLevel = LevelCode + 3 if PosicionalParameter then output.autoTab "Me.Database.AddInParameter(dbCmd, """ & objColumn.Name & """, " & GetDbType(objColumn) & ", " else output.autoTab "Me.Database.AddInParameter(dbCmd, ""@" & objColumn.Name & """, " & GetDbType(objColumn) & ", " end if If lcase(objColumn.Name) = "modifydate" Then output.write "DateTime.Now()" Else output.write "p" & GetObjectName(objTable) & "." & objColumn.Name End If output.write ")" & vbcrlf end if End If Next For mColIndex = 0 to objTable.PrimaryKeys.Count - 1 Set objColumn = objTable.PrimaryKeys(mColIndex) output.tabLevel = LevelCode + 3 if PosicionalParameter then output.autoTab "Me.Database.AddInParameter(dbCmd, """ & objColumn.Name & """, " & GetDbType(objColumn) & ", " else output.autoTab "Me.Database.AddInParameter(dbCmd, ""@" & objColumn.Name & """, " & GetDbType(objColumn) & ", " end if output.write "p" & GetObjectName(objTable) & "." & objColumn.Name output.write ")" & vbcrlf Next %> If Me.Transaction Is Nothing Then If CInt(Me.Database.ExecuteNonQuery(dbCmd)) <> 1 Then oResult.Messages.Add("Update Failed") End If Else If CInt(Me.Database.ExecuteNonQuery(dbCmd, Me.Transaction)) <> 1 Then oResult.Messages.Add("Update Failed") End If End If End Using Return oResult End Function<% End If If objTable.PrimaryKeys.Count > 0 Then%> <DataObjectMethod(DataObjectMethodType.Delete, True)> _ Public Function Delete(<% bFirst = true For mColIndex = 0 to objTable.PrimaryKeys.Count - 1 Set objColumn = objTable.PrimaryKeys(mColIndex) If Not bFirst Then output.write ", " End If output.write "ByVal in" & objColumn.Name & " As " & objColumn.LanguageType bFirst = false Next %>) As MethodResult Dim oResult As New MethodResult() Using dbCmd As Common.DbCommand = Me.Database.GetSqlStringCommand("Delete From <%= objTable.Alias %> Where <% bFirst = true For mColIndex = 0 to objTable.PrimaryKeys.Count - 1 Set objColumn = objTable.PrimaryKeys(mColIndex) If Not bFirst Then output.write " AND " End If if PosicionalParameter then output.write GetDbName(objColumn) & " = ?" else output.write GetDbName(objColumn) & " = @" & GetDbName(objColumn) end if bFirst = false Next %>") <% If objTable.PrimaryKeys.Count > 0 Then output.tabLevel = LevelCode + 3 For mColIndex = 0 to objTable.PrimaryKeys.Count - 1 Set objColumn = objTable.PrimaryKeys(mColIndex) if PosicionalParameter then output.autoTabLn "Me.Database.AddInParameter(dbCmd, """ & objColumn.Name & """, " & GetDbType(objColumn) & ", in" & objColumn.Name & ")" else output.autoTabLn "Me.Database.AddInParameter(dbCmd, ""@" & objColumn.Name & """, " & GetDbType(objColumn) & ", in" & objColumn.Name & ")" end if Next output.tabLevel = LevelCode + 2 End If %> If Me.Transaction Is Nothing Then If CInt(Me.Database.ExecuteScalar(dbCmd)) <> 1 Then oResult.Messages.Add("Delete Failed") End If Else If CInt(Me.Database.ExecuteScalar(dbCmd, Me.Transaction)) <> 1 Then oResult.Messages.Add("Delete Failed") End If End If End Using Return oResult End Function<% End If%> #End Region #Region "Private Methods" Private Function LoadFromReader(ByRef inDataReader As IDataReader) As List(Of <% if prefix then output.write "Global." & ImportsDAL & "._" & GetObjectName(objTable) & ")" else output.write "Global." & ImportsDAL & "." & GetObjectName(objTable) & ")" End If %> Dim oResult As New List(Of <% if prefix then output.write "Global." & ImportsDAL & "._" & GetObjectName(objTable) & ")" else output.write "Global." & ImportsDAL & "." & GetObjectName(objTable) & ")" End If %> If (Not inDataReader Is Nothing) And (Not inDataReader.IsClosed) Then While inDataReader.Read() Dim o<%= GetObjectName(objTable) %> As <% if prefix then output.write "Global." & ImportsDAL & "._" & GetObjectName(objTable) & " = New Global." & ImportsDAL & "._" & GetObjectName(objTable) & "()" else output.write "Global." & ImportsDAL & "." & GetObjectName(objTable) & " = New Global." & ImportsDAL & "." & GetObjectName(objTable) & "()" End If%> <% For mColIndex = 0 to objTable.Columns.Count - 1 Set objColumn = objTable.Columns(mColIndex) %> If Not IsDBNull(inDataReader("<%= GetDbName(objColumn)%>")) Then o<%= GetObjectName(objTable)%>.<%= objColumn.Name%> = CType(inDataReader("<%= GetDbName(objColumn)%>"), <%= objColumn.LanguageType %>) else<% if objColumn.IsNullable then%> o<%= GetObjectName(objTable)%>.<%= objColumn.Name%> = Nothing<% else If objColumn.LanguageType = "String" Then%> o<%= GetObjectName(objTable)%>.<%= objColumn.Name%> = String.Empty<% ElseIf objColumn.LanguageType = "Byte()" Then%> o<%= GetObjectName(objTable)%>.<%= objColumn.Name%> = Nothing<% else%> o<%= GetObjectName(objTable)%>.<%= objColumn.Name%> = New <%= objColumn.LanguageType %>()<% End If End If %> End If<% Next%> oResult.Add(o<%= GetObjectName(objTable) %>) End While inDataReader.Close() End If <% output.tabLevel = LevelCode + 2 output.autoTabLn "Return oResult" output.tabLevel = LevelCode + 1 output.autoTabLn "End Function" %> #End Region #Region "Cleanup Methods" Private disposedValue As Boolean = False ' To detect redundant calls ' IDisposable Protected Overridable Sub Dispose(ByVal disposing As Boolean) If Not Me.disposedValue Then If disposing Then If _InternalTransaction Then If Not _Transaction Is Nothing Then _Transaction.Dispose() End If End If End If ' TODO: free your own state (unmanaged objects). ' TODO: set large fields to null. End If Me.disposedValue = True End Sub #End Region #Region " IDisposable Support " ' This code added by Visual Basic to correctly implement the disposable pattern. Public Sub Dispose() Implements IDisposable.Dispose ' Do not change this code. Put cleanup code in Dispose(ByVal disposing As Boolean) above. Dispose(True) GC.SuppressFinalize(Me) End Sub #End Region <% output.tabLevel = LevelCode output.autoTabLn "End Class" if NamespaceDAL <> "" then output.tabLevel = 0 output.autoTabLn "End Namespace" end if ' Save the output file for this Table Dim filename filename = input.item("txtPathDAL") Dim length Dim pos lenth = Len(filename) pos = InStrRev(filename, "\") If Not pos = lenth Then filename = filename & "\" End If If prefix = True Then filename = filename & "_" & GetObjectName(objTable) & "DAL.vb" Else filename = filename & GetObjectName(objTable) & "DAL.vb" End If output.save filename, false buffer = buffer & output.text output.clear Next ' tableName output.write buffer '=========================================================================== ' These are support routines called by the above script '=========================================================================== Function GetPublicName(objColumn) Dim name name = objColumn.Name GetPublicName = UCase(Left(name, 1)) & Right(name, Len(name) -1) End Function Function GetPrivateName(objColumn) Dim name name = objColumn.Name GetPrivateName = "_" & LCase(Left(name, 1)) & Right(name, Len(name) -1) End Function Function GetDbName(objColumn) GetDbName = objColumn.Name End Function Function GetObjectName(objTable) Dim Name If Right(objTable.Alias, 1) = "s" Then Name = Left(objTable.Alias, Len(objTable.Alias)-1) Else Name = objTable.Alias End If GetObjectName = Name End Function Function TableHasIntegerPrimaryKey(inTable) Dim result If inTable.PrimaryKeys.Count = 1 Then Select Case LCase(inTable.PrimaryKeys(0).LanguageType) Case "integer" result = True Case "long" result = True Case Else result = False End Select Else result = False End If TableHasIntegerPrimaryKey = result End Function Function TrimSpaces(str) Dim tname Dim name Dim char Dim l name = "" tname = str l = Len(tname) For j = 1 To l char = Mid(tname, j, 1) If Not char = " " Then name = name & char End If Next TrimSpaces = name End Function Function GetFullType(objColumn) Select Case LCase(objColumn.LanguageType) Case "string" GetFullType = "String" Case "integer" GetFullType = "Int32" Case "short" GetFullType = "Int16" Case "decimal" GetFullType = "Decimal" Case "datetime" GetFullType = "DateTime" Case Else GetFullType = objColumn.LanguageType End Select End Function Function GetDbType(objColumn) Select Case objColumn.DbTargetType Case "FbDbType.Integer" GetDbType = "DbType.Int32" Case "FbDbType.BigInt" GetDbType = "DbType.Int64" Case "FbDbType.SmallInt" GetDbType = "DbType.Int16" Case "FbDbType.Float" GetDbType = "DbType.Single" Case "FbDbType.Double" GetDbType = "DbType.Double" Case "FbDbType.Numeric" GetDbType = "DbType.Decimal" Case "FbDbType.Date" GetDbType = "DbType.Date" Case "FbDbType.Time" GetDbType = "DbType.Time" Case "FbDbType.TimeStamp" GetDbType = "DbType.DateTime" Case "FbDbType.Char" GetDbType = "DbType.String" Case "FbDbType.VarChar" GetDbType = "DbType.String" Case "FbDbType.Text" GetDbType = "DbType.String" Case "FbDbType.Binary" GetDbType = "DbType.Binary" Case Else GetDbType = objColumn.DbTargetType End Select End Function Function GetEmptyValue(objColumn) Select Case objColumn.DbTargetType Case "DbType.Int16", "DbType.Int32", "DbType.Int64", "DbType.Decimal", "DbType.Double", "DbType.Currency", "DbType.Single" GetEmptyValue = "0" Case "DbType.Guid" GetEmptyValue = "Guid.Empty" Case "DbType.StringFixedLength", "DbType.AnsiStringFixedLength", "DbType.String", "DbType.AnsiString" GetEmptyValue = "String.Empty" Case "DbType.DateTime" GetEmptyValue = "DateTime.MinValue" Case Else GetEmptyValue = Replace(objColumn.DbTargetType, "DbType.", "") End Select End Function Function GetParameterSize(objColumn) Select Case objColumn.DbTargetType Case "DbType.Int32" GetParameterSize = "4" Case "DbType.Binary" GetParameterSize = "8" Case "DbType.Guid" GetParameterSize = "16" Case "DbType.StringFixedLength", "DbType.AnsiStringFixedLength", "DbType.String", "DbType.AnsiString" GetParameterSize = objColumn.CharacterMaxLength Case Else GetParameterSize = "0" End Select End Function Function GetNullValueDefault(objColumn) Select Case objColumn.DbTargetType Case "DbType.Int16", "DbType.Int32", "DbType.Int64", "DbType.Decimal", "DbType.Double", "DbType.Currency", "DbType.Single" GetNullValueDefault = "0" Case "DbType.Guid" GetNullValueDefault = "Guid.Empty" Case "DbType.StringFixedLength", "DbType.AnsiStringFixedLength", "DbType.String", "DbType.AnsiString" GetNullValueDefault = "String.Empty" Case "DbType.DateTime" GetNullValueDefault = "DateTime.Parse(""01/01/1900"")" Case "DbType.Boolean" GetNullValueDefault = "False" Case "DbType.Binary", "DbType.Byte" GetNullValueDefault = "New Byte() {}" Case "DbType.Object" GetNullValueDefault = "Nothing" Case Else GetNullValueDefault = objColumn.DbTargetType '"string.Empty" End Select End Function %>
Dynamic Interface:
Engine:
Microsoft Script
Language:
VBScript
Dim cmbDatabases Dim lstTables Dim chk Dim chkPosicional Sub setup() If Not input.Contains("lstTables") Or Not input.Contains("txtPath") Then ui.Title = "Generate VB.NET Business Objects" ui.Width = 600 ui.Height = 650 ' Grab default output path Dim sOutputPath sOutputPath = "" If input.Contains("defaultOutputPath") Then sOutputPath = input.Item("defaultOutputPath") End If Dim sNamespace sNamespace = "" Dim lblNamespace Set lblNamespace = ui.AddLabel("lblNamespace", "Namespace For Entities: ", "Namespace For Entities.") lblNamespace.Width = 150 Dim txtNamespace Set txtNamespace = ui.AddTextBox("txtNamespace", sNamespace, "Type the Namespace.") txtNamespace.Width = 150 Dim lblImports Set lblImports = ui.AddLabel("lblImports", "Imports: ", "Imports.") lblImports.Width = 150 lblImports.Left = lblNamespace.Left + lblNamespace.Width + 10 lblImports.Top = lblNamespace.Top Dim txtImports Set txtImports = ui.AddTextBox("txtImports", sNamespace, "Imports.") txtImports.Width = 150 txtImports.Left = txtNamespace.Left + txtImports.Width + 10 txtImports.Top = txtNamespace.Top ui.AddLabel "lblPath", "Output file path For Entities: ", "Select the output path." ui.AddTextBox "txtPath", sOutputPath, "Select the Output Path." ui.AddFilePicker "btnPath", "Select Path", "Select the Output Path.", "txtPath", true Dim sNamespaceDAL sNamespaceDAL = "" Dim lblNamespaceDAL Set lblNamespaceDAL = ui.AddLabel("lblNamespaceDAL", "Namespace For DAL: ", "Namespace For DAL.") lblNamespaceDAL.Width = 150 Dim txtNamespaceDAL Set txtNamespaceDAL = ui.AddTextBox("txtNamespaceDAL", sNamespaceDAL, "Type the Namespace For DAL.") txtNamespaceDAL.Width = 150 Dim lblImportsDAL Set lblImportsDAL = ui.AddLabel("lblImportsDAL", "Imports: ", "Imports.") lblImportsDAL.Width = 150 lblImportsDAL.Left = lblNamespaceDAL.Left + lblNamespaceDAL.Width + 10 lblImportsDAL.Top = lblNamespaceDAL.Top Dim txtImportsDAL Set txtImportsDAL = ui.AddTextBox("txtImportsDAL", sNamespace, "Imports.") txtImportsDAL.Width = 150 txtImportsDAL.Left = txtNamespaceDAL.Left + txtImportsDAL.Width + 10 txtImportsDAL.Top = txtNamespaceDAL.Top ui.AddLabel "lblPathDAL", "Output file path For DAL: ", "Select the output path." ui.AddTextBox "txtPathDAL", sOutputPath, "Select the Output Path." ui.AddFilePicker "btnPathDAL", "Select Path", "Select the Output Path.", "txtPathDAL", true ' List Databases in a ComboBox ui.AddLabel "lblDatabases", "Select a database:", "Select a database in the dropdown below." Set cmbDatabases = ui.AddComboBox("cmbDatabase", "Select a database.") ' List Tables in a listbox ui.AddLabel "lblTables", "Select tables:", "Select tables from the listbox below." Set lstTables = ui.AddListBox ("lstTables", "Select tables:") 'lstTables.IsMultiSelect = false lstTables.Height = 120 Set prefix = ui.AddCheckBox("prefix", "Prefix class with underscore?", true, "If checked, the file on disk will begin with an underscore") If MyMeta.DriverString = "FIREBIRD" Then Set chk = ui.AddCheckBox("ckDialect3", "DIALECT 3", false, "If checked, the stored procedure will use dialect 3 syntax") chk.forecolor = "red" End If Set chkPosicional = ui.AddCheckBox("chkPosicional", "Positional Parameters", true, "If checked, the parameter for SQL Startements is positional") ' Attach the onchange event to the cmbDatabases control. setupDatabaseDropdown cmbDatabases cmbDatabases.AttachEvent "onchange", "cmbDatabases_onchange" ui.ShowGUI = true Else ui.ShowGUI = false End if End Sub Sub setupDatabaseDropdown(cmbDatabases) cmbDatabases.BindData MyMeta.Databases If Not MyMeta.DefaultDatabase Is Nothing Then cmbDatabases.SelectedValue = MyMeta.DefaultDatabase.Name bindTables cmbDatabases.SelectedValue End If End Sub Sub bindTables(sDatabase) Set db = MyMeta.Databases.Item(sDatabase) lstTables.BindData(db.Tables) End Sub ' Event Handler Sub cmbDatabases_onchange(control) Set cmbDatabases = ui.item("cmbDatabase") bindTables cmbDatabases.SelectedText End Sub
Copyright © 2004 MyGeneration Software. All rights reserved.
Feedback:
feedback@mygenerationsoftware.com
Support:
support@mygenerationsoftware.com