105 lines
3.6 KiB
C#
105 lines
3.6 KiB
C#
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Linq;
|
|||
|
|
|
|||
|
|
namespace BLL
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 安全问题性质主表
|
|||
|
|
/// </summary>
|
|||
|
|
public class SafetyProblemNatureService
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据主键获取安全问题性质
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="Id"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public static Model.Base_SafetyProblemNature GetNatureById(string Id)
|
|||
|
|
{
|
|||
|
|
var db = Funs.DB;
|
|||
|
|
return db.Base_SafetyProblemNature.FirstOrDefault(e => e.NatureId == Id);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 添加安全问题性质
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="Nature"></param>
|
|||
|
|
public static void AddNature(Model.Base_SafetyProblemNature Nature)
|
|||
|
|
{
|
|||
|
|
var db = Funs.DB;
|
|||
|
|
Model.Base_SafetyProblemNature newModel = new Model.Base_SafetyProblemNature();
|
|||
|
|
newModel.NatureId = Nature.NatureId;
|
|||
|
|
newModel.NatureCode = Nature.NatureCode;
|
|||
|
|
newModel.NatureName = Nature.NatureName;
|
|||
|
|
db.Base_SafetyProblemNature.InsertOnSubmit(newModel);
|
|||
|
|
db.SubmitChanges();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 修改安全问题性质
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="Nature"></param>
|
|||
|
|
public static void UpdateNature(Model.Base_SafetyProblemNature Nature)
|
|||
|
|
{
|
|||
|
|
var db = Funs.DB;
|
|||
|
|
Model.Base_SafetyProblemNature newModel = db.Base_SafetyProblemNature.FirstOrDefault(e => e.NatureId == Nature.NatureId);
|
|||
|
|
if (newModel != null)
|
|||
|
|
{
|
|||
|
|
newModel.NatureCode = Nature.NatureCode;
|
|||
|
|
newModel.NatureName = Nature.NatureName;
|
|||
|
|
db.SubmitChanges();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据主键删除安全问题性质
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="Id"></param>
|
|||
|
|
public static void DeleteNature(string Id)
|
|||
|
|
{
|
|||
|
|
var db = Funs.DB;
|
|||
|
|
Model.Base_SafetyProblemNature Nature = db.Base_SafetyProblemNature.FirstOrDefault(e => e.NatureId == Id);
|
|||
|
|
if (Nature != null)
|
|||
|
|
{
|
|||
|
|
var getItems = from x in Funs.DB.Base_SafetyProblemNatureItem
|
|||
|
|
where x.NatureId == Nature.NatureId
|
|||
|
|
select x;
|
|||
|
|
if (getItems.Count() > 0)
|
|||
|
|
{
|
|||
|
|
db.Base_SafetyProblemNatureItem.DeleteAllOnSubmit(getItems);
|
|||
|
|
}
|
|||
|
|
db.Base_SafetyProblemNature.DeleteOnSubmit(Nature);
|
|||
|
|
db.SubmitChanges();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 查询所有安全问题性质
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns>安全问题性质的集合</returns>
|
|||
|
|
public static List<Model.Base_SafetyProblemNature> GetNature()
|
|||
|
|
{
|
|||
|
|
return (from x in Funs.DB.Base_SafetyProblemNature
|
|||
|
|
orderby x.NatureCode
|
|||
|
|
select x).ToList();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 类型下拉框(末级)
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="dropName"></param>
|
|||
|
|
/// <param name="projectId"></param>
|
|||
|
|
/// <param name="isShowPlease"></param>
|
|||
|
|
public static void InitNatureIsEndDropDownList(FineUIPro.DropDownList dropName, bool isShowPlease)
|
|||
|
|
{
|
|||
|
|
dropName.DataValueField = "NatureId";
|
|||
|
|
dropName.DataTextField = "NatureName";
|
|||
|
|
dropName.DataSource = GetNature();
|
|||
|
|
dropName.DataBind();
|
|||
|
|
if (isShowPlease)
|
|||
|
|
{
|
|||
|
|
Funs.FineUIPleaseSelect(dropName);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|