// File Name: OrderDetails_Dao_Base.cs

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

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

            protected string mstrSproc_Search = "bisp_OrderDetails_Search";

            protected string mstrSproc_DeleteByPk = "bisp_OrderDetails_DeleteByPrimaryKey";

            protected string mstrSproc_GetByPk = "bisp_OrderDetails_SelectByPrimaryKey";

            protected string mstrSproc_GetByPkJoined = "bisp_OrderDetails_SelectByPrimaryKeyJoined";

            protected string mstrSproc_GetAll = "bisp_OrderDetails_SelectAll";

            protected string mstrSproc_Update = "bisp_OrderDetails_Update";

            protected string mstrSproc_Insert = "bisp_OrderDetails_Insert";

            protected string mstrSproc_SelectByOrderID = "bisp_OrderDetails_SelectByOrderID";

            protected string mstrSproc_SelectByProductID = "bisp_OrderDetails_SelectByProductID";

 

            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;

                  // @Discount

                  p = new SqlParameter("@Discount", SqlDbType.Real);

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

                  cm.Parameters.Add(p);

                  // @OrderID

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

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

                  cm.Parameters.Add(p);

                  // @ProductID

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

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

                  cm.Parameters.Add(p);

                  // @Quantity

                  p = new SqlParameter("@Quantity", SqlDbType.SmallInt);

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

                  cm.Parameters.Add(p);

                  // @UnitPrice

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

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

                  cm.Parameters.Add(p);

 

                  // execute insert

                        cm.ExecuteNonQuery();

 

            }

 

            public virtual void Update(OrderDetails_UpdateInputDataSet.OrderDetailsRow rowUpdateInput, IDbTransaction tx, IDbConnection cn) {

                  int intOrderID = rowUpdateInput.SelectByOrderID;

                  int intProductID = rowUpdateInput.SelectByProductID;

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

                  // @SelectProductID

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

                  p.Value = rowUpdateInput.SelectByProductID;

                  cm.Parameters.Add(p);

                  // @NewDiscount

                  p = new SqlParameter("@NewDiscount", SqlDbType.Real);

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

                  cm.Parameters.Add(p);

                  // @NewOrderID

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

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

                  cm.Parameters.Add(p);

                  // @NewProductID

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

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

                  cm.Parameters.Add(p);

                  // @NewQuantity

                  p = new SqlParameter("@NewQuantity", SqlDbType.SmallInt);

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

                  cm.Parameters.Add(p);

                  // @NewUnitPrice

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

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

                  cm.Parameters.Add(p);

 

                  // execute update

                  cm.ExecuteNonQuery();

 

                  // clean up

                  cm.Dispose();

            }

 

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

                  // @ProductID

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

                  p.Value = intProductID;

                  cm.Parameters.Add(p);

 

                  // execute delete

                  cm.ExecuteNonQuery();

 

                  // clean up

                  cm.Dispose();

            }

 

            public virtual void GetByPk(DataTable tblResults, int intOrderID, int intProductID, 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);

                  // @ProductID

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

                  p.Value = intProductID;

                  cm.Parameters.Add(p);

 

                  da.MissingSchemaAction = MissingSchemaAction.Ignore;

                  da.Fill(tblResults);

            }

 

            public virtual void GetByPkJoined(DataTable tblResults, int intOrderID, int intProductID, 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);

                  // @ProductID

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

                  p.Value = intProductID;

                  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 GetByOrderID(DataTable tblResults, int intOrderID, IDbConnection cn) {

                  SqlCommand cm = new SqlCommand(mstrSproc_SelectByOrderID, (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 GetByProductID(DataTable tblResults, int intProductID, IDbConnection cn) {

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

                  cm.CommandType = CommandType.StoredProcedure;

                  SqlDataAdapter da = new SqlDataAdapter(cm);

 

                  // add parameters

                  SqlParameter p;

                  // @ProductID

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

                  p.Value = intProductID;

                  cm.Parameters.Add(p);

 

                  da.MissingSchemaAction = MissingSchemaAction.Ignore;

                  da.Fill(tblResults);

            }

 

 

 

 

 

            public virtual void Search (

                  DataTable tblResults,

                  OrderDetails_SearchInputDataSet.OrderDetailsRow rowSearchInput,

                  IDbConnection cn

                  ) {

 

                  // create search command

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

                  cm.CommandType = CommandType.StoredProcedure;

                  SqlDataAdapter da = new SqlDataAdapter(cm);

 

                  // retrieve the data

                  da.MissingSchemaAction = MissingSchemaAction.Ignore;

                  da.Fill(tblResults);

            }

 

            public void Dispose() {}

 

      }

}