SGGL_JT/SUBQHSE/BLL/ThreeYearAction/FireGasSafety/OldPlacesDeviceUpgradeServi...

139 lines
5.1 KiB
C#
Raw Normal View History

2025-04-07 17:43:30 +08:00
using FineUIPro;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BLL
{
/// <summary>
/// 老旧场所消防设施升级改造管理
/// </summary>
public static class OldPlacesDeviceUpgradeService
{
#region
/// <summary>
/// 记录数
/// </summary>
public static int Count
{
get;
set;
}
public static IQueryable<Model.FireGasSafety_OldPlacesDeviceUpgrade> GetFireGasSafety_OldPlacesDeviceUpgradeByModle(Model.FireGasSafety_OldPlacesDeviceUpgrade table)
{
var q = from x in Funs.DB.FireGasSafety_OldPlacesDeviceUpgrade
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.Remarks) || x.Remarks.Contains(table.Remarks)) &&
(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_OldPlacesDeviceUpgrade table, Grid grid1)
{
var q = GetFireGasSafety_OldPlacesDeviceUpgradeByModle(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.ModelNo,
x.Position,
x.ConfigNum,
x.EnableDate,
x.InspectionCycle,
x.ValidUntilDate,
x.Remarks,
x.CompileMan,
x.CompileDate,
};
}
#endregion
public static Model.FireGasSafety_OldPlacesDeviceUpgrade GetById(string Id)
{
return Funs.DB.FireGasSafety_OldPlacesDeviceUpgrade.FirstOrDefault(x => x.Id == Id);
}
public static void Add(Model.FireGasSafety_OldPlacesDeviceUpgrade newtable)
{
Model.FireGasSafety_OldPlacesDeviceUpgrade table = new Model.FireGasSafety_OldPlacesDeviceUpgrade
{
Id = newtable.Id,
ProjectId = newtable.ProjectId,
Code = newtable.Code,
Name = newtable.Name,
ModelNo = newtable.ModelNo,
Position = newtable.Position,
ConfigNum = newtable.ConfigNum,
EnableDate = newtable.EnableDate,
InspectionCycle = newtable.InspectionCycle,
ValidUntilDate = newtable.ValidUntilDate,
Remarks = newtable.Remarks,
CompileMan = newtable.CompileMan,
CompileDate = newtable.CompileDate,
};
Funs.DB.FireGasSafety_OldPlacesDeviceUpgrade.InsertOnSubmit(table);
Funs.DB.SubmitChanges();
}
public static void Update(Model.FireGasSafety_OldPlacesDeviceUpgrade newtable)
{
Model.FireGasSafety_OldPlacesDeviceUpgrade table = Funs.DB.FireGasSafety_OldPlacesDeviceUpgrade.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.ModelNo = newtable.ModelNo;
table.Position = newtable.Position;
table.ConfigNum = newtable.ConfigNum;
table.EnableDate = newtable.EnableDate;
table.InspectionCycle = newtable.InspectionCycle;
table.ValidUntilDate = newtable.ValidUntilDate;
table.Remarks = newtable.Remarks;
table.CompileMan = newtable.CompileMan;
table.CompileDate = newtable.CompileDate;
Funs.DB.SubmitChanges();
}
}
public static void DeleteById(string Id)
{
Model.FireGasSafety_OldPlacesDeviceUpgrade table = Funs.DB.FireGasSafety_OldPlacesDeviceUpgrade.FirstOrDefault(x => x.Id == Id);
if (table != null)
{
Funs.DB.FireGasSafety_OldPlacesDeviceUpgrade.DeleteOnSubmit(table);
Funs.DB.SubmitChanges();
}
}
}
}