/App_Code/DAL/_Geo_AdministrativeDivision_DAL.cs

# · C# · 259 lines · 145 code · 42 blank · 72 comment · 2 complexity · 9666669f63a40df3fd33934a3d3f7bfe MD5 · raw file

  1. /*
  2. '===============================================================================
  3. ' Generated From - DAAB_DAL_NET2.vbgen
  4. ' It is based on the DAAB from the November 2005 Enterprise Library
  5. '
  6. ' This object is 'abstract' which means you need to inherit from it to be able
  7. ' to instantiate it. This is very easily done. You can override properties and
  8. ' methods in your derived class, this allows you to regenerate this class at any
  9. ' time and not worry about overwriting custom code.
  10. '
  11. ' Custom DAL methods should be written into the inherited class.
  12. '
  13. ' Version: 1.0
  14. ' Date: 30/01/06
  15. ' Summary: SelectOne, SelectAll, SelectAllWForeignKey, Insert, Update, Delete,
  16. ' DeleteAllWForeignKey.
  17. '===============================================================================
  18. */
  19. using System;
  20. using System.Data;
  21. using System.Data.Common;
  22. using System.Configuration;
  23. using System.Web;
  24. using System.Web.Security;
  25. using System.Web.UI;
  26. using System.Web.UI.WebControls;
  27. using System.Web.UI.WebControls.WebParts;
  28. using System.Web.UI.HtmlControls;
  29. using Microsoft.Practices.EnterpriseLibrary.Data;
  30. using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
  31. namespace PlacementManager.DAL
  32. {
  33. public abstract class _Geo_AdministrativeDivision_DAL
  34. {
  35. #region Members
  36. protected int _AdministrativeDivisionID;
  37. protected int _CountryID;
  38. protected string _DivisionName;
  39. protected string _DivisionPostalAbbreviation;
  40. #endregion
  41. #region Properties
  42. public int AdministrativeDivisionID
  43. {
  44. get { return _AdministrativeDivisionID; }
  45. set { _AdministrativeDivisionID = value; }
  46. }
  47. public int CountryID
  48. {
  49. get { return _CountryID; }
  50. set { _CountryID = value; }
  51. }
  52. public string DivisionName
  53. {
  54. get { return _DivisionName; }
  55. set { _DivisionName = value; }
  56. }
  57. public string DivisionPostalAbbreviation
  58. {
  59. get { return _DivisionPostalAbbreviation; }
  60. set { _DivisionPostalAbbreviation = value; }
  61. }
  62. #endregion
  63. //Constructor
  64. public _Geo_AdministrativeDivision_DAL()
  65. {
  66. }
  67. /// <summary>
  68. /// Purpose: SelectAll method. This method will Select all rows from the table.
  69. /// </summary>
  70. /// <returns></returns>
  71. public DataSet SelectAll()
  72. {
  73. // Create the Database object, using the default database service. The
  74. // default database service is determined through configuration.
  75. Database db = DatabaseFactory.CreateDatabase("PlacementManager");
  76. string sqlCommand = "pr_Geo_AdministrativeDivision_DAL_SelectAll";
  77. DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);
  78. // Retrieve products from the specified category.
  79. db.AddInParameter(dbCommand, "ErrorCode", DbType.Int32, null);
  80. DataSet dsToReturn = null;
  81. dsToReturn = db.ExecuteDataSet(dbCommand);
  82. return dsToReturn;
  83. }
  84. /// <summary>
  85. /// Purpose: Select method. This method will Select one existing row from the database, based on the Primary Key.
  86. /// </summary>
  87. /// <returns></returns>
  88. public DataSet SelectOne()
  89. {
  90. // Create the Database object, using the default database service. The
  91. // default database service is determined through configuration.
  92. Database db = DatabaseFactory.CreateDatabase("PlacementManager");
  93. string sqlCommand = "pr_Geo_AdministrativeDivision_DAL_SelectOne";
  94. DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);
  95. db.AddInParameter(dbCommand, "AdministrativeDivisionID", DbType.Int32, _AdministrativeDivisionID);
  96. db.AddInParameter(dbCommand, "ErrorCode", DbType.Int32, null);
  97. DataSet dsToReturn = null;
  98. dsToReturn = db.ExecuteDataSet(dbCommand);
  99. return dsToReturn;
  100. }
  101. /// <summary>
  102. /// Purpose: Select method for a foreign key. This method will Select one or more rows from the database, based on the Foreign Key 'CountryID'.
  103. /// </summary>
  104. /// <returns></returns>
  105. public DataSet SelectAllWCountryID()
  106. {
  107. // Create the Database object, using the default database service. The
  108. // default database service is determined through configuration.
  109. Database db = DatabaseFactory.CreateDatabase("PlacementManager");
  110. string sqlCommand = "pr_Geo_AdministrativeDivision_DAL_SelectAllWCountryID";
  111. DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);
  112. db.AddInParameter(dbCommand, "CountryID", DbType.Int32, _CountryID);
  113. db.AddInParameter(dbCommand, "ErrorCode", DbType.Int32, null);
  114. DataSet dsToReturn = null;
  115. dsToReturn = db.ExecuteDataSet(dbCommand);
  116. return dsToReturn;
  117. }
  118. /// <summary>
  119. /// Inserts the current instance data into the database.
  120. /// </summary>
  121. /// <returns></returns>
  122. public int Insert()
  123. {
  124. // Create the Database object, using the default database service. The
  125. // default database service is determined through configuration.
  126. Database db = DatabaseFactory.CreateDatabase("PlacementManager");
  127. string sqlCommand = "pr_Geo_AdministrativeDivision_DAL_Insert";
  128. DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);
  129. // Add parameters
  130. db.AddInParameter(dbCommand,"CountryID", DbType.Int32, _CountryID);
  131. db.AddInParameter(dbCommand,"DivisionName", DbType.String, _DivisionName);
  132. db.AddInParameter(dbCommand,"DivisionPostalAbbreviation", DbType.StringFixedLength, _DivisionPostalAbbreviation);
  133. db.AddOutParameter(dbCommand, "AdministrativeDivisionID", DbType.Int32, 4);
  134. db.AddOutParameter(dbCommand, "ErrorCode", DbType.Int32, 4);
  135. db.ExecuteNonQuery(dbCommand);
  136. // Save output parameter values
  137. object param;
  138. param = db.GetParameterValue(dbCommand, "AdministrativeDivisionID");
  139. if (param == DBNull.Value) return 0;
  140. _AdministrativeDivisionID = (int)param;
  141. return _AdministrativeDivisionID;
  142. }
  143. /// <summary>
  144. /// Purpose: Update method. This method will Update one existing row in the database.
  145. /// </summary>
  146. /// <returns></returns>
  147. public bool Update()
  148. {
  149. // Create the Database object, using the default database service. The
  150. // default database service is determined through configuration.
  151. Database db = DatabaseFactory.CreateDatabase("PlacementManager");
  152. string sqlCommand = "pr_Geo_AdministrativeDivision_DAL_Update";
  153. DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);
  154. // Add parameters
  155. db.AddInParameter(dbCommand,"AdministrativeDivisionID", DbType.Int32, _AdministrativeDivisionID);
  156. db.AddInParameter(dbCommand,"CountryID", DbType.Int32, _CountryID);
  157. db.AddInParameter(dbCommand,"DivisionName", DbType.String, _DivisionName);
  158. db.AddInParameter(dbCommand,"DivisionPostalAbbreviation", DbType.StringFixedLength, _DivisionPostalAbbreviation);
  159. db.AddInParameter(dbCommand, "ErrorCode", DbType.Int32, null);
  160. //try
  161. //{
  162. db.ExecuteNonQuery(dbCommand);
  163. return true;
  164. //}
  165. //catch
  166. //{
  167. // return false;
  168. //}
  169. }
  170. /// <summary>
  171. /// Purpose: Delete method. This method will Delete one existing row in the database, based on the Primary Key.
  172. /// </summary>
  173. /// <returns></returns>
  174. public bool Delete()
  175. {
  176. // Create the Database object, using the default database service. The
  177. // default database service is determined through configuration.
  178. Database db = DatabaseFactory.CreateDatabase("PlacementManager");
  179. string sqlCommand = "pr_Geo_AdministrativeDivision_DAL_Delete";
  180. DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);
  181. try
  182. {
  183. db.AddInParameter(dbCommand, "AdministrativeDivisionID", DbType.Int32, _AdministrativeDivisionID);
  184. db.AddInParameter(dbCommand, "ErrorCode", DbType.Int32, null);
  185. db.ExecuteNonQuery(dbCommand);
  186. return true;
  187. }
  188. catch
  189. {
  190. return false;
  191. }
  192. }
  193. /// <summary>
  194. /// Purpose: Delete method for a foreign key. This method will Delete one or more rows from the database, based on the Foreign Key 'CountryID'.
  195. /// </summary>
  196. /// <returns></returns>
  197. public bool DeleteAllWCountryID()
  198. {
  199. // Create the Database object, using the default database service. The
  200. // default database service is determined through configuration.
  201. Database db = DatabaseFactory.CreateDatabase("PlacementManager");
  202. string sqlCommand = "pr_Geo_AdministrativeDivision_DAL_DeleteAllWCountryID";
  203. DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);
  204. try
  205. {
  206. db.AddInParameter(dbCommand, "CountryID", DbType.Int32, _CountryID);
  207. db.AddInParameter(dbCommand, "ErrorCode", DbType.Int32, null);
  208. db.ExecuteNonQuery(dbCommand);
  209. return true;
  210. }
  211. catch
  212. {
  213. return false;
  214. }
  215. }
  216. }
  217. }