// File Name: Customers_Dao_Base.cs

// Description: This file contains the generated code relating to 'Customers'.

// Last Generated: 6/8/2005 by Blue Ink - http://www.blueink.biz

// Attention: DO NOT MODIFY THIS FILE.  It is liable to be regenerated and your changes may be lost.

 

using System;

using System.Data;

using System.Data.SqlClient;

 

using AutomatedArchitecture.Northwind.Common.Entities;

using AutomatedArchitecture.Northwind.Dao.Helpers;

 

namespace AutomatedArchitecture.Northwind.Dao.Base {

      public class Customers_Dao_Base : MarshalByRefObject, IDisposable {

            protected string mstrSproc_Search = "bisp_Customers_Search";

            protected string mstrSproc_DeleteByPk = "bisp_Customers_DeleteByPrimaryKey";

            protected string mstrSproc_GetByPk = "bisp_Customers_SelectByPrimaryKey";

            protected string mstrSproc_GetByPkJoined = "bisp_Customers_SelectByPrimaryKeyJoined";

            protected string mstrSproc_GetAll = "bisp_Customers_SelectAll";

            protected string mstrSproc_Update = "bisp_Customers_Update";

            protected string mstrSproc_Insert = "bisp_Customers_Insert";

            protected string mstrSproc_SelectByCity = "bisp_Customers_SelectByCity";

            protected string mstrSproc_SelectByCompanyName = "bisp_Customers_SelectByCompanyName";

            protected string mstrSproc_SelectByPostalCode = "bisp_Customers_SelectByPostalCode";

            protected string mstrSproc_SelectByRegion = "bisp_Customers_SelectByRegion";

 

            public virtual void Insert(DataRow rowInsertInput, IDbTransaction tx, IDbConnection cn) {

                  // create insert command

                  SqlCommand cm = new SqlCommand(mstrSproc_Insert, (SqlConnection)cn);

                  cm.CommandType = CommandType.StoredProcedure;

                  if (tx != null)

                        cm.Transaction = (SqlTransaction)tx;

 

                  // add parameters

                  SqlParameter p;

                  // @Address

                  p = new SqlParameter("@Address", SqlDbType.NVarChar, 60);

                  p.Value = DaoHelper.GetDbValue(rowInsertInput, "Address");

                  cm.Parameters.Add(p);

                  // @City

                  p = new SqlParameter("@City", SqlDbType.NVarChar, 15);

                  p.Value = DaoHelper.GetDbValue(rowInsertInput, "City");

                  cm.Parameters.Add(p);

                  // @CompanyName

                  p = new SqlParameter("@CompanyName", SqlDbType.NVarChar, 40);

                  p.Value = DaoHelper.GetDbValue(rowInsertInput, "CompanyName");

                  cm.Parameters.Add(p);

                  // @ContactName

                  p = new SqlParameter("@ContactName", SqlDbType.NVarChar, 30);

                  p.Value = DaoHelper.GetDbValue(rowInsertInput, "ContactName");

                  cm.Parameters.Add(p);

                  // @ContactTitle

                  p = new SqlParameter("@ContactTitle", SqlDbType.NVarChar, 30);

                  p.Value = DaoHelper.GetDbValue(rowInsertInput, "ContactTitle");

                  cm.Parameters.Add(p);

                  // @Country

                  p = new SqlParameter("@Country", SqlDbType.NVarChar, 15);

                  p.Value = DaoHelper.GetDbValue(rowInsertInput, "Country");

                  cm.Parameters.Add(p);

                  // @CustomerID

                  p = new SqlParameter("@CustomerID", SqlDbType.NChar, 5);

                  p.Value = DaoHelper.GetDbValue(rowInsertInput, "CustomerID");

                  cm.Parameters.Add(p);

                  // @Fax

                  p = new SqlParameter("@Fax", SqlDbType.NVarChar, 24);

                  p.Value = DaoHelper.GetDbValue(rowInsertInput, "Fax");

                  cm.Parameters.Add(p);

                  // @Phone

                  p = new SqlParameter("@Phone", SqlDbType.NVarChar, 24);

                  p.Value = DaoHelper.GetDbValue(rowInsertInput, "Phone");

                  cm.Parameters.Add(p);

                  // @PostalCode

                  p = new SqlParameter("@PostalCode", SqlDbType.NVarChar, 10);

                  p.Value = DaoHelper.GetDbValue(rowInsertInput, "PostalCode");

                  cm.Parameters.Add(p);

                  // @Region

                  p = new SqlParameter("@Region", SqlDbType.NVarChar, 15);

                  p.Value = DaoHelper.GetDbValue(rowInsertInput, "Region");

                  cm.Parameters.Add(p);

 

                  // execute insert

                        cm.ExecuteNonQuery();

 

            }

 

            public virtual void Update(Customers_UpdateInputDataSet.CustomersRow rowUpdateInput, IDbTransaction tx, IDbConnection cn) {

                  string strCustomerID = rowUpdateInput.SelectByCustomerID;

                  // create update command

                  SqlCommand cm = new SqlCommand(mstrSproc_Update, (SqlConnection)cn);

                  cm.CommandType = CommandType.StoredProcedure;

                  if (tx != null)

                        cm.Transaction = (SqlTransaction)tx;

 

                  // add parameters

                  SqlParameter p;

                  // @SelectCustomerID

                  p = new SqlParameter("@SelectCustomerID", SqlDbType.NChar, 5);

                  p.Value = rowUpdateInput.SelectByCustomerID;

                  cm.Parameters.Add(p);

                  // @NewAddress

                  p = new SqlParameter("@NewAddress", SqlDbType.NVarChar, 60);

                  p.Value = DaoHelper.GetDbValue(rowUpdateInput, "Address");

                  cm.Parameters.Add(p);

                  // @NewCity

                  p = new SqlParameter("@NewCity", SqlDbType.NVarChar, 15);

                  p.Value = DaoHelper.GetDbValue(rowUpdateInput, "City");

                  cm.Parameters.Add(p);

                  // @NewCompanyName

                  p = new SqlParameter("@NewCompanyName", SqlDbType.NVarChar, 40);

                  p.Value = DaoHelper.GetDbValue(rowUpdateInput, "CompanyName");

                  cm.Parameters.Add(p);

                  // @NewContactName

                  p = new SqlParameter("@NewContactName", SqlDbType.NVarChar, 30);

                  p.Value = DaoHelper.GetDbValue(rowUpdateInput, "ContactName");

                  cm.Parameters.Add(p);

                  // @NewContactTitle

                  p = new SqlParameter("@NewContactTitle", SqlDbType.NVarChar, 30);

                  p.Value = DaoHelper.GetDbValue(rowUpdateInput, "ContactTitle");

                  cm.Parameters.Add(p);

                  // @NewCountry

                  p = new SqlParameter("@NewCountry", SqlDbType.NVarChar, 15);

                  p.Value = DaoHelper.GetDbValue(rowUpdateInput, "Country");

                  cm.Parameters.Add(p);

                  // @NewCustomerID

                  p = new SqlParameter("@NewCustomerID", SqlDbType.NChar, 5);

                  p.Value = DaoHelper.GetDbValue(rowUpdateInput, "CustomerID");

                  cm.Parameters.Add(p);

                  // @NewFax

                  p = new SqlParameter("@NewFax", SqlDbType.NVarChar, 24);

                  p.Value = DaoHelper.GetDbValue(rowUpdateInput, "Fax");

                  cm.Parameters.Add(p);

                  // @NewPhone

                  p = new SqlParameter("@NewPhone", SqlDbType.NVarChar, 24);

                  p.Value = DaoHelper.GetDbValue(rowUpdateInput, "Phone");

                  cm.Parameters.Add(p);

                  // @NewPostalCode

                  p = new SqlParameter("@NewPostalCode", SqlDbType.NVarChar, 10);

                  p.Value = DaoHelper.GetDbValue(rowUpdateInput, "PostalCode");

                  cm.Parameters.Add(p);

                  // @NewRegion

                  p = new SqlParameter("@NewRegion", SqlDbType.NVarChar, 15);

                  p.Value = DaoHelper.GetDbValue(rowUpdateInput, "Region");

                  cm.Parameters.Add(p);

 

                  // execute update

                  cm.ExecuteNonQuery();

 

                  // clean up

                  cm.Dispose();

            }

 

            public virtual void DeleteByPk(string strCustomerID, IDbTransaction tx, IDbConnection cn) {

                  SqlCommand cm = new SqlCommand(mstrSproc_DeleteByPk, (SqlConnection)cn);

                  cm.CommandType = CommandType.StoredProcedure;

                  if (tx != null)

                        cm.Transaction = (SqlTransaction)tx;

 

                  // add parameters

                  SqlParameter p;

                  // @CustomerID

                  p = new SqlParameter("@CustomerID", SqlDbType.NChar, 5);

                  p.Value = strCustomerID;

                  cm.Parameters.Add(p);

 

                  // execute delete

                  cm.ExecuteNonQuery();

 

                  // clean up

                  cm.Dispose();

            }

 

            public virtual void GetByPk(DataTable tblResults, string strCustomerID, IDbConnection cn) {

                  SqlCommand cm = new SqlCommand(mstrSproc_GetByPk, (SqlConnection)cn);

                  cm.CommandType = CommandType.StoredProcedure;

                  SqlDataAdapter da = new SqlDataAdapter(cm);

 

                  // add parameters

                  SqlParameter p;

                  // @CustomerID

                  p = new SqlParameter("@CustomerID", SqlDbType.NChar, 5);

                  p.Value = strCustomerID;

                  cm.Parameters.Add(p);

 

                  da.MissingSchemaAction = MissingSchemaAction.Ignore;

                  da.Fill(tblResults);

            }

 

            public virtual void GetByPkJoined(DataTable tblResults, string strCustomerID, IDbConnection cn) {

                  SqlCommand cm = new SqlCommand(mstrSproc_GetByPkJoined, (SqlConnection)cn);

                  cm.CommandType = CommandType.StoredProcedure;

                  SqlDataAdapter da = new SqlDataAdapter(cm);

 

                  // add parameters

                  SqlParameter p;

                  // @CustomerID

                  p = new SqlParameter("@CustomerID", SqlDbType.NChar, 5);

                  p.Value = strCustomerID;

                  cm.Parameters.Add(p);

 

                  da.MissingSchemaAction = MissingSchemaAction.Ignore;

                  da.Fill(tblResults);

            }

 

            public virtual void GetAll(DataTable tblResults, IDbConnection cn) {

                  SqlCommand cm = new SqlCommand(mstrSproc_GetAll, (SqlConnection)cn);

                  cm.CommandType = CommandType.StoredProcedure;

                  SqlDataAdapter da = new SqlDataAdapter(cm);

                  da.MissingSchemaAction = MissingSchemaAction.Ignore;

                  da.Fill(tblResults);

            }

 

            public virtual void GetByCity(DataTable tblResults, string strCity, IDbConnection cn) {

                  SqlCommand cm = new SqlCommand(mstrSproc_SelectByCity, (SqlConnection)cn);

                  cm.CommandType = CommandType.StoredProcedure;

                  SqlDataAdapter da = new SqlDataAdapter(cm);

 

                  // add parameters

                  SqlParameter p;

                  // @City

                  p = new SqlParameter("@City", SqlDbType.NVarChar, 15);

                  p.Value = strCity;

                  cm.Parameters.Add(p);

 

                  da.MissingSchemaAction = MissingSchemaAction.Ignore;

                  da.Fill(tblResults);

            }

 

            public virtual void GetByCompanyName(DataTable tblResults, string strCompanyName, IDbConnection cn) {

                  SqlCommand cm = new SqlCommand(mstrSproc_SelectByCompanyName, (SqlConnection)cn);

                  cm.CommandType = CommandType.StoredProcedure;

                  SqlDataAdapter da = new SqlDataAdapter(cm);

 

                  // add parameters

                  SqlParameter p;

                  // @CompanyName

                  p = new SqlParameter("@CompanyName", SqlDbType.NVarChar, 40);

                  p.Value = strCompanyName;

                  cm.Parameters.Add(p);

 

                  da.MissingSchemaAction = MissingSchemaAction.Ignore;

                  da.Fill(tblResults);

            }

 

            public virtual void GetByPostalCode(DataTable tblResults, string strPostalCode, IDbConnection cn) {

                  SqlCommand cm = new SqlCommand(mstrSproc_SelectByPostalCode, (SqlConnection)cn);

                  cm.CommandType = CommandType.StoredProcedure;

                  SqlDataAdapter da = new SqlDataAdapter(cm);

 

                  // add parameters

                  SqlParameter p;

                  // @PostalCode

                  p = new SqlParameter("@PostalCode", SqlDbType.NVarChar, 10);

                  p.Value = strPostalCode;

                  cm.Parameters.Add(p);

 

                  da.MissingSchemaAction = MissingSchemaAction.Ignore;

                  da.Fill(tblResults);

            }

 

            public virtual void GetByRegion(DataTable tblResults, string strRegion, IDbConnection cn) {

                  SqlCommand cm = new SqlCommand(mstrSproc_SelectByRegion, (SqlConnection)cn);

                  cm.CommandType = CommandType.StoredProcedure;

                  SqlDataAdapter da = new SqlDataAdapter(cm);

 

                  // add parameters

                  SqlParameter p;

                  // @Region

                  p = new SqlParameter("@Region", SqlDbType.NVarChar, 15);

                  p.Value = strRegion;

                  cm.Parameters.Add(p);

 

                  da.MissingSchemaAction = MissingSchemaAction.Ignore;

                  da.Fill(tblResults);

            }

 

            public virtual void Search (

                  DataTable tblResults,

                  Customers_SearchInputDataSet.CustomersRow rowSearchInput,

                  IDbConnection cn

                  ) {

 

                  // create search command

                  SqlCommand cm = new SqlCommand(mstrSproc_Search, (SqlConnection)cn);

                  cm.CommandType = CommandType.StoredProcedure;

                  SqlDataAdapter da = new SqlDataAdapter(cm);

 

                  // add parameters

                  SqlParameter p;

                  // @CompanyName

                  p = new SqlParameter("@CompanyName", SqlDbType.NVarChar, 40);

                  p.Value = DaoHelper.GetDbValue(rowSearchInput, "CompanyName");

                  cm.Parameters.Add(p);

                  // @CustomerID

                  p = new SqlParameter("@CustomerID", SqlDbType.NChar, 5);

                  p.Value = DaoHelper.GetDbValue(rowSearchInput, "CustomerID");

                  cm.Parameters.Add(p);

 

                  // retrieve the data

                  da.MissingSchemaAction = MissingSchemaAction.Ignore;

                  da.Fill(tblResults);

            }

 

            public void Dispose() {}

 

      }

}