ChengDa_English/SGGL/BLL/TestRun/DriverGoods/GoodsPlanService.cs

83 lines
3.2 KiB
C#
Raw Normal View History

2022-03-15 17:36:38 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BLL
{
/// <summary>
/// 开车物资计划
/// </summary>
public static class GoodsPlanService
{
/// <summary>
/// 根据主键获取开车物资计划信息
/// </summary>
/// <param name="GoodsPlanId"></param>
/// <returns></returns>
public static Model.DriverGoods_GoodsPlan GetGoodsPlanById(string GoodsPlanId)
{
return Funs.DB.DriverGoods_GoodsPlan.FirstOrDefault(e => e.GoodsPlanId == GoodsPlanId);
}
/// <summary>
/// 添加开车物资计划信息
/// </summary>
/// <param name="GoodsPlan"></param>
public static void AddGoodsPlan(Model.DriverGoods_GoodsPlan GoodsPlan)
{
Model.DriverGoods_GoodsPlan newGoodsPlan = new Model.DriverGoods_GoodsPlan();
newGoodsPlan.GoodsPlanId = GoodsPlan.GoodsPlanId;
newGoodsPlan.ProjectId = GoodsPlan.ProjectId;
newGoodsPlan.Code = GoodsPlan.Code;
newGoodsPlan.PlanName = GoodsPlan.PlanName;
newGoodsPlan.PlanCode = GoodsPlan.PlanCode;
newGoodsPlan.CompileMan = GoodsPlan.CompileMan;
newGoodsPlan.ApprovalDate = GoodsPlan.ApprovalDate;
newGoodsPlan.AttachUrl = GoodsPlan.AttachUrl;
newGoodsPlan.Remark = GoodsPlan.Remark;
Funs.DB.DriverGoods_GoodsPlan.InsertOnSubmit(newGoodsPlan);
Funs.DB.SubmitChanges();
}
/// <summary>
/// 修改开车物资计划
/// </summary>
/// <param name="GoodsPlan"></param>
public static void UpdateGoodsPlan(Model.DriverGoods_GoodsPlan GoodsPlan)
{
Model.DriverGoods_GoodsPlan newGoodsPlan = Funs.DB.DriverGoods_GoodsPlan.FirstOrDefault(e => e.GoodsPlanId == GoodsPlan.GoodsPlanId);
if (newGoodsPlan != null)
{
newGoodsPlan.Code = GoodsPlan.Code;
newGoodsPlan.PlanName = GoodsPlan.PlanName;
newGoodsPlan.PlanCode = GoodsPlan.PlanCode;
//newGoodsPlan.CompileMan = GoodsPlan.CompileMan;
newGoodsPlan.ApprovalDate = GoodsPlan.ApprovalDate;
newGoodsPlan.AttachUrl = GoodsPlan.AttachUrl;
newGoodsPlan.Remark = GoodsPlan.Remark;
Funs.DB.SubmitChanges();
}
}
/// <summary>
/// 根据主键删除开车物资计划
/// </summary>
/// <param name="GoodsPlanId"></param>
public static void DeleteGoodsPlan(string GoodsPlanId)
{
Model.DriverGoods_GoodsPlan GoodsPlan = Funs.DB.DriverGoods_GoodsPlan.FirstOrDefault(e => e.GoodsPlanId == GoodsPlanId);
if (GoodsPlan != null)
{
if (!string.IsNullOrEmpty(GoodsPlan.AttachUrl))
{
BLL.UploadAttachmentService.DeleteFile(Funs.RootPath, GoodsPlan.AttachUrl);//删除附件
}
Funs.DB.DriverGoods_GoodsPlan.DeleteOnSubmit(GoodsPlan);
Funs.DB.SubmitChanges();
}
}
}
}