// File Name: Employees_Dao_Base.cs

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

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

            protected string mstrSproc_Search = "bisp_Employees_Search";

            protected string mstrSproc_DeleteByPk = "bisp_Employees_DeleteByPrimaryKey";

            protected string mstrSproc_GetByPk = "bisp_Employees_SelectByPrimaryKey";

            protected string mstrSproc_GetByPkJoined = "bisp_Employees_SelectByPrimaryKeyJoined";

            protected string mstrSproc_GetAll = "bisp_Employees_SelectAll";

            protected string mstrSproc_Update = "bisp_Employees_Update";

            protected string mstrSproc_Insert = "bisp_Employees_Insert";

            protected string mstrSproc_SelectByLastName = "bisp_Employees_SelectByLastName";

            protected string mstrSproc_SelectByPostalCode = "bisp_Employees_SelectByPostalCode";

            protected string mstrSproc_SelectByReportsTo = "bisp_Employees_SelectByReportsTo";

 

            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;

                  // @Address

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

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

                  cm.Parameters.Add(p);

                  // @BirthDate

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

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

                  cm.Parameters.Add(p);

                  // @City

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

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

                  cm.Parameters.Add(p);

                  // @Country

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

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

                  cm.Parameters.Add(p);

                  // @EmployeeID OUTPUT

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

                  pNewPk.Direction = ParameterDirection.Output;

                  cm.Parameters.Add(pNewPk);

                  // @Extension

                  p = new SqlParameter("@Extension", SqlDbType.NVarChar, 4);

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

                  cm.Parameters.Add(p);

                  // @FirstName

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

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

                  cm.Parameters.Add(p);

                  // @HireDate

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

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

                  cm.Parameters.Add(p);

                  // @HomePhone

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

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

                  cm.Parameters.Add(p);

                  // @LastName

                  p = new SqlParameter("@LastName", SqlDbType.NVarChar, 20);

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

                  cm.Parameters.Add(p);

                  // @Notes

                  p = new SqlParameter("@Notes", SqlDbType.NText);

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

                  cm.Parameters.Add(p);

                  // @Photo

                  p = new SqlParameter("@Photo", SqlDbType.Image);

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

                  cm.Parameters.Add(p);

                  // @PhotoPath

                  p = new SqlParameter("@PhotoPath", SqlDbType.NVarChar, 255);

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

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

                  // @ReportsTo

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

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

                  cm.Parameters.Add(p);

                  // @Title

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

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

                  cm.Parameters.Add(p);

                  // @TitleOfCourtesy

                  p = new SqlParameter("@TitleOfCourtesy", SqlDbType.NVarChar, 25);

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

                  cm.Parameters.Add(p);

 

                  int intNewPk;

                  // execute insert

                        cm.ExecuteNonQuery();

                        intNewPk = Convert.ToInt32(pNewPk.Value);

 

                  return intNewPk;

            }

 

            public virtual void Update(Employees_UpdateInputDataSet.EmployeesRow rowUpdateInput, IDbTransaction tx, IDbConnection cn) {

                  int intEmployeeID = rowUpdateInput.SelectByEmployeeID;

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

                  // @SelectEmployeeID

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

                  p.Value = rowUpdateInput.SelectByEmployeeID;

                  cm.Parameters.Add(p);

                  // @NewAddress

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

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

                  cm.Parameters.Add(p);

                  // @NewBirthDate

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

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

                  cm.Parameters.Add(p);

                  // @NewCity

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

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

                  cm.Parameters.Add(p);

                  // @NewCountry

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

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

                  cm.Parameters.Add(p);

                  // @NewExtension

                  p = new SqlParameter("@NewExtension", SqlDbType.NVarChar, 4);

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

                  cm.Parameters.Add(p);

                  // @NewFirstName

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

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

                  cm.Parameters.Add(p);

                  // @NewHireDate

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

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

                  cm.Parameters.Add(p);

                  // @NewHomePhone

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

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

                  cm.Parameters.Add(p);

                  // @NewLastName

                  p = new SqlParameter("@NewLastName", SqlDbType.NVarChar, 20);

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

                  cm.Parameters.Add(p);

                  // @NewNotes

                  p = new SqlParameter("@NewNotes", SqlDbType.NText);

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

                  cm.Parameters.Add(p);

                  // @NewPhoto

                  p = new SqlParameter("@NewPhoto", SqlDbType.Image);

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

                  cm.Parameters.Add(p);

                  // @NewPhotoPath

                  p = new SqlParameter("@NewPhotoPath", SqlDbType.NVarChar, 255);

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

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

                  // @NewReportsTo

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

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

                  cm.Parameters.Add(p);

                  // @NewTitle

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

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

                  cm.Parameters.Add(p);

                  // @NewTitleOfCourtesy

                  p = new SqlParameter("@NewTitleOfCourtesy", SqlDbType.NVarChar, 25);

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

                  cm.Parameters.Add(p);

 

                  // execute update

                  cm.ExecuteNonQuery();

 

                  // clean up

                  cm.Dispose();

            }

 

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

                  // @EmployeeID

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

                  p.Value = intEmployeeID;

                  cm.Parameters.Add(p);

 

                  // execute delete

                  cm.ExecuteNonQuery();

 

                  // clean up

                  cm.Dispose();

            }

 

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

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

                  SqlCommand cm = new SqlCommand(mstrSproc_GetByPkJoined, (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 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 GetByReportsTo(DataTable tblResults, int intReportsTo, IDbConnection cn) {

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

                  cm.CommandType = CommandType.StoredProcedure;

                  SqlDataAdapter da = new SqlDataAdapter(cm);

 

                  // add parameters

                  SqlParameter p;

                  // @ReportsTo

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

                  p.Value = intReportsTo;

                  cm.Parameters.Add(p);

 

                  da.MissingSchemaAction = MissingSchemaAction.Ignore;

                  da.Fill(tblResults);

            }

 

            public virtual void GetByLastName(DataTable tblResults, string strLastName, IDbConnection cn) {

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

                  cm.CommandType = CommandType.StoredProcedure;

                  SqlDataAdapter da = new SqlDataAdapter(cm);

 

                  // add parameters

                  SqlParameter p;

                  // @LastName

                  p = new SqlParameter("@LastName", SqlDbType.NVarChar, 20);

                  p.Value = strLastName;

                  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 Search (

                  DataTable tblResults,

                  Employees_SearchInputDataSet.EmployeesRow 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;

                  // @FirstName

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

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

                  cm.Parameters.Add(p);

                  // @LastName

                  p = new SqlParameter("@LastName", SqlDbType.NVarChar, 20);

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

                  cm.Parameters.Add(p);

 

                  // retrieve the data

                  da.MissingSchemaAction = MissingSchemaAction.Ignore;

                  da.Fill(tblResults);

            }

 

            public void Dispose() {}

 

      }

}