using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; namespace BLL { /// /// 无损检测管理 /// public static class NondestructiveTestService { public static Model.SGGLDB db = Funs.DB; /// /// 记录数 /// private static int count { get; set; } /// /// 获取分页列表数 /// /// /// /// /// /// /// /// /// /// public static IEnumerable GetListData(string projectId, string UnitWorkId, string unitId, string welderCode, string startDate, string endDate, int startRowIndex, int maximumRows) { Model.SGGLDB db = Funs.DB; IQueryable q = from x in db.ProcessControl_NondestructiveTest where x.ProjectId == projectId orderby x.NondestructiveTestDate descending select x; if (UnitWorkId != "0") { q = q.Where(e => e.UnitWorkId == UnitWorkId); } if (unitId != "0") { q = q.Where(e => e.UnitId == unitId); } if (!string.IsNullOrEmpty(welderCode)) { q = q.Where(e => e.WelderCode.Contains(welderCode)); } if (!string.IsNullOrEmpty(startDate) && !string.IsNullOrEmpty(endDate)) { q = q.Where(e => e.NondestructiveTestDate >= Funs.GetNewDateTime(startDate) && e.NondestructiveTestDate <= Funs.GetNewDateTime(endDate)); } count = q.Count(); if (count == 0) { return new object[] { "" }; } return from x in q.Skip(startRowIndex).Take(maximumRows) select new { x.NondestructiveTestId, x.ProjectId, InstallationName = (from y in db.WBS_UnitWork where y.UnitWorkId == x.UnitWorkId select y.UnitWorkName).FirstOrDefault(), UnitName = (from y in db.Base_Unit where y.UnitId == x.UnitId select y.UnitName).FirstOrDefault(), //ProfessionalName = (from y in db.WBS_CNProfessional where y.CNProfessionalId == x.CNProfessionalId select y.ProfessionalName).FirstOrDefault(), x.WelderCode, x.NondestructiveTestCode, x.PieceCount, x.OnceQualifiedCount, x.NondestructiveTestDate, InspectionAreaName = (from y in db.Base_InspectionArea where y.InspectionAreaId == x.InspectionAreaId select y.InspectionAreaName).FirstOrDefault(), }; } /// /// 获取分页列表数 /// /// /// /// /// /// /// /// public static int GetListCount(string projectId, string UnitWorkId, string unitId, string welderCode, string startDate, string endDate) { return count; } /// /// 根据主键获取无损检测管理 /// /// /// public static Model.ProcessControl_NondestructiveTest GetNondestructiveTestById(string nondestructiveTestId) { return Funs.DB.ProcessControl_NondestructiveTest.FirstOrDefault(e => e.NondestructiveTestId == nondestructiveTestId); } /// /// 添加无损检测管理 /// /// public static void AddNondestructiveTest(Model.ProcessControl_NondestructiveTest nondestructiveTest) { Model.SGGLDB db = Funs.DB; Model.ProcessControl_NondestructiveTest newNondestructiveTest = new Model.ProcessControl_NondestructiveTest(); newNondestructiveTest.NondestructiveTestId = nondestructiveTest.NondestructiveTestId; newNondestructiveTest.ProjectId = nondestructiveTest.ProjectId; newNondestructiveTest.UnitWorkId = nondestructiveTest.UnitWorkId; newNondestructiveTest.UnitId = nondestructiveTest.UnitId; //newNondestructiveTest.CNProfessionalId = nondestructiveTest.CNProfessionalId; newNondestructiveTest.WelderCode = nondestructiveTest.WelderCode; newNondestructiveTest.NondestructiveTestCode = nondestructiveTest.NondestructiveTestCode; newNondestructiveTest.PieceCount = nondestructiveTest.PieceCount; newNondestructiveTest.OnceQualifiedCount = nondestructiveTest.OnceQualifiedCount; newNondestructiveTest.NondestructiveTestDate = nondestructiveTest.NondestructiveTestDate; newNondestructiveTest.WED_ID = nondestructiveTest.WED_ID; newNondestructiveTest.STE_ID = nondestructiveTest.STE_ID; newNondestructiveTest.CompileMan = nondestructiveTest.CompileMan; newNondestructiveTest.InspectionAreaId = nondestructiveTest.InspectionAreaId; db.ProcessControl_NondestructiveTest.InsertOnSubmit(newNondestructiveTest); db.SubmitChanges(); } /// /// 修改无损检测管理 /// /// public static void UpdateNondestructiveTest(Model.ProcessControl_NondestructiveTest nondestructiveTest) { Model.SGGLDB db = Funs.DB; Model.ProcessControl_NondestructiveTest newNondestructiveTest = db.ProcessControl_NondestructiveTest.FirstOrDefault(e => e.NondestructiveTestId == nondestructiveTest.NondestructiveTestId); if (newNondestructiveTest != null) { newNondestructiveTest.ProjectId = nondestructiveTest.ProjectId; newNondestructiveTest.UnitWorkId = nondestructiveTest.UnitWorkId; newNondestructiveTest.UnitId = nondestructiveTest.UnitId; //newNondestructiveTest.CNProfessionalId = nondestructiveTest.CNProfessionalId; newNondestructiveTest.WelderCode = nondestructiveTest.WelderCode; newNondestructiveTest.NondestructiveTestCode = nondestructiveTest.NondestructiveTestCode; newNondestructiveTest.PieceCount = nondestructiveTest.PieceCount; newNondestructiveTest.OnceQualifiedCount = nondestructiveTest.OnceQualifiedCount; newNondestructiveTest.NondestructiveTestDate = nondestructiveTest.NondestructiveTestDate; newNondestructiveTest.WED_ID = nondestructiveTest.WED_ID; newNondestructiveTest.STE_ID = nondestructiveTest.STE_ID; newNondestructiveTest.InspectionAreaId = nondestructiveTest.InspectionAreaId; db.SubmitChanges(); } } /// /// 根据主键删除无损检测管理 /// /// public static void DeleteNondestructiveTest(string nondestructiveTestId) { Model.SGGLDB db = Funs.DB; Model.ProcessControl_NondestructiveTest nondestructiveTest = db.ProcessControl_NondestructiveTest.FirstOrDefault(e => e.NondestructiveTestId == nondestructiveTestId); if (nondestructiveTest != null) { db.ProcessControl_NondestructiveTest.DeleteOnSubmit(nondestructiveTest); db.SubmitChanges(); } } /// /// 根据单位获取对应时间内的集合 /// /// /// /// /// /// public static List GetNondestructiveTestListByUnitIdAndDate(string projectId, string unitId, DateTime startDate, DateTime SoptDate) { List NondestructiveTestList = (from x in Funs.DB.ProcessControl_NondestructiveTest where x.ProjectId == projectId select x).ToList(); NondestructiveTestList = (from x in NondestructiveTestList where x.UnitId == unitId select x).ToList(); if (startDate != null && SoptDate != null) { NondestructiveTestList = (from x in NondestructiveTestList where x.NondestructiveTestDate >= startDate && x.NondestructiveTestDate <= SoptDate select x).ToList(); } return NondestructiveTestList; } } }