using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BLL
{
public class CheckSortCService
{
public static Model.SGGLDB db = Funs.DB;
///
/// 根据月报告主键获取所有月报告HSE检查情况信息
///
/// 月报告主键
///
public static List GetCheckSortsByMonthReportId(string monthReportId)
{
return (from x in Funs.DB.Manager_CheckSortC where x.MonthReportId == monthReportId orderby x.SortIndex select x).ToList();
}
public static Model.Manager_CheckSortC GetCheckSortByMonthReportIdAndCheckType(string monthReportId, string checkType)
{
return (from x in Funs.DB.Manager_CheckSortC where x.MonthReportId == monthReportId && x.CheckType == checkType select x).FirstOrDefault();
}
///
/// 根据月报告主键获取总检查次数
///
/// 安全检查类型
/// 月报告主键
///
public static decimal? GetSumCheckNumberByMonthReportId(string monthReportId, string checkType)
{
return (from x in Funs.DB.Manager_CheckSortC where x.MonthReportId == monthReportId && x.CheckType == checkType select x.CheckNumber).Sum();
}
///
/// 根据月报告主键获取总违章数量
///
/// 安全检查类型
/// 月报告主键
///
public static decimal? GetSumViolationNumberByMonthReportId(string monthReportId, string checkType)
{
return (from x in Funs.DB.Manager_CheckSortC where x.MonthReportId == monthReportId && x.CheckType == checkType select x.ViolationNumber).Sum();
}
///
/// 增加月报告HSE检查情况信息
///
/// 月报告HSE检查情况实体
public static void AddCheckSort(Model.Manager_CheckSortC checkSort)
{
Model.SGGLDB db = Funs.DB;
string newKeyID = SQLHelper.GetNewID(typeof(Model.Manager_CheckSortC));
Model.Manager_CheckSortC newCheckSort = new Model.Manager_CheckSortC
{
CheckSortId = newKeyID,
MonthReportId = checkSort.MonthReportId,
SortIndex = checkSort.SortIndex,
CheckType = checkSort.CheckType,
CheckNumber = checkSort.CheckNumber,
YearCheckNum = checkSort.YearCheckNum,
TotalCheckNum = checkSort.TotalCheckNum,
ViolationNumber = checkSort.ViolationNumber,
YearViolationNum = checkSort.YearViolationNum
};
db.Manager_CheckSortC.InsertOnSubmit(newCheckSort);
db.SubmitChanges();
}
///
/// 根据月报告主键删除对应的所有月报告HSE检查情况信息
///
/// 月报告主键
public static void DeleteCheckSortsByMonthReportId(string monthReportId)
{
var q = (from x in db.Manager_CheckSortC where x.MonthReportId == monthReportId select x).ToList();
db.Manager_CheckSortC.DeleteAllOnSubmit(q);
db.SubmitChanges();
}
}
}