xinjiang/SGGL/BLL/HSSE/Material/MaterPhyQuantityService.cs

138 lines
5.3 KiB
C#

using FineUIPro;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BLL
{
public static class HSSE_MaterPhyQuantityService
{
#region
/// <summary>
/// 记录数
/// </summary>
public static int Count
{
get;
set;
}
public static IEnumerable<Model.HSSE_MaterPhyQuantity> GetHSSE_MaterPhyQuantityByModle(Model.HSSE_MaterPhyQuantity table)
{
var q = from x in Funs.DB.HSSE_MaterPhyQuantity
where
(string.IsNullOrEmpty(table.MaterPhyQuantityId) || x.MaterPhyQuantityId.Contains(table.MaterPhyQuantityId)) &&
(string.IsNullOrEmpty(table.ProjectId) || x.ProjectId.Contains(table.ProjectId)) &&
(string.IsNullOrEmpty(table.MaterPhyQuantityType) || x.MaterPhyQuantityType.Contains(table.MaterPhyQuantityType)) &&
(string.IsNullOrEmpty(table.UnitOfMeasurement) || x.UnitOfMeasurement.Contains(table.UnitOfMeasurement)) &&
(string.IsNullOrEmpty(table.Remark) || x.Remark.Contains(table.Remark))
select x
;
return q.ToList();
}
/// <summary>
/// 获取分页列表
/// </summary>
/// <param name="table"></param>
/// <param name="grid1"></param>
/// <returns></returns>
public static IEnumerable GetListData(Model.HSSE_MaterPhyQuantity table, Grid grid1)
{
var q = GetHSSE_MaterPhyQuantityByModle(table);
Count = q.Count();
if (Count == 0)
{
return null;
}
q = q.Skip(grid1.PageSize * grid1.PageIndex).Take(grid1.PageSize).ToList();
// q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
return from x in q
select new
{
x.MaterPhyQuantityId,
x.ProjectId,
MaterPhyQuantityTypeName=(from y in Funs.DB.Sys_Const where y.GroupId== "MaterPhyQuantityType" && y.ConstValue== x.MaterPhyQuantityType select y.ConstText ).FirstOrDefault() ,
x.UnitOfMeasurement,
x.Total,
x.PlanCompletedNum,
x.ActCompletedNum,
x.ReportDate,
x.Remark,
x.CreateMan,
x.CompleteDate,
};
}
#endregion
public static Model.HSSE_MaterPhyQuantity GetHSSE_MaterPhyQuantityById(string MaterPhyQuantityId)
{
return Funs.DB.HSSE_MaterPhyQuantity.FirstOrDefault(x => x.MaterPhyQuantityId == MaterPhyQuantityId);
}
public static void AddHSSE_MaterPhyQuantity(Model.HSSE_MaterPhyQuantity newtable)
{
Model.HSSE_MaterPhyQuantity table = new Model.HSSE_MaterPhyQuantity
{
MaterPhyQuantityId = newtable.MaterPhyQuantityId,
ProjectId = newtable.ProjectId,
MaterPhyQuantityType = newtable.MaterPhyQuantityType,
UnitOfMeasurement = newtable.UnitOfMeasurement,
Total = newtable.Total,
PlanCompletedNum = newtable.PlanCompletedNum,
ActCompletedNum = newtable.ActCompletedNum,
ReportDate = newtable.ReportDate,
Remark = newtable.Remark,
CreateMan = newtable.CreateMan,
CompleteDate = newtable.CompleteDate,
};
Funs.DB.HSSE_MaterPhyQuantity.InsertOnSubmit(table);
Funs.DB.SubmitChanges();
}
public static void UpdateHSSE_MaterPhyQuantity(Model.HSSE_MaterPhyQuantity newtable)
{
Model.HSSE_MaterPhyQuantity table = Funs.DB.HSSE_MaterPhyQuantity.FirstOrDefault(x => x.MaterPhyQuantityId == newtable.MaterPhyQuantityId);
if (table != null)
{
table.MaterPhyQuantityId = newtable.MaterPhyQuantityId;
table.ProjectId = newtable.ProjectId;
table.MaterPhyQuantityType = newtable.MaterPhyQuantityType;
table.UnitOfMeasurement = newtable.UnitOfMeasurement;
table.Total = newtable.Total;
table.PlanCompletedNum = newtable.PlanCompletedNum;
table.ActCompletedNum = newtable.ActCompletedNum;
table.ReportDate = newtable.ReportDate;
table.Remark = newtable.Remark;
table.CreateMan = newtable.CreateMan;
table.CompleteDate = newtable.CompleteDate;
Funs.DB.SubmitChanges();
}
}
public static void DeleteHSSE_MaterPhyQuantityById(string MaterPhyQuantityId)
{
Model.HSSE_MaterPhyQuantity table = Funs.DB.HSSE_MaterPhyQuantity.FirstOrDefault(x => x.MaterPhyQuantityId == MaterPhyQuantityId);
if (table != null)
{
Funs.DB.HSSE_MaterPhyQuantity.DeleteOnSubmit(table);
Funs.DB.SubmitChanges();
}
}
}
}