223 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			223 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			C#
		
	
	
	
| 
								 | 
							
								using System;
							 | 
						|||
| 
								 | 
							
								using System.Collections.Generic;
							 | 
						|||
| 
								 | 
							
								using System.Linq;
							 | 
						|||
| 
								 | 
							
								using System.Text;
							 | 
						|||
| 
								 | 
							
								using System.Collections;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								namespace BLL
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    /// <summary>
							 | 
						|||
| 
								 | 
							
								    /// NCR管理
							 | 
						|||
| 
								 | 
							
								    /// </summary>
							 | 
						|||
| 
								 | 
							
								    public static class NCRManagementService
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        public static Model.SGGLDB db = Funs.DB;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 记录数
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        private static int count
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            get;
							 | 
						|||
| 
								 | 
							
								            set;
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 获取分页列表
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="startRowIndex"></param>
							 | 
						|||
| 
								 | 
							
								        /// <param name="maximumRows"></param>
							 | 
						|||
| 
								 | 
							
								        /// <returns></returns>
							 | 
						|||
| 
								 | 
							
								        public static IEnumerable GetListData(string projectId, string sendUnit, string cnProfessionalId, string startDate, string endDate, int startRowIndex, int maximumRows)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            IQueryable<Model.Comprehensive_NCRManagement> q = from x in db.Comprehensive_NCRManagement
							 | 
						|||
| 
								 | 
							
								                                                              where x.ProjectId == projectId
							 | 
						|||
| 
								 | 
							
								                                                              orderby x.IssuedDate descending
							 | 
						|||
| 
								 | 
							
								                                                              select x;
							 | 
						|||
| 
								 | 
							
								            if (sendUnit!="0")
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                q = q.Where(e => e.SendUnit == sendUnit);
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            if (cnProfessionalId != "0")
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                q = q.Where(e => e.CNProfessionalId == cnProfessionalId);
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            if (!string.IsNullOrEmpty(startDate) && !string.IsNullOrEmpty(endDate) && Convert.ToDateTime(startDate) <= Convert.ToDateTime(endDate))
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                q = q.Where(e => e.CompleteDate >= Convert.ToDateTime(startDate) && e.CompleteDate <= Convert.ToDateTime(endDate));
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            count = q.Count();
							 | 
						|||
| 
								 | 
							
								            if (count == 0)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                return new object[] { };
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            return from x in q.Skip(startRowIndex).Take(maximumRows)
							 | 
						|||
| 
								 | 
							
								                   select new
							 | 
						|||
| 
								 | 
							
								                   {
							 | 
						|||
| 
								 | 
							
								                       x.NCRManagementId,
							 | 
						|||
| 
								 | 
							
								                       x.ProjectId,
							 | 
						|||
| 
								 | 
							
								                       SendUnit=(from y in db.Base_Unit where y.UnitId==x.SendUnit select y.UnitName).FirstOrDefault(),
							 | 
						|||
| 
								 | 
							
								                       ProfessionalName = (from y in db.Base_CNProfessional where y.CNProfessionalId == x.CNProfessionalId select y.ProfessionalName).FirstOrDefault(),
							 | 
						|||
| 
								 | 
							
								                       x.NCRCode,
							 | 
						|||
| 
								 | 
							
								                       x.Contents,
							 | 
						|||
| 
								 | 
							
								                       x.IssuedDate,
							 | 
						|||
| 
								 | 
							
								                       ReceiveUnit = x.ReceiveUnit!= null ? BLL.UnitService.getUnitNamesUnitIds(x.ReceiveUnit) : null,
							 | 
						|||
| 
								 | 
							
								                       UnitWorkName = x.UnitWorkId != null ? BLL.UnitWorkService.GetUnitWorkName(x.UnitWorkId) : null,
							 | 
						|||
| 
								 | 
							
								                       x.ClosedDate,
							 | 
						|||
| 
								 | 
							
								                       x.CompleteDate,
							 | 
						|||
| 
								 | 
							
								                       x.ResponsibleMan,
							 | 
						|||
| 
								 | 
							
								                       x.AttachUrl,
							 | 
						|||
| 
								 | 
							
								                       x.ImplementationFrontState,
							 | 
						|||
| 
								 | 
							
								                       //TotalCount = x.NCRManagementId.Count()
							 | 
						|||
| 
								 | 
							
								                   };
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 获取分页列表数
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="projectId"></param>
							 | 
						|||
| 
								 | 
							
								        /// <returns></returns>
							 | 
						|||
| 
								 | 
							
								        public static int GetListCount(string projectId, string sendUnit, string cnProfessionalId, string startDate, string endDate)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            return count;
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 根据主键获取NCR管理
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="nCRManagementId"></param>
							 | 
						|||
| 
								 | 
							
								        /// <returns></returns>
							 | 
						|||
| 
								 | 
							
								        public static Model.Comprehensive_NCRManagement GetNCRManagementById(string nCRManagementId)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            return Funs.DB.Comprehensive_NCRManagement.FirstOrDefault(e => e.NCRManagementId == nCRManagementId);
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 添加NCR管理
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="nCRManagement"></param>
							 | 
						|||
| 
								 | 
							
								        public static void AddNCRManagement(Model.Comprehensive_NCRManagement nCRManagement)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            Model.SGGLDB db = Funs.DB;
							 | 
						|||
| 
								 | 
							
								            Model.Comprehensive_NCRManagement newNCRManagement = new Model.Comprehensive_NCRManagement();
							 | 
						|||
| 
								 | 
							
								            newNCRManagement.NCRManagementId = nCRManagement.NCRManagementId;
							 | 
						|||
| 
								 | 
							
								            newNCRManagement.ProjectId = nCRManagement.ProjectId;
							 | 
						|||
| 
								 | 
							
								            newNCRManagement.SendUnit = nCRManagement.SendUnit;
							 | 
						|||
| 
								 | 
							
								            newNCRManagement.CNProfessionalId = nCRManagement.CNProfessionalId;
							 | 
						|||
| 
								 | 
							
								            newNCRManagement.NCRCode = nCRManagement.NCRCode;
							 | 
						|||
| 
								 | 
							
								            newNCRManagement.Contents = nCRManagement.Contents;
							 | 
						|||
| 
								 | 
							
								            newNCRManagement.IssuedDate = nCRManagement.IssuedDate;
							 | 
						|||
| 
								 | 
							
								            newNCRManagement.ReceiveUnit = nCRManagement.ReceiveUnit;
							 | 
						|||
| 
								 | 
							
								            newNCRManagement.ClosedDate = nCRManagement.ClosedDate;
							 | 
						|||
| 
								 | 
							
								            newNCRManagement.CompleteDate = nCRManagement.CompleteDate;
							 | 
						|||
| 
								 | 
							
								            newNCRManagement.ResponsibleMan = nCRManagement.ResponsibleMan;
							 | 
						|||
| 
								 | 
							
								            newNCRManagement.AttachUrl = nCRManagement.AttachUrl;
							 | 
						|||
| 
								 | 
							
								            newNCRManagement.ImplementationFrontState = nCRManagement.ImplementationFrontState;
							 | 
						|||
| 
								 | 
							
								            newNCRManagement.CompileMan = nCRManagement.CompileMan;
							 | 
						|||
| 
								 | 
							
								            newNCRManagement.UnitWorkId = nCRManagement.UnitWorkId;
							 | 
						|||
| 
								 | 
							
								            db.Comprehensive_NCRManagement.InsertOnSubmit(newNCRManagement);
							 | 
						|||
| 
								 | 
							
								            db.SubmitChanges();
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 修改NCR管理
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="nCRManagement"></param>
							 | 
						|||
| 
								 | 
							
								        public static void UpdateNCRManagement(Model.Comprehensive_NCRManagement nCRManagement)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            Model.SGGLDB db = Funs.DB;
							 | 
						|||
| 
								 | 
							
								            Model.Comprehensive_NCRManagement newNCRManagement = db.Comprehensive_NCRManagement.FirstOrDefault(e => e.NCRManagementId == nCRManagement.NCRManagementId);
							 | 
						|||
| 
								 | 
							
								            if (newNCRManagement != null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                newNCRManagement.ProjectId = nCRManagement.ProjectId;
							 | 
						|||
| 
								 | 
							
								                newNCRManagement.SendUnit = nCRManagement.SendUnit;
							 | 
						|||
| 
								 | 
							
								                newNCRManagement.CNProfessionalId = nCRManagement.CNProfessionalId;
							 | 
						|||
| 
								 | 
							
								                newNCRManagement.NCRCode = nCRManagement.NCRCode;
							 | 
						|||
| 
								 | 
							
								                newNCRManagement.Contents = nCRManagement.Contents;
							 | 
						|||
| 
								 | 
							
								                newNCRManagement.IssuedDate = nCRManagement.IssuedDate;
							 | 
						|||
| 
								 | 
							
								                newNCRManagement.ReceiveUnit = nCRManagement.ReceiveUnit;
							 | 
						|||
| 
								 | 
							
								                newNCRManagement.ClosedDate = nCRManagement.ClosedDate;
							 | 
						|||
| 
								 | 
							
								                newNCRManagement.CompleteDate = nCRManagement.CompleteDate;
							 | 
						|||
| 
								 | 
							
								                newNCRManagement.ResponsibleMan = nCRManagement.ResponsibleMan;
							 | 
						|||
| 
								 | 
							
								                newNCRManagement.AttachUrl = nCRManagement.AttachUrl;
							 | 
						|||
| 
								 | 
							
								                newNCRManagement.ImplementationFrontState = nCRManagement.ImplementationFrontState;
							 | 
						|||
| 
								 | 
							
								                newNCRManagement.UnitWorkId = nCRManagement.UnitWorkId;
							 | 
						|||
| 
								 | 
							
								                db.SubmitChanges();
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 根据主键删除NCR管理
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="nCRManagementId"></param>
							 | 
						|||
| 
								 | 
							
								        public static void DeleteNCRManagement(string nCRManagementId)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            Model.SGGLDB db = Funs.DB;
							 | 
						|||
| 
								 | 
							
								            Model.Comprehensive_NCRManagement nCRManagement = db.Comprehensive_NCRManagement.FirstOrDefault(e => e.NCRManagementId == nCRManagementId);
							 | 
						|||
| 
								 | 
							
								            if (nCRManagement != null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                if (!string.IsNullOrEmpty(nCRManagement.AttachUrl))
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    BLL.UploadAttachmentService.DeleteFile(Funs.RootPath, nCRManagement.AttachUrl);//删除附件
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                db.Comprehensive_NCRManagement.DeleteOnSubmit(nCRManagement);
							 | 
						|||
| 
								 | 
							
								                db.SubmitChanges();
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 获取对应时间内的集合
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="projectId"></param>
							 | 
						|||
| 
								 | 
							
								        /// <param name="unitId"></param>
							 | 
						|||
| 
								 | 
							
								        /// <param name="startDate"></param>
							 | 
						|||
| 
								 | 
							
								        /// <param name="SoptDate"></param>
							 | 
						|||
| 
								 | 
							
								        /// <returns></returns>
							 | 
						|||
| 
								 | 
							
								        public static List<Model.Comprehensive_NCRManagement> GetNCRManagementListByDate(string projectId, DateTime startDate, DateTime SoptDate)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            List<Model.Comprehensive_NCRManagement> NondestructiveTestList = (from x in Funs.DB.Comprehensive_NCRManagement where x.ProjectId == projectId select x).ToList();
							 | 
						|||
| 
								 | 
							
								            if (startDate != null && SoptDate != null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                NondestructiveTestList = (from x in NondestructiveTestList where x.IssuedDate >= startDate && x.IssuedDate <= SoptDate select x).ToList();
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            return NondestructiveTestList;
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 根据接收单位获取对应时间内的集合
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="projectId"></param>
							 | 
						|||
| 
								 | 
							
								        /// <param name="unitName"></param>
							 | 
						|||
| 
								 | 
							
								        /// <param name="startDate"></param>
							 | 
						|||
| 
								 | 
							
								        /// <param name="SoptDate"></param>
							 | 
						|||
| 
								 | 
							
								        /// <returns></returns>
							 | 
						|||
| 
								 | 
							
								        public static List<Model.Comprehensive_NCRManagement> GetNCRManagementListByUnitNameAndDate(string projectId, string unitName, DateTime startDate, DateTime SoptDate)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            List<Model.Comprehensive_NCRManagement> NondestructiveTestList = (from x in Funs.DB.Comprehensive_NCRManagement where x.ProjectId == projectId && x.ReceiveUnit==unitName select x).ToList();
							 | 
						|||
| 
								 | 
							
								            if (startDate != null && SoptDate != null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                NondestructiveTestList = (from x in NondestructiveTestList where x.IssuedDate >= startDate && x.IssuedDate <= SoptDate select x).ToList();
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            return NondestructiveTestList;
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 根据专业获取对应时间内的集合
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="projectId"></param>
							 | 
						|||
| 
								 | 
							
								        /// <param name="cNProfessionalId"></param>
							 | 
						|||
| 
								 | 
							
								        /// <param name="startDate"></param>
							 | 
						|||
| 
								 | 
							
								        /// <param name="SoptDate"></param>
							 | 
						|||
| 
								 | 
							
								        /// <returns></returns>
							 | 
						|||
| 
								 | 
							
								        public static List<Model.Comprehensive_NCRManagement> GetNCRManagementListByCNProfessionalIdAndDate(string projectId, string cNProfessionalId, DateTime startDate, DateTime SoptDate)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            List<Model.Comprehensive_NCRManagement> NondestructiveTestList = (from x in Funs.DB.Comprehensive_NCRManagement where x.ProjectId == projectId && x.CNProfessionalId == cNProfessionalId select x).ToList();
							 | 
						|||
| 
								 | 
							
								            if (startDate != null && SoptDate != null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                NondestructiveTestList = (from x in NondestructiveTestList where x.IssuedDate >= startDate && x.IssuedDate <= SoptDate select x).ToList();
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            return NondestructiveTestList;
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								}
							 |