narsil/Tanshu.Accounts.BI/ProductBI.cs
2011-01-10 05:06:24 +05:30

135 lines
4.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
using Tanshu.Accounts.Contracts;
using Tanshu.Accounts.DAOFactory;
using System.Data.SqlClient;
using Tanshu.Data.DAO;
namespace Tanshu.Accounts.BI
{
public class ProductBI : IProductBI
{
public bool Insert(ProductBO product)
{
GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (IConnectionDAO connection = factory.Connection)
{
using (IProductDAO dao = factory.GetProductDAO(connection))
{
return dao.Insert(product);
}
}
}
public bool Update(ProductBO product)
{
GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (IConnectionDAO connection = factory.Connection)
{
using (IProductDAO dao = factory.GetProductDAO(connection))
{
return dao.Update(product);
}
}
}
public bool Delete(Guid productID)
{
GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (IConnectionDAO connection = factory.Connection)
{
using (IProductDAO dao = factory.GetProductDAO(connection))
{
return dao.Delete(productID);
}
}
}
public ProductBO GetProductFromName(string nameAndUnits)
{
GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (IConnectionDAO connection = factory.Connection)
{
using (IProductDAO dao = factory.GetProductDAO(connection))
{
return dao.GetProduct(nameAndUnits);
}
}
}
public ProductBO GetProduct(Guid productID)
{
GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (IConnectionDAO connection = factory.Connection)
{
using (IProductDAO dao = factory.GetProductDAO(connection))
{
return dao.GetProduct(productID);
}
}
}
public decimal GetProductStock(DateTime date, Guid productID, Guid? voucherID)
{
GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (IConnectionDAO connection = factory.Connection)
{
using (IProductDAO dao = factory.GetProductDAO(connection))
{
return dao.GetProductStock(date, productID, voucherID);
}
}
}
public List<ProductDisplayBO> GetProducts()
{
GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (IConnectionDAO connection = factory.Connection)
{
using (IProductDAO dao = factory.GetProductDAO(connection))
{
return dao.GetProducts();
}
}
}
public List<ProductDisplaySmallBO> GetFilteredProducts(Dictionary<string, string> filter)
{
GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (IConnectionDAO connection = factory.Connection)
{
using (IProductDAO dao = factory.GetProductDAO(connection))
{
return dao.GetFilteredProducts(filter);
}
}
}
public void UpdateShortName()
{
GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (IConnectionDAO connection = factory.Connection)
{
using (IProductDAO dao = factory.GetProductDAO(connection))
{
dao.UpdateShortName();
}
}
}
public List<ProductDisplaySmallBO> GetUnFilteredProducts()
{
Dictionary<string, string> filter = new Dictionary<string, string>();
filter.Add("Name", "");
filter.Add("Type", "");
return GetFilteredProducts(filter);
}
public List<ProductDisplaySmallBO> GetProducts(Guid productTypeID)
{
GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (IConnectionDAO connection = factory.Connection)
{
using (IProductDAO dao = factory.GetProductDAO(connection))
{
return dao.GetProducts(productTypeID);
}
}
}
}
}