包装管理修改
This commit is contained in:
@@ -0,0 +1,236 @@
|
||||
using FineUIPro;
|
||||
using Model;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
|
||||
public static class HJGLPackagingmanagedetailService
|
||||
{
|
||||
#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<Model.PipelinePrefabricatedComponentsItem> GetPackagingData(string PackagingManageId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(PackagingManageId))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var pack = HJGL_PackagingmanageService.GetHJGL_PackagingManageById(PackagingManageId);
|
||||
if (pack == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var result = new List<Model.PipelinePrefabricatedComponentsItem>();
|
||||
if (pack.TypeInt == (int)HJGL_PackagingmanageService.TypeInt.预制散件)
|
||||
{
|
||||
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 /*&& (detail.PipelineId != null || detail.PipelineId != "") && (detail.PipelineComponentId == null || detail.PipelineComponentId == "")*/
|
||||
select new PipelinePrefabricatedComponentsItem
|
||||
{
|
||||
Id = detail.Id,
|
||||
MaterialCode = libItem.MaterialCode,
|
||||
MaterialName = libItem.MaterialName,
|
||||
MaterialUnit = libItem.MaterialUnit,
|
||||
MaterialSpec = libItem.MaterialSpec,
|
||||
MaterialMade = libItem.MaterialMade,
|
||||
MaterialDef = libItem.MaterialDef,
|
||||
Number = detail.Number,
|
||||
PipelineId = lineItem.PipelineId,
|
||||
PipelineCode = lineItem.PipelineCode,
|
||||
UnitWorkId=lineItem.UnitWorkId,
|
||||
|
||||
};
|
||||
result= q.ToList();
|
||||
}
|
||||
else if(pack.TypeInt == (int)HJGL_PackagingmanageService.TypeInt.其他材料)
|
||||
{
|
||||
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 /*&& (detail.PipelineId == null || detail.PipelineId == "")*/
|
||||
select new PipelinePrefabricatedComponentsItem
|
||||
{
|
||||
Id = detail.Id,
|
||||
MaterialCode = libItem.MaterialCode,
|
||||
MaterialName = libItem.MaterialName,
|
||||
MaterialUnit = libItem.MaterialUnit,
|
||||
MaterialSpec = libItem.MaterialSpec,
|
||||
MaterialMade = libItem.MaterialMade,
|
||||
MaterialDef = libItem.MaterialDef,
|
||||
Number = detail.Number,
|
||||
PipelineId = lineItem.PipelineId,
|
||||
PipelineCode = lineItem.PipelineCode,
|
||||
|
||||
};
|
||||
result = q.ToList();
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user