SGGL_SHJ/SGGL/BLL/HJGL/PreDesign/YardPlanningService.cs

85 lines
3.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BLL
{
public static class HJGL_YardPlanningService
{
public static Model.HJGL_YardPlanning GetHJGL_YardPlanningById(string YardPlanningId)
{
return Funs.DB.HJGL_YardPlanning.FirstOrDefault(e => e.YardPlanningId == YardPlanningId);
}
public static Model.HJGL_YardPlanning GetHJGL_YardPlanningByProjectId(string projectId)
{
return Funs.DB.HJGL_YardPlanning.FirstOrDefault(e => e.ProjectId == projectId);
}
/// <summary>
/// 保存应急流程图
/// </summary>
/// <param name="projectid"></param>
/// <param name="unitid"></param>
/// <param name="imgurl"></param>
public static void SavePic(string projectid, string imgurl)
{
var model = Funs.DB.HJGL_YardPlanning.FirstOrDefault(e => e.ProjectId == projectid);
if (model != null)
{
model.FlowChartPic = imgurl;
UpdateHJGL_YardPlanning(model);
}
else
{
Model.HJGL_YardPlanning table = new Model.HJGL_YardPlanning();
table.YardPlanningId = SQLHelper.GetNewID(typeof(Model.HJGL_YardPlanning));
table.ProjectId = projectid;
table.FlowChartPic = imgurl;
Funs.DB.HJGL_YardPlanning.InsertOnSubmit(table);
Funs.DB.SubmitChanges();
}
}
public static void AddHJGL_YardPlanning(Model.HJGL_YardPlanning newtable)
{
Model.HJGL_YardPlanning table = new Model.HJGL_YardPlanning();
table.YardPlanningId = newtable.YardPlanningId;
table.ProjectId = newtable.ProjectId;
table.Remark = newtable.Remark;
table.FlowChartPic = newtable.FlowChartPic;
Funs.DB.HJGL_YardPlanning.InsertOnSubmit(table);
Funs.DB.SubmitChanges();
}
public static void UpdateHJGL_YardPlanning(Model.HJGL_YardPlanning newtable)
{
Model.HJGL_YardPlanning table = Funs.DB.HJGL_YardPlanning.FirstOrDefault(e => e.YardPlanningId == newtable.YardPlanningId);
if (table != null)
{
table.YardPlanningId = newtable.YardPlanningId;
table.ProjectId = newtable.ProjectId;
table.Remark = newtable.Remark;
table.FlowChartPic = newtable.FlowChartPic;
Funs.DB.SubmitChanges();
}
}
public static void DeleteHJGL_YardPlanningById(string YardPlanningId)
{
Model.HJGL_YardPlanning table = Funs.DB.HJGL_YardPlanning.FirstOrDefault(e => e.YardPlanningId == YardPlanningId);
if (table != null)
{
Funs.DB.HJGL_YardPlanning.DeleteOnSubmit(table);
Funs.DB.SubmitChanges();
}
}
}
}