273 lines
11 KiB
C#
273 lines
11 KiB
C#
|
using FineUIPro;
|
|||
|
using Microsoft.SqlServer.Dts.Runtime;
|
|||
|
using System;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.IO;
|
|||
|
using System.Linq;
|
|||
|
|
|||
|
namespace BLL
|
|||
|
{
|
|||
|
public class ConstructionLogNewService
|
|||
|
{
|
|||
|
public static Model.SGGLDB db = Funs.DB;
|
|||
|
|
|||
|
#region 获取人员列表信息
|
|||
|
/// <summary>
|
|||
|
/// 记录数
|
|||
|
/// </summary>
|
|||
|
public static int count
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 定义变量
|
|||
|
/// </summary>
|
|||
|
private static IQueryable<Model.InformationProject_ConstructionLog> getDataLists = from x in db.InformationProject_ConstructionLog
|
|||
|
select x;
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 数据列表
|
|||
|
/// </summary>
|
|||
|
/// <param name="unitId"></param>
|
|||
|
/// <param name="projetcId"></param>
|
|||
|
/// <param name="name"></param>
|
|||
|
/// <param name="Grid1"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public static IEnumerable getListData(string projetcId, string unitId, string personId, string name, DateTime? startTime, DateTime? endTime, Grid Grid1)
|
|||
|
{
|
|||
|
IQueryable<Model.InformationProject_ConstructionLog> getDataList = getDataLists;
|
|||
|
if (!string.IsNullOrEmpty(projetcId) && projetcId != Const._Null)
|
|||
|
{
|
|||
|
getDataList = getDataList.Where(e => e.ProjectId == projetcId);
|
|||
|
}
|
|||
|
if (!string.IsNullOrEmpty(unitId) && unitId != Const._Null)
|
|||
|
{
|
|||
|
getDataList = getDataList.Where(e => e.UnitId == unitId);
|
|||
|
}
|
|||
|
if (!string.IsNullOrEmpty(personId))
|
|||
|
{
|
|||
|
getDataList = getDataList.Where(e => e.PersonId == personId);
|
|||
|
}
|
|||
|
if (!string.IsNullOrEmpty(name))
|
|||
|
{
|
|||
|
getDataList = getDataList.Where(e => e.PersonName.Contains(name));
|
|||
|
}
|
|||
|
if (startTime.HasValue)
|
|||
|
{
|
|||
|
getDataList = getDataList.Where(e => e.WorkDate >= startTime);
|
|||
|
}
|
|||
|
if (endTime.HasValue)
|
|||
|
{
|
|||
|
getDataList = getDataList.Where(e => e.WorkDate <= endTime);
|
|||
|
}
|
|||
|
|
|||
|
count = getDataList.Count();
|
|||
|
if (count == 0)
|
|||
|
{
|
|||
|
return null;
|
|||
|
}
|
|||
|
getDataList = SortConditionHelper.SortingAndPaging(getDataList, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
|
|||
|
return from x in getDataList
|
|||
|
select new
|
|||
|
{
|
|||
|
x.ConstructionLogId,
|
|||
|
x.ProjectId,
|
|||
|
ProjectName = ProjectService.GetProjectNameByProjectId(x.ProjectId),
|
|||
|
x.UnitId,
|
|||
|
UnitName = UnitService.GetUnitNameByUnitId(x.UnitId),
|
|||
|
x.PersonId,
|
|||
|
x.PersonName,
|
|||
|
x.WorkDate,
|
|||
|
};
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 根据主键获取施工日志
|
|||
|
/// </summary>
|
|||
|
/// <param name="ConstructionLogId"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public static Model.InformationProject_ConstructionLog GetConstructionLogById(string ConstructionLogId)
|
|||
|
{
|
|||
|
return Funs.DB.InformationProject_ConstructionLog.FirstOrDefault(e => e.ConstructionLogId == ConstructionLogId);
|
|||
|
}
|
|||
|
|
|||
|
public static Model.InformationProject_ConstructionLog GetConstructionLogByPersonIdDate(string projectId, string personId, DateTime date)
|
|||
|
{
|
|||
|
return Funs.DB.InformationProject_ConstructionLog.FirstOrDefault(e => e.ProjectId == projectId && e.PersonId == personId && e.WorkDate.Value.Year == date.Year
|
|||
|
&& e.WorkDate.Value.Month == date.Month && e.WorkDate.Value.Day == date.Day);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 添加施工日志
|
|||
|
/// </summary>
|
|||
|
/// <param name="ConstructionLog"></param>
|
|||
|
public static void AddConstructionLog(Model.InformationProject_ConstructionLog ConstructionLog)
|
|||
|
{
|
|||
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|||
|
{
|
|||
|
Model.InformationProject_ConstructionLog newConstructionLog = new Model.InformationProject_ConstructionLog
|
|||
|
{
|
|||
|
ConstructionLogId = ConstructionLog.ConstructionLogId,
|
|||
|
ProjectId = ConstructionLog.ProjectId,
|
|||
|
WorkDate = ConstructionLog.WorkDate,
|
|||
|
UnitId = ConstructionLog.UnitId,
|
|||
|
PersonId = ConstructionLog.PersonId,
|
|||
|
PersonName = ConstructionLog.PersonName,
|
|||
|
};
|
|||
|
db.InformationProject_ConstructionLog.InsertOnSubmit(newConstructionLog);
|
|||
|
db.SubmitChanges();
|
|||
|
|
|||
|
PersonStarLevelService.collectLog(ConstructionLog.ProjectId, ConstructionLog.PersonId);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 修改施工日志
|
|||
|
/// </summary>
|
|||
|
/// <param name="ConstructionLog"></param>
|
|||
|
public static void UpdateConstructionLog(Model.InformationProject_ConstructionLog ConstructionLog)
|
|||
|
{
|
|||
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|||
|
{
|
|||
|
Model.InformationProject_ConstructionLog newConstructionLog = db.InformationProject_ConstructionLog.FirstOrDefault(e => e.ConstructionLogId == ConstructionLog.ConstructionLogId);
|
|||
|
if (newConstructionLog != null)
|
|||
|
{
|
|||
|
newConstructionLog.ProjectId = ConstructionLog.ProjectId;
|
|||
|
newConstructionLog.UnitId = ConstructionLog.UnitId;
|
|||
|
newConstructionLog.PersonId = ConstructionLog.PersonId;
|
|||
|
newConstructionLog.PersonName = ConstructionLog.PersonName;
|
|||
|
newConstructionLog.WorkDate = ConstructionLog.WorkDate;
|
|||
|
db.SubmitChanges();
|
|||
|
}
|
|||
|
|
|||
|
PersonStarLevelService.collectLog(ConstructionLog.ProjectId, ConstructionLog.PersonId);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 根据主键删除施工日志
|
|||
|
/// </summary>
|
|||
|
/// <param name="ConstructionLogId"></param>
|
|||
|
public static void DeleteConstructionLogById(string ConstructionLogId)
|
|||
|
{
|
|||
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|||
|
{
|
|||
|
Model.InformationProject_ConstructionLog ConstructionLog = db.InformationProject_ConstructionLog.FirstOrDefault(e => e.ConstructionLogId == ConstructionLogId);
|
|||
|
if (ConstructionLog != null)
|
|||
|
{
|
|||
|
DeleteConstructionLogItemById(ConstructionLogId);
|
|||
|
db.InformationProject_ConstructionLog.DeleteOnSubmit(ConstructionLog);
|
|||
|
db.SubmitChanges();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 获取施工日志列表
|
|||
|
/// </summary>
|
|||
|
/// <returns></returns>
|
|||
|
public static List<Model.InformationProject_ConstructionLog> GetConstructionLogList()
|
|||
|
{
|
|||
|
return (from x in Funs.DB.InformationProject_ConstructionLog orderby x.WorkDate descending select x).ToList();
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
#region 施工日志明细表
|
|||
|
/// <summary>
|
|||
|
/// 根据主键获取施工日志明细
|
|||
|
/// </summary>
|
|||
|
/// <param name="ConstructionLogItemId"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public static Model.InformationProject_ConstructionLogItem GetConstructionLogItemById(string ConstructionLogItemId)
|
|||
|
{
|
|||
|
return Funs.DB.InformationProject_ConstructionLogItem.FirstOrDefault(e => e.ConstructionLogItemId == ConstructionLogItemId);
|
|||
|
}
|
|||
|
|
|||
|
public static List<Model.InformationProject_ConstructionLogItem> GetConstructionLogItemListByConstructionLogId(string ConstructionLogId)
|
|||
|
{
|
|||
|
var getList = from x in Funs.DB.InformationProject_ConstructionLogItem
|
|||
|
where x.ConstructionLogId == ConstructionLogId
|
|||
|
orderby x.ExamTypeId
|
|||
|
select x;
|
|||
|
return getList.ToList();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 添加施工日志明细
|
|||
|
/// </summary>
|
|||
|
/// <param name="item"></param>
|
|||
|
public static void AddConstructionLogItem(Model.InformationProject_ConstructionLogItem item)
|
|||
|
{
|
|||
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|||
|
{
|
|||
|
Model.InformationProject_ConstructionLogItem newConstructionLog = new Model.InformationProject_ConstructionLogItem
|
|||
|
{
|
|||
|
ConstructionLogItemId = item.ConstructionLogItemId,
|
|||
|
ConstructionLogId = item.ConstructionLogId,
|
|||
|
ExamTypeId = item.ExamTypeId,
|
|||
|
Frequency = item.Frequency,
|
|||
|
};
|
|||
|
db.InformationProject_ConstructionLogItem.InsertOnSubmit(newConstructionLog);
|
|||
|
db.SubmitChanges();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 修改施工日志明细
|
|||
|
/// </summary>
|
|||
|
/// <param name="item"></param>
|
|||
|
public static void UpdateConstructionLogItem(Model.InformationProject_ConstructionLogItem item)
|
|||
|
{
|
|||
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|||
|
{
|
|||
|
Model.InformationProject_ConstructionLogItem newConstructionLog = db.InformationProject_ConstructionLogItem.FirstOrDefault(e => e.ConstructionLogItemId == item.ConstructionLogItemId);
|
|||
|
if (newConstructionLog != null)
|
|||
|
{
|
|||
|
newConstructionLog.ExamTypeId = item.ExamTypeId;
|
|||
|
newConstructionLog.Frequency = item.Frequency;
|
|||
|
db.SubmitChanges();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 根据主键删除施工日志明细
|
|||
|
/// </summary>
|
|||
|
/// <param name="ConstructionLogItemId"></param>
|
|||
|
public static void DeleteConstructionLogItemById(string ConstructionLogId)
|
|||
|
{
|
|||
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|||
|
{
|
|||
|
var getDeleteItem = db.InformationProject_ConstructionLogItem.Where(e => e.ConstructionLogId == ConstructionLogId);
|
|||
|
if (getDeleteItem.Count() > 0)
|
|||
|
{
|
|||
|
db.InformationProject_ConstructionLogItem.DeleteAllOnSubmit(getDeleteItem);
|
|||
|
db.SubmitChanges();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 根据主键删除施工日志明细
|
|||
|
/// </summary>
|
|||
|
/// <param name="ConstructionLogItemId"></param>
|
|||
|
public static void DeleteConstructionLogItemByConstructionLogItemId(string ConstructionLogItemId)
|
|||
|
{
|
|||
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|||
|
{
|
|||
|
Model.InformationProject_ConstructionLogItem ConstructionLog = db.InformationProject_ConstructionLogItem.FirstOrDefault(e => e.ConstructionLogItemId == ConstructionLogItemId);
|
|||
|
if (ConstructionLog != null)
|
|||
|
{
|
|||
|
db.InformationProject_ConstructionLogItem.DeleteOnSubmit(ConstructionLog);
|
|||
|
db.SubmitChanges();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|