Work Request DAL Work Request IDAL
| |
DAL = Data Access Layer
Sample .NET Class
///////////////////////////////////////////////////////////////////////////
// Description: Data Access class for the table 'Assignment'
// Generated by LLBLGen v1.2.1045.38210 Final on: Thursday, November 21, 2002, 3:16:28 PM
// Because the Base Class already implements IDispose, this class doesn't.
///////////////////////////////////////////////////////////////////////////
using System;
using System.Data;
using System.Data.SqlTypes;
using System.Data.SqlClient;
namespace WorkRequestLLBL
{
/// <summary>
/// Purpose: Data Access class for the table 'Assignment'.
/// </summary>
public class Assignment : DBInteractionBase
{
#region Class Member Declarations
private SqlInt32 _priorityID, _priorityIDOld, _requestID, _requestIDOld, _projectID, _projectIDOld, _personID, _personIDOld, _assignmentID, _departmentID, _departmentIDOld;
private SqlInt16 _number, _priorityRank;
#endregion
/// <summary>
/// Purpose: Class constructor.
/// </summary>
public Assignment()
{
// Nothing for now.
}
/// <summary>
/// Purpose: Insert method. This method will insert one new row into the database.
/// </summary>
/// <returns>True if succeeded, otherwise an Exception is thrown. </returns>
/// <remarks>
/// Properties needed for this method:
/// <UL>
/// <LI>PersonID. May be SqlInt32.Null</LI>
/// <LI>DepartmentID. May be SqlInt32.Null</LI>
/// <LI>PriorityID. May be SqlInt32.Null</LI>
/// <LI>PriorityRank. May be SqlInt16.Null</LI>
/// <LI>RequestID</LI>
/// <LI>Number</LI>
/// <LI>ProjectID. May be SqlInt32.Null</LI>
/// </UL>
/// Properties set after a succesful call of this method:
/// <UL>
/// <LI>AssignmentID</LI>
/// <LI>ErrorCode</LI>
/// </UL>
/// </remarks>
public override bool Insert()
{
SqlCommand cmdToExecute = new SqlCommand();
cmdToExecute.CommandText = "dbo.[sp_Assignment_Insert]";
cmdToExecute.CommandType = CommandType.StoredProcedure;
// Use base class' connection object
cmdToExecute.Connection = _mainConnection;
try
{
cmdToExecute.Parameters.Add(new SqlParameter("@iPersonID", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, _personID));
cmdToExecute.Parameters.Add(new SqlParameter("@iDepartmentID", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, _departmentID));
cmdToExecute.Parameters.Add(new SqlParameter("@iPriorityID", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, _priorityID));
cmdToExecute.Parameters.Add(new SqlParameter("@siPriorityRank", SqlDbType.SmallInt, 2, ParameterDirection.Input, true, 5, 0, "", DataRowVersion.Proposed, _priorityRank));
cmdToExecute.Parameters.Add(new SqlParameter("@iRequestID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, _requestID));
cmdToExecute.Parameters.Add(new SqlParameter("@siNumber", SqlDbType.SmallInt, 2, ParameterDirection.Input, false, 5, 0, "", DataRowVersion.Proposed, _number));
cmdToExecute.Parameters.Add(new SqlParameter("@iProjectID", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, _projectID));
cmdToExecute.Parameters.Add(new SqlParameter("@iAssignmentID", SqlDbType.Int, 4, ParameterDirection.Output, true, 10, 0, "", DataRowVersion.Proposed, _assignmentID));
cmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, true, 10, 0, "", DataRowVersion.Proposed, _errorCode));
if(_mainConnectionIsCreatedLocal)
{
// Open connection.
_mainConnection.Open();
}
else
{
if(_mainConnectionProvider.IsTransactionPending)
{
cmdToExecute.Transaction = _mainConnectionProvider.CurrentTransaction;
}
}
// Execute query.
cmdToExecute.ExecuteNonQuery();
_assignmentID = (Int32)cmdToExecute.Parameters["@iAssignmentID"].Value;
_errorCode = (Int32)cmdToExecute.Parameters["@iErrorCode"].Value;
if(_errorCode != (int)LLBLError.AllOk)
{
// Throw error.
throw new Exception("Stored Procedure 'sp_Assignment_Insert' reported the ErrorCode: " + _errorCode);
}
return true;
}
catch(Exception ex)
{
// some error occured. Bubble it to caller and encapsulate Exception object
throw new Exception("Assignment::Insert::Error occured.", ex);
}
finally
{
if(_mainConnectionIsCreatedLocal)
{
// Close connection.
_mainConnection.Close();
}
cmdToExecute.Dispose();
}
}
/// <summary>
/// Purpose: Update method. This method will Update one existing row in the database.
/// </summary>
/// <returns>True if succeeded, otherwise an Exception is thrown. </returns>
/// <remarks>
/// Properties needed for this method:
/// <UL>
/// <LI>AssignmentID</LI>
/// <LI>PersonID. May be SqlInt32.Null</LI>
/// <LI>DepartmentID. May be SqlInt32.Null</LI>
/// <LI>PriorityID. May be SqlInt32.Null</LI>
/// <LI>PriorityRank. May be SqlInt16.Null</LI>
/// <LI>RequestID</LI>
/// <LI>Number</LI>
/// <LI>ProjectID. May be SqlInt32.Null</LI>
/// </UL>
/// Properties set after a succesful call of this method:
/// <UL>
/// <LI>ErrorCode</LI>
/// </UL>
/// </remarks>
public override bool Update()
{
SqlCommand cmdToExecute = new SqlCommand();
cmdToExecute.CommandText = "dbo.[sp_Assignment_Update]";
cmdToExecute.CommandType = CommandType.StoredProcedure;
// Use base class' connection object
cmdToExecute.Connection = _mainConnection;
try
{
cmdToExecute.Parameters.Add(new SqlParameter("@iAssignmentID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, _assignmentID));
cmdToExecute.Parameters.Add(new SqlParameter("@iPersonID", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, _personID));
cmdToExecute.Parameters.Add(new SqlParameter("@iDepartmentID", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, _departmentID));
cmdToExecute.Parameters.Add(new SqlParameter("@iPriorityID", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, _priorityID));
cmdToExecute.Parameters.Add(new SqlParameter("@siPriorityRank", SqlDbType.SmallInt, 2, ParameterDirection.Input, true, 5, 0, "", DataRowVersion.Proposed, _priorityRank));
cmdToExecute.Parameters.Add(new SqlParameter("@iRequestID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, _requestID));
cmdToExecute.Parameters.Add(new SqlParameter("@siNumber", SqlDbType.SmallInt, 2, ParameterDirection.Input, false, 5, 0, "", DataRowVersion.Proposed, _number));
cmdToExecute.Parameters.Add(new SqlParameter("@iProjectID", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, _projectID));
cmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, true, 10, 0, "", DataRowVersion.Proposed, _errorCode));
if(_mainConnectionIsCreatedLocal)
{
// Open connection.
_mainConnection.Open();
}
else
{
if(_mainConnectionProvider.IsTransactionPending)
{
cmdToExecute.Transaction = _mainConnectionProvider.CurrentTransaction;
}
}
// Execute query.
cmdToExecute.ExecuteNonQuery();
_errorCode = (Int32)cmdToExecute.Parameters["@iErrorCode"].Value;
if(_errorCode != (int)LLBLError.AllOk)
{
// Throw error.
throw new Exception("Stored Procedure 'sp_Assignment_Update' reported the ErrorCode: " + _errorCode);
}
return true;
}
catch(Exception ex)
{
// some error occured. Bubble it to caller and encapsulate Exception object
throw new Exception("Assignment::Update::Error occured.", ex);
}
finally
{
if(_mainConnectionIsCreatedLocal)
{
// Close connection.
_mainConnection.Close();
}
cmdToExecute.Dispose();
}
}
/// <summary>
/// Purpose: Update method for updating one or more rows using the Foreign Key 'PersonID.
/// This method will Update one or more existing rows in the database. It will reset the field 'PersonID' in
/// all rows which have as value for this field the value as set in property 'PersonIDOld' to
/// the value as set in property 'PersonID'.
/// </summary>
/// <returns>True if succeeded, otherwise an Exception is thrown. </returns>
/// <remarks>
/// Properties needed for this method:
/// <UL>
/// <LI>PersonID. May be SqlInt32.Null</LI>
/// <LI>PersonIDOld. May be SqlInt32.Null</LI>
/// </UL>
/// Properties set after a succesful call of this method:
/// <UL>
/// <LI>ErrorCode</LI>
/// </UL>
/// </remarks>
public bool UpdateAllWPersonIDLogic()
{
SqlCommand cmdToExecute = new SqlCommand();
cmdToExecute.CommandText = "dbo.[sp_Assignment_UpdateAllWPersonIDLogic]";
cmdToExecute.CommandType = CommandType.StoredProcedure;
// Use base class' connection object
cmdToExecute.Connection = _mainConnection;
try
{
cmdToExecute.Parameters.Add(new SqlParameter("@iPersonID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, _personID));
cmdToExecute.Parameters.Add(new SqlParameter("@iPersonIDOld", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, _personIDOld));
cmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, true, 10, 0, "", DataRowVersion.Proposed, _errorCode));
if(_mainConnectionIsCreatedLocal)
{
// Open connection.
_mainConnection.Open();
}
else
{
if(_mainConnectionProvider.IsTransactionPending)
{
cmdToExecute.Transaction = _mainConnectionProvider.CurrentTransaction;
}
}
// Execute query.
cmdToExecute.ExecuteNonQuery();
_errorCode = (Int32)cmdToExecute.Parameters["@iErrorCode"].Value;
if(_errorCode != (int)LLBLError.AllOk)
{
// Throw error.
throw new Exception("Stored Procedure 'sp_Assignment_UpdateAllWPersonIDLogic' reported the ErrorCode: " + _errorCode);
}
return true;
}
catch(Exception ex)
{
// some error occured. Bubble it to caller and encapsulate Exception object
throw new Exception("Assignment::UpdateAllWPersonIDLogic::Error occured.", ex);
}
finally
{
if(_mainConnectionIsCreatedLocal)
{
// Close connection.
_mainConnection.Close();
}
cmdToExecute.Dispose();
}
}
/// <summary>
/// Purpose: Update method for updating one or more rows using the Foreign Key 'DepartmentID.
/// This method will Update one or more existing rows in the database. It will reset the field 'DepartmentID' in
/// all rows which have as value for this field the value as set in property 'DepartmentIDOld' to
/// the value as set in property 'DepartmentID'.
/// </summary>
/// <returns>True if succeeded, otherwise an Exception is thrown. </returns>
/// <remarks>
/// Properties needed for this method:
/// <UL>
/// <LI>DepartmentID. May be SqlInt32.Null</LI>
/// <LI>DepartmentIDOld. May be SqlInt32.Null</LI>
/// </UL>
/// Properties set after a succesful call of this method:
/// <UL>
/// <LI>ErrorCode</LI>
/// </UL>
/// </remarks>
public bool UpdateAllWDepartmentIDLogic()
{
SqlCommand cmdToExecute = new SqlCommand();
cmdToExecute.CommandText = "dbo.[sp_Assignment_UpdateAllWDepartmentIDLogic]";
cmdToExecute.CommandType = CommandType.StoredProcedure;
// Use base class' connection object
cmdToExecute.Connection = _mainConnection;
try
{
cmdToExecute.Parameters.Add(new SqlParameter("@iDepartmentID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, _departmentID));
cmdToExecute.Parameters.Add(new SqlParameter("@iDepartmentIDOld", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, _departmentIDOld));
cmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, true, 10, 0, "", DataRowVersion.Proposed, _errorCode));
if(_mainConnectionIsCreatedLocal)
{
// Open connection.
_mainConnection.Open();
}
else
{
if(_mainConnectionProvider.IsTransactionPending)
{
cmdToExecute.Transaction = _mainConnectionProvider.CurrentTransaction;
}
}
// Execute query.
cmdToExecute.ExecuteNonQuery();
_errorCode = (Int32)cmdToExecute.Parameters["@iErrorCode"].Value;
if(_errorCode != (int)LLBLError.AllOk)
{
// Throw error.
throw new Exception("Stored Procedure 'sp_Assignment_UpdateAllWDepartmentIDLogic' reported the ErrorCode: " + _errorCode);
}
return true;
}
catch(Exception ex)
{
// some error occured. Bubble it to caller and encapsulate Exception object
throw new Exception("Assignment::UpdateAllWDepartmentIDLogic::Error occured.", ex);
}
finally
{
if(_mainConnectionIsCreatedLocal)
{
// Close connection.
_mainConnection.Close();
}
cmdToExecute.Dispose();
}
}
/// <summary>
/// Purpose: Update method for updating one or more rows using the Foreign Key 'PriorityID.
/// This method will Update one or more existing rows in the database. It will reset the field 'PriorityID' in
/// all rows which have as value for this field the value as set in property 'PriorityIDOld' to
/// the value as set in property 'PriorityID'.
/// </summary>
/// <returns>True if succeeded, otherwise an Exception is thrown. </returns>
/// <remarks>
/// Properties needed for this method:
/// <UL>
/// <LI>PriorityID. May be SqlInt32.Null</LI>
/// <LI>PriorityIDOld. May be SqlInt32.Null</LI>
/// </UL>
/// Properties set after a succesful call of this method:
/// <UL>
/// <LI>ErrorCode</LI>
/// </UL>
/// </remarks>
public bool UpdateAllWPriorityIDLogic()
{
SqlCommand cmdToExecute = new SqlCommand();
cmdToExecute.CommandText = "dbo.[sp_Assignment_UpdateAllWPriorityIDLogic]";
cmdToExecute.CommandType = CommandType.StoredProcedure;
// Use base class' connection object
cmdToExecute.Connection = _mainConnection;
try
{
cmdToExecute.Parameters.Add(new SqlParameter("@iPriorityID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, _priorityID));
cmdToExecute.Parameters.Add(new SqlParameter("@iPriorityIDOld", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, _priorityIDOld));
cmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, true, 10, 0, "", DataRowVersion.Proposed, _errorCode));
if(_mainConnectionIsCreatedLocal)
{
// Open connection.
_mainConnection.Open();
}
else
{
if(_mainConnectionProvider.IsTransactionPending)
{
cmdToExecute.Transaction = _mainConnectionProvider.CurrentTransaction;
}
}
// Execute query.
cmdToExecute.ExecuteNonQuery();
_errorCode = (Int32)cmdToExecute.Parameters["@iErrorCode"].Value;
if(_errorCode != (int)LLBLError.AllOk)
{
// Throw error.
throw new Exception("Stored Procedure 'sp_Assignment_UpdateAllWPriorityIDLogic' reported the ErrorCode: " + _errorCode);
}
return true;
}
catch(Exception ex)
{
// some error occured. Bubble it to caller and encapsulate Exception object
throw new Exception("Assignment::UpdateAllWPriorityIDLogic::Error occured.", ex);
}
finally
{
if(_mainConnectionIsCreatedLocal)
{
// Close connection.
_mainConnection.Close();
}
cmdToExecute.Dispose();
}
}
/// <summary>
/// Purpose: Update method for updating one or more rows using the Foreign Key 'RequestID.
/// This method will Update one or more existing rows in the database. It will reset the field 'RequestID' in
/// all rows which have as value for this field the value as set in property 'RequestIDOld' to
/// the value as set in property 'RequestID'.
/// </summary>
/// <returns>True if succeeded, otherwise an Exception is thrown. </returns>
/// <remarks>
/// Properties needed for this method:
/// <UL>
/// <LI>RequestID</LI>
/// <LI>RequestIDOld</LI>
/// </UL>
/// Properties set after a succesful call of this method:
/// <UL>
/// <LI>ErrorCode</LI>
/// </UL>
/// </remarks>
public bool UpdateAllWRequestIDLogic()
{
SqlCommand cmdToExecute = new SqlCommand();
cmdToExecute.CommandText = "dbo.[sp_Assignment_UpdateAllWRequestIDLogic]";
cmdToExecute.CommandType = CommandType.StoredProcedure;
// Use base class' connection object
cmdToExecute.Connection = _mainConnection;
try
{
cmdToExecute.Parameters.Add(new SqlParameter("@iRequestID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, _requestID));
cmdToExecute.Parameters.Add(new SqlParameter("@iRequestIDOld", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, _requestIDOld));
cmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, true, 10, 0, "", DataRowVersion.Proposed, _errorCode));
if(_mainConnectionIsCreatedLocal)
{
// Open connection.
_mainConnection.Open();
}
else
{
if(_mainConnectionProvider.IsTransactionPending)
{
cmdToExecute.Transaction = _mainConnectionProvider.CurrentTransaction;
}
}
// Execute query.
cmdToExecute.ExecuteNonQuery();
_errorCode = (Int32)cmdToExecute.Parameters["@iErrorCode"].Value;
if(_errorCode != (int)LLBLError.AllOk)
{
// Throw error.
throw new Exception("Stored Procedure 'sp_Assignment_UpdateAllWRequestIDLogic' reported the ErrorCode: " + _errorCode);
}
return true;
}
catch(Exception ex)
{
// some error occured. Bubble it to caller and encapsulate Exception object
throw new Exception("Assignment::UpdateAllWRequestIDLogic::Error occured.", ex);
}
finally
{
if(_mainConnectionIsCreatedLocal)
{
// Close connection.
_mainConnection.Close();
}
cmdToExecute.Dispose();
}
}
/// <summary>
/// Purpose: Update method for updating one or more rows using the Foreign Key 'ProjectID.
/// This method will Update one or more existing rows in the database. It will reset the field 'ProjectID' in
/// all rows which have as value for this field the value as set in property 'ProjectIDOld' to
/// the value as set in property 'ProjectID'.
/// </summary>
/// <returns>True if succeeded, otherwise an Exception is thrown. </returns>
/// <remarks>
/// Properties needed for this method:
/// <UL>
/// <LI>ProjectID. May be SqlInt32.Null</LI>
/// <LI>ProjectIDOld. May be SqlInt32.Null</LI>
/// </UL>
/// Properties set after a succesful call of this method:
/// <UL>
/// <LI>ErrorCode</LI>
/// </UL>
/// </remarks>
public bool UpdateAllWProjectIDLogic()
{
SqlCommand cmdToExecute = new SqlCommand();
cmdToExecute.CommandText = "dbo.[sp_Assignment_UpdateAllWProjectIDLogic]";
cmdToExecute.CommandType = CommandType.StoredProcedure;
// Use base class' connection object
cmdToExecute.Connection = _mainConnection;
try
{
cmdToExecute.Parameters.Add(new SqlParameter("@iProjectID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, _projectID));
cmdToExecute.Parameters.Add(new SqlParameter("@iProjectIDOld", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, _projectIDOld));
cmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, true, 10, 0, "", DataRowVersion.Proposed, _errorCode));
if(_mainConnectionIsCreatedLocal)
{
// Open connection.
_mainConnection.Open();
}
else
{
if(_mainConnectionProvider.IsTransactionPending)
{
cmdToExecute.Transaction = _mainConnectionProvider.CurrentTransaction;
}
}
// Execute query.
cmdToExecute.ExecuteNonQuery();
_errorCode = (Int32)cmdToExecute.Parameters["@iErrorCode"].Value;
if(_errorCode != (int)LLBLError.AllOk)
{
// Throw error.
throw new Exception("Stored Procedure 'sp_Assignment_UpdateAllWProjectIDLogic' reported the ErrorCode: " + _errorCode);
}
return true;
}
catch(Exception ex)
{
// some error occured. Bubble it to caller and encapsulate Exception object
throw new Exception("Assignment::UpdateAllWProjectIDLogic::Error occured.", ex);
}
finally
{
if(_mainConnectionIsCreatedLocal)
{
// Close connection.
_mainConnection.Close();
}
cmdToExecute.Dispose();
}
}
/// <summary>
/// Purpose: Delete method. This method will Delete one existing row in the database, based on the Primary Key.
/// </summary>
/// <returns>True if succeeded, otherwise an Exception is thrown. </returns>
/// <remarks>
/// Properties needed for this method:
/// <UL>
/// <LI>AssignmentID</LI>
/// </UL>
/// Properties set after a succesful call of this method:
/// <UL>
/// <LI>ErrorCode</LI>
/// </UL>
/// </remarks>
public override bool Delete()
{
SqlCommand cmdToExecute = new SqlCommand();
cmdToExecute.CommandText = "dbo.[sp_Assignment_Delete]";
cmdToExecute.CommandType = CommandType.StoredProcedure;
// Use base class' connection object
cmdToExecute.Connection = _mainConnection;
try
{
cmdToExecute.Parameters.Add(new SqlParameter("@iAssignmentID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, _assignmentID));
cmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, true, 10, 0, "", DataRowVersion.Proposed, _errorCode));
if(_mainConnectionIsCreatedLocal)
{
// Open connection.
_mainConnection.Open();
}
else
{
if(_mainConnectionProvider.IsTransactionPending)
{
cmdToExecute.Transaction = _mainConnectionProvider.CurrentTransaction;
}
}
// Execute query.
cmdToExecute.ExecuteNonQuery();
_errorCode = (Int32)cmdToExecute.Parameters["@iErrorCode"].Value;
if(_errorCode != (int)LLBLError.AllOk)
{
// Throw error.
throw new Exception("Stored Procedure 'sp_Assignment_Delete' reported the ErrorCode: " + _errorCode);
}
return true;
}
catch(Exception ex)
{
// some error occured. Bubble it to caller and encapsulate Exception object
throw new Exception("Assignment::Delete::Error occured.", ex);
}
finally
{
if(_mainConnectionIsCreatedLocal)
{
// Close connection.
_mainConnection.Close();
}
cmdToExecute.Dispose();
}
}
/// <summary>
/// Purpose: Select method. This method will Select one existing row from the database, based on the Primary Key.
/// </summary>
/// <returns>DataTable object if succeeded, otherwise an Exception is thrown. </returns>
/// <remarks>
/// Properties needed for this method:
/// <UL>
/// <LI>AssignmentID</LI>
/// </UL>
/// Properties set after a succesful call of this method:
/// <UL>
/// <LI>ErrorCode</LI>
/// <LI>AssignmentID</LI>
/// <LI>PersonID</LI>
/// <LI>DepartmentID</LI>
/// <LI>PriorityID</LI>
/// <LI>PriorityRank</LI>
/// <LI>RequestID</LI>
/// <LI>Number</LI>
/// <LI>ProjectID</LI>
/// </UL>
/// Will fill all properties corresponding with a field in the table with the value of the row selected.
/// </remarks>
public override DataTable SelectOne()
{
SqlCommand cmdToExecute = new SqlCommand();
cmdToExecute.CommandText = "dbo.[sp_Assignment_SelectOne]";
cmdToExecute.CommandType = CommandType.StoredProcedure;
DataTable toReturn = new DataTable("Assignment");
SqlDataAdapter adapter = new SqlDataAdapter(cmdToExecute);
// Use base class' connection object
cmdToExecute.Connection = _mainConnection;
try
{
cmdToExecute.Parameters.Add(new SqlParameter("@iAssignmentID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, _assignmentID));
cmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, true, 10, 0, "", DataRowVersion.Proposed, _errorCode));
if(_mainConnectionIsCreatedLocal)
{
// Open connection.
_mainConnection.Open();
}
else
{
if(_mainConnectionProvider.IsTransactionPending)
{
cmdToExecute.Transaction = _mainConnectionProvider.CurrentTransaction;
}
}
// Execute query.
adapter.Fill(toReturn);
_errorCode = (Int32)cmdToExecute.Parameters["@iErrorCode"].Value;
if(_errorCode != (int)LLBLError.AllOk)
{
// Throw error.
throw new Exception("Stored Procedure 'sp_Assignment_SelectOne' reported the ErrorCode: " + _errorCode);
}
if(toReturn.Rows.Count > 0)
{
_assignmentID = (Int32)toReturn.Rows[0]["AssignmentID"];
_personID = toReturn.Rows[0]["PersonID"] == System.DBNull.Value ? SqlInt32.Null : (Int32)toReturn.Rows[0]["PersonID"];
_departmentID = toReturn.Rows[0]["DepartmentID"] == System.DBNull.Value ? SqlInt32.Null : (Int32)toReturn.Rows[0]["DepartmentID"];
_priorityID = toReturn.Rows[0]["PriorityID"] == System.DBNull.Value ? SqlInt32.Null : (Int32)toReturn.Rows[0]["PriorityID"];
_priorityRank = toReturn.Rows[0]["PriorityRank"] == System.DBNull.Value ? SqlInt16.Null : (Int16)toReturn.Rows[0]["PriorityRank"];
_requestID = (Int32)toReturn.Rows[0]["RequestID"];
_number = (Int16)toReturn.Rows[0]["Number"];
_projectID = toReturn.Rows[0]["ProjectID"] == System.DBNull.Value ? SqlInt32.Null : (Int32)toReturn.Rows[0]["ProjectID"];
}
return toReturn;
}
catch(Exception ex)
{
// some error occured. Bubble it to caller and encapsulate Exception object
throw new Exception("Assignment::SelectOne::Error occured.", ex);
}
finally
{
if(_mainConnectionIsCreatedLocal)
{
// Close connection.
_mainConnection.Close();
}
cmdToExecute.Dispose();
adapter.Dispose();
}
}
/// <summary>
/// Purpose: SelectAll method. This method will Select all rows from the table.
/// </summary>
/// <returns>DataTable object if succeeded, otherwise an Exception is thrown. </returns>
/// <remarks>
/// Properties set after a succesful call of this method:
/// <UL>
/// <LI>ErrorCode</LI>
/// </UL>
/// </remarks>
public override DataTable SelectAll()
{
SqlCommand cmdToExecute = new SqlCommand();
cmdToExecute.CommandText = "dbo.[sp_Assignment_SelectAll]";
cmdToExecute.CommandType = CommandType.StoredProcedure;
DataTable toReturn = new DataTable("Assignment");
SqlDataAdapter adapter = new SqlDataAdapter(cmdToExecute);
// Use base class' connection object
cmdToExecute.Connection = _mainConnection;
try
{
cmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, true, 10, 0, "", DataRowVersion.Proposed, _errorCode));
if(_mainConnectionIsCreatedLocal)
{
// Open connection.
_mainConnection.Open();
}
else
{
if(_mainConnectionProvider.IsTransactionPending)
{
cmdToExecute.Transaction = _mainConnectionProvider.CurrentTransaction;
}
}
// Execute query.
adapter.Fill(toReturn);
_errorCode = (Int32)cmdToExecute.Parameters["@iErrorCode"].Value;
if(_errorCode != (int)LLBLError.AllOk)
{
// Throw error.
throw new Exception("Stored Procedure 'sp_Assignment_SelectAll' reported the ErrorCode: " + _errorCode);
}
return toReturn;
}
catch(Exception ex)
{
// some error occured. Bubble it to caller and encapsulate Exception object
throw new Exception("Assignment::SelectAll::Error occured.", ex);
}
finally
{
if(_mainConnectionIsCreatedLocal)
{
// Close connection.
_mainConnection.Close();
}
cmdToExecute.Dispose();
adapter.Dispose();
}
}
/// <summary>
/// Purpose: Select method for a foreign key. This method will Select one or more rows from the database, based on the Foreign Key 'PersonID'
/// </summary>
/// <returns>DataTable object if succeeded, otherwise an Exception is thrown. </returns>
/// <remarks>
/// Properties needed for this method:
/// <UL>
/// <LI>PersonID. May be SqlInt32.Null</LI>
/// </UL>
/// Properties set after a succesful call of this method:
/// <UL>
/// <LI>ErrorCode</LI>
/// </UL>
/// </remarks>
public DataTable SelectAllWPersonIDLogic()
{
SqlCommand cmdToExecute = new SqlCommand();
cmdToExecute.CommandText = "dbo.[sp_Assignment_SelectAllWPersonIDLogic]";
cmdToExecute.CommandType = CommandType.StoredProcedure;
DataTable toReturn = new DataTable("Assignment");
SqlDataAdapter adapter = new SqlDataAdapter(cmdToExecute);
// Use base class' connection object
cmdToExecute.Connection = _mainConnection;
try
{
cmdToExecute.Parameters.Add(new SqlParameter("@iPersonID", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, _personID));
cmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, true, 10, 0, "", DataRowVersion.Proposed, _errorCode));
if(_mainConnectionIsCreatedLocal)
{
// Open connection.
_mainConnection.Open();
}
else
{
if(_mainConnectionProvider.IsTransactionPending)
{
cmdToExecute.Transaction = _mainConnectionProvider.CurrentTransaction;
}
}
// Execute query.
adapter.Fill(toReturn);
_errorCode = (Int32)cmdToExecute.Parameters["@iErrorCode"].Value;
if(_errorCode != (int)LLBLError.AllOk)
{
// Throw error.
throw new Exception("Stored Procedure 'sp_Assignment_SelectAllWPersonIDLogic' reported the ErrorCode: " + _errorCode);
}
return toReturn;
}
catch(Exception ex)
{
// some error occured. Bubble it to caller and encapsulate Exception object
throw new Exception("Assignment::SelectAllWPersonIDLogic::Error occured.", ex);
}
finally
{
if(_mainConnectionIsCreatedLocal)
{
// Close connection.
_mainConnection.Close();
}
cmdToExecute.Dispose();
adapter.Dispose();
}
}
/// <summary>
/// Purpose: Select method for a foreign key. This method will Select one or more rows from the database, based on the Foreign Key 'DepartmentID'
/// </summary>
/// <returns>DataTable object if succeeded, otherwise an Exception is thrown. </returns>
/// <remarks>
/// Properties needed for this method:
/// <UL>
/// <LI>DepartmentID. May be SqlInt32.Null</LI>
/// </UL>
/// Properties set after a succesful call of this method:
/// <UL>
/// <LI>ErrorCode</LI>
/// </UL>
/// </remarks>
public DataTable SelectAllWDepartmentIDLogic()
{
SqlCommand cmdToExecute = new SqlCommand();
cmdToExecute.CommandText = "dbo.[sp_Assignment_SelectAllWDepartmentIDLogic]";
cmdToExecute.CommandType = CommandType.StoredProcedure;
DataTable toReturn = new DataTable("Assignment");
SqlDataAdapter adapter = new SqlDataAdapter(cmdToExecute);
// Use base class' connection object
cmdToExecute.Connection = _mainConnection;
try
{
cmdToExecute.Parameters.Add(new SqlParameter("@iDepartmentID", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, _departmentID));
cmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, true, 10, 0, "", DataRowVersion.Proposed, _errorCode));
if(_mainConnectionIsCreatedLocal)
{
// Open connection.
_mainConnection.Open();
}
else
{
if(_mainConnectionProvider.IsTransactionPending)
{
cmdToExecute.Transaction = _mainConnectionProvider.CurrentTransaction;
}
}
// Execute query.
adapter.Fill(toReturn);
_errorCode = (Int32)cmdToExecute.Parameters["@iErrorCode"].Value;
if(_errorCode != (int)LLBLError.AllOk)
{
// Throw error.
throw new Exception("Stored Procedure 'sp_Assignment_SelectAllWDepartmentIDLogic' reported the ErrorCode: " + _errorCode);
}
return toReturn;
}
catch(Exception ex)
{
// some error occured. Bubble it to caller and encapsulate Exception object
throw new Exception("Assignment::SelectAllWDepartmentIDLogic::Error occured.", ex);
}
finally
{
if(_mainConnectionIsCreatedLocal)
{
// Close connection.
_mainConnection.Close();
}
cmdToExecute.Dispose();
adapter.Dispose();
}
}
/// <summary>
/// Purpose: Select method for a foreign key. This method will Select one or more rows from the database, based on the Foreign Key 'PriorityID'
/// </summary>
/// <returns>DataTable object if succeeded, otherwise an Exception is thrown. </returns>
/// <remarks>
/// Properties needed for this method:
/// <UL>
/// <LI>PriorityID. May be SqlInt32.Null</LI>
/// </UL>
/// Properties set after a succesful call of this method:
/// <UL>
/// <LI>ErrorCode</LI>
/// </UL>
/// </remarks>
public DataTable SelectAllWPriorityIDLogic()
{
SqlCommand cmdToExecute = new SqlCommand();
cmdToExecute.CommandText = "dbo.[sp_Assignment_SelectAllWPriorityIDLogic]";
cmdToExecute.CommandType = CommandType.StoredProcedure;
DataTable toReturn = new DataTable("Assignment");
SqlDataAdapter adapter = new SqlDataAdapter(cmdToExecute);
// Use base class' connection object
cmdToExecute.Connection = _mainConnection;
try
{
cmdToExecute.Parameters.Add(new SqlParameter("@iPriorityID", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, _priorityID));
cmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, true, 10, 0, "", DataRowVersion.Proposed, _errorCode));
if(_mainConnectionIsCreatedLocal)
{
// Open connection.
_mainConnection.Open();
}
else
{
if(_mainConnectionProvider.IsTransactionPending)
{
cmdToExecute.Transaction = _mainConnectionProvider.CurrentTransaction;
}
}
// Execute query.
adapter.Fill(toReturn);
_errorCode = (Int32)cmdToExecute.Parameters["@iErrorCode"].Value;
if(_errorCode != (int)LLBLError.AllOk)
{
// Throw error.
throw new Exception("Stored Procedure 'sp_Assignment_SelectAllWPriorityIDLogic' reported the ErrorCode: " + _errorCode);
}
return toReturn;
}
catch(Exception ex)
{
// some error occured. Bubble it to caller and encapsulate Exception object
throw new Exception("Assignment::SelectAllWPriorityIDLogic::Error occured.", ex);
}
finally
{
if(_mainConnectionIsCreatedLocal)
{
// Close connection.
_mainConnection.Close();
}
cmdToExecute.Dispose();
adapter.Dispose();
}
}
/// <summary>
/// Purpose: Select method for a foreign key. This method will Select one or more rows from the database, based on the Foreign Key 'RequestID'
/// </summary>
/// <returns>DataTable object if succeeded, otherwise an Exception is thrown. </returns>
/// <remarks>
/// Properties needed for this method:
/// <UL>
/// <LI>RequestID</LI>
/// </UL>
/// Properties set after a succesful call of this method:
/// <UL>
/// <LI>ErrorCode</LI>
/// </UL>
/// </remarks>
public DataTable SelectAllWRequestIDLogic()
{
SqlCommand cmdToExecute = new SqlCommand();
cmdToExecute.CommandText = "dbo.[sp_Assignment_SelectAllWRequestIDLogic]";
cmdToExecute.CommandType = CommandType.StoredProcedure;
DataTable toReturn = new DataTable("Assignment");
SqlDataAdapter adapter = new SqlDataAdapter(cmdToExecute);
// Use base class' connection object
cmdToExecute.Connection = _mainConnection;
try
{
cmdToExecute.Parameters.Add(new SqlParameter("@iRequestID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, _requestID));
cmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, true, 10, 0, "", DataRowVersion.Proposed, _errorCode));
if(_mainConnectionIsCreatedLocal)
{
// Open connection.
_mainConnection.Open();
}
else
{
if(_mainConnectionProvider.IsTransactionPending)
{
cmdToExecute.Transaction = _mainConnectionProvider.CurrentTransaction;
}
}
// Execute query.
adapter.Fill(toReturn);
_errorCode = (Int32)cmdToExecute.Parameters["@iErrorCode"].Value;
if(_errorCode != (int)LLBLError.AllOk)
{
// Throw error.
throw new Exception("Stored Procedure 'sp_Assignment_SelectAllWRequestIDLogic' reported the ErrorCode: " + _errorCode);
}
return toReturn;
}
catch(Exception ex)
{
// some error occured. Bubble it to caller and encapsulate Exception object
throw new Exception("Assignment::SelectAllWRequestIDLogic::Error occured.", ex);
}
finally
{
if(_mainConnectionIsCreatedLocal)
{
// Close connection.
_mainConnection.Close();
}
cmdToExecute.Dispose();
adapter.Dispose();
}
}
/// <summary>
/// Purpose: Select method for a foreign key. This method will Select one or more rows from the database, based on the Foreign Key 'ProjectID'
/// </summary>
/// <returns>DataTable object if succeeded, otherwise an Exception is thrown. </returns>
/// <remarks>
/// Properties needed for this method:
/// <UL>
/// <LI>ProjectID. May be SqlInt32.Null</LI>
/// </UL>
/// Properties set after a succesful call of this method:
/// <UL>
/// <LI>ErrorCode</LI>
/// </UL>
/// </remarks>
public DataTable SelectAllWProjectIDLogic()
{
SqlCommand cmdToExecute = new SqlCommand();
cmdToExecute.CommandText = "dbo.[sp_Assignment_SelectAllWProjectIDLogic]";
cmdToExecute.CommandType = CommandType.StoredProcedure;
DataTable toReturn = new DataTable("Assignment");
SqlDataAdapter adapter = new SqlDataAdapter(cmdToExecute);
// Use base class' connection object
cmdToExecute.Connection = _mainConnection;
try
{
cmdToExecute.Parameters.Add(new SqlParameter("@iProjectID", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, _projectID));
cmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, true, 10, 0, "", DataRowVersion.Proposed, _errorCode));
if(_mainConnectionIsCreatedLocal)
{
// Open connection.
_mainConnection.Open();
}
else
{
if(_mainConnectionProvider.IsTransactionPending)
{
cmdToExecute.Transaction = _mainConnectionProvider.CurrentTransaction;
}
}
// Execute query.
adapter.Fill(toReturn);
_errorCode = (Int32)cmdToExecute.Parameters["@iErrorCode"].Value;
if(_errorCode != (int)LLBLError.AllOk)
{
// Throw error.
throw new Exception("Stored Procedure 'sp_Assignment_SelectAllWProjectIDLogic' reported the ErrorCode: " + _errorCode);
}
return toReturn;
}
catch(Exception ex)
{
// some error occured. Bubble it to caller and encapsulate Exception object
throw new Exception("Assignment::SelectAllWProjectIDLogic::Error occured.", ex);
}
finally
{
if(_mainConnectionIsCreatedLocal)
{
// Close connection.
_mainConnection.Close();
}
cmdToExecute.Dispose();
adapter.Dispose();
}
}
#region Class Property Declarations
public SqlInt32 AssignmentID
{
get
{
return _assignmentID;
}
set
{
SqlInt32 assignmentIDTmp = (SqlInt32)value;
if(assignmentIDTmp.IsNull)
{
throw new ArgumentOutOfRangeException("AssignmentID", "AssignmentID can't be NULL");
}
_assignmentID = value;
}
}
public SqlInt32 PersonID
{
get
{
return _personID;
}
set
{
_personID = value;
}
}
public SqlInt32 PersonIDOld
{
get
{
return _personIDOld;
}
set
{
_personIDOld = value;
}
}
public SqlInt32 DepartmentID
{
get
{
return _departmentID;
}
set
{
_departmentID = value;
}
}
public SqlInt32 DepartmentIDOld
{
get
{
return _departmentIDOld;
}
set
{
_departmentIDOld = value;
}
}
public SqlInt32 PriorityID
{
get
{
return _priorityID;
}
set
{
_priorityID = value;
}
}
public SqlInt32 PriorityIDOld
{
get
{
return _priorityIDOld;
}
set
{
_priorityIDOld = value;
}
}
public SqlInt16 PriorityRank
{
get
{
return _priorityRank;
}
set
{
_priorityRank = value;
}
}
public SqlInt32 RequestID
{
get
{
return _requestID;
}
set
{
SqlInt32 requestIDTmp = (SqlInt32)value;
if(requestIDTmp.IsNull)
{
throw new ArgumentOutOfRangeException("RequestID", "RequestID can't be NULL");
}
_requestID = value;
}
}
public SqlInt32 RequestIDOld
{
get
{
return _requestIDOld;
}
set
{
SqlInt32 requestIDOldTmp = (SqlInt32)value;
if(requestIDOldTmp.IsNull)
{
throw new ArgumentOutOfRangeException("RequestIDOld", "RequestIDOld can't be NULL");
}
_requestIDOld = value;
}
}
public SqlInt16 Number
{
get
{
return _number;
}
set
{
SqlInt16 numberTmp = (SqlInt16)value;
if(numberTmp.IsNull)
{
throw new ArgumentOutOfRangeException("Number", "Number can't be NULL");
}
_number = value;
}
}
public SqlInt32 ProjectID
{
get
{
return _projectID;
}
set
{
_projectID = value;
}
}
public SqlInt32 ProjectIDOld
{
get
{
return _projectIDOld;
}
set
{
_projectIDOld = value;
}
}
#endregion
}
}
|
|
|