narsil/Tanshu.Accounts.SqlDAO/PrintLocationDAO.cs

53 lines
1.9 KiB
C#

using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using Tanshu.Accounts.Contracts;
using Tanshu.Data.DAO;
using Tanshu.Accounts.DAOFactory;
namespace Tanshu.Accounts.SqlDAO
{
public class PrintLocationDAO : BaseDAO, IPrintLocationDAO
{
public PrintLocationDAO(IConnectionDAO connection)
: base(connection)
{ }
public void Insert(PrintLocationBO printLocation)
{
throw new NotImplementedException();
}
public void Update(PrintLocationBO printLocation)
{
throw new NotImplementedException();
}
public bool Delete(int tableID)
{
throw new NotImplementedException();
}
public PrintLocationBO GetPrintLocation(int printLocationID)
{
SqlCommand cmd = new SqlCommand("SELECT * FROM PrintLocation WHERE PrintLocationID = @PrintLocationID;");
cmd.Parameters.AddWithValue("@PrintLocationID", printLocationID);
return BusinessObjectDAO<PrintLocationBO>.GetBusinessObject(connection.ExecuteReader(cmd));
}
public PrintLocationBO GetPrintLocation(Guid? productTypeID, string location)
{
string query = @"SELECT * FROM PrintLocation WHERE ProductTypeID {0} AND Location = @Location";
if (productTypeID.HasValue)
query = string.Format(query, "= @ProductTypeID");
else
query = string.Format(query, "IS NULL");
using (SqlCommand cmd = new SqlCommand(query))
{
if (productTypeID.HasValue)
cmd.Parameters.AddWithValue("@ProductTypeID", productTypeID.Value);
cmd.Parameters.AddWithValue("@Location", location);
return BusinessObjectDAO<PrintLocationBO>.GetBusinessObject(connection.ExecuteReader(cmd));
}
}
}
}