/App_Code/DAL/_Geo_AdministrativeDivision_DAL.cs
# · C# · 259 lines · 145 code · 42 blank · 72 comment · 2 complexity · 9666669f63a40df3fd33934a3d3f7bfe MD5 · raw file
- /*
- '===============================================================================
- ' Generated From - DAAB_DAL_NET2.vbgen
- ' It is based on the DAAB from the November 2005 Enterprise Library
- '
- ' This object is 'abstract' which means you need to inherit from it to be able
- ' to instantiate it. This is very easily done. You can override properties and
- ' methods in your derived class, this allows you to regenerate this class at any
- ' time and not worry about overwriting custom code.
- '
- ' Custom DAL methods should be written into the inherited class.
- '
- ' Version: 1.0
- ' Date: 30/01/06
- ' Summary: SelectOne, SelectAll, SelectAllWForeignKey, Insert, Update, Delete,
- ' DeleteAllWForeignKey.
- '===============================================================================
- */
- using System;
- using System.Data;
- using System.Data.Common;
- using System.Configuration;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- using Microsoft.Practices.EnterpriseLibrary.Data;
- using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
-
-
- namespace PlacementManager.DAL
- {
- public abstract class _Geo_AdministrativeDivision_DAL
- {
- #region Members
- protected int _AdministrativeDivisionID;
- protected int _CountryID;
- protected string _DivisionName;
- protected string _DivisionPostalAbbreviation;
- #endregion
-
- #region Properties
-
- public int AdministrativeDivisionID
- {
- get { return _AdministrativeDivisionID; }
- set { _AdministrativeDivisionID = value; }
- }
-
- public int CountryID
- {
- get { return _CountryID; }
- set { _CountryID = value; }
- }
-
- public string DivisionName
- {
- get { return _DivisionName; }
- set { _DivisionName = value; }
- }
-
- public string DivisionPostalAbbreviation
- {
- get { return _DivisionPostalAbbreviation; }
- set { _DivisionPostalAbbreviation = value; }
- }
-
- #endregion
-
- //Constructor
- public _Geo_AdministrativeDivision_DAL()
- {
-
- }
-
- /// <summary>
- /// Purpose: SelectAll method. This method will Select all rows from the table.
- /// </summary>
- /// <returns></returns>
- public DataSet SelectAll()
- {
- // Create the Database object, using the default database service. The
- // default database service is determined through configuration.
- Database db = DatabaseFactory.CreateDatabase("PlacementManager");
-
- string sqlCommand = "pr_Geo_AdministrativeDivision_DAL_SelectAll";
- DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);
-
- // Retrieve products from the specified category.
- db.AddInParameter(dbCommand, "ErrorCode", DbType.Int32, null);
-
- DataSet dsToReturn = null;
- dsToReturn = db.ExecuteDataSet(dbCommand);
- return dsToReturn;
- }
-
- /// <summary>
- /// Purpose: Select method. This method will Select one existing row from the database, based on the Primary Key.
- /// </summary>
- /// <returns></returns>
- public DataSet SelectOne()
- {
- // Create the Database object, using the default database service. The
- // default database service is determined through configuration.
- Database db = DatabaseFactory.CreateDatabase("PlacementManager");
-
- string sqlCommand = "pr_Geo_AdministrativeDivision_DAL_SelectOne";
- DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);
-
- db.AddInParameter(dbCommand, "AdministrativeDivisionID", DbType.Int32, _AdministrativeDivisionID);
-
- db.AddInParameter(dbCommand, "ErrorCode", DbType.Int32, null);
-
- DataSet dsToReturn = null;
- dsToReturn = db.ExecuteDataSet(dbCommand);
- return dsToReturn;
- }
-
- /// <summary>
- /// Purpose: Select method for a foreign key. This method will Select one or more rows from the database, based on the Foreign Key 'CountryID'.
- /// </summary>
- /// <returns></returns>
- public DataSet SelectAllWCountryID()
- {
- // Create the Database object, using the default database service. The
- // default database service is determined through configuration.
- Database db = DatabaseFactory.CreateDatabase("PlacementManager");
- string sqlCommand = "pr_Geo_AdministrativeDivision_DAL_SelectAllWCountryID";
- DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);
- db.AddInParameter(dbCommand, "CountryID", DbType.Int32, _CountryID);
- db.AddInParameter(dbCommand, "ErrorCode", DbType.Int32, null);
- DataSet dsToReturn = null;
- dsToReturn = db.ExecuteDataSet(dbCommand);
- return dsToReturn;
- }
-
- /// <summary>
- /// Inserts the current instance data into the database.
- /// </summary>
- /// <returns></returns>
- public int Insert()
- {
- // Create the Database object, using the default database service. The
- // default database service is determined through configuration.
- Database db = DatabaseFactory.CreateDatabase("PlacementManager");
-
- string sqlCommand = "pr_Geo_AdministrativeDivision_DAL_Insert";
- DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);
-
- // Add parameters
- db.AddInParameter(dbCommand,"CountryID", DbType.Int32, _CountryID);
- db.AddInParameter(dbCommand,"DivisionName", DbType.String, _DivisionName);
- db.AddInParameter(dbCommand,"DivisionPostalAbbreviation", DbType.StringFixedLength, _DivisionPostalAbbreviation);
- db.AddOutParameter(dbCommand, "AdministrativeDivisionID", DbType.Int32, 4);
- db.AddOutParameter(dbCommand, "ErrorCode", DbType.Int32, 4);
-
- db.ExecuteNonQuery(dbCommand);
-
- // Save output parameter values
- object param;
- param = db.GetParameterValue(dbCommand, "AdministrativeDivisionID");
- if (param == DBNull.Value) return 0;
- _AdministrativeDivisionID = (int)param;
-
- return _AdministrativeDivisionID;
- }
-
- /// <summary>
- /// Purpose: Update method. This method will Update one existing row in the database.
- /// </summary>
- /// <returns></returns>
- public bool Update()
- {
- // Create the Database object, using the default database service. The
- // default database service is determined through configuration.
- Database db = DatabaseFactory.CreateDatabase("PlacementManager");
-
- string sqlCommand = "pr_Geo_AdministrativeDivision_DAL_Update";
- DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);
-
-
- // Add parameters
- db.AddInParameter(dbCommand,"AdministrativeDivisionID", DbType.Int32, _AdministrativeDivisionID);
- db.AddInParameter(dbCommand,"CountryID", DbType.Int32, _CountryID);
- db.AddInParameter(dbCommand,"DivisionName", DbType.String, _DivisionName);
- db.AddInParameter(dbCommand,"DivisionPostalAbbreviation", DbType.StringFixedLength, _DivisionPostalAbbreviation);
-
-
- db.AddInParameter(dbCommand, "ErrorCode", DbType.Int32, null);
-
- //try
- //{
- db.ExecuteNonQuery(dbCommand);
- return true;
- //}
- //catch
- //{
- // return false;
- //}
- }
-
-
- /// <summary>
- /// Purpose: Delete method. This method will Delete one existing row in the database, based on the Primary Key.
- /// </summary>
- /// <returns></returns>
- public bool Delete()
- {
- // Create the Database object, using the default database service. The
- // default database service is determined through configuration.
- Database db = DatabaseFactory.CreateDatabase("PlacementManager");
-
- string sqlCommand = "pr_Geo_AdministrativeDivision_DAL_Delete";
- DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);
-
- try
- {
-
- db.AddInParameter(dbCommand, "AdministrativeDivisionID", DbType.Int32, _AdministrativeDivisionID);
-
- db.AddInParameter(dbCommand, "ErrorCode", DbType.Int32, null);
- db.ExecuteNonQuery(dbCommand);
- return true;
- }
- catch
- {
- return false;
- }
- }
- /// <summary>
- /// Purpose: Delete method for a foreign key. This method will Delete one or more rows from the database, based on the Foreign Key 'CountryID'.
- /// </summary>
- /// <returns></returns>
- public bool DeleteAllWCountryID()
- {
- // Create the Database object, using the default database service. The
- // default database service is determined through configuration.
- Database db = DatabaseFactory.CreateDatabase("PlacementManager");
- string sqlCommand = "pr_Geo_AdministrativeDivision_DAL_DeleteAllWCountryID";
- DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);
- try
- {
- db.AddInParameter(dbCommand, "CountryID", DbType.Int32, _CountryID);
- db.AddInParameter(dbCommand, "ErrorCode", DbType.Int32, null);
- db.ExecuteNonQuery(dbCommand);
- return true;
- }
- catch
- {
- return false;
- }
- }
-
-
- }
- }