139 lines
		
	
	
		
			5.3 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			139 lines
		
	
	
		
			5.3 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System;
 | |
| using System.Collections;
 | |
| using System.Diagnostics.CodeAnalysis;
 | |
| using System.Globalization;
 | |
| using System.Linq;
 | |
| using System.Data.Linq;
 | |
| using System.Web.Security;
 | |
| using System.Web.UI.WebControls;
 | |
| using Model;
 | |
| using BLL;
 | |
| using System.Collections.Generic;
 | |
| 
 | |
| namespace BLL
 | |
| {
 | |
|     public class CnProfessionService
 | |
|     {
 | |
|         /// <summary>
 | |
|         /// 根据专业Id获取专业信息
 | |
|         /// </summary>
 | |
|         /// <param name="unitProjectId">专业Id</param>
 | |
|         /// <returns></returns>
 | |
|         public static Model.WBS_CnProfession GetCnProfessionByCnProfessionId(string cnProfessionId)
 | |
|         {
 | |
|             return Funs.DB.WBS_CnProfession.FirstOrDefault(e => e.CnProfessionId == cnProfessionId);
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据装置Id和专业编号获取专业Id
 | |
|         /// </summary>
 | |
|         /// <param name="unitProjectId">专业Id</param>
 | |
|         /// <returns></returns>
 | |
|         public static string GetCnProfessionIdByInstallationIdAndOldId(string installationId, string oldId)
 | |
|         {
 | |
|             string cnProfessionId = string.Empty;
 | |
|             Model.SGGLDB db = Funs.DB;
 | |
|             var ins = db.Project_Installation.FirstOrDefault(x => x.InstallationId == installationId);
 | |
|             if (ins.IsEnd == true)
 | |
|             {
 | |
|                 var cn = db.WBS_CnProfession.FirstOrDefault(x => x.InstallationId == ins.InstallationId && x.OldId.ToString() == oldId);
 | |
|                 cnProfessionId = cn.CnProfessionId;
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 var childIns = db.Project_Installation.FirstOrDefault(x => x.SuperInstallationId == installationId);
 | |
|                 cnProfessionId = GetCnProfessionIdByInstallationIdAndOldId(childIns.InstallationId, oldId);
 | |
|             }
 | |
|             return cnProfessionId;
 | |
|         }
 | |
| 
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 增加专业
 | |
|         /// </summary>
 | |
|         /// <param name="user">专业</param>
 | |
|         public static void AddCnProfession(Model.WBS_CnProfession cnProfession)
 | |
|         {
 | |
|             Model.SGGLDB db = Funs.DB;
 | |
|             Model.WBS_CnProfession newCnP = new Model.WBS_CnProfession();
 | |
|             newCnP.CnProfessionId = SQLHelper.GetNewID(typeof(Model.WBS_CnProfession));
 | |
|             newCnP.CnProfessionName = cnProfession.CnProfessionName;
 | |
|             newCnP.CnProfessionCode = cnProfession.CnProfessionCode;
 | |
|             newCnP.InstallationId = cnProfession.InstallationId;
 | |
|             newCnP.ProjectId = cnProfession.ProjectId;
 | |
|             newCnP.StartDate = cnProfession.StartDate;
 | |
|             newCnP.EndDate = cnProfession.EndDate;
 | |
|             newCnP.Weights = cnProfession.Weights;
 | |
|             newCnP.OldId = cnProfession.OldId;
 | |
|             newCnP.UnitId = cnProfession.UnitId;
 | |
| 
 | |
|             db.WBS_CnProfession.InsertOnSubmit(newCnP);
 | |
|             db.SubmitChanges();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 修改专业
 | |
|         /// </summary>
 | |
|         /// <param name="user">专业</param>
 | |
|         public static void UpdateCnProfession(Model.WBS_CnProfession cnProfession)
 | |
|         {
 | |
|             Model.SGGLDB db = Funs.DB;
 | |
|             Model.WBS_CnProfession newCnP = db.WBS_CnProfession.First(e => e.CnProfessionId == cnProfession.CnProfessionId);
 | |
| 
 | |
|             newCnP.CnProfessionName = cnProfession.CnProfessionName;
 | |
|             newCnP.CnProfessionCode = cnProfession.CnProfessionCode;
 | |
|             newCnP.StartDate = cnProfession.StartDate;
 | |
|             newCnP.EndDate = cnProfession.EndDate;
 | |
|             newCnP.Weights = cnProfession.Weights;
 | |
|             newCnP.WeightsMoney = cnProfession.WeightsMoney;
 | |
|             newCnP.IsWeightsApprove = cnProfession.IsWeightsApprove;
 | |
|             newCnP.UnitId = cnProfession.UnitId;
 | |
|             newCnP.IsSelected = cnProfession.IsSelected;
 | |
|             newCnP.IsApprove = cnProfession.IsApprove;
 | |
|             db.SubmitChanges();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据Id删除专业信息
 | |
|         /// </summary>
 | |
|         /// <param name="userId"></param>
 | |
|         public static void DeleteCnProfession(string cnProfessionId)
 | |
|         {
 | |
|             Model.SGGLDB db = Funs.DB;
 | |
|             Model.WBS_CnProfession CnP = db.WBS_CnProfession.First(e => e.CnProfessionId == cnProfessionId);
 | |
|             db.WBS_CnProfession.DeleteOnSubmit(CnP);
 | |
|             db.SubmitChanges();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 获取装置下所有专业
 | |
|         /// </summary>
 | |
|         /// <returns></returns>
 | |
|         public static List<Model.WBS_CnProfession> GetCnProfessionByInstallation(string ins)
 | |
|         {
 | |
|             var list = (from x in Funs.DB.WBS_CnProfession where x.InstallationId == ins orderby x.CnProfessionId select x).ToList();
 | |
|             return list;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 获取专业下拉选项
 | |
|         /// </summary>
 | |
|         /// <returns></returns>
 | |
|         public static List<Model.WBS_CnProfessionInit> GetCnProfessionDropDownList()
 | |
|         {
 | |
|             var list = (from x in Funs.DB.WBS_CnProfessionInit orderby x.CnProfessionId select x).ToList();
 | |
|             return list;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 获取专业下拉选项(不含总图)
 | |
|         /// </summary>
 | |
|         /// <returns></returns>
 | |
|         public static List<Model.WBS_CnProfessionInit> GetCnProfessionDropDownList2()
 | |
|         {
 | |
|             var list = (from x in Funs.DB.WBS_CnProfessionInit where x.CnProfessionId != 19 orderby x.CnProfessionId select x).ToList();
 | |
|             return list;
 | |
|         }
 | |
|     }
 | |
| }
 |