2011-01-30 07:14:05 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using Tanshu.Accounts.Contracts;
|
|
|
|
|
using System.Data.SqlClient;
|
|
|
|
|
using Tanshu.Data.DAO;
|
|
|
|
|
using Tanshu.Accounts.Entities;
|
|
|
|
|
using Tanshu.Accounts.SqlDAO;
|
|
|
|
|
using NHibernate.Criterion;
|
2011-01-31 20:33:22 +00:00
|
|
|
|
using NHibernate;
|
2011-01-30 07:14:05 +00:00
|
|
|
|
|
|
|
|
|
namespace Tanshu.Accounts.Repository
|
|
|
|
|
{
|
|
|
|
|
public class ProductGroupBI
|
|
|
|
|
{
|
|
|
|
|
public ProductGroup GetProductGroup(int productGroupID)
|
|
|
|
|
{
|
|
|
|
|
using (var session = SessionManager.Session)
|
|
|
|
|
{
|
|
|
|
|
return session.Get<ProductGroup>(productGroupID);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public ProductGroup GetProductGroupByName(string name)
|
|
|
|
|
{
|
|
|
|
|
using (var session = SessionManager.Session)
|
|
|
|
|
{
|
|
|
|
|
return session.CreateCriteria<ProductGroup>()
|
|
|
|
|
.Add(Restrictions.Eq("Name", name))
|
|
|
|
|
.UniqueResult<ProductGroup>();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void Insert(ProductGroup productGroup)
|
|
|
|
|
{
|
|
|
|
|
using (var session = SessionManager.Session)
|
|
|
|
|
{
|
|
|
|
|
session.Save(productGroup);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void Update(ProductGroup productGroup)
|
|
|
|
|
{
|
|
|
|
|
using (var session = SessionManager.Session)
|
|
|
|
|
{
|
|
|
|
|
session.Update(productGroup);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public IList<ProductGroup> GetProductGroups()
|
|
|
|
|
{
|
|
|
|
|
using (var session = SessionManager.Session)
|
|
|
|
|
{
|
|
|
|
|
return session.CreateCriteria<ProductGroup>()
|
|
|
|
|
.List<ProductGroup>();
|
|
|
|
|
}
|
2011-01-31 20:33:22 +00:00
|
|
|
|
}
|
|
|
|
|
public ProductGroup GetProductGroupOfProduct(int productID)
|
|
|
|
|
{
|
|
|
|
|
using (var session = SessionManager.Session)
|
|
|
|
|
{
|
|
|
|
|
var item = (from p in session.QueryOver<Product>()
|
|
|
|
|
where p.ProductID == productID
|
|
|
|
|
select p.ProductGroup).SingleOrDefault<ProductGroup>();
|
|
|
|
|
NHibernateUtil.Initialize(item);
|
|
|
|
|
return item;
|
|
|
|
|
}
|
2011-01-30 07:14:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|