173 lines
7.0 KiB
C#
173 lines
7.0 KiB
C#
using FineUIPro;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Security.Cryptography;
|
|
using System.Text;
|
|
|
|
|
|
namespace BLL
|
|
{
|
|
|
|
public static class ProjectEnergyReportService
|
|
{
|
|
public static Model.SGGLDB db = Funs.DB;
|
|
|
|
|
|
#region 获取列表
|
|
/// <summary>
|
|
/// 记录数
|
|
/// </summary>
|
|
public static int count
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
public static List<Model.Environmental_ProjectEnergyReport> GetEnvironmental_ProjectEnergyReportByModle(Model.Environmental_ProjectEnergyReport table)
|
|
{
|
|
var q = from x in db.Environmental_ProjectEnergyReport
|
|
where
|
|
(string.IsNullOrEmpty(table.EnergyReportId) || x.EnergyReportId.Contains(table.EnergyReportId)) &&
|
|
(string.IsNullOrEmpty(table.UnitId) || x.UnitId.Contains(table.UnitId)) &&
|
|
(string.IsNullOrEmpty(table.FillingMan) || x.FillingMan.Contains(table.FillingMan)) &&
|
|
(string.IsNullOrEmpty(table.DutyPerson) || x.DutyPerson.Contains(table.DutyPerson)) &&
|
|
(string.IsNullOrEmpty(table.UpState) || x.UpState.Contains(table.UpState))
|
|
select x
|
|
;
|
|
|
|
return q.ToList();
|
|
}
|
|
|
|
/// 获取分页列表
|
|
/// </summary>
|
|
/// <param name="PageIndex">页码</param>
|
|
/// <param name="PageSize">每页数量</param>
|
|
/// <returns></returns>
|
|
public static IEnumerable getListData(Model.Environmental_ProjectEnergyReport table, Grid Grid1)
|
|
{
|
|
var q = GetEnvironmental_ProjectEnergyReportByModle(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.EnergyReportId,
|
|
x.UnitId,
|
|
x.Year,
|
|
x.Quarters,
|
|
x.FillingMan,
|
|
x.FillingDate,
|
|
x.DutyPerson,
|
|
x.UpState,
|
|
x.ProjectId
|
|
|
|
};
|
|
}
|
|
#endregion
|
|
|
|
public static Model.Environmental_ProjectEnergyReport GetEnvironmental_ProjectEnergyReportById(string EnergyReportId)
|
|
{
|
|
return db.Environmental_ProjectEnergyReport.FirstOrDefault(x => x.EnergyReportId == EnergyReportId);
|
|
}
|
|
|
|
public static Model.Environmental_ProjectEnergyReport GetEnvironmental_ProjectEnergyReportByProjectIdAndYearAndQuarters(string ProjectId, int year, int Quarters)
|
|
{
|
|
return Funs.DB.Environmental_ProjectEnergyReport.FirstOrDefault(e => e.ProjectId == ProjectId && e.Quarters == Quarters && e.Year == year);
|
|
}
|
|
public static void AddEnvironmental_ProjectEnergyReport(Model.Environmental_ProjectEnergyReport newtable)
|
|
{
|
|
|
|
Model.Environmental_ProjectEnergyReport table = new Model.Environmental_ProjectEnergyReport
|
|
{
|
|
EnergyReportId = newtable.EnergyReportId,
|
|
UnitId = newtable.UnitId,
|
|
Year = newtable.Year,
|
|
Quarters = newtable.Quarters,
|
|
FillingMan = newtable.FillingMan,
|
|
FillingDate = newtable.FillingDate,
|
|
DutyPerson = newtable.DutyPerson,
|
|
UpState = newtable.UpState,
|
|
ProjectId=newtable.ProjectId,
|
|
};
|
|
db.Environmental_ProjectEnergyReport.InsertOnSubmit(table);
|
|
db.SubmitChanges();
|
|
}
|
|
|
|
public static void AddBulkEnvironmental_ProjectEnergyReport(List<Model.Environmental_ProjectEnergyReport> newtables)
|
|
{
|
|
|
|
db.Environmental_ProjectEnergyReport.InsertAllOnSubmit(newtables);
|
|
db.SubmitChanges();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据报表单位,报表时间判断是否存在
|
|
/// </summary>
|
|
/// <param name="Id">Id</param>
|
|
/// <returns></returns>
|
|
public static Model.Environmental_ProjectEnergyReport GetEnergyReportByProjectIdDate(string ProjectId, int year, int Quarters)
|
|
{
|
|
return Funs.DB.Environmental_ProjectEnergyReport.FirstOrDefault(e => e.ProjectId == ProjectId && e.Year == year && e.Quarters == Quarters);
|
|
}
|
|
public static List<Model.Environmental_ProjectEnergyReport> GetEnergyReportByDate(int year, int Quarters)
|
|
{
|
|
var q = (from x in Funs.DB.Environmental_ProjectEnergyReport where x.Year == year && x.Quarters == Quarters select x).ToList();
|
|
return q;
|
|
}
|
|
/// <summary>
|
|
/// 根据报表单位,报表年份获取对应集合
|
|
/// </summary>
|
|
/// <param name="Id">Id</param>
|
|
/// <returns></returns>
|
|
public static List<Model.Environmental_ProjectEnergyReport> GetEnergyReportByProjectIdYear(string ProjectId, int year)
|
|
{
|
|
return (from x in Funs.DB.Environmental_ProjectEnergyReport where x.ProjectId == ProjectId && x.Year == year select x).ToList();
|
|
}
|
|
public static void UpdateEnvironmental_ProjectEnergyReport(Model.Environmental_ProjectEnergyReport newtable)
|
|
{
|
|
|
|
Model.Environmental_ProjectEnergyReport table = db.Environmental_ProjectEnergyReport.FirstOrDefault(x => x.EnergyReportId == newtable.EnergyReportId);
|
|
if (table != null)
|
|
{
|
|
table.EnergyReportId = newtable.EnergyReportId;
|
|
table.UnitId = newtable.UnitId;
|
|
table.Year = newtable.Year;
|
|
table.Quarters = newtable.Quarters;
|
|
table.FillingMan = newtable.FillingMan;
|
|
table.FillingDate = newtable.FillingDate;
|
|
table.DutyPerson = newtable.DutyPerson;
|
|
table.UpState = newtable.UpState;
|
|
table.ProjectId=newtable.ProjectId;
|
|
db.SubmitChanges();
|
|
}
|
|
|
|
}
|
|
public static void DeleteEnvironmental_ProjectEnergyReportById(string EnergyReportId)
|
|
{
|
|
|
|
Model.Environmental_ProjectEnergyReport table = db.Environmental_ProjectEnergyReport.FirstOrDefault(x => x.EnergyReportId == EnergyReportId);
|
|
if (table != null)
|
|
{
|
|
db.Environmental_ProjectEnergyReport.DeleteOnSubmit(table);
|
|
db.SubmitChanges();
|
|
}
|
|
|
|
}
|
|
|
|
public static void DeleteALLEnvironmental_ProjectEnergyReport()
|
|
{
|
|
if (db.Environmental_ProjectEnergyReport != null)
|
|
{
|
|
db.Environmental_ProjectEnergyReport.DeleteAllOnSubmit(db.Environmental_ProjectEnergyReport);
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
}
|
|
} |