SGGL_SHJ/SGGL/BLL/CQMS/Check/CheckMaterialacceptance.cs

143 lines
5.4 KiB
C#

using FineUIPro;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace BLL
{
public static class CheckMaterialacceptanceService
{
#region
/// <summary>
/// 记录数
/// </summary>
public static int count
{
get;
set;
}
public static List<Model.Check_MaterialAcceptance> GetCheck_MaterialAcceptanceByModle(Model.Check_MaterialAcceptance table)
{
var q = from x in Funs.DB.Check_MaterialAcceptance
where
(string.IsNullOrEmpty(table.MaterialAcceptanceId) || x.MaterialAcceptanceId.Contains(table.MaterialAcceptanceId)) &&
(string.IsNullOrEmpty(table.ProjectId) || x.ProjectId.Contains(table.ProjectId)) &&
(string.IsNullOrEmpty(table.PlanCode) || x.PlanCode.Contains(table.PlanCode)) &&
(string.IsNullOrEmpty(table.FileName) || x.FileName.Contains(table.FileName)) &&
(string.IsNullOrEmpty(table.CompileMan) || x.CompileMan.Contains(table.CompileMan)) &&
(string.IsNullOrEmpty(table.State) || x.State.Contains(table.State)) &&
(string.IsNullOrEmpty(table.FilePath) || x.FilePath.Contains(table.FilePath))
select x
;
return q.ToList();
}
/// 获取分页列表
/// </summary>
/// <param name="PageIndex">页码</param>
/// <param name="PageSize">每页数量</param>
/// <returns></returns>
public static IEnumerable getListData(Model.Check_MaterialAcceptance table, Grid Grid1)
{
var q = GetCheck_MaterialAcceptanceByModle(table);
count = q.Count();
if (count == 0)
{
return null;
}
// q= q.Take(Grid1.PageSize * Grid1.PageIndex).Skip(Grid1.PageSize * (Grid1.PageIndex)).ToList();
// q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
return from x in q
select new
{
x.MaterialAcceptanceId,
x.ProjectId,
x.PlanCode,
x.FileName,
x.CompileMan,
x.CompileDate,
x.State,
x.FilePath,
};
}
#endregion
public static Model.Check_MaterialAcceptance GetCheck_MaterialAcceptanceById(string MaterialAcceptanceId)
{
return Funs.DB.Check_MaterialAcceptance.FirstOrDefault(x => x.MaterialAcceptanceId == MaterialAcceptanceId);
}
public static void AddCheck_MaterialAcceptance(Model.Check_MaterialAcceptance newtable)
{
Model.Check_MaterialAcceptance table = new Model.Check_MaterialAcceptance
{
MaterialAcceptanceId = newtable.MaterialAcceptanceId,
ProjectId = newtable.ProjectId,
PlanCode = newtable.PlanCode,
FileName = newtable.FileName,
CompileMan = newtable.CompileMan,
CompileDate = newtable.CompileDate,
State = newtable.State,
FilePath = newtable.FilePath,
};
var db1 = Funs.DB;
db1.Check_MaterialAcceptance.InsertOnSubmit(table);
db1.SubmitChanges();
}
public static void AddBulkCheck_MaterialAcceptance(List<Model.Check_MaterialAcceptance> newtables)
{
var db1 = Funs.DB;
db1.Check_MaterialAcceptance.InsertAllOnSubmit(newtables);
db1.SubmitChanges();
}
public static void UpdateCheck_MaterialAcceptance(Model.Check_MaterialAcceptance newtable)
{
var db1 = Funs.DB;
Model.Check_MaterialAcceptance table = db1.Check_MaterialAcceptance.FirstOrDefault(x => x.MaterialAcceptanceId == newtable.MaterialAcceptanceId);
if (table != null)
{
table.MaterialAcceptanceId = newtable.MaterialAcceptanceId;
table.ProjectId = newtable.ProjectId;
table.PlanCode = newtable.PlanCode;
table.FileName = newtable.FileName;
table.CompileMan = newtable.CompileMan;
table.CompileDate = newtable.CompileDate;
table.State = newtable.State;
table.FilePath = newtable.FilePath;
db1.SubmitChanges();
}
}
public static void DeleteCheck_MaterialAcceptanceById(string MaterialAcceptanceId)
{
var db1 = Funs.DB;
Model.Check_MaterialAcceptance table = db1.Check_MaterialAcceptance.FirstOrDefault(x => x.MaterialAcceptanceId == MaterialAcceptanceId);
if (table != null)
{
db1.Check_MaterialAcceptance.DeleteOnSubmit(table);
db1.SubmitChanges();
}
}
public static void DeleteALLCheck_MaterialAcceptance()
{
var db1 = Funs.DB;
if (db1.Check_MaterialAcceptance != null)
{
db1.Check_MaterialAcceptance.DeleteAllOnSubmit(db1.Check_MaterialAcceptance);
db1.SubmitChanges();
}
}
}
}