- downloads.zip
- Downloads
- BusinessObjectGenerator
- GeneratedFiles
- Sample
- src
- BusinessObjectGenerator
- App_Code
- App_Data
- TheProperties_Data
- Default.aspx
- Default.aspx.cs
- Default_Console.aspx
- Default_Console.aspx.cs
- images
- background_label.gif
- logo.gif
- InvoiceClassDef.xml
- InvoiceClassDef.xsd
- InvoiceClassDef.xsx
- PropertyAndUIPropertyMaps.xml
- PropertyControls
- References
- EntLibHelper.dll
- Microsoft.Practices.EnterpriseLibrary.Caching.dll
- Microsoft.Practices.EnterpriseLibrary.Common.dll
- Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.dll
- Microsoft.Practices.EnterpriseLibrary.Logging.dll
- Microsoft.Practices.ObjectBuilder.dll
- Providers.dll
- Providers.dll.refresh
- SmartCodeGen.ImplementedProviders.dll
- SmartCodeGen.ImplementedProviders.dll.refresh
- SmartCodeGen.WebUtil.dll
- SmartCodeGen.WebUtil.dll.refresh
- scgxsd_console.exe_
- styles
- Templates
- Web.Config
- BusinessObjects.Templates
- src.gpState
- src.sln
- src.suo
- SmartCodeGeneratorXsdConsole
- downloads-noexe.zip
|
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="DataGeneratorTemplate.ascx.cs" Inherits="DataGeneratorTemplate" %>
//---------------------------------------------------------------------------------------
//Originally written by The Austin Conner Group. I modified according to my needs to fit
//SmartCodeGenerator Framework
//Shahed Khan
//12 April 2007
//---------------------------------------------------------------------------------------
// Copyright Notice
// This file contains proprietary information of The Austin Conner Group.
// Copying or reproduction without prior written approval is prohibited.
// Copyright (C) 2004 The Austin Conner Group. All rights reserved.
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this list
// of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other materials
// provided with the distribution.
//
// * Neither the name of The Austin Conner Group nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific prior
// written permission.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
// OR OTHER DEALINGS IN THE SOFTWARE.
//---------------------------------------------------------------------------------------
// History
// <%= DateTime.Now.ToShortDateString() %> <%= CompanyName%> - <%= DeveloperName%> - Original Version
//---------------------------------------------------------------------------------------
<% string comma = ""; %>
if exists (select * from dbo.sysobjects where id = object_id(N'[<%= TargetClass %>]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [<%= TargetClass %>]
GO
CREATE TABLE [<%= TargetClass %>](
<%
comma = " ";
foreach(System.Xml.XmlNode propertyNode in PropertyList){
if(isSystemType(propertyNode.Attributes["type"].Value)){
%>
<%= comma %>[<%= propertyNode.Attributes["name"].Value %>] <%= GetSqlType(propertyNode) %> NOT NULL
<%
comma = ",";
} // else class name
} // for each propertyNode
%>
)
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[<%= PascalCase(TargetClass) %>_Create]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[<%= PascalCase(TargetClass) %>_Create]
GO
--- <summary>
--- <%= ProperName(TargetClass) %>_Create
--- </summary>
CREATE PROCEDURE <%= TargetClass %>_Create
(
<%
comma = " ";
foreach(System.Xml.XmlNode propertyNode in PropertyList){
if(isSystemType(propertyNode.Attributes["type"].Value)){
%>
<%= comma %>@<%= propertyNode.Attributes["name"].Value %> <%= GetSqlType(propertyNode) %>
<%
comma = ",";
} // else class name
} // for each propertyNode
%>
)
AS
SET NOCOUNT ON
DECLARE @ReturnCode INT
BEGIN TRANSACTION
INSERT INTO [<%= TargetClass %>](
<%
comma = " ";
foreach(System.Xml.XmlNode propertyNode in PropertyList){
if(isSystemType(propertyNode.Attributes["type"].Value)){
%>
<%= comma %>[<%= propertyNode.Attributes["name"].Value %>]
<%
comma = ",";
} // else class name
} // for each propertyNode
%>
)
VALUES(
<%
comma = " ";
foreach(System.Xml.XmlNode propertyNode in PropertyList){
if(isSystemType(propertyNode.Attributes["type"].Value)){
%>
<%= comma %>@<%= propertyNode.Attributes["name"].Value %>
<%
comma = ",";
} // else class name
} // for each propertyNode
%>
)
-- ERROR CHECK
SELECT @ReturnCode = @@ERROR
IF @ReturnCode <> 0 GOTO ErrorHandeler
-- Commit if no Errors
COMMIT TRANSACTION
RETURN @ReturnCode
-- Rollback if Errors
ErrorHandeler:
ROLLBACK TRANSACTION
RETURN @ReturnCode
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[<%= PascalCase(TargetClass) %>_Update]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[<%= PascalCase(TargetClass) %>_Update]
GO
--- <summary>
--- <%= ProperName(TargetClass) %>_Update
--- </summary>
CREATE PROCEDURE <%= TargetClass %>_Update
(
<%
comma = " ";
foreach(System.Xml.XmlNode propertyNode in PropertyList){
if(isSystemType(propertyNode.Attributes["type"].Value)){
%>
<%= comma %>@<%= propertyNode.Attributes["name"].Value %> <%= GetSqlType(propertyNode) %>
<%
comma = ",";
} // else class name
} // for each propertyNode
%>
)
AS
SET NOCOUNT ON
DECLARE @ReturnCode INT
BEGIN TRANSACTION
UPDATE [<%= TargetClass %>] SET
<%
comma = " ";
foreach(System.Xml.XmlNode propertyNode in PropertyList){
if(isSystemType(propertyNode.Attributes["type"].Value)){
%>
<%= comma %>[<%= propertyNode.Attributes["name"].Value %>] = @<%= propertyNode.Attributes["name"].Value %>
<%
comma = ",";
} // else class name
} // for each propertyNode
%>
WHERE
[<%= TargetClass %>].Id = @Id
-- ERROR CHECK
SELECT @ReturnCode = @@ERROR
IF @ReturnCode <> 0 GOTO ErrorHandeler
-- Commit if no Errors
COMMIT TRANSACTION
RETURN @ReturnCode
-- Rollback if Errors
ErrorHandeler:
ROLLBACK TRANSACTION
RETURN @ReturnCode
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[<%= PascalCase(TargetClass) %>_Delete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[<%= PascalCase(TargetClass) %>_Delete]
GO
--- <summary>
--- <%= ProperName(TargetClass) %>_Delete
--- </summary>
CREATE PROCEDURE <%= TargetClass %>_Delete
(
@Id NvarChar(36)
)
AS
SET NOCOUNT ON
DECLARE @ReturnCode INT
BEGIN TRANSACTION
DELETE
[<%= TargetClass %>]
WHERE
[<%= TargetClass %>].Id = @Id
-- ERROR CHECK
SELECT @ReturnCode = @@ERROR
IF @ReturnCode <> 0 GOTO ErrorHandeler
-- Commit if no Errors
COMMIT TRANSACTION
RETURN @ReturnCode
-- Rollback if Errors
ErrorHandeler:
ROLLBACK TRANSACTION
RETURN @ReturnCode
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[<%= PascalCase(TargetClass) %>_Fetch]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[<%= PascalCase(TargetClass) %>_Fetch]
GO
--- <summary>
--- <%= ProperName(TargetClass) %>_Fetch
--- </summary>
CREATE PROCEDURE <%= TargetClass %>_Fetch
(
@Id NvarChar(36)
)
AS
SET NOCOUNT ON
SELECT
<%
comma = " ";
foreach(System.Xml.XmlNode propertyNode in PropertyList){
if(isSystemType(propertyNode.Attributes["type"].Value)){
%>
<%= comma %>[<%= propertyNode.Attributes["name"].Value %>]
<%
comma = ",";
} // else class name
} // for each propertyNode
%>
FROM
[<%= TargetClass %>] WITH (NOLOCK)
WHERE
[<%= TargetClass %>].Id = @Id
GO
<%
if(ForeignKeys.Count != 0){
System.Collections.IEnumerator ForeignKeysEnumerator = ForeignKeys.GetEnumerator();
while ( ForeignKeysEnumerator.MoveNext() )
{
%>
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[<%= TargetClass %>_FetchBy<%= ForeignKeysEnumerator.Current.ToString() %>') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[<%= TargetClass %>_FetchBy<%= ForeignKeysEnumerator.Current.ToString()%>]
GO
--- <summary>
--- <%= TargetClass %>_FetchBy<%= ForeignKeysEnumerator.Current.ToString() %>
--- </summary>
CREATE PROCEDURE <%= TargetClass %>_FetchBy<%= ForeignKeysEnumerator.Current.ToString() %>
(
@<%= ForeignKeysEnumerator.Current.ToString() %> NvarChar(36)
)
AS
SET NOCOUNT ON
SELECT
<%
comma = " ";
foreach(System.Xml.XmlNode propertyNode in PropertyList){
if(isSystemType(propertyNode.Attributes["type"].Value)){
%>
<%= comma %>[<%= propertyNode.Attributes["name"].Value %>]
<%
comma = ",";
} // else class name
} // for each propertyNode
%>
FROM
[<%= TargetClass %>] WITH (NOLOCK)
WHERE
[<%= TargetClass %>].<%= ForeignKeysEnumerator.Current.ToString() %> = @<%= ForeignKeysEnumerator.Current.ToString() %>
<%
}
}
%>
GO
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.