88 lines
3.2 KiB
C#
88 lines
3.2 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Text;
|
|||
|
using Tanshu.Accounts.Contracts;
|
|||
|
using System.Data.SqlClient;
|
|||
|
using Tanshu.Data.DAO;
|
|||
|
using System.Configuration;
|
|||
|
using Tanshu.Accounts.Entities;
|
|||
|
using Tanshu.Accounts.SqlDAO;
|
|||
|
using NHibernate.Criterion;
|
|||
|
|
|||
|
namespace Tanshu.Accounts.Repository
|
|||
|
{
|
|||
|
public class PrintLocationBI
|
|||
|
{
|
|||
|
public void Insert(PrintLocation printLocation)
|
|||
|
{
|
|||
|
using (var session = SessionManager.Session)
|
|||
|
{
|
|||
|
session.Save(printLocation);
|
|||
|
}
|
|||
|
}
|
|||
|
public void Update(PrintLocation printLocation)
|
|||
|
{
|
|||
|
using (var session = SessionManager.Session)
|
|||
|
{
|
|||
|
session.Update(printLocation);
|
|||
|
}
|
|||
|
}
|
|||
|
public void Delete(int printLocationID)
|
|||
|
{
|
|||
|
using (var session = SessionManager.Session)
|
|||
|
{
|
|||
|
session.Delete(new PrintLocation() { PrintLocationID = printLocationID });
|
|||
|
}
|
|||
|
}
|
|||
|
public PrintLocation GetPrintLocation(int printLocationID)
|
|||
|
{
|
|||
|
using (var session = SessionManager.Session)
|
|||
|
{
|
|||
|
return session.Get<PrintLocation>(printLocationID);
|
|||
|
}
|
|||
|
}
|
|||
|
public PrintLocation GetPrintLocation(int productGroupID, string location)
|
|||
|
{
|
|||
|
using (var session = SessionManager.Session)
|
|||
|
{
|
|||
|
return (from pl in session.QueryOver<PrintLocation>()
|
|||
|
where pl.ProductGroup.ProductGroupID == productGroupID && pl.Location == location
|
|||
|
select pl).SingleOrDefault();
|
|||
|
//return session.CreateCriteria<PrintLocation>()
|
|||
|
// .Add(Restrictions.Eq("ProductGroupID", productGroupID))
|
|||
|
// .Add(Restrictions.Eq("Location", location))
|
|||
|
// .UniqueResult<PrintLocation>();
|
|||
|
}
|
|||
|
}
|
|||
|
public PrintLocation GetPrintLocation(string location)
|
|||
|
{
|
|||
|
using (var session = SessionManager.Session)
|
|||
|
{
|
|||
|
return (from pl in session.QueryOver<PrintLocation>()
|
|||
|
where pl.Location == location && pl.ProductGroup.ProductGroupID == null
|
|||
|
select pl).SingleOrDefault();
|
|||
|
//return session.CreateCriteria<PrintLocation>()
|
|||
|
// .Add(Restrictions.IsNull("ProductGroupID"))
|
|||
|
// .Add(Restrictions.Eq("Location", location))
|
|||
|
// .UniqueResult<PrintLocation>();
|
|||
|
}
|
|||
|
}
|
|||
|
public static PrintLocation BasePrinter
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
string location = ConfigurationManager.AppSettings["Location"].ToLowerInvariant();
|
|||
|
return new PrintLocationBI().GetPrintLocation(location);
|
|||
|
}
|
|||
|
}
|
|||
|
public static PrintLocation KotPrinter(int productGroupID)
|
|||
|
{
|
|||
|
string location = ConfigurationManager.AppSettings["Location"].ToLowerInvariant();
|
|||
|
PrintLocation p = new PrintLocationBI().GetPrintLocation(productGroupID, location);
|
|||
|
if (p == null)
|
|||
|
p = new PrintLocationBI().GetPrintLocation(location);
|
|||
|
return p;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|