99 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			99 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			C#
		
	
	
	
|  | using System; | |||
|  | using System.Collections.Generic; | |||
|  | using System.Data.SqlClient; | |||
|  | using System.Linq; | |||
|  | 
 | |||
|  | namespace BLL | |||
|  | { | |||
|  |     /// <summary> | |||
|  |     /// 检验试验计划管理 | |||
|  |     /// </summary> | |||
|  |     public class InspectionTestPlanService | |||
|  |     { | |||
|  |         public static bool Insert(Model.Inspection_Test_Plan model) | |||
|  |         { | |||
|  |             try | |||
|  |             { | |||
|  |                 Funs.DB.Inspection_Test_Plan.InsertOnSubmit(model); | |||
|  |                 Funs.DB.SubmitChanges(); | |||
|  |                 return true; | |||
|  |             } | |||
|  |             catch (Exception ex) | |||
|  |             { | |||
|  |                 ErrLogInfo.WriteLog($"插入数据失败,原因:{ex.Message}"); | |||
|  |                 return false; | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  |         public static bool Update(Model.Inspection_Test_Plan model) | |||
|  |         { | |||
|  |             try | |||
|  |             { | |||
|  |                 var result = Funs.DB.Inspection_Test_Plan.FirstOrDefault(a => a.Id == model.Id); | |||
|  |                 if (result != null) | |||
|  |                 { | |||
|  |                     result.UnitId = model.UnitId; | |||
|  |                     result.CNProfessionalId = model.CNProfessionalId; | |||
|  |                     result.PlanCode = model.PlanCode; | |||
|  |                     result.PlanName = model.PlanName; | |||
|  |                     result.ApprovalDate = model.ApprovalDate; | |||
|  |                     result.AuditMan = model.AuditMan; | |||
|  |                     result.ApprovalMan = model.ApprovalMan; | |||
|  |                     result.Remarks = model.Remarks; | |||
|  |                     Funs.DB.SubmitChanges(); | |||
|  |                 } | |||
|  |                 return true; | |||
|  |             } | |||
|  |             catch (Exception ex) | |||
|  |             { | |||
|  |                 ErrLogInfo.WriteLog($"更新表数据失败,原因:{ex.Message}"); | |||
|  |                 return false; | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  |         public static bool Delete(List<string> newId) | |||
|  |         { | |||
|  |             try | |||
|  |             { | |||
|  |                 var result = Funs.DB.Inspection_Test_Plan.Where(a => newId.Contains(a.Id)).ToList(); | |||
|  |                 if (result.Count > 0) | |||
|  |                 { | |||
|  |                     Funs.DB.Inspection_Test_Plan.DeleteAllOnSubmit(result); | |||
|  |                     Funs.DB.SubmitChanges(); | |||
|  |                 } | |||
|  |                 return true; | |||
|  |             } | |||
|  |             catch (Exception ex) | |||
|  |             { | |||
|  |                 ErrLogInfo.WriteLog($"删除数据失败,原因:{ex.Message}"); | |||
|  |                 return false; | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  |         public static bool Delete(string newId) | |||
|  |         { | |||
|  |             try | |||
|  |             { | |||
|  |                 var result = Funs.DB.Inspection_Test_Plan.Where(a => a.Id == newId).ToList(); | |||
|  |                 if (result.Count > 0) | |||
|  |                 { | |||
|  |                     Funs.DB.Inspection_Test_Plan.DeleteAllOnSubmit(result); | |||
|  |                     Funs.DB.SubmitChanges(); | |||
|  |                 } | |||
|  |                 return true; | |||
|  |             } | |||
|  |             catch (Exception ex) | |||
|  |             { | |||
|  |                 ErrLogInfo.WriteLog($"删除数据失败,原因:{ex.Message}"); | |||
|  |                 return false; | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  |         public static Model.Inspection_Test_Plan Detail(string newId) | |||
|  |         { | |||
|  |             var result = Funs.DB.Inspection_Test_Plan.FirstOrDefault(a => a.Id == newId); | |||
|  |             return result; | |||
|  |         } | |||
|  |     } | |||
|  | } |