| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using System.Linq; | 
					
						
							|  |  |  |  | using System.Text; | 
					
						
							|  |  |  |  | using System.Collections; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace BLL | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     /// <summary> | 
					
						
							|  |  |  |  |     /// 现场签证管理表 | 
					
						
							|  |  |  |  |     /// </summary> | 
					
						
							|  |  |  |  |     public static class SiteVisaManagementService | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         public static Model.SGGLDB db = Funs.DB; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 记录数 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         private static int count | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             get; | 
					
						
							|  |  |  |  |             set; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 获取分页列表 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="projectId"></param> | 
					
						
							|  |  |  |  |         /// <param name="unitId"></param> | 
					
						
							|  |  |  |  |         /// <param name="cNProfessionalId"></param> | 
					
						
							|  |  |  |  |         /// <param name="startDate"></param> | 
					
						
							|  |  |  |  |         /// <param name="endDate"></param> | 
					
						
							|  |  |  |  |         /// <param name="startRowIndex"></param> | 
					
						
							|  |  |  |  |         /// <param name="maximumRows"></param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         public static IEnumerable GetListData(string projectId, string unitId, string cNProfessionalId, string startDate, string endDate, int startRowIndex, int maximumRows) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             IQueryable<Model.Comprehensive_SiteVisaManagement> q = from x in db.Comprehensive_SiteVisaManagement | 
					
						
							|  |  |  |  |                                                                    where x.ProjectId == projectId | 
					
						
							|  |  |  |  |                                                                    orderby x.VisaDate descending | 
					
						
							|  |  |  |  |                                                                    select x; | 
					
						
							|  |  |  |  |             if (unitId != "0") | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 q = q.Where(e => e.UnitId == unitId); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             if (cNProfessionalId != "0") | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 q = q.Where(e => e.CNProfessionalId == cNProfessionalId); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             if (!string.IsNullOrEmpty(startDate) && !string.IsNullOrEmpty(endDate)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 q = q.Where(e => e.VisaDate >= Funs.GetNewDateTime(startDate) && e.VisaDate <= Funs.GetNewDateTime(endDate)); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             count = q.Count(); | 
					
						
							|  |  |  |  |             if (count == 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return new object[] { "" }; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return from x in q.Skip(startRowIndex).Take(maximumRows) | 
					
						
							|  |  |  |  |                    select new | 
					
						
							|  |  |  |  |                    { | 
					
						
							|  |  |  |  |                        x.VisaId, | 
					
						
							|  |  |  |  |                        x.ProjectId, | 
					
						
							|  |  |  |  |                        UnitName = (from y in db.Base_Unit where y.UnitId == x.UnitId select y.UnitName).FirstOrDefault(), | 
					
						
							|  |  |  |  |                        x.VisaCode, | 
					
						
							|  |  |  |  |                        ProfessionalName = (from y in db.Base_CNProfessional where y.CNProfessionalId == x.CNProfessionalId select y.ProfessionalName).FirstOrDefault(), | 
					
						
							|  |  |  |  |                        x.VisaReson, | 
					
						
							|  |  |  |  |                        UnitWorkName = (from y in db.WBS_UnitWork where y.UnitWorkId == x.UnitWorkId select y.UnitWorkName).FirstOrDefault(), | 
					
						
							|  |  |  |  |                        x.VisaDate, | 
					
						
							|  |  |  |  |                        x.EstimatedCost, | 
					
						
							|  |  |  |  |                        x.Confirmation, | 
					
						
							|  |  |  |  |                        x.AttachUrl, | 
					
						
							|  |  |  |  |                        x.ConstructionManager, | 
					
						
							|  |  |  |  |                        x.ControlManager, | 
					
						
							|  |  |  |  |                        x.ProcessingState, | 
					
						
							|  |  |  |  |                        x.AccountingExpenses, | 
					
						
							|  |  |  |  |                        x.VisaContent, | 
					
						
							|  |  |  |  |                        x.SignMan, | 
					
						
							|  |  |  |  |                        x.AuditMan, | 
					
						
							|  |  |  |  |                        x.Remark, | 
					
						
							|  |  |  |  |                        x.UnitWorkId, | 
					
						
							|  |  |  |  |                    }; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 获取分页列表数 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="projectId"></param> | 
					
						
							|  |  |  |  |         /// <param name="unitId"></param> | 
					
						
							|  |  |  |  |         /// <param name="cNProfessionalId"></param> | 
					
						
							|  |  |  |  |         /// <param name="startDate"></param> | 
					
						
							|  |  |  |  |         /// <param name="endDate"></param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         public static int GetListCount(string projectId, string unitId, string cNProfessionalId, string startDate, string endDate) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return count; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 根据主键获取现场签证管理 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="visaId"></param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         public static Model.Comprehensive_SiteVisaManagement GetSiteVisaManagementById(string visaId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return Funs.DB.Comprehensive_SiteVisaManagement.FirstOrDefault(e => e.VisaId == visaId); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 添加现场签证管理 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="siteVisaMangement"></param> | 
					
						
							|  |  |  |  |         public static void AddSiteVisaManagement(Model.Comprehensive_SiteVisaManagement siteVisaMangement) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Model.SGGLDB db = Funs.DB; | 
					
						
							|  |  |  |  |             Model.Comprehensive_SiteVisaManagement newSiteVisaManagement = new Model.Comprehensive_SiteVisaManagement(); | 
					
						
							|  |  |  |  |             newSiteVisaManagement.VisaId = siteVisaMangement.VisaId; | 
					
						
							|  |  |  |  |             newSiteVisaManagement.ProjectId = siteVisaMangement.ProjectId; | 
					
						
							|  |  |  |  |             newSiteVisaManagement.UnitId = siteVisaMangement.UnitId; | 
					
						
							|  |  |  |  |             newSiteVisaManagement.VisaCode = siteVisaMangement.VisaCode; | 
					
						
							|  |  |  |  |             newSiteVisaManagement.CNProfessionalId = siteVisaMangement.CNProfessionalId; | 
					
						
							|  |  |  |  |             newSiteVisaManagement.VisaReson = siteVisaMangement.VisaReson; | 
					
						
							|  |  |  |  |             newSiteVisaManagement.VisaDate = siteVisaMangement.VisaDate; | 
					
						
							|  |  |  |  |             newSiteVisaManagement.EstimatedCost = siteVisaMangement.EstimatedCost; | 
					
						
							|  |  |  |  |             newSiteVisaManagement.Confirmation = siteVisaMangement.Confirmation; | 
					
						
							|  |  |  |  |             newSiteVisaManagement.AttachUrl = siteVisaMangement.AttachUrl; | 
					
						
							|  |  |  |  |             newSiteVisaManagement.ProcessingState = siteVisaMangement.ProcessingState; | 
					
						
							|  |  |  |  |             newSiteVisaManagement.ConstructionManager = siteVisaMangement.ConstructionManager; | 
					
						
							|  |  |  |  |             newSiteVisaManagement.ControlManager = siteVisaMangement.ControlManager; | 
					
						
							|  |  |  |  |             newSiteVisaManagement.AccountingExpenses = siteVisaMangement.AccountingExpenses; | 
					
						
							|  |  |  |  |             newSiteVisaManagement.CompileMan = siteVisaMangement.CompileMan; | 
					
						
							|  |  |  |  |             newSiteVisaManagement.VisaContent = siteVisaMangement.VisaContent; | 
					
						
							|  |  |  |  |             newSiteVisaManagement.UnitWorkId = siteVisaMangement.UnitWorkId; | 
					
						
							|  |  |  |  |             newSiteVisaManagement.SignMan = siteVisaMangement.SignMan; | 
					
						
							|  |  |  |  |             newSiteVisaManagement.AuditMan = siteVisaMangement.AuditMan; | 
					
						
							|  |  |  |  |             newSiteVisaManagement.Remark = siteVisaMangement.Remark; | 
					
						
							| 
									
										
										
										
											2023-04-28 17:46:41 +08:00
										 |  |  |  |             newSiteVisaManagement.Status = siteVisaMangement.Status; | 
					
						
							| 
									
										
										
										
											2024-04-23 16:41:21 +08:00
										 |  |  |  |             newSiteVisaManagement.RemarkCode = siteVisaMangement.RemarkCode; | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |             db.Comprehensive_SiteVisaManagement.InsertOnSubmit(newSiteVisaManagement); | 
					
						
							|  |  |  |  |             db.SubmitChanges(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 修改现场签证管理 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="siteVisaManagement"></param> | 
					
						
							|  |  |  |  |         public static void UpdateSiteVisaManagement(Model.Comprehensive_SiteVisaManagement siteVisaMangement) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Model.SGGLDB db = Funs.DB; | 
					
						
							|  |  |  |  |             Model.Comprehensive_SiteVisaManagement newSiteVisaManagement = db.Comprehensive_SiteVisaManagement.FirstOrDefault(e => e.VisaId == siteVisaMangement.VisaId); | 
					
						
							|  |  |  |  |             if (newSiteVisaManagement != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 newSiteVisaManagement.ProjectId = siteVisaMangement.ProjectId; | 
					
						
							|  |  |  |  |                 newSiteVisaManagement.UnitId = siteVisaMangement.UnitId; | 
					
						
							|  |  |  |  |                 newSiteVisaManagement.VisaCode = siteVisaMangement.VisaCode; | 
					
						
							|  |  |  |  |                 newSiteVisaManagement.CNProfessionalId = siteVisaMangement.CNProfessionalId; | 
					
						
							|  |  |  |  |                 newSiteVisaManagement.VisaReson = siteVisaMangement.VisaReson; | 
					
						
							|  |  |  |  |                 newSiteVisaManagement.VisaDate = siteVisaMangement.VisaDate; | 
					
						
							|  |  |  |  |                 newSiteVisaManagement.EstimatedCost = siteVisaMangement.EstimatedCost; | 
					
						
							|  |  |  |  |                 newSiteVisaManagement.Confirmation = siteVisaMangement.Confirmation; | 
					
						
							|  |  |  |  |                 newSiteVisaManagement.AttachUrl = siteVisaMangement.AttachUrl; | 
					
						
							|  |  |  |  |                 newSiteVisaManagement.ProcessingState = siteVisaMangement.ProcessingState; | 
					
						
							|  |  |  |  |                 newSiteVisaManagement.ConstructionManager = siteVisaMangement.ConstructionManager; | 
					
						
							|  |  |  |  |                 newSiteVisaManagement.ControlManager = siteVisaMangement.ControlManager; | 
					
						
							|  |  |  |  |                 newSiteVisaManagement.AccountingExpenses = siteVisaMangement.AccountingExpenses; | 
					
						
							|  |  |  |  |                 newSiteVisaManagement.VisaContent = siteVisaMangement.VisaContent; | 
					
						
							|  |  |  |  |                 newSiteVisaManagement.UnitWorkId = siteVisaMangement.UnitWorkId; | 
					
						
							|  |  |  |  |                 newSiteVisaManagement.SignMan = siteVisaMangement.SignMan; | 
					
						
							|  |  |  |  |                 newSiteVisaManagement.AuditMan = siteVisaMangement.AuditMan; | 
					
						
							|  |  |  |  |                 newSiteVisaManagement.Remark = siteVisaMangement.Remark; | 
					
						
							| 
									
										
										
										
											2023-04-28 17:46:41 +08:00
										 |  |  |  |                 newSiteVisaManagement.Status = siteVisaMangement.Status; | 
					
						
							| 
									
										
										
										
											2024-04-30 09:29:36 +08:00
										 |  |  |  |                 newSiteVisaManagement.RemarkCode = siteVisaMangement.RemarkCode; | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |                 db.SubmitChanges(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 根据主键删除现场签证管理 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="visaId"></param> | 
					
						
							|  |  |  |  |         public static void DeleteSiteVisaManagement(string visaId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Model.SGGLDB db = Funs.DB; | 
					
						
							|  |  |  |  |             Model.Comprehensive_SiteVisaManagement siteVisaManagement = db.Comprehensive_SiteVisaManagement.FirstOrDefault(e => e.VisaId == visaId); | 
					
						
							|  |  |  |  |             if (siteVisaManagement != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 if (!string.IsNullOrEmpty(siteVisaManagement.AttachUrl)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     BLL.UploadAttachmentService.DeleteFile(Funs.RootPath, siteVisaManagement.AttachUrl);//删除附件 | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 db.Comprehensive_SiteVisaManagement.DeleteOnSubmit(siteVisaManagement); | 
					
						
							|  |  |  |  |                 db.SubmitChanges(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } |