288 lines
		
	
	
		
			15 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			288 lines
		
	
	
		
			15 KiB
		
	
	
	
		
			C#
		
	
	
	
| using FineUIPro;
 | |
| using System;
 | |
| using System.Collections;
 | |
| using System.Collections.Generic;
 | |
| using System.Linq;
 | |
| using System.Text;
 | |
| 
 | |
| 
 | |
| namespace BLL
 | |
| {
 | |
| 
 | |
|     public static class ProjectEnergyreportItemService
 | |
|     {
 | |
|         public static Model.SGGLDB db = Funs.DB;
 | |
| 
 | |
| 
 | |
|         #region 获取列表
 | |
|         /// <summary>
 | |
|         /// 记录数
 | |
|         /// </summary>
 | |
|         public static int count
 | |
|         {
 | |
|             get;
 | |
|             set;
 | |
|         }
 | |
|         public static List<Model.Environmental_ProjectEnergyReportItem> GetEnvironmental_ProjectEnergyReportItemByModle(Model.Environmental_ProjectEnergyReportItem table)
 | |
|         {
 | |
|             var q = from x in db.Environmental_ProjectEnergyReportItem
 | |
|                     where
 | |
|                               (string.IsNullOrEmpty(table.EnergyReportItemId) || x.EnergyReportItemId.Contains(table.EnergyReportItemId)) &&
 | |
|                               (string.IsNullOrEmpty(table.EnergyReportId) || x.EnergyReportId.Contains(table.EnergyReportId)) &&
 | |
|                               (string.IsNullOrEmpty(table.SortIndex) || x.SortIndex.Contains(table.SortIndex)) &&
 | |
|                               (string.IsNullOrEmpty(table.BusinessCategory) || x.BusinessCategory.Contains(table.BusinessCategory)) &&
 | |
|                               (string.IsNullOrEmpty(table.Throughput_UnitOfMeasurement) || x.Throughput_UnitOfMeasurement.Contains(table.Throughput_UnitOfMeasurement)) &&
 | |
|                               (string.IsNullOrEmpty(table.Yield_UnitOfMeasurement) || x.Yield_UnitOfMeasurement.Contains(table.Yield_UnitOfMeasurement)) &&
 | |
|                               (string.IsNullOrEmpty(table.OperationScale_UnitOfMeasurement) || x.OperationScale_UnitOfMeasurement.Contains(table.OperationScale_UnitOfMeasurement))
 | |
|                     select x
 | |
|                   ;
 | |
| 
 | |
|             return q.ToList();
 | |
|         }
 | |
| 
 | |
|         /// 获取分页列表
 | |
|         /// </summary>
 | |
|         /// <param name="PageIndex">页码</param>
 | |
|         /// <param name="PageSize">每页数量</param>
 | |
|         /// <returns></returns>
 | |
|         public static IEnumerable getListData(Model.Environmental_ProjectEnergyReportItem table, Grid Grid1)
 | |
|         {
 | |
|             var q = GetEnvironmental_ProjectEnergyReportItemByModle(table);
 | |
|             count = q.Count();
 | |
|             if (count == 0)
 | |
|             {
 | |
|                 return null;
 | |
|             }
 | |
|             //  q=  q.Take(Grid1.PageSize * Grid1.PageIndex).Skip(Grid1.PageSize * (Grid1.PageIndex)).ToList();
 | |
|             // q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
 | |
|             return from x in q
 | |
|                    select new
 | |
|                    {
 | |
|                        x.EnergyReportItemId,
 | |
|                        x.EnergyReportId,
 | |
|                        x.SortIndex,
 | |
|                        x.BusinessCategory,
 | |
|                        x.Throughput_BasePeriod,
 | |
|                        x.Throughput_LastPeriod,
 | |
|                        x.Throughput_ThisPeriod,
 | |
|                        x.Throughput_UnitOfMeasurement,
 | |
|                        x.Yield_BasePeriod,
 | |
|                        x.Yield_LastPeriod,
 | |
|                        x.Yield_ThisPeriod,
 | |
|                        x.Yield_UnitOfMeasurement,
 | |
|                        x.OutputValue_BasePeriod,
 | |
|                        x.OutputValue_LastYear,
 | |
|                        x.OutputValue_ThisYear,
 | |
|                        x.OperationScale_BasePeriod,
 | |
|                        x.OperationScale_LastYear,
 | |
|                        x.OperationScale_ThisYear,
 | |
|                        x.OperationScale_UnitOfMeasurement,
 | |
|                        x.ServiceOperatingIncome_BasePeriod,
 | |
|                        x.ServiceOperatingIncome_LastYear,
 | |
|                        x.ServiceOperatingIncome_ThisYear,
 | |
| 
 | |
|                    };
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         public static Model.Environmental_ProjectEnergyReportItem GetEnvironmental_ProjectEnergyReportItemById(string EnergyReportItemId)
 | |
|         {
 | |
|             return db.Environmental_ProjectEnergyReportItem.FirstOrDefault(x => x.EnergyReportItemId == EnergyReportItemId);
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据主表Id获取明细记录集合
 | |
|         /// </summary>
 | |
|         /// <param name="ChemicalReportItemId"></param>
 | |
|         /// <returns>明细记录集合</returns>
 | |
|         public static List<Model.Environmental_ProjectEnergyReportItem> GetItems(string EnergyReportId)
 | |
|         {
 | |
|             return (from x in Funs.DB.Environmental_ProjectEnergyReportItem
 | |
|                     where x.EnergyReportId == EnergyReportId
 | |
|                     orderby x.SortIndex
 | |
|                     select x).ToList();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据主表Id获取明细记录集合
 | |
|         /// </summary>
 | |
|         /// <param name="ChemicalReportItemId">化工行业能源节约与生态环境保护汇总明细表Id</param>
 | |
|         /// <returns>明细记录集合</returns>
 | |
|         public static List<Model.Environmental_ProjectEnergyReportItem> GetYearSumItems(string ProjectId, int? year, int? Quarters)
 | |
|         {
 | |
|             return (from x in Funs.DB.Environmental_ProjectEnergyReportItem
 | |
|                     join y in Funs.DB.Environmental_ProjectEnergyReport
 | |
|                     on x.EnergyReportId equals y.EnergyReportId
 | |
|                     where y.ProjectId == ProjectId && y.Year == year && y.Quarters == Quarters
 | |
|                     orderby x.SortIndex
 | |
|                     select x).Distinct().ToList();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据主表Id获取年度明细记录集合
 | |
|         /// </summary>
 | |
|         /// <param name="ChemicalReportItemId">化工行业能源节约与生态环境保护汇总明细表Id</param>
 | |
|         /// <returns>年度明细记录集合</returns>
 | |
|         public static List<Model.Environmental_ProjectEnergyReportItem> GetItemsByDate(int year, int Quarters)
 | |
|         {
 | |
|             return (from x in Funs.DB.Environmental_ProjectEnergyReportItem
 | |
|                     join y in Funs.DB.Environmental_ProjectEnergyReport
 | |
|                     on x.EnergyReportId equals y.EnergyReportId
 | |
|                     where y.Year == year && y.Quarters== Quarters
 | |
|                     select x).Distinct().ToList();
 | |
|         }
 | |
|         public static List<Model.Environmental_ProjectEnergyReportItem> GetLastYearItems(int year)
 | |
|         {
 | |
|             return (from x in Funs.DB.Environmental_ProjectEnergyReportItem
 | |
|                     join y in Funs.DB.Environmental_ProjectEnergyReport
 | |
|                     on x.EnergyReportId equals y.EnergyReportId
 | |
|                     where y.Year == year 
 | |
|                     select x).Distinct().ToList();
 | |
|         }
 | |
|         /// <summary>
 | |
|         /// 根据主表Id获取明细记录集合(不包含本月合计行)
 | |
|         /// </summary>
 | |
|         /// <param name="ChemicalReportItemId">化工行业能源节约与生态环境保护汇总明细表Id</param>
 | |
|         /// <returns>明细记录集合</returns>
 | |
|         public static List<Model.Environmental_ProjectEnergyReportItem> GetShowItems(string EnergyReportId)
 | |
|         {
 | |
|             var q = (from x in Funs.DB.Environmental_ProjectEnergyReportItem
 | |
|                      where x.EnergyReportId == EnergyReportId
 | |
|                      orderby x.SortIndex
 | |
|                      select x).ToList();
 | |
|             List<Model.Environmental_ProjectEnergyReportItem> newItems = new List<Model.Environmental_ProjectEnergyReportItem>();
 | |
|             foreach (var item in q)
 | |
|             {
 | |
|                 Model.Environmental_ProjectEnergyReportItem newItem = new Model.Environmental_ProjectEnergyReportItem();
 | |
| 
 | |
|                 newItem.EnergyReportItemId = item.EnergyReportItemId;
 | |
|                 newItem.EnergyReportId = item.EnergyReportId;
 | |
|                 newItem.SortIndex = item.SortIndex;
 | |
|                 newItem.BusinessCategory = item.BusinessCategory;
 | |
|                 newItem.Throughput_BasePeriod = item.Throughput_BasePeriod;
 | |
|                 newItem.Throughput_LastPeriod = item.Throughput_LastPeriod;
 | |
|                 newItem.Throughput_ThisPeriod = item.Throughput_ThisPeriod;
 | |
|                 newItem.Throughput_UnitOfMeasurement = item.Throughput_UnitOfMeasurement;
 | |
|                 newItem.Yield_BasePeriod = item.Yield_BasePeriod;
 | |
|                 newItem.Yield_LastPeriod = item.Yield_LastPeriod;
 | |
|                 newItem.Yield_ThisPeriod = item.Yield_ThisPeriod;
 | |
|                 newItem.Yield_UnitOfMeasurement = item.Yield_UnitOfMeasurement;
 | |
|                 newItem.OutputValue_BasePeriod = item.OutputValue_BasePeriod;
 | |
|                 newItem.OutputValue_LastYear = item.OutputValue_LastYear;
 | |
|                 newItem.OutputValue_ThisYear = item.OutputValue_ThisYear;
 | |
|                 newItem.OperationScale_BasePeriod = item.OperationScale_BasePeriod;
 | |
|                 newItem.OperationScale_LastYear = item.OperationScale_LastYear;
 | |
|                 newItem.OperationScale_ThisYear = item.OperationScale_ThisYear;
 | |
|                 newItem.OperationScale_UnitOfMeasurement = item.OperationScale_UnitOfMeasurement;
 | |
|                 newItem.ServiceOperatingIncome_BasePeriod = item.ServiceOperatingIncome_BasePeriod;
 | |
|                 newItem.ServiceOperatingIncome_LastYear = item.ServiceOperatingIncome_LastYear;
 | |
|                 newItem.ServiceOperatingIncome_ThisYear = item.ServiceOperatingIncome_ThisYear;
 | |
|                 newItems.Add(newItem);
 | |
|             }
 | |
|             return newItems;
 | |
|         }
 | |
|         public static void AddEnvironmental_ProjectEnergyReportItem(Model.Environmental_ProjectEnergyReportItem newtable)
 | |
|         {
 | |
| 
 | |
|             Model.Environmental_ProjectEnergyReportItem table = new Model.Environmental_ProjectEnergyReportItem
 | |
|             {
 | |
|                 EnergyReportItemId = newtable.EnergyReportItemId,
 | |
|                 EnergyReportId = newtable.EnergyReportId,
 | |
|                 SortIndex = newtable.SortIndex,
 | |
|                 BusinessCategory = newtable.BusinessCategory,
 | |
|                 Throughput_BasePeriod = newtable.Throughput_BasePeriod,
 | |
|                 Throughput_LastPeriod = newtable.Throughput_LastPeriod,
 | |
|                 Throughput_ThisPeriod = newtable.Throughput_ThisPeriod,
 | |
|                 Throughput_UnitOfMeasurement = newtable.Throughput_UnitOfMeasurement,
 | |
|                 Yield_BasePeriod = newtable.Yield_BasePeriod,
 | |
|                 Yield_LastPeriod = newtable.Yield_LastPeriod,
 | |
|                 Yield_ThisPeriod = newtable.Yield_ThisPeriod,
 | |
|                 Yield_UnitOfMeasurement = newtable.Yield_UnitOfMeasurement,
 | |
|                 OutputValue_BasePeriod = newtable.OutputValue_BasePeriod,
 | |
|                 OutputValue_LastYear = newtable.OutputValue_LastYear,
 | |
|                 OutputValue_ThisYear = newtable.OutputValue_ThisYear,
 | |
|                 OperationScale_BasePeriod = newtable.OperationScale_BasePeriod,
 | |
|                 OperationScale_LastYear = newtable.OperationScale_LastYear,
 | |
|                 OperationScale_ThisYear = newtable.OperationScale_ThisYear,
 | |
|                 OperationScale_UnitOfMeasurement = newtable.OperationScale_UnitOfMeasurement,
 | |
|                 ServiceOperatingIncome_BasePeriod = newtable.ServiceOperatingIncome_BasePeriod,
 | |
|                 ServiceOperatingIncome_LastYear = newtable.ServiceOperatingIncome_LastYear,
 | |
|                 ServiceOperatingIncome_ThisYear = newtable.ServiceOperatingIncome_ThisYear,
 | |
|             };
 | |
|             db.Environmental_ProjectEnergyReportItem.InsertOnSubmit(table);
 | |
|             db.SubmitChanges();
 | |
|         }
 | |
| 
 | |
|         public static void AddBulkEnvironmental_ProjectEnergyReportItem(List<Model.Environmental_ProjectEnergyReportItem> newtables)
 | |
|         {
 | |
| 
 | |
|             db.Environmental_ProjectEnergyReportItem.InsertAllOnSubmit(newtables);
 | |
|             db.SubmitChanges();
 | |
|         }
 | |
| 
 | |
| 
 | |
|         public static void UpdateEnvironmental_ProjectEnergyReportItem(Model.Environmental_ProjectEnergyReportItem newtable)
 | |
|         {
 | |
| 
 | |
|             Model.Environmental_ProjectEnergyReportItem table = db.Environmental_ProjectEnergyReportItem.FirstOrDefault(x => x.EnergyReportItemId == newtable.EnergyReportItemId);
 | |
|             if (table != null)
 | |
|             {
 | |
|                 table.EnergyReportItemId = newtable.EnergyReportItemId;
 | |
|                 table.EnergyReportId = newtable.EnergyReportId;
 | |
|                 table.SortIndex = newtable.SortIndex;
 | |
|                 table.BusinessCategory = newtable.BusinessCategory;
 | |
|                 table.Throughput_BasePeriod = newtable.Throughput_BasePeriod;
 | |
|                 table.Throughput_LastPeriod = newtable.Throughput_LastPeriod;
 | |
|                 table.Throughput_ThisPeriod = newtable.Throughput_ThisPeriod;
 | |
|                 table.Throughput_UnitOfMeasurement = newtable.Throughput_UnitOfMeasurement;
 | |
|                 table.Yield_BasePeriod = newtable.Yield_BasePeriod;
 | |
|                 table.Yield_LastPeriod = newtable.Yield_LastPeriod;
 | |
|                 table.Yield_ThisPeriod = newtable.Yield_ThisPeriod;
 | |
|                 table.Yield_UnitOfMeasurement = newtable.Yield_UnitOfMeasurement;
 | |
|                 table.OutputValue_BasePeriod = newtable.OutputValue_BasePeriod;
 | |
|                 table.OutputValue_LastYear = newtable.OutputValue_LastYear;
 | |
|                 table.OutputValue_ThisYear = newtable.OutputValue_ThisYear;
 | |
|                 table.OperationScale_BasePeriod = newtable.OperationScale_BasePeriod;
 | |
|                 table.OperationScale_LastYear = newtable.OperationScale_LastYear;
 | |
|                 table.OperationScale_ThisYear = newtable.OperationScale_ThisYear;
 | |
|                 table.OperationScale_UnitOfMeasurement = newtable.OperationScale_UnitOfMeasurement;
 | |
|                 table.ServiceOperatingIncome_BasePeriod = newtable.ServiceOperatingIncome_BasePeriod;
 | |
|                 table.ServiceOperatingIncome_LastYear = newtable.ServiceOperatingIncome_LastYear;
 | |
|                 table.ServiceOperatingIncome_ThisYear = newtable.ServiceOperatingIncome_ThisYear;
 | |
|                 db.SubmitChanges();
 | |
|             }
 | |
| 
 | |
|         }
 | |
|         public static void DeleteEnvironmental_ProjectEnergyReportItemById(string EnergyReportItemId)
 | |
|         {
 | |
| 
 | |
|             Model.Environmental_ProjectEnergyReportItem table = db.Environmental_ProjectEnergyReportItem.FirstOrDefault(x => x.EnergyReportItemId == EnergyReportItemId);
 | |
|             if (table != null)
 | |
|             {
 | |
|                 db.Environmental_ProjectEnergyReportItem.DeleteOnSubmit(table);
 | |
|                 db.SubmitChanges();
 | |
|             }
 | |
| 
 | |
|         }
 | |
| 
 | |
|         public static void DeleteALLEnvironmental_ProjectEnergyReportItem()
 | |
|         {
 | |
|             if (db.Environmental_ProjectEnergyReportItem != null)
 | |
|             {
 | |
|                 db.Environmental_ProjectEnergyReportItem.DeleteAllOnSubmit(db.Environmental_ProjectEnergyReportItem);
 | |
|                 db.SubmitChanges();
 | |
|             }
 | |
|         }
 | |
|         public static void DeleteEnergyReportItemByChemicalReportId(string EnergyReportId)
 | |
|         {
 | |
|             var q = from x in Funs.DB.Environmental_ProjectEnergyReportItem where x.EnergyReportId == EnergyReportId select x;
 | |
|             if (q != null)
 | |
|             {
 | |
|                 Funs.DB.Environmental_ProjectEnergyReportItem.DeleteAllOnSubmit(q);
 | |
|                 Funs.DB.SubmitChanges();
 | |
|             }
 | |
|         }
 | |
| 
 | |
| 
 | |
|     }
 | |
| } |