SGGL_SHJ/SGGL/BLL/CQMS/PersonManage/CQMS_TestPlanDetailService.cs

134 lines
5.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
namespace BLL
{
public class CQMS_TestPlanDetailService
{
public static Model.SGGLDB db = Funs.DB;
/// <summary>
/// 获取焊工考试计划明细列表
/// </summary>
/// <param name="satartRowIndex"></param>
/// <param name="maximumRows"></param>
/// <returns></returns>
public static IEnumerable getListData(string TestPlanId)
{
return from x in db.Welder_TestPlanDetail
join z in db.Welder_TestPlan on x.TestPlanId equals z.TestPlanId
where x.TestPlanId == TestPlanId
select new
{
x.TestPlanDetailId,
x.TestPlanId,
x.PersonId,
x.QualifiedItem,
x.TestItem,
x.IsAppearanceOK,
IsAppearanceOKStr = x.IsAppearanceOK == null ? "" : (x.IsAppearanceOK == true ? "是" : "否"),
x.CheckMan,
CheckManStr = (from y in db.SitePerson_Person where y.ProjectId == z.ProjectId && y.PersonId == x.CheckMan select y.PersonName).First(),
x.NDTResult,
NDTResultStr = x.NDTResult == null ? "" : (x.NDTResult == true ? "合格" : "不合格"),
x.CheckUnit,
CheckUnitStr = (from y in db.Base_Unit where y.UnitId == x.CheckUnit select y.UnitName).First(),
x.State,
StateStr = x.State == null ? "" : (x.State == true ? "合格" : "不合格"),
};
}
/// <summary>
/// 获取焊工考试计划明细列表
/// </summary>
/// <param name="satartRowIndex"></param>
/// <param name="maximumRows"></param>
/// <returns></returns>
public static List<string> getPersonIdList(string TestPlanId)
{
return (from x in db.Welder_TestPlanDetail
where x.TestPlanId == TestPlanId
select x.PersonId).ToList();
}
/// <summary>
/// 增加焊工考试计划明细
/// </summary>
/// <param name="managerRuleApprove">焊工考试计划明细</param>
public static void AddTestPlanDetail(Model.Welder_TestPlanDetail TestPlanDetail)
{
Model.SGGLDB db = Funs.DB;
Model.Welder_TestPlanDetail newTestPlanDetail = new Model.Welder_TestPlanDetail();
newTestPlanDetail.TestPlanDetailId = TestPlanDetail.TestPlanDetailId;
newTestPlanDetail.TestPlanId = TestPlanDetail.TestPlanId;
newTestPlanDetail.PersonId = TestPlanDetail.PersonId;
newTestPlanDetail.QualifiedItem = TestPlanDetail.QualifiedItem;
newTestPlanDetail.TestItem = TestPlanDetail.TestItem;
db.Welder_TestPlanDetail.InsertOnSubmit(newTestPlanDetail);
db.SubmitChanges();
}
/// <summary>
/// 修改焊工考试计划信息
/// </summary>
/// <param name="WPQ"></param>
public static void UpdateTestPlanDetail(Model.Welder_TestPlanDetail TestPlanDetail)
{
Model.SGGLDB db = Funs.DB;
Model.Welder_TestPlanDetail newTestPlanDetail = db.Welder_TestPlanDetail.FirstOrDefault(e => e.TestPlanDetailId == TestPlanDetail.TestPlanDetailId);
if (newTestPlanDetail != null)
{
newTestPlanDetail.PersonId = TestPlanDetail.PersonId;
newTestPlanDetail.QualifiedItem = TestPlanDetail.QualifiedItem;
newTestPlanDetail.TestItem = TestPlanDetail.TestItem;
newTestPlanDetail.IsAppearanceOK = TestPlanDetail.IsAppearanceOK;
newTestPlanDetail.CheckMan = TestPlanDetail.CheckMan;
newTestPlanDetail.NDTResult = TestPlanDetail.NDTResult;
newTestPlanDetail.CheckUnit = TestPlanDetail.CheckUnit;
newTestPlanDetail.State = TestPlanDetail.State;
db.SubmitChanges();
}
}
/// <summary>
/// 根据焊工考试计划id删除对应的所有焊工考试计划明细
/// </summary>
/// <param name="TestPlanId">焊工考试计划id</param>
public static void DeleteTestPlanDetailsByTestPlanId(string TestPlanId)
{
Model.SGGLDB db = Funs.DB;
var q = (from x in db.Welder_TestPlanDetail where x.TestPlanId == TestPlanId select x).ToList();
if (q.Count() > 0)
{
db.Welder_TestPlanDetail.DeleteAllOnSubmit(q);
db.SubmitChanges();
}
}
/// <summary>
/// 根据焊工考试计划id获取对应的所有焊工考试计划明细
/// </summary>
/// <param name="TestPlanId">焊工考试计划id</param>
public static List<Model.Welder_TestPlanDetail> GetTestPlanDetailsByTestPlanId(string TestPlanId)
{
Model.SGGLDB db = Funs.DB;
return (from x in db.Welder_TestPlanDetail where x.TestPlanId == TestPlanId select x).ToList();
}
/// <summary>
/// 根据焊工考试计划id和人员id获取对应的所有焊工考试计划明细
/// </summary>
/// <param name="TestPlanId">焊工考试计划id</param>
public static Model.Welder_TestPlanDetail GetTestPlanDetailByTestPlanIdAndPersonId(string TestPlanId, string PersonId)
{
Model.SGGLDB db = Funs.DB;
return (from x in db.Welder_TestPlanDetail where x.TestPlanId == TestPlanId && x.PersonId == PersonId select x).FirstOrDefault();
}
}
}