181 lines
7.1 KiB
C#
181 lines
7.1 KiB
C#
|
using FineUIPro;
|
|||
|
using System;
|
|||
|
using System.Collections;
|
|||
|
using System.Linq;
|
|||
|
using Model;
|
|||
|
|
|||
|
namespace BLL
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 项目潜在自然灾害风险清单
|
|||
|
/// </summary>
|
|||
|
public class DisasterRiskListService
|
|||
|
{
|
|||
|
public static Model.SUBQHSEDB db = Funs.DB;
|
|||
|
|
|||
|
#region 获取在项目潜在自然灾害风险清单列表信息
|
|||
|
/// <summary>
|
|||
|
/// 记录数
|
|||
|
/// </summary>
|
|||
|
public static int count
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 定义变量
|
|||
|
/// </summary>
|
|||
|
private static IQueryable<Model.Manager_DisasterRiskList> getDataLists = from x in db.Manager_DisasterRiskList
|
|||
|
select x;
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 数据列表
|
|||
|
/// </summary>
|
|||
|
/// <param name="unitId"></param>
|
|||
|
/// <param name="Grid1"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public static IEnumerable getListData(string unitId, string projectId, string month, Grid Grid1)
|
|||
|
{
|
|||
|
IQueryable<Model.Manager_DisasterRiskList> getDataList = getDataLists;
|
|||
|
if (!string.IsNullOrEmpty(unitId) && unitId != Const._Null)
|
|||
|
{
|
|||
|
getDataList = from x in getDataList
|
|||
|
join y in db.Base_Project on x.ProjectId equals y.ProjectId
|
|||
|
where y.UnitId == unitId
|
|||
|
select x;
|
|||
|
}
|
|||
|
if (!string.IsNullOrEmpty(projectId))
|
|||
|
{
|
|||
|
getDataList = getDataList.Where(x => x.ProjectId == projectId);
|
|||
|
}
|
|||
|
if (!string.IsNullOrEmpty(month))
|
|||
|
{
|
|||
|
DateTime? monthTime = Funs.GetNewDateTime(month);
|
|||
|
if (monthTime.HasValue)
|
|||
|
{
|
|||
|
getDataList = getDataList.Where(x => x.Months == monthTime.Value);
|
|||
|
}
|
|||
|
}
|
|||
|
count = getDataList.Count();
|
|||
|
if (count == 0)
|
|||
|
{
|
|||
|
return null;
|
|||
|
}
|
|||
|
getDataList = SortConditionHelper.SortingAndPaging(getDataList, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
|
|||
|
return from x in getDataList
|
|||
|
join y in db.Base_Project on x.ProjectId equals y.ProjectId
|
|||
|
orderby x.Months, y.UnitId, x.ProjectId
|
|||
|
select new
|
|||
|
{
|
|||
|
x.DisasterRiskListId,
|
|||
|
x.Months,
|
|||
|
y.UnitId,
|
|||
|
db.Base_Unit.First(u => u.UnitId == y.UnitId).UnitName,
|
|||
|
x.ProjectId,
|
|||
|
db.Base_Project.First(u => u.ProjectId == x.ProjectId).ProjectName,
|
|||
|
x.Address,
|
|||
|
x.DisasterRiskId,
|
|||
|
db.Base_DisasterRisk.First(u => u.DisasterRiskId == x.DisasterRiskId).DisasterRiskName,
|
|||
|
x.ContactInfo,
|
|||
|
x.EmergencyPlan,
|
|||
|
x.EmergencyDrill,
|
|||
|
x.RiskStatus,
|
|||
|
x.FillManId,
|
|||
|
db.Sys_User.First(u => u.UserId == x.FillManId).UserName,
|
|||
|
x.FillingTime,
|
|||
|
x.FillManContact,
|
|||
|
};
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 根据主键获取项目潜在自然灾害风险清单
|
|||
|
/// </summary>
|
|||
|
/// <param name="DisasterRiskListId"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public static Model.Manager_DisasterRiskList GetDisasterRiskListById(string DisasterRiskListId)
|
|||
|
{
|
|||
|
return Funs.DB.Manager_DisasterRiskList.FirstOrDefault(e => e.DisasterRiskListId == DisasterRiskListId);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 根据月份获取项目潜在自然灾害风险清单
|
|||
|
/// </summary>
|
|||
|
/// <param name="months"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public static Manager_DisasterRiskList GetDisasterRiskListByMonths(DateTime months, string projectId)
|
|||
|
{
|
|||
|
return Funs.DB.Manager_DisasterRiskList.FirstOrDefault(e => e.ProjectId == projectId && e.Months.Value.Year == months.Year && e.Months.Value.Month == months.Month);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 添加项目潜在自然灾害风险清单
|
|||
|
/// </summary>
|
|||
|
/// <param name="newReport"></param>
|
|||
|
public static string AddDisasterRiskList(Manager_DisasterRiskList newList)
|
|||
|
{
|
|||
|
string newDisasterRiskListId = SQLHelper.GetNewID();
|
|||
|
Model.Manager_DisasterRiskList newReport = new Manager_DisasterRiskList
|
|||
|
{
|
|||
|
DisasterRiskListId = newDisasterRiskListId,
|
|||
|
Months = newList.Months,
|
|||
|
ProjectId = newList.ProjectId,
|
|||
|
Address = newList.Address,
|
|||
|
DisasterRiskId = newList.DisasterRiskId,
|
|||
|
ContactInfo = newList.ContactInfo,
|
|||
|
EmergencyPlan = newList.EmergencyPlan,
|
|||
|
EmergencyDrill = newList.EmergencyDrill,
|
|||
|
RiskStatus = newList.RiskStatus,
|
|||
|
FillManId = newList.FillManId,
|
|||
|
FillingTime = newList.FillingTime,
|
|||
|
FillManContact = newList.FillManContact,
|
|||
|
};
|
|||
|
Funs.DB.Manager_DisasterRiskList.InsertOnSubmit(newReport);
|
|||
|
Funs.DB.SubmitChanges();
|
|||
|
|
|||
|
return newDisasterRiskListId;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 修改项目潜在自然灾害风险清单
|
|||
|
/// </summary>
|
|||
|
/// <param name="list"></param>
|
|||
|
public static void UpdateDisasterRiskList (Model.Manager_DisasterRiskList list)
|
|||
|
{
|
|||
|
var getList = Funs.DB.Manager_DisasterRiskList.FirstOrDefault(e => e.DisasterRiskListId == list.DisasterRiskListId);
|
|||
|
if (getList != null)
|
|||
|
{
|
|||
|
getList.Months = list.Months;
|
|||
|
getList.ProjectId = list.ProjectId;
|
|||
|
getList.Address = list.Address;
|
|||
|
getList.DisasterRiskId = list.DisasterRiskId;
|
|||
|
getList.ContactInfo = list.ContactInfo;
|
|||
|
getList.EmergencyPlan = list.EmergencyPlan;
|
|||
|
getList.EmergencyDrill = list.EmergencyDrill;
|
|||
|
getList.RiskStatus = list.RiskStatus;
|
|||
|
getList.FillManId = list.FillManId;
|
|||
|
getList.FillingTime = list.FillingTime;
|
|||
|
getList.FillManContact = list.FillManContact;
|
|||
|
Funs.DB.SubmitChanges();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#region 根据主键删除项目潜在自然灾害风险清单
|
|||
|
/// <summary>
|
|||
|
/// 根据主键删除项目潜在自然灾害风险清单
|
|||
|
/// </summary>
|
|||
|
/// <param name="DisasterRiskListId"></param>
|
|||
|
public static void DeleteDisasterRiskListById(string DisasterRiskListId)
|
|||
|
{
|
|||
|
var DisasterRiskList = Funs.DB.Manager_DisasterRiskList.FirstOrDefault(e => e.DisasterRiskListId == DisasterRiskListId);
|
|||
|
if (DisasterRiskList != null)
|
|||
|
{
|
|||
|
Funs.DB.Manager_DisasterRiskList.DeleteOnSubmit(DisasterRiskList);
|
|||
|
Funs.DB.SubmitChanges();
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|