125 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			125 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			C#
		
	
	
	
| using FineUIPro;
 | |
| using System;
 | |
| using System.Collections;
 | |
| using System.Linq;
 | |
| 
 | |
| namespace BLL
 | |
| {
 | |
|     public static class LeavePostService
 | |
|     {
 | |
|         public static Model.SGGLDB db = Funs.DB;
 | |
|         #region 获取列表
 | |
|         /// <summary>
 | |
|         /// 记录数
 | |
|         /// </summary>
 | |
|         public static int count
 | |
|         {
 | |
|             get;
 | |
|             set;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 定义变量
 | |
|         /// </summary>
 | |
|         private static IQueryable<Model.RealName_LeavePost> getLeavePosts = from x in db.RealName_LeavePost select x;
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 获取分页列表
 | |
|         /// </summary>
 | |
|         /// <param name="PageIndex">页码</param>
 | |
|         /// <param name="PageSize">每页数量</param>
 | |
|         /// <returns></returns>
 | |
|         public static IEnumerable getListData(string states, string projectCode, string personName, string identityCard, Grid Grid1)
 | |
|         {
 | |
|             IQueryable<Model.RealName_LeavePost> getLeavePostList = getLeavePosts;
 | |
|             if (states == "1")
 | |
|             {
 | |
|                 getLeavePostList = getLeavePostList.Where(x => x.OutTime.HasValue);
 | |
|             }
 | |
|             if (!string.IsNullOrEmpty(personName))
 | |
|             {
 | |
|                 getLeavePostList = getLeavePostList.Where(x => x.PersonName.Contains(personName));
 | |
|             }
 | |
|             if (!string.IsNullOrEmpty(identityCard))
 | |
|             {
 | |
|                 getLeavePostList = getLeavePostList.Where(x => x.IdentityCard.Contains(identityCard));
 | |
|             }
 | |
| 
 | |
|             count = getLeavePostList.Count();
 | |
|             if (count == 0)
 | |
|             {
 | |
|                 return null;
 | |
|             }
 | |
|             
 | |
|             getLeavePostList = SortConditionHelper.SortingAndPaging(getLeavePostList.OrderBy(x=>x.ProjectCode), Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
 | |
|             return from x in getLeavePostList                   
 | |
|                    select new
 | |
|                    {
 | |
|                        x.NewId,
 | |
|                        x.Id,
 | |
|                        x.PersonName,
 | |
|                        x.IdentityCard,
 | |
|                        x.ProjectId,
 | |
|                        x.ProjectCode,
 | |
|                        x.ProjectShortName,
 | |
|                        x.InTime,
 | |
|                        x.OutTime,
 | |
|                    };
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 添加实名制人员信息
 | |
|         /// </summary>
 | |
|         /// <param name="LeavePost"></param>
 | |
|         public static void AddLeavePost(Model.RealName_LeavePost LeavePost)
 | |
|         {
 | |
|             Model.SGGLDB db = Funs.DB;
 | |
|             Model.RealName_LeavePost newLeavePost = new Model.RealName_LeavePost
 | |
|             {
 | |
|                 NewId = SQLHelper.GetNewID(),
 | |
|                 Id = LeavePost.Id,
 | |
|                 PersonName = LeavePost.PersonName,
 | |
|                 IdentityCard = LeavePost.IdentityCard,
 | |
|                 ProjectId = LeavePost.ProjectId,
 | |
|                 ProjectCode = LeavePost.ProjectCode,
 | |
|                 ProjectShortName = LeavePost.ProjectShortName,
 | |
|                 InTime = LeavePost.InTime,
 | |
|                 OutTime = LeavePost.OutTime
 | |
|             };
 | |
|             db.RealName_LeavePost.InsertOnSubmit(newLeavePost);
 | |
|             db.SubmitChanges();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 修改实名制人员信息
 | |
|         /// </summary>
 | |
|         /// <param name="LeavePost"></param>
 | |
|         public static void UpdateLeavePost(Model.RealName_LeavePost LeavePost)
 | |
|         {
 | |
|             Model.SGGLDB db = Funs.DB;
 | |
|             var getLeavePost = db.RealName_LeavePost.FirstOrDefault(e => e.NewId == LeavePost.NewId);
 | |
|             if (getLeavePost != null)
 | |
|             {
 | |
|                 getLeavePost.OutTime = LeavePost.OutTime;
 | |
|                 db.SubmitChanges();
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 
 | |
|         /// </summary>
 | |
|         /// <param name="LeavePost"></param>
 | |
|         public static void DeleteLeavePost()
 | |
|         {
 | |
|             Model.SGGLDB db = Funs.DB;
 | |
|             var getLeavePost = from x in db.RealName_LeavePost select x;
 | |
|             if (getLeavePost.Count() > 0)
 | |
|             {
 | |
|                 db.RealName_LeavePost.DeleteAllOnSubmit(getLeavePost);
 | |
|                 db.SubmitChanges();
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| }
 |