104 lines
		
	
	
		
			3.5 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			104 lines
		
	
	
		
			3.5 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.Linq;
 | |
| 
 | |
| namespace BLL
 | |
| {
 | |
|     public class ManPowerPlanService
 | |
|     {
 | |
|         public static Model.SGGLDB db = Funs.DB;
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据主键获取施工人力计划情况
 | |
|         /// </summary>
 | |
|         /// <param name="Id"></param>
 | |
|         /// <returns></returns>
 | |
|         public static Model.JDGL_SGManPower GetSGManPowerById(string Id)
 | |
|         {
 | |
|             return Funs.DB.JDGL_SGManPower.FirstOrDefault(x => x.Id == Id);
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 添加施工人力计划
 | |
|         /// </summary>
 | |
|         /// <param name="SGManPower"></param>
 | |
|         public static void AddSGManPower(Model.JDGL_SGManPower SGManPower)
 | |
|         {
 | |
|             Model.SGGLDB db = Funs.DB;
 | |
|             Model.JDGL_SGManPower newSGManPower = new Model.JDGL_SGManPower
 | |
|             {
 | |
|                 Id = SGManPower.Id,
 | |
|                 ProjectId = SGManPower.ProjectId,
 | |
|                 UnitId = SGManPower.UnitId,
 | |
|                 UnitWorkId = SGManPower.UnitWorkId,
 | |
|                 WorkPostId = SGManPower.WorkPostId,
 | |
|                 Version = SGManPower.Version,
 | |
|                 Quantity = SGManPower.Quantity,
 | |
|                 PlanDate = SGManPower.PlanDate,
 | |
|                 CompileMan = SGManPower.CompileMan,
 | |
|                 CompileTime = SGManPower.CompileTime,
 | |
|                 Remarks = SGManPower.Remarks,
 | |
|             };
 | |
|             db.JDGL_SGManPower.InsertOnSubmit(newSGManPower);
 | |
|             db.SubmitChanges();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 修改施工人力计划
 | |
|         /// </summary>
 | |
|         /// <param name="SGManPower"></param>
 | |
|         public static void UpdateSGManPower(Model.JDGL_SGManPower SGManPower)
 | |
|         {
 | |
|             Model.SGGLDB db = Funs.DB;
 | |
|             Model.JDGL_SGManPower newSGManPower =
 | |
|                 db.JDGL_SGManPower.FirstOrDefault(x => x.Id == SGManPower.Id);
 | |
|             if (newSGManPower != null)
 | |
|             {
 | |
|                 newSGManPower.UnitId = SGManPower.UnitId;
 | |
|                 newSGManPower.UnitWorkId = SGManPower.UnitWorkId;
 | |
|                 newSGManPower.WorkPostId = SGManPower.WorkPostId;
 | |
|                 newSGManPower.Version = SGManPower.Version;
 | |
|                 newSGManPower.Quantity = SGManPower.Quantity;
 | |
|                 newSGManPower.PlanDate = SGManPower.PlanDate;
 | |
|                 newSGManPower.CompileMan = SGManPower.CompileMan;
 | |
|                 newSGManPower.CompileTime = SGManPower.CompileTime;
 | |
|                 newSGManPower.Remarks = SGManPower.Remarks;
 | |
| 
 | |
|                 db.SubmitChanges();
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据主键删除施工人力计划
 | |
|         /// </summary>
 | |
|         /// <param name="Id"></param>
 | |
|         public static void DeleteSGManPowerById(string Id)
 | |
|         {
 | |
|             Model.SGGLDB db = Funs.DB;
 | |
|             var q = (from x in db.JDGL_SGManPower where x.Id == Id select x).FirstOrDefault();
 | |
|             if (q != null)
 | |
|             {
 | |
|                 db.JDGL_SGManPower.DeleteOnSubmit(q);
 | |
|                 db.SubmitChanges();
 | |
|             }
 | |
|         }
 | |
|         
 | |
|         
 | |
|         /// <summary>
 | |
|         /// 根据项目获取工力计划版本
 | |
|         /// </summary>
 | |
|         /// <param name="projectId"></param>
 | |
|         public static List<string> getGroupVersion(string projectId)
 | |
|         {
 | |
|             var versions = Funs.DB.JDGL_SGManPower
 | |
|                 .Where(x => x.ProjectId == projectId)
 | |
|                 .GroupBy(x => x.Version)
 | |
|                 .Select(g => g.Key)
 | |
|                 .OrderByDescending(v => v)
 | |
|                 .ToList();
 | |
|             
 | |
|             return versions; 
 | |
|         }
 | |
| 
 | |
|     }
 | |
| } |