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; /// /// 获取焊工考试计划明细列表 /// /// /// /// 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 ? "合格" : "不合格"), }; } /// /// 获取焊工考试计划明细列表 /// /// /// /// public static List getPersonIdList(string TestPlanId) { return (from x in db.Welder_TestPlanDetail where x.TestPlanId == TestPlanId select x.PersonId).ToList(); } /// /// 增加焊工考试计划明细 /// /// 焊工考试计划明细 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(); } /// /// 修改焊工考试计划信息 /// /// 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(); } } /// /// 根据焊工考试计划id删除对应的所有焊工考试计划明细 /// /// 焊工考试计划id 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(); } } /// /// 根据焊工考试计划id获取对应的所有焊工考试计划明细 /// /// 焊工考试计划id public static List GetTestPlanDetailsByTestPlanId(string TestPlanId) { Model.SGGLDB db = Funs.DB; return (from x in db.Welder_TestPlanDetail where x.TestPlanId == TestPlanId select x).ToList(); } /// /// 根据焊工考试计划id和人员id获取对应的所有焊工考试计划明细 /// /// 焊工考试计划id 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(); } } }