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
|
|
|
|
|
{
|
|
|
|
|
public class ProductBI : IProductBI
|
|
|
|
|
{
|
|
|
|
|
public bool Insert(ProductBO product)
|
|
|
|
|
{
|
2011-12-05 09:23:02 +00:00
|
|
|
|
var factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
|
|
|
|
|
using (var connection = factory.Connection)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
using (IProductDAO dao = factory.GetProductDAO(connection))
|
|
|
|
|
{
|
|
|
|
|
return dao.Insert(product);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public bool Update(ProductBO product)
|
|
|
|
|
{
|
2011-12-05 09:23:02 +00:00
|
|
|
|
var factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
|
|
|
|
|
using (var connection = factory.Connection)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
using (IProductDAO dao = factory.GetProductDAO(connection))
|
|
|
|
|
{
|
|
|
|
|
return dao.Update(product);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public bool Delete(Guid productID)
|
|
|
|
|
{
|
2011-12-05 09:23:02 +00:00
|
|
|
|
var factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
|
|
|
|
|
using (var connection = factory.Connection)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
using (IProductDAO dao = factory.GetProductDAO(connection))
|
|
|
|
|
{
|
|
|
|
|
return dao.Delete(productID);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public ProductBO GetProductFromName(string nameAndUnits)
|
|
|
|
|
{
|
2011-12-05 09:23:02 +00:00
|
|
|
|
var factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
|
|
|
|
|
using (var connection = factory.Connection)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
using (IProductDAO dao = factory.GetProductDAO(connection))
|
|
|
|
|
{
|
|
|
|
|
return dao.GetProduct(nameAndUnits);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public ProductBO GetProduct(Guid productID)
|
|
|
|
|
{
|
2011-12-05 09:23:02 +00:00
|
|
|
|
var factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
|
|
|
|
|
using (var connection = factory.Connection)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
using (IProductDAO dao = factory.GetProductDAO(connection))
|
|
|
|
|
{
|
|
|
|
|
return dao.GetProduct(productID);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public decimal GetProductStock(DateTime date, Guid productID, Guid? voucherID)
|
|
|
|
|
{
|
2011-12-05 09:23:02 +00:00
|
|
|
|
var factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
|
|
|
|
|
using (var connection = factory.Connection)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
using (IProductDAO dao = factory.GetProductDAO(connection))
|
|
|
|
|
{
|
|
|
|
|
return dao.GetProductStock(date, productID, voucherID);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public List<ProductDisplayBO> GetProducts()
|
|
|
|
|
{
|
2011-12-05 09:23:02 +00:00
|
|
|
|
var factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
|
|
|
|
|
using (var connection = factory.Connection)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
using (IProductDAO dao = factory.GetProductDAO(connection))
|
|
|
|
|
{
|
|
|
|
|
return dao.GetProducts();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<ProductDisplaySmallBO> GetFilteredProducts(Dictionary<string, string> filter)
|
|
|
|
|
{
|
2011-12-05 09:23:02 +00:00
|
|
|
|
var factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
|
|
|
|
|
using (var connection = factory.Connection)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
using (IProductDAO dao = factory.GetProductDAO(connection))
|
|
|
|
|
{
|
|
|
|
|
return dao.GetFilteredProducts(filter);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UpdateShortName()
|
|
|
|
|
{
|
2011-12-05 09:23:02 +00:00
|
|
|
|
var factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
|
|
|
|
|
using (var connection = factory.Connection)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
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<ProductTypeBO> GetProductTypes()
|
|
|
|
|
{
|
2011-12-05 09:23:02 +00:00
|
|
|
|
var factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
|
|
|
|
|
using (var connection = factory.Connection)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
using (IProductDAO dao = factory.GetProductDAO(connection))
|
|
|
|
|
{
|
|
|
|
|
return dao.GetProductTypes();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|