narsil/Tanshu.Accounts.BI/ProductBI.cs
2011-01-22 18:08:30 +05:30

135 lines
4.8 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 static class ProductBI
{
public static 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 static 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 static 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 static 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 static 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 static 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 static List<ProductDisplayBO> GetProducts()
{
GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (IConnectionDAO connection = factory.Connection)
{
using (IProductDAO dao = factory.GetProductDAO(connection))
{
return dao.GetProducts();
}
}
}
public static 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 static void UpdateShortName()
{
GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (IConnectionDAO connection = factory.Connection)
{
using (IProductDAO dao = factory.GetProductDAO(connection))
{
dao.UpdateShortName();
}
}
}
public static List<ProductDisplaySmallBO> GetUnFilteredProducts()
{
Dictionary<string, string> filter = new Dictionary<string, string>();
filter.Add("Name", "");
filter.Add("Type", "");
return GetFilteredProducts(filter);
}
public static 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);
}
}
}
}
}