190 lines
		
	
	
		
			8.9 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			190 lines
		
	
	
		
			8.9 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.Linq;
 | |
| using System.Text;
 | |
| using System.Collections;
 | |
| 
 | |
| namespace BLL
 | |
| {
 | |
|     /// <summary>
 | |
|     /// 机具报验
 | |
|     /// </summary>
 | |
|     public static class InspectionMachineService
 | |
|     {
 | |
|         public static Model.SGGLDB db = Funs.DB;
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 记录数
 | |
|         /// </summary>
 | |
|         private static int count
 | |
|         {
 | |
|             get;
 | |
|             set;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 获取分页列表
 | |
|         /// </summary>
 | |
|         /// <param name="projectId"></param>
 | |
|         /// <param name="unitId"></param>
 | |
|         /// <param name="startRowIndex"></param>
 | |
|         /// <param name="maximumRows"></param>
 | |
|         /// <returns></returns>
 | |
|         public static IEnumerable GetListData(string projectId, string unitId, string cnProfessionalId, string inspectionType, int startRowIndex, int maximumRows)
 | |
|         {
 | |
|             IQueryable<Model.Comprehensive_InspectionMachine> q = from x in db.Comprehensive_InspectionMachine
 | |
|                                                                   where x.ProjectId == projectId
 | |
|                                                                   orderby x.InspectionMachineCode descending
 | |
|                                                                   select x;
 | |
|             if (unitId != "0")
 | |
|             {
 | |
|                 q = q.Where(e => e.UnitId == unitId);
 | |
|             }
 | |
| 
 | |
|             if (cnProfessionalId != "0")
 | |
|             {
 | |
|                 q = q.Where(e => e.CNProfessionalId == cnProfessionalId);
 | |
|             }
 | |
| 
 | |
|             if (inspectionType != "0")
 | |
|             {
 | |
|                 q = q.Where(e => e.InspectionType == inspectionType);
 | |
|             }
 | |
| 
 | |
|             count = q.Count();
 | |
|             if (count == 0)
 | |
|             {
 | |
|                 return new object[] { "" };
 | |
|             }
 | |
|             return from x in q.Skip(startRowIndex).Take(maximumRows)
 | |
|                    select new
 | |
|                    {
 | |
|                        x.InspectionMachineId,
 | |
|                        x.ProjectId,
 | |
|                        UnitName = (from y in db.Base_Unit where y.UnitId == x.UnitId select y.UnitName).FirstOrDefault(),
 | |
|                        x.InspectionMachineCode,
 | |
|                        x.InspectionMachineName,
 | |
|                        x.SpecificationModel,
 | |
|                        x.NextTestDate,
 | |
|                        x.TestCycle,
 | |
|                        IsVerification = x.IsVerification == true ? "是" : "否",
 | |
|                        x.InspectionDate,
 | |
|                        x.AttachUrl,
 | |
|                        x.CNProfessionalId,
 | |
|                        x.InspectionType,
 | |
|                        x.UnitsCount,
 | |
|                        x.LeaveDate,
 | |
|                        ProfessionalName = (from y in db.Base_CNProfessional where y.CNProfessionalId == x.CNProfessionalId select y.ProfessionalName).FirstOrDefault(),
 | |
|                    };
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 获取分页列表数
 | |
|         /// </summary>
 | |
|         /// <param name="projectId"></param>
 | |
|         /// <param name="unitId"></param>
 | |
|         /// <returns></returns>
 | |
|         public static int GetListCount(string projectId, string unitId, string cnProfessionalId, string inspectionType)
 | |
|         {
 | |
|             return count;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据主键获取机具校验
 | |
|         /// </summary>
 | |
|         /// <param name="inspectionMachineId"></param>
 | |
|         /// <returns></returns>
 | |
|         public static Model.Comprehensive_InspectionMachine GetInspectionMachineById(string inspectionMachineId)
 | |
|         {
 | |
|             return Funs.DB.Comprehensive_InspectionMachine.FirstOrDefault(e => e.InspectionMachineId == inspectionMachineId);
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 添加机具校验
 | |
|         /// </summary>
 | |
|         /// <param name="inspectionMachine"></param>
 | |
|         public static void AddInspectionMachine(Model.Comprehensive_InspectionMachine inspectionMachine)
 | |
|         {
 | |
|             Model.SGGLDB db = Funs.DB; ;
 | |
|             Model.Comprehensive_InspectionMachine newInspectionMachine = new Model.Comprehensive_InspectionMachine();
 | |
|             newInspectionMachine.InspectionMachineId = inspectionMachine.InspectionMachineId;
 | |
|             newInspectionMachine.ProjectId = inspectionMachine.ProjectId;
 | |
|             newInspectionMachine.UnitId = inspectionMachine.UnitId;
 | |
|             newInspectionMachine.InspectionMachineCode = inspectionMachine.InspectionMachineCode;
 | |
|             newInspectionMachine.InspectionMachineName = inspectionMachine.InspectionMachineName;
 | |
|             newInspectionMachine.SpecificationModel = inspectionMachine.SpecificationModel;
 | |
|             newInspectionMachine.IsCheckOK = inspectionMachine.IsCheckOK;
 | |
|             newInspectionMachine.InspectionType = inspectionMachine.InspectionType;
 | |
|             newInspectionMachine.NextTestDate = inspectionMachine.NextTestDate;
 | |
|             newInspectionMachine.TestCycle = inspectionMachine.TestCycle;
 | |
|             newInspectionMachine.IsVerification = inspectionMachine.IsVerification;
 | |
|             newInspectionMachine.InspectionDate = inspectionMachine.InspectionDate;
 | |
|             newInspectionMachine.AttachUrl = inspectionMachine.AttachUrl;
 | |
|             newInspectionMachine.CNProfessionalId = inspectionMachine.CNProfessionalId;
 | |
|             newInspectionMachine.CompileMan = inspectionMachine.CompileMan;
 | |
|             newInspectionMachine.CompileDate = inspectionMachine.CompileDate;
 | |
|             newInspectionMachine.CompileDate = inspectionMachine.CompileDate;
 | |
|             newInspectionMachine.IsOnSite = inspectionMachine.IsOnSite;
 | |
|             newInspectionMachine.UnitsCount = inspectionMachine.UnitsCount;
 | |
|             newInspectionMachine.LeaveDate = inspectionMachine.LeaveDate;
 | |
|             newInspectionMachine.Status = inspectionMachine.Status;
 | |
|             newInspectionMachine.RemarkCode = inspectionMachine.RemarkCode;
 | |
|             db.Comprehensive_InspectionMachine.InsertOnSubmit(newInspectionMachine);
 | |
|             db.SubmitChanges();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 修改机具校验
 | |
|         /// </summary>
 | |
|         /// <param name="inspectionMachine"></param>
 | |
|         public static void UpdateInspectionMachine(Model.Comprehensive_InspectionMachine inspectionMachine)
 | |
|         {
 | |
|             using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
 | |
|             {
 | |
|                 Model.Comprehensive_InspectionMachine newInspectionMachine = db.Comprehensive_InspectionMachine.FirstOrDefault(e => e.InspectionMachineId == inspectionMachine.InspectionMachineId);
 | |
|                 if (newInspectionMachine != null)
 | |
|                 {
 | |
|                     newInspectionMachine.ProjectId = inspectionMachine.ProjectId;
 | |
|                     newInspectionMachine.UnitId = inspectionMachine.UnitId;
 | |
|                     newInspectionMachine.InspectionMachineCode = inspectionMachine.InspectionMachineCode;
 | |
|                     newInspectionMachine.InspectionMachineName = inspectionMachine.InspectionMachineName;
 | |
|                     newInspectionMachine.SpecificationModel = inspectionMachine.SpecificationModel;
 | |
|                     newInspectionMachine.IsCheckOK = inspectionMachine.IsCheckOK;
 | |
|                     newInspectionMachine.InspectionType = inspectionMachine.InspectionType;
 | |
|                     newInspectionMachine.NextTestDate = inspectionMachine.NextTestDate;
 | |
|                     newInspectionMachine.TestCycle = inspectionMachine.TestCycle;
 | |
|                     newInspectionMachine.IsVerification = inspectionMachine.IsVerification;
 | |
|                     newInspectionMachine.InspectionDate = inspectionMachine.InspectionDate;
 | |
|                     newInspectionMachine.AttachUrl = inspectionMachine.AttachUrl;
 | |
|                     newInspectionMachine.CNProfessionalId = inspectionMachine.CNProfessionalId;
 | |
|                     newInspectionMachine.IsOnSite = inspectionMachine.IsOnSite;
 | |
|                     newInspectionMachine.UnitsCount = inspectionMachine.UnitsCount;
 | |
|                     newInspectionMachine.LeaveDate = inspectionMachine.LeaveDate;
 | |
|                     newInspectionMachine.Status = inspectionMachine.Status;
 | |
|                     newInspectionMachine.RemarkCode = inspectionMachine.RemarkCode;
 | |
|                     db.SubmitChanges();
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据主键删除机具校验
 | |
|         /// </summary>
 | |
|         /// <param name="inspectionMachineId"></param>
 | |
|         public static void DeleteInspectionMachine(string inspectionMachineId)
 | |
|         {
 | |
|             Model.SGGLDB db = Funs.DB;
 | |
|             Model.Comprehensive_InspectionMachine inspectionMachine = db.Comprehensive_InspectionMachine.FirstOrDefault(e => e.InspectionMachineId == inspectionMachineId);
 | |
|             if (inspectionMachine != null)
 | |
|             {
 | |
|                 if (!string.IsNullOrEmpty(inspectionMachine.AttachUrl))
 | |
|                 {
 | |
|                     BLL.UploadAttachmentService.DeleteFile(Funs.RootPath, inspectionMachine.AttachUrl);//删除附件
 | |
|                 }
 | |
|                 db.Comprehensive_InspectionMachine.DeleteOnSubmit(inspectionMachine);
 | |
|                 db.SubmitChanges();
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| }
 |