ChengDa_English/SGGL/BLL/CQMS/ManageReport/RowMaterialProblemService.cs

70 lines
2.7 KiB
C#
Raw Permalink Normal View History

2022-03-15 17:36:38 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BLL
{
/// <summary>
/// 原材料问题
/// </summary>
public static class RowMaterialProblemService
{
public static Model.SGGLDB db = Funs.DB;
/// <summary>
/// 根据主键获取原材料问题
/// </summary>
/// <param name="rowMaterialProblemId"></param>
/// <returns></returns>
public static Model.Report_RowMaterialProblem GetRowMaterialProblemById(string rowMaterialProblemId)
{
return Funs.DB.Report_RowMaterialProblem.FirstOrDefault(e => e.RowMaterialProblemId == rowMaterialProblemId);
}
/// <summary>
/// 根据周报Id获取相关原材料问题
/// </summary>
/// <param name="reportId"></param>
/// <returns></returns>
public static List<Model.Report_RowMaterialProblem> GetRowMaterialProblemByReportId(string reportId)
{
return (from x in db.Report_RowMaterialProblem where x.ReportId == reportId select x).ToList();
}
/// <summary>
/// 添加原材料问题
/// </summary>
/// <param name="rowMaterialProblem"></param>
public static void AddRowMaterialProblem(Model.Report_RowMaterialProblem rowMaterialProblem)
{
Model.SGGLDB db = Funs.DB;
Model.Report_RowMaterialProblem newRowMaterialProblem = new Model.Report_RowMaterialProblem();
newRowMaterialProblem.RowMaterialProblemId = rowMaterialProblem.RowMaterialProblemId;
newRowMaterialProblem.ReportId = rowMaterialProblem.ReportId;
newRowMaterialProblem.UnitId = rowMaterialProblem.UnitId;
newRowMaterialProblem.ProblemDesrioption = rowMaterialProblem.ProblemDesrioption;
newRowMaterialProblem.TreatmentMeasures = rowMaterialProblem.TreatmentMeasures;
newRowMaterialProblem.ProcessingResults = rowMaterialProblem.ProcessingResults;
newRowMaterialProblem.Remark = rowMaterialProblem.Remark;
db.Report_RowMaterialProblem.InsertOnSubmit(newRowMaterialProblem);
db.SubmitChanges();
}
/// <summary>
/// 根据周报Id删除所有相关原材料问题
/// </summary>
/// <param name="reportId"></param>
public static void DeleteRowMaterialProbleByReportId(string reportId)
{
Model.SGGLDB db = Funs.DB;
var q = (from x in db.Report_RowMaterialProblem where x.ReportId == reportId select x).ToList();
if (q.Count() > 0)
{
db.Report_RowMaterialProblem.DeleteAllOnSubmit(q);
db.SubmitChanges();
}
}
}
}