feat(hjgl): 新增防腐等级字典管理
将防腐等级维护纳入焊接设置菜单,便于统一维护防腐等级编码并复用系统权限配置。
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
using Model;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
public static class PaintCodeDictService
|
||||
{
|
||||
public static List<Tw_PaintCodeDict> GetList(string paintCode)
|
||||
{
|
||||
var query = Funs.DB.Tw_PaintCodeDict.AsQueryable();
|
||||
if (!string.IsNullOrEmpty(paintCode))
|
||||
{
|
||||
query = query.Where(x => x.PaintCode.Contains(paintCode));
|
||||
}
|
||||
|
||||
return query.OrderBy(x => x.SortIndex).ThenBy(x => x.PaintCode).ToList();
|
||||
}
|
||||
|
||||
public static Tw_PaintCodeDict GetById(string id)
|
||||
{
|
||||
return Funs.DB.Tw_PaintCodeDict.FirstOrDefault(x => x.Id == id);
|
||||
}
|
||||
|
||||
public static bool PaintCodeExists(string paintCode, string excludeId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(excludeId))
|
||||
{
|
||||
return Funs.DB.Tw_PaintCodeDict.Any(x => x.PaintCode == paintCode);
|
||||
}
|
||||
|
||||
return Funs.DB.Tw_PaintCodeDict.Any(x => x.PaintCode == paintCode && x.Id != excludeId);
|
||||
}
|
||||
|
||||
public static void Add(Tw_PaintCodeDict paintCodeDict)
|
||||
{
|
||||
Funs.DB.Tw_PaintCodeDict.InsertOnSubmit(paintCodeDict);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
public static void Update(Tw_PaintCodeDict paintCodeDict)
|
||||
{
|
||||
var model = Funs.DB.Tw_PaintCodeDict.First(x => x.Id == paintCodeDict.Id);
|
||||
model.PaintCode = paintCodeDict.PaintCode;
|
||||
model.Primer = paintCodeDict.Primer;
|
||||
model.IntermediatePaint = paintCodeDict.IntermediatePaint;
|
||||
model.Topcoat = paintCodeDict.Topcoat;
|
||||
model.ColorCode = paintCodeDict.ColorCode;
|
||||
model.SortIndex = paintCodeDict.SortIndex;
|
||||
model.IsUsed = paintCodeDict.IsUsed;
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
public static string GetDeleteRestriction(string id)
|
||||
{
|
||||
if (Funs.DB.HJGL_Pipeline.Any(x => x.PaintId == id))
|
||||
{
|
||||
return "已在【管线信息】中使用,不能删除!";
|
||||
}
|
||||
|
||||
if (Funs.DB.HJGL_AntiCorrosionCheckRecord.Any(x => x.PaintId == id))
|
||||
{
|
||||
return "已在【防腐检查记录】中使用,不能删除!";
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public static void Delete(string id)
|
||||
{
|
||||
var model = Funs.DB.Tw_PaintCodeDict.First(x => x.Id == id);
|
||||
Funs.DB.Tw_PaintCodeDict.DeleteOnSubmit(model);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user