242 lines
		
	
	
		
			8.6 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			242 lines
		
	
	
		
			8.6 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.Linq;
 | |
| using System.Text;
 | |
| using System.Collections;
 | |
| using System.Web.UI.WebControls;
 | |
| 
 | |
| namespace BLL
 | |
| {
 | |
|     public class BreakdownService
 | |
|     {
 | |
|         public static Model.SGGLDB db = Funs.DB;
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 记录数
 | |
|         /// </summary>
 | |
|         public static int count
 | |
|         {
 | |
|             get;
 | |
|             set;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 定义变量
 | |
|         /// </summary>                  
 | |
|         private static IQueryable<Model.WBS_Breakdown> qq = from x in db.WBS_Breakdown orderby x.SortIndex select x;
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 获取项目列表
 | |
|         /// </summary>
 | |
|         /// <param name="searchItem"></param>
 | |
|         /// <param name="searchValue"></param>
 | |
|         /// <param name="startRowIndex"></param>
 | |
|         /// <param name="maximumRows"></param>
 | |
|         /// <returns></returns>
 | |
|         public static IEnumerable getListData(string divisionId, string name, int startRowIndex, int maximumRows)
 | |
|         {
 | |
|             IQueryable<Model.WBS_Breakdown> q = qq;
 | |
|             if (!string.IsNullOrEmpty(divisionId))
 | |
|             {
 | |
|                 q = q.Where(e => e.DivisionId == divisionId);
 | |
|             }
 | |
|             if (!string.IsNullOrEmpty(name))
 | |
|             {
 | |
|                 q = q.Where(e => e.BreakdownName.Contains(name));
 | |
|             }
 | |
|             count = q.Count();
 | |
|             if (count == 0)
 | |
|             {
 | |
|                 return new object[] { "" };
 | |
|             }
 | |
|             return from x in q.Skip(startRowIndex).Take(maximumRows)
 | |
|                    select new
 | |
|                    {
 | |
|                        x.BreakdownId,
 | |
|                        x.BreakdownCode,
 | |
|                        x.BreakdownName,
 | |
|                        x.DivisionId,
 | |
|                        x.Basis,
 | |
|                        x.CheckPoints,
 | |
|                        x.RecordAndCode,
 | |
|                        x.Class,
 | |
|                        x.Remark,
 | |
|                        x.FenBao,
 | |
|                        x.WuHuan,
 | |
|                        x.JianLi,
 | |
|                        x.YeZhu,
 | |
|                        x.CheckAcceptType,
 | |
|                        CheckPointsDef = Funs.GetSubStr(x.CheckPoints, 15),
 | |
|                        RecordAndCodeDef = Funs.GetSubStr(x.RecordAndCode, 15),
 | |
|                        x.ModelURL
 | |
|                    };
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 获取列表数
 | |
|         /// </summary>
 | |
|         /// <param name="searchItem"></param>
 | |
|         /// <param name="searchValue"></param>
 | |
|         /// <returns></returns>
 | |
|         public static int getListCount(string divisionId, string name)
 | |
|         {
 | |
|             return count;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 添加分项
 | |
|         /// </summary>
 | |
|         /// <param name="Installation"></param>
 | |
|         public static void AddBreakdown(Model.WBS_Breakdown breakdown)
 | |
|         {
 | |
|             Model.SGGLDB db = Funs.DB;
 | |
|             Model.WBS_Breakdown newBreakdown = new Model.WBS_Breakdown();
 | |
| 
 | |
|             newBreakdown.BreakdownId = breakdown.BreakdownId;
 | |
|             newBreakdown.BreakdownCode = breakdown.BreakdownCode;
 | |
|             newBreakdown.BreakdownName = breakdown.BreakdownName;
 | |
|             newBreakdown.DivisionId = breakdown.DivisionId;
 | |
|             newBreakdown.Basis = breakdown.Basis;
 | |
|             newBreakdown.CheckPoints = breakdown.CheckPoints;
 | |
|             newBreakdown.RecordAndCode = breakdown.RecordAndCode;
 | |
|             newBreakdown.Class = breakdown.Class;
 | |
|             newBreakdown.SortIndex = breakdown.SortIndex;
 | |
|             newBreakdown.Remark = breakdown.Remark;
 | |
|             newBreakdown.ModelURL = breakdown.ModelURL;
 | |
|             newBreakdown.IsAcceptance = breakdown.IsAcceptance;
 | |
|             newBreakdown.FenBao = breakdown.FenBao;
 | |
|             newBreakdown.WuHuan = breakdown.WuHuan;
 | |
|             newBreakdown.JianLi = breakdown.JianLi;
 | |
|             newBreakdown.YeZhu = breakdown.YeZhu;
 | |
|             newBreakdown.CheckAcceptType = breakdown.CheckAcceptType;
 | |
| 
 | |
|             db.WBS_Breakdown.InsertOnSubmit(newBreakdown);
 | |
|             db.SubmitChanges();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 修改分项
 | |
|         /// </summary>
 | |
|         /// <param name="breakdown"></param>
 | |
|         public static void UpdateBreakdown(Model.WBS_Breakdown breakdown)
 | |
|         {
 | |
|             Model.SGGLDB db = Funs.DB;
 | |
|             Model.WBS_Breakdown newBreakdown = db.WBS_Breakdown.First(e => e.BreakdownId == breakdown.BreakdownId);
 | |
|             newBreakdown.BreakdownCode = breakdown.BreakdownCode;
 | |
|             newBreakdown.BreakdownName = breakdown.BreakdownName;
 | |
|             newBreakdown.DivisionId = breakdown.DivisionId;
 | |
|             newBreakdown.Basis = breakdown.Basis;
 | |
|             newBreakdown.CheckPoints = breakdown.CheckPoints;
 | |
|             newBreakdown.RecordAndCode = breakdown.RecordAndCode;
 | |
|             newBreakdown.Class = breakdown.Class;
 | |
|             newBreakdown.SortIndex = breakdown.SortIndex;
 | |
|             newBreakdown.Remark = breakdown.Remark;
 | |
|             newBreakdown.ModelURL = breakdown.ModelURL;
 | |
|             newBreakdown.FenBao = breakdown.FenBao;
 | |
|             newBreakdown.WuHuan = breakdown.WuHuan;
 | |
|             newBreakdown.JianLi = breakdown.JianLi;
 | |
|             newBreakdown.YeZhu = breakdown.YeZhu;
 | |
|             newBreakdown.CheckAcceptType = breakdown.CheckAcceptType;
 | |
|             db.SubmitChanges();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据一个分项信息
 | |
|         /// </summary>
 | |
|         /// <param name="breakdownCode"></param>
 | |
|         public static void DeleteBreakdown(string breakdownId)
 | |
|         {
 | |
|             Model.SGGLDB db = Funs.DB;
 | |
|             Model.WBS_Breakdown breakdown = db.WBS_Breakdown.First(e => e.BreakdownId == breakdownId);
 | |
|             db.WBS_Breakdown.DeleteOnSubmit(breakdown);
 | |
|             db.SubmitChanges();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据一个子分部信息删除所有对应分项信息
 | |
|         /// </summary>
 | |
|         /// <param name="breakdownCode"></param>
 | |
|         public static void DeleteAllBreakdown(string divisionId)
 | |
|         {
 | |
|             Model.SGGLDB db = Funs.DB;
 | |
|             var q = from x in db.WBS_Breakdown where x.DivisionId == divisionId select x;
 | |
|             if (q.Count() > 0)
 | |
|             {
 | |
|                 db.WBS_Breakdown.DeleteAllOnSubmit(q);
 | |
|                 db.SubmitChanges();
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 获取施工分项项
 | |
|         /// </summary>
 | |
|         /// <returns></returns>
 | |
|         public static ListItem[] GetBreakdownNameList()
 | |
|         {
 | |
|             var q = (from x in Funs.DB.WBS_Breakdown orderby x.SortIndex select x).ToList();
 | |
|             ListItem[] list = new ListItem[q.Count()];
 | |
|             for (int i = 0; i < q.Count(); i++)
 | |
|             {
 | |
|                 list[i] = new ListItem(q[i].BreakdownName ?? "", q[i].BreakdownId.ToString());
 | |
|             }
 | |
|             return list;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据主键返回一个分项信息
 | |
|         /// </summary>
 | |
|         /// <param name="cnProfessionalCode">分项编号</param>
 | |
|         /// <returns></returns>
 | |
|         public static Model.WBS_Breakdown GetBreakdownById(string breakdownId)
 | |
|         {
 | |
|             return Funs.DB.WBS_Breakdown.FirstOrDefault(x => x.BreakdownId == breakdownId);
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据子分部Id返回所有分项信息
 | |
|         /// </summary>
 | |
|         /// <param name="cnProfessionalCode">分项编号</param>
 | |
|         /// <returns></returns>
 | |
|         public static List<Model.WBS_Breakdown> GetBreakdownsByDivisionId(string divisionId)
 | |
|         {
 | |
|             return (from x in Funs.DB.WBS_Breakdown where x.DivisionId == divisionId select x).ToList();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 判断分项编号是否存在
 | |
|         /// </summary>
 | |
|         /// <param name="breakdownCode"></param>
 | |
|         /// <returns></returns>
 | |
|         public static bool IsExistBreakdownCode(string breakdownCode, string breakdownId)
 | |
|         {
 | |
|             Model.WBS_Breakdown m = Funs.DB.WBS_Breakdown.FirstOrDefault(e => e.BreakdownCode == breakdownCode && e.BreakdownId != breakdownId);
 | |
|             if (m != null)
 | |
|             {
 | |
|                 return true;
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 return false;
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 判断分项名称是否存在
 | |
|         /// </summary>
 | |
|         /// <param name="professionalName"></param>
 | |
|         /// <returns></returns>
 | |
|         public static bool IsExistProfessionalName(string breakdownName, string breakdownId)
 | |
|         {
 | |
|             Model.WBS_Breakdown m = Funs.DB.WBS_Breakdown.FirstOrDefault(e => e.BreakdownName == breakdownName && e.BreakdownId != breakdownId);
 | |
|             if (m != null)
 | |
|             {
 | |
|                 return true;
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 return false;
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| }
 |