58 lines
1.8 KiB
C#
58 lines
1.8 KiB
C#
|
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 Tanshu.Accounts.Entities.Auth;
|
|||
|
|
|||
|
namespace Tanshu.Accounts.Repository
|
|||
|
{
|
|||
|
public class AdvanceBI
|
|||
|
{
|
|||
|
public void Insert(Advance advance)
|
|||
|
{
|
|||
|
using (var session = SessionManager.Session)
|
|||
|
{
|
|||
|
using (var trans = session.BeginTransaction())
|
|||
|
{
|
|||
|
session.Save(advance);
|
|||
|
trans.Commit();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
public IList<Advance> GetAdvances(DateTime startDate, DateTime finishDate, bool all)
|
|||
|
{
|
|||
|
startDate = startDate.Date;
|
|||
|
finishDate = finishDate.Date.AddHours(23).AddMinutes(59).AddSeconds(59);
|
|||
|
using (var session = SessionManager.Session)
|
|||
|
{
|
|||
|
var ab = from ad in session.QueryOver<Advance>()
|
|||
|
where ad.DateIn >= startDate && ad.DateIn <= finishDate
|
|||
|
select ad;
|
|||
|
if (!all)
|
|||
|
ab = from a in ab
|
|||
|
where a.CashierOut == null
|
|||
|
select a;
|
|||
|
return ab.List();
|
|||
|
}
|
|||
|
}
|
|||
|
public void Adjust(int advanceID, int userID)
|
|||
|
{
|
|||
|
using (var session = SessionManager.Session)
|
|||
|
{
|
|||
|
using (var trans = session.BeginTransaction())
|
|||
|
{
|
|||
|
var advance = session.Get<Advance>(advanceID);
|
|||
|
advance.DateOut = DbValues.Date;
|
|||
|
advance.CashierOut = session.Get<User>(userID);
|
|||
|
session.Update(advance);
|
|||
|
trans.Commit();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|