201 lines
7.0 KiB
C#
201 lines
7.0 KiB
C#
using FineUIPro;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
|
|
namespace BLL
|
|
{
|
|
|
|
public static class PackagingmanagedetailService
|
|
{
|
|
|
|
|
|
|
|
#region 获取列表
|
|
/// <summary>
|
|
/// 记录数
|
|
/// </summary>
|
|
public static int Count
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
private static IQueryable<Model.HJGL_PackagingManageDetail> GetByQueryModle(Model.HJGL_PackagingManageDetail table)
|
|
{
|
|
var q = from x in Funs.DB.HJGL_PackagingManageDetail select x;
|
|
if (table == null)
|
|
{
|
|
return q;
|
|
}
|
|
if (!string.IsNullOrEmpty(table.Id))
|
|
{
|
|
q = q.Where(x => x.Id.Contains(table.Id));
|
|
}
|
|
if (!string.IsNullOrEmpty(table.PackagingManageId))
|
|
{
|
|
q = q.Where(x => x.PackagingManageId.Contains(table.PackagingManageId));
|
|
}
|
|
if (!string.IsNullOrEmpty(table.PipelineId))
|
|
{
|
|
q = q.Where(x => x.PipelineId.Contains(table.PipelineId));
|
|
}
|
|
if (!string.IsNullOrEmpty(table.PipelineComponentId))
|
|
{
|
|
q = q.Where(x => x.PipelineComponentId.Contains(table.PipelineComponentId));
|
|
}
|
|
if (!string.IsNullOrEmpty(table.MaterialCode))
|
|
{
|
|
q = q.Where(x => x.MaterialCode.Contains(table.MaterialCode));
|
|
}
|
|
if (table.Number != null)
|
|
{
|
|
q = q.Where(x => x.Number == table.Number);
|
|
}
|
|
if (table.CreateTime != null)
|
|
{
|
|
q = q.Where(x => x.CreateTime == table.CreateTime);
|
|
}
|
|
if (!string.IsNullOrEmpty(table.CreateUser))
|
|
{
|
|
q = q.Where(x => x.CreateUser.Contains(table.CreateUser));
|
|
}
|
|
;
|
|
|
|
return q;
|
|
}
|
|
public static List<Model.HJGL_PackagingManageDetail> GetListByQueryModle(Model.HJGL_PackagingManageDetail table)
|
|
{
|
|
return GetByQueryModle(table).ToList();
|
|
|
|
}
|
|
public static (List<Model.HJGL_PackagingManageDetail> Data, int Total) GetListByQueryModle(Model.HJGL_PackagingManageDetail table, int pageIndex = 0, int pageSize = 20)
|
|
{
|
|
var baseQuery = GetByQueryModle(table);
|
|
var pagedData = baseQuery
|
|
.Skip((pageIndex) * pageSize)
|
|
.Take(pageSize)
|
|
.ToList();
|
|
|
|
// 获取总记录数(延迟计数优化)
|
|
var totalCount = baseQuery.Count();
|
|
|
|
return (pagedData, totalCount);
|
|
|
|
}
|
|
/// <summary>
|
|
/// 获取分页列表
|
|
/// </summary>
|
|
/// <param name="table"></param>
|
|
/// <param name="grid1"></param>
|
|
/// <returns></returns>
|
|
public static IEnumerable GetListData(Model.HJGL_PackagingManageDetail table, Grid grid1)
|
|
{
|
|
var q = GetByQueryModle(table);
|
|
Count = q.Count();
|
|
if (Count == 0)
|
|
{
|
|
return null;
|
|
}
|
|
q = q.Skip(grid1.PageSize * grid1.PageIndex).Take(grid1.PageSize);
|
|
// q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
|
|
return from x in q
|
|
select new
|
|
{
|
|
x.Id,
|
|
x.PackagingManageId,
|
|
x.PipelineId,
|
|
x.PipelineComponentId,
|
|
x.MaterialCode,
|
|
x.Number,
|
|
x.CreateTime,
|
|
x.CreateUser,
|
|
|
|
};
|
|
}
|
|
|
|
#endregion
|
|
|
|
public static Model.HJGL_PackagingManageDetail GetModelById(string Id)
|
|
{
|
|
return Funs.DB.HJGL_PackagingManageDetail.FirstOrDefault(x => x.Id == Id);
|
|
}
|
|
public static IEnumerable GetPackagingData(string PackagingManageId)
|
|
{
|
|
var q = from detail in Funs.DB.HJGL_PackagingManageDetail
|
|
join lib in Funs.DB.HJGL_MaterialCodeLib on detail.MaterialCode equals lib.MaterialCode into libJoin
|
|
from libItem in libJoin.DefaultIfEmpty()
|
|
join line in Funs.DB.HJGL_Pipeline on detail.PipelineId equals line.PipelineId into lineJoin
|
|
from lineItem in lineJoin.DefaultIfEmpty()
|
|
where detail.PackagingManageId == PackagingManageId
|
|
select new
|
|
{
|
|
detail.Id,
|
|
libItem.MaterialCode,
|
|
libItem.MaterialName,
|
|
libItem.MaterialUnit,
|
|
libItem.MaterialSpec,
|
|
libItem.MaterialMade,
|
|
libItem.MaterialDef,
|
|
detail.Number,
|
|
lineItem.PipelineId,
|
|
lineItem.PipelineCode,
|
|
|
|
};
|
|
return q;
|
|
}
|
|
|
|
|
|
public static void Add(Model.HJGL_PackagingManageDetail newtable)
|
|
{
|
|
|
|
Model.HJGL_PackagingManageDetail table = new Model.HJGL_PackagingManageDetail
|
|
{
|
|
Id = newtable.Id,
|
|
PackagingManageId = newtable.PackagingManageId,
|
|
PipelineId = newtable.PipelineId,
|
|
PipelineComponentId = newtable.PipelineComponentId,
|
|
MaterialCode = newtable.MaterialCode,
|
|
Number = newtable.Number,
|
|
CreateTime = newtable.CreateTime,
|
|
CreateUser = newtable.CreateUser,
|
|
};
|
|
Funs.DB.HJGL_PackagingManageDetail.InsertOnSubmit(table);
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
|
|
|
|
public static void Update(Model.HJGL_PackagingManageDetail newtable)
|
|
{
|
|
|
|
Model.HJGL_PackagingManageDetail table = Funs.DB.HJGL_PackagingManageDetail.FirstOrDefault(x => x.Id == newtable.Id);
|
|
if (table != null)
|
|
{
|
|
table.Id = newtable.Id;
|
|
table.PackagingManageId = newtable.PackagingManageId;
|
|
table.PipelineId = newtable.PipelineId;
|
|
table.PipelineComponentId = newtable.PipelineComponentId;
|
|
table.MaterialCode = newtable.MaterialCode;
|
|
table.Number = newtable.Number;
|
|
table.CreateTime = newtable.CreateTime;
|
|
table.CreateUser = newtable.CreateUser;
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
|
|
}
|
|
public static void DeleteById(string Id)
|
|
{
|
|
|
|
Model.HJGL_PackagingManageDetail table = Funs.DB.HJGL_PackagingManageDetail.FirstOrDefault(x => x.Id == Id);
|
|
if (table != null)
|
|
{
|
|
Funs.DB.HJGL_PackagingManageDetail.DeleteOnSubmit(table);
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
} |