SGGL_JT/SUBQHSE/BLL/ThreeYearAction/FireGasSafety/Safetyresponsibilityagreeme...

130 lines
4.8 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 SafetyresponsibilityagreementService
{
#region
/// <summary>
/// 记录数
/// </summary>
public static int Count
{
get;
set;
}
public static IQueryable<Model.FireGasSafety_SafetyResponsibilityAgreement> GetFireGasSafety_SafetyResponsibilityAgreementByModle(Model.FireGasSafety_SafetyResponsibilityAgreement table)
{
var q = from x in Funs.DB.FireGasSafety_SafetyResponsibilityAgreement
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.ResponsibleMan) || x.ResponsibleMan.Contains(table.ResponsibleMan)) &&
(string.IsNullOrEmpty(table.Content) || x.Content.Contains(table.Content)) &&
(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.FireGasSafety_SafetyResponsibilityAgreement table, Grid grid1)
{
var q = GetFireGasSafety_SafetyResponsibilityAgreementByModle(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.ProjectId,
x.Code,
x.Name,
x.ResponsibleMan,
x.Content,
x.CompileMan,
x.CompileDate,
};
}
#endregion
public static Model.FireGasSafety_SafetyResponsibilityAgreement GetById(string Id)
{
return Funs.DB.FireGasSafety_SafetyResponsibilityAgreement.FirstOrDefault(x => x.Id == Id);
}
public static void Add(Model.FireGasSafety_SafetyResponsibilityAgreement newtable)
{
Model.FireGasSafety_SafetyResponsibilityAgreement table = new Model.FireGasSafety_SafetyResponsibilityAgreement
{
Id = newtable.Id,
ProjectId = newtable.ProjectId,
Code = newtable.Code,
Name = newtable.Name,
ResponsibleMan = newtable.ResponsibleMan,
Content = newtable.Content,
CompileMan = newtable.CompileMan,
CompileDate = newtable.CompileDate,
};
Funs.DB.FireGasSafety_SafetyResponsibilityAgreement.InsertOnSubmit(table);
Funs.DB.SubmitChanges();
}
public static void Update(Model.FireGasSafety_SafetyResponsibilityAgreement newtable)
{
Model.FireGasSafety_SafetyResponsibilityAgreement table = Funs.DB.FireGasSafety_SafetyResponsibilityAgreement.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.ResponsibleMan = newtable.ResponsibleMan;
table.Content = newtable.Content;
table.CompileMan = newtable.CompileMan;
table.CompileDate = newtable.CompileDate;
Funs.DB.SubmitChanges();
}
}
public static void DeleteById(string Id)
{
Model.FireGasSafety_SafetyResponsibilityAgreement table = Funs.DB.FireGasSafety_SafetyResponsibilityAgreement.FirstOrDefault(x => x.Id == Id);
if (table != null)
{
Funs.DB.FireGasSafety_SafetyResponsibilityAgreement.DeleteOnSubmit(table);
Funs.DB.SubmitChanges();
}
}
}
}