SGGL_JT/SUBQHSE/BLL/ThreeYearAction/ConstructionStandardization/BenchmarkWorkSiteService.cs

128 lines
4.9 KiB
C#

using FineUIPro;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BLL
{
/// <summary>
/// 标杆示范工地创建活动管理
/// </summary>
public static class BenchmarkWorkSiteService
{
#region
/// <summary>
/// 记录数
/// </summary>
public static int Count
{
get;
set;
}
public static IQueryable<Model.ConstructionStandardization_BenchmarkWorkSite> GetConstructionStandardization_BenchmarkWorkSiteByModle(Model.ConstructionStandardization_BenchmarkWorkSite table)
{
var q = from x in Funs.DB.ConstructionStandardization_BenchmarkWorkSite
where
(string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) &&
(string.IsNullOrEmpty(table.ProjectId) || x.ProjectId.Contains(table.ProjectId)) &&
(string.IsNullOrEmpty(table.Code) || x.Code.Contains(table.Code)) &&
(string.IsNullOrEmpty(table.Name) || x.Name.Contains(table.Name)) &&
(string.IsNullOrEmpty(table.CompileMan) || x.CompileMan.Contains(table.CompileMan))
select x
;
return q;
}
/// <summary>
/// 获取分页列表
/// </summary>
/// <param name="table"></param>
/// <param name="grid1"></param>
/// <returns></returns>
public static IEnumerable GetListData(Model.ConstructionStandardization_BenchmarkWorkSite table, Grid grid1)
{
var q = GetConstructionStandardization_BenchmarkWorkSiteByModle(table);
Count = q.Count();
if (Count == 0)
{
return null;
}
q = q.Skip(grid1.PageSize * grid1.PageIndex).Take(grid1.PageSize);
return from x in q
select new
{
x.Id,
x.ProjectId,
x.Code,
x.Name,
x.CompileMan,
x.CompileDate,
};
}
#endregion
public static Model.ConstructionStandardization_BenchmarkWorkSite GetById(string Id)
{
return Funs.DB.ConstructionStandardization_BenchmarkWorkSite.FirstOrDefault(x => x.Id == Id);
}
public static void Add(Model.ConstructionStandardization_BenchmarkWorkSite newtable)
{
Model.ConstructionStandardization_BenchmarkWorkSite table = new Model.ConstructionStandardization_BenchmarkWorkSite
{
Id = newtable.Id,
ProjectId = newtable.ProjectId,
Code = newtable.Code,
Name = newtable.Name,
GeneralContractor = newtable.GeneralContractor,
Owner = newtable.Owner,
Supervisor = newtable.Supervisor,
AchieveResults = newtable.AchieveResults,
GraphicProgress = newtable.GraphicProgress,
UnitOpinion = newtable.UnitOpinion,
CompileMan = newtable.CompileMan,
CompileDate = newtable.CompileDate,
};
Funs.DB.ConstructionStandardization_BenchmarkWorkSite.InsertOnSubmit(table);
Funs.DB.SubmitChanges();
}
public static void Update(Model.ConstructionStandardization_BenchmarkWorkSite newtable)
{
Model.ConstructionStandardization_BenchmarkWorkSite table = Funs.DB.ConstructionStandardization_BenchmarkWorkSite.FirstOrDefault(x => x.Id == newtable.Id);
if (table != null)
{
table.Id = newtable.Id;
table.ProjectId = newtable.ProjectId;
table.Code = newtable.Code;
table.Name = newtable.Name;
table.GeneralContractor = newtable.GeneralContractor;
table.Owner = newtable.Owner;
table.Supervisor = newtable.Supervisor;
table.AchieveResults = newtable.AchieveResults;
table.GraphicProgress = newtable.GraphicProgress;
table.UnitOpinion = newtable.UnitOpinion;
table.CompileMan = newtable.CompileMan;
table.CompileDate = newtable.CompileDate;
Funs.DB.SubmitChanges();
}
}
public static void DeleteById(string Id)
{
Model.ConstructionStandardization_BenchmarkWorkSite table = Funs.DB.ConstructionStandardization_BenchmarkWorkSite.FirstOrDefault(x => x.Id == Id);
if (table != null)
{
Funs.DB.ConstructionStandardization_BenchmarkWorkSite.DeleteOnSubmit(table);
Funs.DB.SubmitChanges();
}
}
}
}