You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
2.1 KiB
C#
89 lines
2.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Numerics;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Chloe;
|
|
|
|
using DB.Entity;
|
|
|
|
using Tool;
|
|
|
|
namespace DB.Service
|
|
{
|
|
public class FromPlanService
|
|
{
|
|
public void Insert(FromPlan plan)
|
|
{
|
|
using (var dbContext = DbFactory.GetContext)
|
|
{
|
|
dbContext.Insert(plan);
|
|
}
|
|
}
|
|
|
|
public FromPlan Query(long id)
|
|
{
|
|
using (var dbContext = DbFactory.GetContext)
|
|
{
|
|
return dbContext.QueryByKey<FromPlan>(id);
|
|
}
|
|
}
|
|
|
|
public void Update(FromPlan plan)
|
|
{
|
|
using (var dbContext = DbFactory.GetContext)
|
|
{
|
|
dbContext.Update(plan);
|
|
}
|
|
}
|
|
|
|
public void Del(long id)
|
|
{
|
|
using (var dbContext = DbFactory.GetContext)
|
|
{
|
|
dbContext.DeleteByKey<FromPlan>(id);
|
|
}
|
|
}
|
|
|
|
public string GetMaxCode()
|
|
{
|
|
using (var dbContext = DbFactory.GetContext)
|
|
{
|
|
string dt = DateTime.Now.ToString("yyyyMMdd");
|
|
string code = dbContext.Query<FromPlan>()
|
|
.Where(x => x.Code.StartsWith(dt)).OrderByDesc(x => x.ID)
|
|
.Select(x => x.Code).FirstOrDefault();
|
|
|
|
if (string.IsNullOrEmpty(code))
|
|
{
|
|
return dt + "001";
|
|
}
|
|
|
|
int s = code.Substring(8).ToInt() + 1;
|
|
|
|
return dt + s.ToString().PadLeft(3, '0');
|
|
}
|
|
}
|
|
|
|
|
|
public PagedList<FromPlan> GetPagedList(int pageIndex, int pageSize)
|
|
{
|
|
|
|
using (var dbContext = DbFactory.GetContext)
|
|
{
|
|
var dao = dbContext.Query<FromPlan>()
|
|
.OrderByDesc(x => x.ID)
|
|
.Paging(pageIndex, pageSize);
|
|
|
|
|
|
PagedList<FromPlan> paged =
|
|
new PagedList<FromPlan>(dao.DataList, dao.Totals.ToInt(), pageIndex, pageSize);
|
|
return paged;
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|