SGGL_JT/SUBQHSE/BLL/ThreeYearAction/FireGasSafety/FirefightingequipmentServic...

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