narsil/Tanshu.Accounts.BI/ProductBI.cs

135 lines
4.8 KiB
C#
Raw Normal View History

2010-03-02 17:56:21 +00:00
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
{
2011-01-22 12:38:30 +00:00
public static class ProductBI
2010-03-02 17:56:21 +00:00
{
2011-01-22 12:38:30 +00:00
public static bool Insert(ProductBO product)
2010-03-02 17:56:21 +00:00
{
GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (IConnectionDAO connection = factory.Connection)
{
using (IProductDAO dao = factory.GetProductDAO(connection))
{
return dao.Insert(product);
}
}
}
2011-01-22 12:38:30 +00:00
public static bool Update(ProductBO product)
2010-03-02 17:56:21 +00:00
{
GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (IConnectionDAO connection = factory.Connection)
{
using (IProductDAO dao = factory.GetProductDAO(connection))
{
return dao.Update(product);
}
}
}
2011-01-22 12:38:30 +00:00
public static bool Delete(Guid productID)
2010-03-02 17:56:21 +00:00
{
GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (IConnectionDAO connection = factory.Connection)
{
using (IProductDAO dao = factory.GetProductDAO(connection))
{
return dao.Delete(productID);
}
}
}
2011-01-22 12:38:30 +00:00
public static ProductBO GetProductFromName(string nameAndUnits)
2010-03-02 17:56:21 +00:00
{
GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (IConnectionDAO connection = factory.Connection)
{
using (IProductDAO dao = factory.GetProductDAO(connection))
{
return dao.GetProduct(nameAndUnits);
}
}
}
2011-01-22 12:38:30 +00:00
public static ProductBO GetProduct(Guid productID)
2010-03-02 17:56:21 +00:00
{
GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (IConnectionDAO connection = factory.Connection)
{
using (IProductDAO dao = factory.GetProductDAO(connection))
{
return dao.GetProduct(productID);
}
}
}
2011-01-22 12:38:30 +00:00
public static decimal GetProductStock(DateTime date, Guid productID, Guid? voucherID)
2010-03-02 17:56:21 +00:00
{
GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (IConnectionDAO connection = factory.Connection)
{
using (IProductDAO dao = factory.GetProductDAO(connection))
{
return dao.GetProductStock(date, productID, voucherID);
}
}
}
2011-01-22 12:38:30 +00:00
public static List<ProductDisplayBO> GetProducts()
2010-03-02 17:56:21 +00:00
{
GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (IConnectionDAO connection = factory.Connection)
{
using (IProductDAO dao = factory.GetProductDAO(connection))
{
return dao.GetProducts();
}
}
}
2011-01-22 12:38:30 +00:00
public static List<ProductDisplaySmallBO> GetFilteredProducts(Dictionary<string, string> filter)
2010-03-02 17:56:21 +00:00
{
GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (IConnectionDAO connection = factory.Connection)
{
using (IProductDAO dao = factory.GetProductDAO(connection))
{
return dao.GetFilteredProducts(filter);
}
}
}
2011-01-22 12:38:30 +00:00
public static void UpdateShortName()
2010-03-02 17:56:21 +00:00
{
GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (IConnectionDAO connection = factory.Connection)
{
using (IProductDAO dao = factory.GetProductDAO(connection))
{
dao.UpdateShortName();
}
}
}
2011-01-22 12:38:30 +00:00
public static List<ProductDisplaySmallBO> GetUnFilteredProducts()
2010-03-02 17:56:21 +00:00
{
Dictionary<string, string> filter = new Dictionary<string, string>();
filter.Add("Name", "");
filter.Add("Type", "");
return GetFilteredProducts(filter);
}
2011-01-22 12:38:30 +00:00
public static List<ProductDisplaySmallBO> GetProducts(Guid productTypeID)
2010-03-02 17:56:21 +00:00
{
GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (IConnectionDAO connection = factory.Connection)
{
using (IProductDAO dao = factory.GetProductDAO(connection))
{
2011-01-09 23:36:24 +00:00
return dao.GetProducts(productTypeID);
2010-03-02 17:56:21 +00:00
}
}
}
}
}