using FineUIPro; using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; namespace BLL { public static class CheckMaterialacceptanceService { public static Model.SGGLDB db = Funs.DB; #region 获取列表 /// /// 记录数 /// public static int count { get; set; } public static List GetCheck_MaterialAcceptanceByModle(Model.Check_MaterialAcceptance table) { var q = from x in 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(); } /// 获取分页列表 /// /// 页码 /// 每页数量 /// 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 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, }; db.Check_MaterialAcceptance.InsertOnSubmit(table); db.SubmitChanges(); } public static void AddBulkCheck_MaterialAcceptance(List newtables) { db.Check_MaterialAcceptance.InsertAllOnSubmit(newtables); db.SubmitChanges(); } public static void UpdateCheck_MaterialAcceptance(Model.Check_MaterialAcceptance newtable) { Model.Check_MaterialAcceptance table = db.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; db.SubmitChanges(); } } public static void DeleteCheck_MaterialAcceptanceById(string MaterialAcceptanceId) { Model.Check_MaterialAcceptance table = db.Check_MaterialAcceptance.FirstOrDefault(x => x.MaterialAcceptanceId == MaterialAcceptanceId); if (table != null) { db.Check_MaterialAcceptance.DeleteOnSubmit(table); db.SubmitChanges(); } } public static void DeleteALLCheck_MaterialAcceptance() { if (db.Check_MaterialAcceptance != null) { db.Check_MaterialAcceptance.DeleteAllOnSubmit(db.Check_MaterialAcceptance); db.SubmitChanges(); } } } }