208 lines
		
	
	
		
			9.0 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			208 lines
		
	
	
		
			9.0 KiB
		
	
	
	
		
			C#
		
	
	
	
using System;
 | 
						|
using System.Collections.Generic;
 | 
						|
using System.Linq;
 | 
						|
using System.Text;
 | 
						|
using System.Collections;
 | 
						|
 | 
						|
namespace BLL
 | 
						|
{
 | 
						|
    /// <summary>
 | 
						|
    /// 设计交底管理
 | 
						|
    /// </summary>
 | 
						|
    public static class DesignDetailsService
 | 
						|
    {
 | 
						|
        public static Model.SGGLDB db = Funs.DB;
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 记录数
 | 
						|
        /// </summary>
 | 
						|
        private static int count
 | 
						|
        {
 | 
						|
            get;
 | 
						|
            set;
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 获取分页列表
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="projectId"></param>
 | 
						|
        /// <param name="cNProfessionalId"></param>
 | 
						|
        /// <param name="startRowIndex"></param>
 | 
						|
        /// <param name="maximumRows"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        public static IEnumerable GetListData(string projectId, string cNProfessionalId, int startRowIndex, int maximumRows)
 | 
						|
        {
 | 
						|
            IQueryable<Model.Comprehensive_DesignDetails> q = from x in db.Comprehensive_DesignDetails
 | 
						|
                                                              where x.ProjectId == projectId
 | 
						|
                                                              orderby x.DetailsDate descending
 | 
						|
                                                              select x;
 | 
						|
            if (cNProfessionalId != "0")
 | 
						|
            {
 | 
						|
                q = q.Where(e => e.CNProfessionalId == cNProfessionalId);
 | 
						|
            }
 | 
						|
            count = q.Count();
 | 
						|
            if (count == 0)
 | 
						|
            {
 | 
						|
                return new object[] { "" };
 | 
						|
            }
 | 
						|
            return from x in q.Skip(startRowIndex).Take(maximumRows)
 | 
						|
                   select new
 | 
						|
                   {
 | 
						|
                       x.DesignDetailsId,
 | 
						|
                       x.ProjectId,
 | 
						|
                       ProfessionalName = (from y in db.Base_CNProfessional where y.CNProfessionalId == x.CNProfessionalId select y.ProfessionalName).FirstOrDefault(),
 | 
						|
                       x.DesignDetailsCode,
 | 
						|
                       x.DetailsMan,
 | 
						|
                       x.DetailsDate,
 | 
						|
                       UnitWorkName = x.UnitWorkId != null ? BLL.UnitWorkService.GetUnitWorkName(x.UnitWorkId) : null,
 | 
						|
                       UnitName = x.UnitName != null ? BLL.UnitService.getUnitNamesUnitIds(x.UnitName) : null,
 | 
						|
                       x.AttachUrl
 | 
						|
                   };
 | 
						|
        }
 | 
						|
 | 
						|
        public static IEnumerable GetListDataForDataType(string UnitWorkId, string projectId, string cNProfessionalId, int startRowIndex, int maximumRows)
 | 
						|
        {
 | 
						|
            IQueryable<Model.Comprehensive_DesignDetails> q = from x in db.Comprehensive_DesignDetails
 | 
						|
                                                              where x.ProjectId == projectId
 | 
						|
                                                              orderby x.DetailsDate descending
 | 
						|
                                                              select x;
 | 
						|
            if (cNProfessionalId != "0")
 | 
						|
            {
 | 
						|
                q = q.Where(e => e.CNProfessionalId == cNProfessionalId);
 | 
						|
            }
 | 
						|
            if (!string.IsNullOrEmpty(UnitWorkId))
 | 
						|
            {
 | 
						|
                q = q.Where(e =>  e.UnitWorkId .Contains(UnitWorkId));
 | 
						|
            }
 | 
						|
            count = q.Count();
 | 
						|
            if (count == 0)
 | 
						|
            {
 | 
						|
                return new object[] { "" };
 | 
						|
            }
 | 
						|
            return from x in q.Skip(startRowIndex).Take(maximumRows)
 | 
						|
                   select new
 | 
						|
                   {
 | 
						|
                       x.DesignDetailsId,
 | 
						|
                       x.ProjectId,
 | 
						|
                       ProfessionalName = (from y in db.Base_CNProfessional where y.CNProfessionalId == x.CNProfessionalId select y.ProfessionalName).FirstOrDefault(),
 | 
						|
                       x.DesignDetailsCode,
 | 
						|
                       x.DetailsMan,
 | 
						|
                       x.DetailsDate,
 | 
						|
                       UnitWorkName = x.UnitWorkId != null ? BLL.UnitWorkService.GetUnitWorkName(x.UnitWorkId) : null,
 | 
						|
                       UnitName = x.UnitName != null ? BLL.UnitService.getUnitNamesUnitIds(x.UnitName) : null,
 | 
						|
                       x.AttachUrl
 | 
						|
                   };
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 获取分页列表数
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="projectId"></param>
 | 
						|
        /// <param name="cNProfessionalId"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        public static int GetListCount(string projectId, string cNProfessionalId)
 | 
						|
        {
 | 
						|
            return count;
 | 
						|
        }
 | 
						|
        public static int GetListCountForDataType(string UnitWorkId, string projectId, string cNProfessionalId)
 | 
						|
        {
 | 
						|
            return count;
 | 
						|
        }
 | 
						|
        
 | 
						|
        /// <summary>
 | 
						|
        /// 根据主键获取设计交底管理
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="designDetailsId"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        public static Model.Comprehensive_DesignDetails GetDesignDetailsById(string designDetailsId)
 | 
						|
        {
 | 
						|
            return Funs.DB.Comprehensive_DesignDetails.FirstOrDefault(e => e.DesignDetailsId == designDetailsId);
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 添加设计交底管理
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="designDetails"></param>
 | 
						|
        public static void AddDesignDetails(Model.Comprehensive_DesignDetails designDetails)
 | 
						|
        {
 | 
						|
            Model.SGGLDB db = Funs.DB;
 | 
						|
            Model.Comprehensive_DesignDetails newDesignDetails = new Model.Comprehensive_DesignDetails();
 | 
						|
            newDesignDetails.DesignDetailsId = designDetails.DesignDetailsId;
 | 
						|
            newDesignDetails.ProjectId = designDetails.ProjectId;
 | 
						|
            newDesignDetails.CNProfessionalId = designDetails.CNProfessionalId;
 | 
						|
            newDesignDetails.DesignDetailsCode = designDetails.DesignDetailsCode;
 | 
						|
            newDesignDetails.DetailsMan = designDetails.DetailsMan;
 | 
						|
            newDesignDetails.DetailsDate = designDetails.DetailsDate;
 | 
						|
            newDesignDetails.UnitWorkId = designDetails.UnitWorkId;
 | 
						|
            newDesignDetails.UnitName = designDetails.UnitName;
 | 
						|
            newDesignDetails.AttachUrl = designDetails.AttachUrl;
 | 
						|
            newDesignDetails.CompileMan = designDetails.CompileMan;
 | 
						|
            newDesignDetails.CompileDate = designDetails.CompileDate;
 | 
						|
            newDesignDetails.Status = designDetails.Status;
 | 
						|
            newDesignDetails.AuditMan = designDetails.AuditMan;
 | 
						|
            newDesignDetails.JoinPersonNum = designDetails.JoinPersonNum;
 | 
						|
            newDesignDetails.RemarCode = designDetails.RemarCode;
 | 
						|
            
 | 
						|
            db.Comprehensive_DesignDetails.InsertOnSubmit(newDesignDetails);
 | 
						|
            db.SubmitChanges();
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 修改设计交底管理
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="designDetails"></param>
 | 
						|
        public static void UpdateDesignDetails(Model.Comprehensive_DesignDetails designDetails)
 | 
						|
        {
 | 
						|
            Model.SGGLDB db = Funs.DB;
 | 
						|
            Model.Comprehensive_DesignDetails newDesignDetails = db.Comprehensive_DesignDetails.FirstOrDefault(e => e.DesignDetailsId == designDetails.DesignDetailsId);
 | 
						|
            if (newDesignDetails != null)
 | 
						|
            {
 | 
						|
                newDesignDetails.ProjectId = designDetails.ProjectId;
 | 
						|
                newDesignDetails.CNProfessionalId = designDetails.CNProfessionalId;
 | 
						|
                newDesignDetails.DesignDetailsCode = designDetails.DesignDetailsCode;
 | 
						|
                newDesignDetails.DetailsMan = designDetails.DetailsMan;
 | 
						|
                newDesignDetails.DetailsDate = designDetails.DetailsDate;
 | 
						|
                newDesignDetails.UnitWorkId = designDetails.UnitWorkId;
 | 
						|
                newDesignDetails.UnitName = designDetails.UnitName;
 | 
						|
                newDesignDetails.AttachUrl = designDetails.AttachUrl;
 | 
						|
                newDesignDetails.Status = designDetails.Status;
 | 
						|
                newDesignDetails.AuditMan = designDetails.AuditMan;
 | 
						|
                newDesignDetails.JoinPersonNum = designDetails.JoinPersonNum;
 | 
						|
 | 
						|
                db.SubmitChanges();
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 根据主键删除设计交底管理
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="designDetailsId"></param>
 | 
						|
        public static void DeleteDesignDetails(string designDetailsId)
 | 
						|
        {
 | 
						|
            Model.SGGLDB db = Funs.DB;
 | 
						|
            Model.Comprehensive_DesignDetails designDetails = db.Comprehensive_DesignDetails.FirstOrDefault(e => e.DesignDetailsId == designDetailsId);
 | 
						|
            if (designDetails != null)
 | 
						|
            {
 | 
						|
                if (!string.IsNullOrEmpty(designDetails.AttachUrl))
 | 
						|
                {
 | 
						|
                    BLL.UploadAttachmentService.DeleteFile(Funs.RootPath, designDetails.AttachUrl);//删除附件
 | 
						|
                }
 | 
						|
                db.Comprehensive_DesignDetails.DeleteOnSubmit(designDetails);
 | 
						|
                db.SubmitChanges();
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 根据装置判断是否存在设计交底管理
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="UnitWorkId">装置Id</param>
 | 
						|
        /// <returns></returns>
 | 
						|
        public static bool IsExitDesignDetailsByUnitWorkId(string UnitWorkId)
 | 
						|
        {
 | 
						|
            return (from x in Funs.DB.Comprehensive_DesignDetails
 | 
						|
                    where x.UnitWorkId == UnitWorkId
 | 
						|
                    select x).Count() > 0;
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 |