using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using
YellowbridgeSoftwareInc.Info;
namespace
YellowbridgeSoftwareInc.BusinessBase
{
/// <summary>
///
Purpose: Business base class for the table 'Shippers'.
/// </summary>
public class
Shippers
{
#region Class Member Declarations
string
_connectionString;
SqlConnection _cn;
private int _ShipperID;
private string _CompanyName;
private string _Phone;
private bool
_PhoneIsNull = true;
#endregion
public Shippers( string
connectionString )
{
_connectionString = connectionString ;
}
// Create a new
BusinessBase.Shippers object and fill it with data by it's primary key
public Shippers( string
connectionString, int ShipperID )
{
_connectionString = connectionString ;
// Fill the object with
data by primary key
Fill( ShipperID
);
}
public Shippers( SqlConnection cn )
{
_cn = cn;
}
// Create a new
BusinessBase.Shippers object and fill it with data by it's primary key
public Shippers( SqlConnection cn, int
ShipperID )
{
_cn = cn;
// Fill the object with
data by primary key
Fill( ShipperID
);
}
#region Select One Methods
public void Fill( int
ShipperID )
{
// Get new transport
object
ShippersInfo info = new
ShippersInfo();
// Get a Persist.Shippers
Persist.Shippers persist;
if ( _cn == null )
persist = new
Persist.Shippers( _connectionString );
else
persist = new
Persist.Shippers( _cn );
// Fill the transport
persist.SelectOneInfo( ref
info, ShipperID );
// Fill the fields
FillFromTransport( info );
}
public void Fill()
{
// Get new transport
object
ShippersInfo info = new
ShippersInfo();
// Get a Persist.Shippers
Persist.Shippers persist;
if ( _cn == null )
persist = new
Persist.Shippers( _connectionString );
else
persist = new
Persist.Shippers( _cn );
// Fill the transport
persist.SelectOneInfo( ref
info, ShipperID );
// Fill the fields
FillFromTransport( info );
}
public ShippersInfo
SelectOneInfo( int ShipperID )
{
// Get a Persist.Shippers
Persist.Shippers persist;
if ( _cn == null )
persist = new
Persist.Shippers( _connectionString );
else
persist = new
Persist.Shippers( _cn );
return
persist.SelectOneInfo( ShipperID );
}
public DataTable
SelectOneDataTable( int ShipperID )
{
// Get a Persist.Shippers
Persist.Shippers
persist;
if ( _cn == null )
persist = new
Persist.Shippers( _connectionString );
else
persist = new
Persist.Shippers( _cn );
return
persist.SelectOneDataTable( ShipperID );
}
public SqlDataReader
SelectOneDataReader( int ShipperID )
{
// Get a Persist.Shippers
Persist.Shippers persist;
if ( _cn == null )
persist = new
Persist.Shippers( _connectionString );
else
persist = new
Persist.Shippers( _cn );
return
persist.SelectOneDataReader( ShipperID
);
}
#endregion
#region Select All Methods
public
ShippersInfoCollection SelectAllInfoCollection()
{
// Create a collection
ShippersInfoCollection infoCollection = new ShippersInfoCollection();
// Create a
ersist.Shippers
Persist.Shippers persist;
if ( _cn == null )
persist = new
Persist.Shippers( _connectionString );
else
persist = new
Persist.Shippers( _cn );
// Fill the info
collection
persist.SelectAllInfoCollection( ref infoCollection );
// Return the collection
return
infoCollection;
}
public DataTable
SelectAllDataTable()
{
// Create a
Persist.Shippers
Persist.Shippers persist;
if ( _cn == null )
persist = new
Persist.Shippers( _connectionString );
else
persist = new
Persist.Shippers( _cn );
return
persist.SelectAllDataTable( );
}
public SqlDataReader
SelectAllDataReader()
{
// Create a
Persist.Shippers
Persist.Shippers persist;
if ( _cn == null )
persist = new
Persist.Shippers( _connectionString );
else
persist = new
Persist.Shippers( _cn );
return
persist.SelectAllDataReader( );
}
#endregion
#region Foreign Key Methods
public OrdersInfoCollection GetOrdersByShipVia()
{
// Create the where
clause
string whereClause
= "[Orders].[ShipVia] = " + _ShipperID.ToString() ;
// Create a collection
OrdersInfoCollection infoCollection = new OrdersInfoCollection();
// Create a
Persist.Shippers
Persist.Orders persist;
if ( _cn == null )
persist = new
Persist.Orders( _connectionString );
else
persist = new
Persist.Orders( _cn );
// Fill the collection
persist.SelectWhereInfoCollection( ref infoCollection, whereClause );
// Return the collection
return
infoCollection;
}
public DataTable
GetDataTableByShipVia()
{
// Create the where
clause
string whereClause
= "[Orders].[ShipVia] = " + _ShipperID.ToString() ;
// Create a DataTable
DataTable dt;
// Create a
Persist.Shippers
Persist.Orders persist;
if ( _cn == null )
persist = new
Persist.Orders( _connectionString );
else
persist = new
Persist.Orders( _cn );
// Get the DataTable
dt = persist.SelectWhereDataTable( whereClause );
// Return the DataTable
return dt;
}
public SqlDataReader
GetDataReaderByShipVia()
{
// Create the where
clause
string whereClause
= "[Orders].[ShipVia] = " + _ShipperID.ToString() ;
// Create a DataReader
SqlDataReader dr;
// Create a
Persist.Shippers
Persist.Orders persist;
if ( _cn == null )
persist = new
Persist.Orders( _connectionString );
else
persist = new
Persist.Orders( _cn );
// Get the SqlDataReader
dr = persist.SelectWhereDataReader( whereClause );
// Return the DataReader
return dr;
}
#endregion
#region Select Where Methods
public
ShippersInfoCollection SelectWhereInfoCollection( string
whereClause )
{
// Create a collection
ShippersInfoCollection infoCollection = new ShippersInfoCollection();
// Create a
Persist.Shippers
Persist.Shippers persist;
if ( _cn == null )
persist = new
Persist.Shippers( _connectionString );
else
persist = new
Persist.Shippers( _cn );
// Fill the collection
persist.SelectWhereInfoCollection( ref infoCollection, whereClause );
// Return the collection
return
infoCollection;
}
public DataTable
SelectWhereDataTable( string whereClause )
{
// Create a
Persist.Shippers
Persist.Shippers persist;
if ( _cn == null )
persist = new
Persist.Shippers( _connectionString );
else
persist = new
Persist.Shippers( _cn );
// Return the DataTable
return
persist.SelectWhereDataTable( whereClause );
}
public SqlDataReader
SelectWhereDataReader( string whereClause )
{
// Create a
Persist.Shippers
Persist.Shippers persist;
if ( _cn == null )
persist = new
Persist.Shippers( _connectionString );
else
persist = new
Persist.Shippers( _cn );
// Return the DataTable
return
persist.SelectWhereDataReader( whereClause );
}
#endregion
#region Insert Methods
public bool Insert ()
{
ShippersInfo info = PackageTransport();
Persist.Shippers persist;
if ( _cn == null )
persist = new
Persist.Shippers( _connectionString );
else
persist = new
Persist.Shippers( _cn );
bool insertSuccess
= persist.Insert( ref info );
// Fill the fields
FillFromTransport( info );
return
insertSuccess;
}
public ArrayList Insert
( ref
ShippersInfoCollection data)
{
Persist.Shippers persist;
if ( _cn == null )
persist = new
Persist.Shippers( _connectionString );
else
persist = new
Persist.Shippers( _cn );
return
persist.Insert( ref data );
}
public bool Insert ( ref ShippersInfo data)
{
Persist.Shippers persist;
if ( _cn == null )
persist = new
Persist.Shippers( _connectionString );
else
persist = new
Persist.Shippers( _cn );
return
persist.Insert( ref data );
}
public bool Insert ( out int
ShipperIDOutput, string CompanyName, string Phone )
{
Persist.Shippers persist;
if ( _cn == null )
persist = new
Persist.Shippers( _connectionString );
else
persist = new
Persist.Shippers( _cn );
return persist.Insert( out
ShipperIDOutput, CompanyName, Phone );
}
public static bool Insert(
SqlTransaction transaction, ref ShippersInfo
data )
{
return
Persist.Shippers.Insert( transaction, ref data
);
}
public static bool Insert(
SqlTransaction transaction, ShippersInfo data )
{
return
Persist.Shippers.Insert( transaction, data );
}
#endregion
#region Update Methods
public bool Update ()
{
ShippersInfo info = PackageTransport();
Persist.Shippers persist;
if ( _cn == null )
persist = new
Persist.Shippers( _connectionString );
else
persist = new
Persist.Shippers( _cn );
bool updateSuccess
= persist.Update( ref info );
// Fill the fields
FillFromTransport( info );
return
updateSuccess;
}
public ArrayList Update
( ref
ShippersInfoCollection data)
{
Persist.Shippers persist;
if ( _cn == null )
persist = new
Persist.Shippers( _connectionString );
else
persist = new
Persist.Shippers( _cn );
return
persist.Update( ref data );
}
public bool Update( ShippersInfo data)
{
Persist.Shippers persist;
if ( _cn == null )
persist = new
Persist.Shippers( _connectionString );
else
persist = new
Persist.Shippers( _cn );
return
persist.Update( data );
}
public bool Update( ref
ShippersInfo data)
{
Persist.Shippers persist;
if ( _cn == null )
persist = new
Persist.Shippers( _connectionString );
else
persist = new
Persist.Shippers( _cn );
return
persist.Update( ref data );
}
public bool Update( int
ShipperID, string CompanyName, string Phone )
{
Persist.Shippers persist;
if ( _cn == null )
persist = new
Persist.Shippers( _connectionString );
else
persist = new
Persist.Shippers( _cn );
return
persist.Update( ShipperID, CompanyName, Phone
);
}
public static bool Update(
SqlTransaction transaction, ref ShippersInfo
data)
{
return
Persist.Shippers.Update( transaction, ref data
);
}
public static bool Update (
SqlTransaction transaction, ShippersInfo data )
{
return
Persist.Shippers.Update( transaction, data );
}
#endregion
#region Delete Methods
public bool Delete()
{
Persist.Shippers persist;
if ( _cn == null )
persist = new
Persist.Shippers( _connectionString );
else
persist = new
Persist.Shippers( _cn );
bool deleteSuccess
= persist.Delete( ShipperID );
return deleteSuccess;
}
public bool Delete( int
ShipperID )
{
Persist.Shippers persist;
if ( _cn == null )
persist = new
Persist.Shippers( _connectionString );