// File Name: Orders_Dao_Base.cs

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

// 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 Orders_Dao_Base : MarshalByRefObject, IDisposable {

            protected string mstrSproc_Search = "bisp_Orders_Search";

            protected string mstrSproc_DeleteByPk = "bisp_Orders_DeleteByPrimaryKey";

            protected string mstrSproc_GetByPk = "bisp_Orders_SelectByPrimaryKey";

            protected string mstrSproc_GetByPkJoined = "bisp_Orders_SelectByPrimaryKeyJoined";

            protected string mstrSproc_GetAll = "bisp_Orders_SelectAll";

            protected string mstrSproc_Update = "bisp_Orders_Update";

            protected string mstrSproc_Insert = "bisp_Orders_Insert";

            protected string mstrSproc_SelectByCustomerID = "bisp_Orders_SelectByCustomerID";

            protected string mstrSproc_SelectByEmployeeID = "bisp_Orders_SelectByEmployeeID";

            protected string mstrSproc_SelectByOrderDate = "bisp_Orders_SelectByOrderDate";

            protected string mstrSproc_SelectByShippedDate = "bisp_Orders_SelectByShippedDate";

            protected string mstrSproc_SelectByShipVia = "bisp_Orders_SelectByShipVia";

            protected string mstrSproc_SelectByShipPostalCode = "bisp_Orders_SelectByShipPostalCode";

 

            public virtual int 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;

                  // @CustomerID

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

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

                  cm.Parameters.Add(p);

                  // @EmployeeID

                  p = new SqlParameter("@EmployeeID", SqlDbType.Int);

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

                  cm.Parameters.Add(p);

                  // @Freight

                  p = new SqlParameter("@Freight", SqlDbType.Money);

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

                  cm.Parameters.Add(p);

                  // @OrderDate

                  p = new SqlParameter("@OrderDate", SqlDbType.DateTime);

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

                  cm.Parameters.Add(p);

                  // @OrderID OUTPUT

                  SqlParameter pNewPk = new SqlParameter("@OrderID", SqlDbType.Int);

                  pNewPk.Direction = ParameterDirection.Output;

                  cm.Parameters.Add(pNewPk);

                  // @RequiredDate

                  p = new SqlParameter("@RequiredDate", SqlDbType.DateTime);

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

                  cm.Parameters.Add(p);

                  // @ShipAddress

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

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

                  cm.Parameters.Add(p);

                  // @ShipCity

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

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

                  cm.Parameters.Add(p);

                  // @ShipCountry

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

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

                  cm.Parameters.Add(p);

                  // @ShipName

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

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

                  cm.Parameters.Add(p);

                  // @ShippedDate

                  p = new SqlParameter("@ShippedDate", SqlDbType.DateTime);

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

                  cm.Parameters.Add(p);

                  // @ShipPostalCode

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

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

                  cm.Parameters.Add(p);

                  // @ShipRegion

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

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

                  cm.Parameters.Add(p);

                  // @ShipVia

                  p = new SqlParameter("@ShipVia", SqlDbType.Int);

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

                  cm.Parameters.Add(p);

 

                  int intNewPk;

                  // execute insert

                        cm.ExecuteNonQuery();

                        intNewPk = Convert.ToInt32(pNewPk.Value);

 

                  return intNewPk;

            }

 

            public virtual void Update(Orders_UpdateInputDataSet.OrdersRow rowUpdateInput, IDbTransaction tx, IDbConnection cn) {

                  int intOrderID = rowUpdateInput.SelectByOrderID;

                  // 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;

                  // @SelectOrderID

                  p = new SqlParameter("@SelectOrderID", SqlDbType.Int);

                  p.Value = rowUpdateInput.SelectByOrderID;

                  cm.Parameters.Add(p);

                  // @NewCustomerID

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

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

                  cm.Parameters.Add(p);

                  // @NewEmployeeID

                  p = new SqlParameter("@NewEmployeeID", SqlDbType.Int);

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

                  cm.Parameters.Add(p);

                  // @NewFreight

                  p = new SqlParameter("@NewFreight", SqlDbType.Money);

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

                  cm.Parameters.Add(p);

                  // @NewOrderDate

                  p = new SqlParameter("@NewOrderDate", SqlDbType.DateTime);

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

                  cm.Parameters.Add(p);

                  // @NewRequiredDate

                  p = new SqlParameter("@NewRequiredDate", SqlDbType.DateTime);

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

                  cm.Parameters.Add(p);

                  // @NewShipAddress

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

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

                  cm.Parameters.Add(p);

                  // @NewShipCity

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

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

                  cm.Parameters.Add(p);

                  // @NewShipCountry

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

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

                  cm.Parameters.Add(p);

                  // @NewShipName

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

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

                  cm.Parameters.Add(p);

                  // @NewShippedDate

                  p = new SqlParameter("@NewShippedDate", SqlDbType.DateTime);

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

                  cm.Parameters.Add(p);

                  // @NewShipPostalCode

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

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

                  cm.Parameters.Add(p);

                  // @NewShipRegion

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

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

                  cm.Parameters.Add(p);

                  // @NewShipVia

                  p = new SqlParameter("@NewShipVia", SqlDbType.Int);

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

                  cm.Parameters.Add(p);

 

                  // execute update

                  cm.ExecuteNonQuery();

 

                  // clean up

                  cm.Dispose();

            }

 

            public virtual void DeleteByPk(int intOrderID, 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;

                  // @OrderID

                  p = new SqlParameter("@OrderID", SqlDbType.Int);

                  p.Value = intOrderID;

                  cm.Parameters.Add(p);

 

                  // execute delete

                  cm.ExecuteNonQuery();

 

                  // clean up

                  cm.Dispose();

            }

 

            public virtual void GetByPk(DataTable tblResults, int intOrderID, IDbConnection cn) {

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

                  cm.CommandType = CommandType.StoredProcedure;

                  SqlDataAdapter da = new SqlDataAdapter(cm);

 

                  // add parameters

                  SqlParameter p;

                  // @OrderID

                  p = new SqlParameter("@OrderID", SqlDbType.Int);

                  p.Value = intOrderID;

                  cm.Parameters.Add(p);

 

                  da.MissingSchemaAction = MissingSchemaAction.Ignore;

                  da.Fill(tblResults);

            }

 

            public virtual void GetByPkJoined(DataTable tblResults, int intOrderID, IDbConnection cn) {

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

                  cm.CommandType = CommandType.StoredProcedure;

                  SqlDataAdapter da = new SqlDataAdapter(cm);

 

                  // add parameters

                  SqlParameter p;

                  // @OrderID

                  p = new SqlParameter("@OrderID", SqlDbType.Int);

                  p.Value = intOrderID;

                  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 GetByCustomerID(DataTable tblResults, string strCustomerID, IDbConnection cn) {

                  SqlCommand cm = new SqlCommand(mstrSproc_SelectByCustomerID, (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 GetByEmployeeID(DataTable tblResults, int intEmployeeID, IDbConnection cn) {

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

                  cm.CommandType = CommandType.StoredProcedure;

                  SqlDataAdapter da = new SqlDataAdapter(cm);

 

                  // add parameters

                  SqlParameter p;

                  // @EmployeeID

                  p = new SqlParameter("@EmployeeID", SqlDbType.Int);

                  p.Value = intEmployeeID;

                  cm.Parameters.Add(p);

 

                  da.MissingSchemaAction = MissingSchemaAction.Ignore;

                  da.Fill(tblResults);

            }

 

            public virtual void GetByShipVia(DataTable tblResults, int intShipVia, IDbConnection cn) {

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

                  cm.CommandType = CommandType.StoredProcedure;

                  SqlDataAdapter da = new SqlDataAdapter(cm);

 

                  // add parameters

                  SqlParameter p;

                  // @ShipVia

                  p = new SqlParameter("@ShipVia", SqlDbType.Int);

                  p.Value = intShipVia;

                  cm.Parameters.Add(p);

 

                  da.MissingSchemaAction = MissingSchemaAction.Ignore;

                  da.Fill(tblResults);

            }

 

 

 

 

 

            public virtual void GetByOrderDate(DataTable tblResults, System.DateTime objOrderDate, IDbConnection cn) {

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

                  cm.CommandType = CommandType.StoredProcedure;

                  SqlDataAdapter da = new SqlDataAdapter(cm);

 

                  // add parameters

                  SqlParameter p;

                  // @OrderDate

                  p = new SqlParameter("@OrderDate", SqlDbType.DateTime);

                  p.Value = objOrderDate;

                  cm.Parameters.Add(p);

 

                  da.MissingSchemaAction = MissingSchemaAction.Ignore;

                  da.Fill(tblResults);

            }

 

            public virtual void GetByShippedDate(DataTable tblResults, System.DateTime objShippedDate, IDbConnection cn) {

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

                  cm.CommandType = CommandType.StoredProcedure;

                  SqlDataAdapter da = new SqlDataAdapter(cm);

 

                  // add parameters

                  SqlParameter p;

                  // @ShippedDate

                  p = new SqlParameter("@ShippedDate", SqlDbType.DateTime);

                  p.Value = objShippedDate;

                  cm.Parameters.Add(p);

 

                  da.MissingSchemaAction = MissingSchemaAction.Ignore;

                  da.Fill(tblResults);

            }

 

 

            public virtual void GetByShipPostalCode(DataTable tblResults, string strShipPostalCode, IDbConnection cn) {

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

                  cm.CommandType = CommandType.StoredProcedure;

                  SqlDataAdapter da = new SqlDataAdapter(cm);

 

                  // add parameters

                  SqlParameter p;

                  // @ShipPostalCode

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

                  p.Value = strShipPostalCode;

                  cm.Parameters.Add(p);

 

                  da.MissingSchemaAction = MissingSchemaAction.Ignore;

                  da.Fill(tblResults);

            }

 

            public virtual void Search (

                  DataTable tblResults,

                  Orders_SearchInputDataSet.OrdersRow 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;

                  // @CustomerID

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

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

                  cm.Parameters.Add(p);

                  // @EmployeeID

                  p = new SqlParameter("@EmployeeID", SqlDbType.Int);

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

                  cm.Parameters.Add(p);

                  // @OrderDate

                  p = new SqlParameter("@OrderDate", SqlDbType.DateTime);

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

                  cm.Parameters.Add(p);

 

                  // retrieve the data

                  da.MissingSchemaAction = MissingSchemaAction.Ignore;

                  da.Fill(tblResults);

            }

 

            public void Dispose() {}

 

      }

}