narsil/Tanshu.Accounts.Repository/BusinessLayer/ProductBI.cs
unknown 2d1030abf6 Scripts to transition database to new version.
Changed inventory and product entities to split Vat and Service Tax and IsScTaxable.
Added MessageBox on startup to inform about Debug Mode.
Updated ProductForm for the change.
Work still needs to be done on Thermal Printing where the hack for VAT on Food and VAT on Liqour is still there.
Now No Service Tax on Delivery Works as promised.
2012-04-08 17:58:15 +05:30

88 lines
2.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using Tanshu.Accounts.Contracts;
using Tanshu.Accounts.Entities;
using NHibernate;
namespace Tanshu.Accounts.Repository
{
public class ProductBI : FluentGenericBase<Product>
{
public ProductBI()
: base()
{ }
public ProductBI(bool beginTransaction)
: base(beginTransaction)
{ }
public ProductBI(ISession session)
: base(session)
{ }
public ProductBI(ISession session, bool beginTransaction)
: base(session, beginTransaction)
{ }
public Product Get(string nameAndUnits)
{
return Get(x => x.Name + " (" + x.Units + ")" == nameAndUnits);
}
public new IList<Product> List(Expression<Func<Product, bool>> query)
{
var list = Query()
.Where(query)
.OrderBy(x => x.SortOrder).Asc
.ThenBy(x => x.Name).Asc
.List();
foreach (var item in list)
{
NHibernateUtil.Initialize(item.ProductGroup);
NHibernateUtil.Initialize(item.ServiceTax);
NHibernateUtil.Initialize(item.Vat);
}
return list;
}
public new IList<Product> List()
{
var list = Query()
.OrderBy(x => x.ProductGroup).Asc
.ThenBy(x => x.SortOrder).Asc
.ThenBy(x => x.Name).Asc
.List();
foreach (var item in list)
{
NHibernateUtil.Initialize(item.ProductGroup);
NHibernateUtil.Initialize(item.ServiceTax);
NHibernateUtil.Initialize(item.Vat);
}
return list;
}
public static List<ProductDisplaySmall> GetFilteredProducts(Dictionary<string, string> filter)
{
throw new NotImplementedException();
}
public static List<ProductDisplaySmall> GetUnFilteredProducts()
{
Dictionary<string, string> filter = new Dictionary<string, string>();
filter.Add("Name", "");
filter.Add("Type", "");
return GetFilteredProducts(filter);
}
public static IList<Product> List(int productGroupID)
{
using (var session = SessionManager.Session)
{
return (from product in session.QueryOver<Product>()
where product.ProductGroup.ProductGroupID == productGroupID
select product).List();
}
}
}
}