103 lines
		
	
	
		
			4.2 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			103 lines
		
	
	
		
			4.2 KiB
		
	
	
	
		
			C#
		
	
	
	
|  | using System; | |||
|  | using System.Collections.Generic; | |||
|  | using System.Linq; | |||
|  | using System.Text; | |||
|  | using System.Threading.Tasks; | |||
|  | 
 | |||
|  | namespace BLL | |||
|  | { | |||
|  |     /// <summary> | |||
|  |     /// 党支部基本情况 | |||
|  |     /// </summary> | |||
|  |     public class BasicInformationService | |||
|  |     { | |||
|  |         /// <summary> | |||
|  |         /// 根据主键获取党支部基本情况 | |||
|  |         /// </summary> | |||
|  |         /// <param name="basicInformationId"></param> | |||
|  |         /// <returns></returns> | |||
|  |         public static Model.Party_BasicInformation GetBasicInformationById(string basicInformationId) | |||
|  |         { | |||
|  |             return Funs.DB.Party_BasicInformation.FirstOrDefault(e => e.BasicInformationId == basicInformationId); | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 根据年份获取党支部基本情况 | |||
|  |         /// </summary> | |||
|  |         /// <param name="year"></param> | |||
|  |         /// <returns></returns> | |||
|  |         public static Model.Party_BasicInformation GetBasicInformationByYear(string year) | |||
|  |         { | |||
|  |             return Funs.DB.Party_BasicInformation.FirstOrDefault(e => e.Year == Convert.ToInt32(year)); | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 获取最近的党支部基本情况 | |||
|  |         /// </summary> | |||
|  |         /// <returns></returns> | |||
|  |         public static Model.Party_BasicInformation GetOldBasicInformation() | |||
|  |         { | |||
|  |             return Funs.DB.Party_BasicInformation.OrderByDescending(x => x.Year).FirstOrDefault(); | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 添加党支部基本情况 | |||
|  |         /// </summary> | |||
|  |         /// <param name="basicInformation"></param> | |||
|  |         public static void AddBasicInformation(Model.Party_BasicInformation basicInformation) | |||
|  |         { | |||
|  |             Model.Party_BasicInformation newBasicInformation = new Model.Party_BasicInformation | |||
|  |             { | |||
|  |                 BasicInformationId = basicInformation.BasicInformationId, | |||
|  |                 Year = basicInformation.Year, | |||
|  |                 Name = basicInformation.Name, | |||
|  |                 StartDate = basicInformation.StartDate, | |||
|  |                 Component = basicInformation.Component, | |||
|  |                 PartyerNum = basicInformation.PartyerNum, | |||
|  |                 PersonNum = basicInformation.PersonNum, | |||
|  |                 PartyGroupNum = basicInformation.PartyGroupNum, | |||
|  |                 Commendation = basicInformation.Commendation, | |||
|  |                 Punishment = basicInformation.Punishment | |||
|  |             }; | |||
|  |             Funs.DB.Party_BasicInformation.InsertOnSubmit(newBasicInformation); | |||
|  |             Funs.DB.SubmitChanges(); | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 修改党支部基本情况 | |||
|  |         /// </summary> | |||
|  |         /// <param name="basicInformation"></param> | |||
|  |         public static void UpdateBasicInformation(Model.Party_BasicInformation basicInformation) | |||
|  |         { | |||
|  |             Model.Party_BasicInformation newBasicInformation = Funs.DB.Party_BasicInformation.FirstOrDefault(e => e.BasicInformationId == basicInformation.BasicInformationId); | |||
|  |             if (newBasicInformation != null) | |||
|  |             { | |||
|  |                 newBasicInformation.Name = basicInformation.Name; | |||
|  |                 newBasicInformation.StartDate = basicInformation.StartDate; | |||
|  |                 newBasicInformation.Component = basicInformation.Component; | |||
|  |                 newBasicInformation.PartyerNum = basicInformation.PartyerNum; | |||
|  |                 newBasicInformation.PersonNum = basicInformation.PersonNum; | |||
|  |                 newBasicInformation.PartyGroupNum = basicInformation.PartyGroupNum; | |||
|  |                 newBasicInformation.Commendation = basicInformation.Commendation; | |||
|  |                 newBasicInformation.Punishment = basicInformation.Punishment; | |||
|  |                 Funs.DB.SubmitChanges(); | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 根据主键删除党支部基本情况 | |||
|  |         /// </summary> | |||
|  |         /// <param name="basicInformationId"></param> | |||
|  |         public static void DeleteBasicInformationById(string basicInformationId) | |||
|  |         { | |||
|  |             Model.Party_BasicInformation basicInformation = Funs.DB.Party_BasicInformation.FirstOrDefault(e => e.BasicInformationId == basicInformationId); | |||
|  |             if (basicInformation != null) | |||
|  |             { | |||
|  |                 CommonService.DeleteAttachFileById(basicInformationId); | |||
|  |                 Funs.DB.Party_BasicInformation.DeleteOnSubmit(basicInformation); | |||
|  |                 Funs.DB.SubmitChanges(); | |||
|  |             } | |||
|  |         } | |||
|  |     } | |||
|  | } |