using FineUIPro; using System; using System.Collections; using System.Linq; namespace BLL { public static class SafetyWorkReportService { public static Model.SUBQHSEDB db = Funs.DB; #region 获取月度安全工作汇报列表信息 /// /// 记录数 /// public static int count { get; set; } /// /// 定义变量 /// private static IQueryable getDataLists = from x in db.Manager_SafetyWorkReport select x; /// /// 数据列表 /// /// /// /// public static IEnumerable getListData(string unitId, Grid Grid1) { IQueryable getDataList = getDataLists; if (!string.IsNullOrEmpty(unitId) && unitId != BLL.CommonService.GetThisUnitId()) { getDataList = getDataList.Where(x => x.UnitId == unitId); } 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.SafetyWorkReportId, x.UnitId, db.Base_Unit.First(u=>u.UnitId == x.UnitId).UnitName, x.Months, x.ReportManId, db.Sys_User.First(u => u.UserId == x.ReportManId).UserName, x.ReportDate, }; } #endregion public static Model.Manager_SafetyWorkReport GetManager_SafetyWorkReportById(string SafetyWorkReportId) { return Funs.DB.Manager_SafetyWorkReport.FirstOrDefault(e => e.SafetyWorkReportId == SafetyWorkReportId); } /// /// 根据安全工作汇报告主键获取安全工作汇报告信息 /// /// 安全工作汇报告主键 /// 安全工作汇报告信息 public static Model.Manager_SafetyWorkReport GetSafetyWorkReportySafetyWorkReportId(string safetyWorkReportId) { return Funs.DB.Manager_SafetyWorkReport.FirstOrDefault(x => x.SafetyWorkReportId == safetyWorkReportId); } /// /// 根据日期获得安全工作汇报告信息 /// /// 日期 /// public static Model.Manager_SafetyWorkReport GetSafetyWorkReportyMonth(DateTime month, string unitId) { return (from x in Funs.DB.Manager_SafetyWorkReport where x.Months == month && x.UnitId == unitId select x).FirstOrDefault(); } public static void AddManager_SafetyWorkReport(Model.Manager_SafetyWorkReport newtable) { Model.Manager_SafetyWorkReport table = new Model.Manager_SafetyWorkReport { SafetyWorkReportId = newtable.SafetyWorkReportId, UnitId = newtable.UnitId, ProjectId = newtable.ProjectId, Months = newtable.Months, ReportManId = newtable.ReportManId, ReportDate = newtable.ReportDate, Num1 = newtable.Num1, Num2 = newtable.Num2, Num3 = newtable.Num3, Num4 = newtable.Num4, Num5 = newtable.Num5, Num6 = newtable.Num6, Num7 = newtable.Num7, Num8 = newtable.Num8, Num9 = newtable.Num9, Cost1 = newtable.Cost1, Hour1 = newtable.Hour1, Cost2 = newtable.Cost2, Hour2 = newtable.Hour2, ExistAccident = newtable.ExistAccident, AccidentNum = newtable.AccidentNum, AccidentType = newtable.AccidentType, InjurySituation = newtable.InjurySituation, LossMoney = newtable.LossMoney, LossWorkDay = newtable.LossWorkDay, ExistMeeting = newtable.ExistMeeting, MeetingNum = newtable.MeetingNum, MeetingType = newtable.MeetingType, ExistLeaderCheck = newtable.ExistLeaderCheck, LeaderCheckNum = newtable.LeaderCheckNum, ExistSafetyCheck = newtable.ExistSafetyCheck, CheckNum1 = newtable.CheckNum1, CheckNum2 = newtable.CheckNum2, CheckNum3 = newtable.CheckNum3, CheckNum4 = newtable.CheckNum4, CheckLimitDate = newtable.CheckLimitDate, ExistTrain = newtable.ExistTrain, TrainNum = newtable.TrainNum, ExistContribution = newtable.ExistContribution, ContributionNum1 = newtable.ContributionNum1, ContributionNum2 = newtable.ContributionNum2, NextWork = newtable.NextWork, Problem = newtable.Problem, Suggestion = newtable.Suggestion, CompileMan = newtable.CompileMan, CompileDate = newtable.CompileDate, }; Funs.DB.Manager_SafetyWorkReport.InsertOnSubmit(table); Funs.DB.SubmitChanges(); } public static void UpdateManager_SafetyWorkReport(Model.Manager_SafetyWorkReport newtable) { var table = Funs.DB.Manager_SafetyWorkReport.FirstOrDefault(e => e.SafetyWorkReportId == newtable.SafetyWorkReportId); if (table != null) { table.UnitId = newtable.UnitId; table.ProjectId = newtable.ProjectId; table.Months = newtable.Months; table.ReportManId = newtable.ReportManId; table.ReportDate = newtable.ReportDate; table.Num1 = newtable.Num1; table.Num2 = newtable.Num2; table.Num3 = newtable.Num3; table.Num4 = newtable.Num4; table.Num5 = newtable.Num5; table.Num6 = newtable.Num6; table.Num7 = newtable.Num7; table.Num8 = newtable.Num8; table.Num9 = newtable.Num9; table.Cost1 = newtable.Cost1; table.Hour1 = newtable.Hour1; table.Cost2 = newtable.Cost2; table.Hour2 = newtable.Hour2; table.ExistAccident = newtable.ExistAccident; table.AccidentNum = newtable.AccidentNum; table.AccidentType = newtable.AccidentType; table.InjurySituation = newtable.InjurySituation; table.LossMoney = newtable.LossMoney; table.LossWorkDay = newtable.LossWorkDay; table.ExistMeeting = newtable.ExistMeeting; table.MeetingNum = newtable.MeetingNum; table.MeetingType = newtable.MeetingType; table.ExistLeaderCheck = newtable.ExistLeaderCheck; table.LeaderCheckNum = newtable.LeaderCheckNum; table.ExistSafetyCheck = newtable.ExistSafetyCheck; table.CheckNum1 = newtable.CheckNum1; table.CheckNum2 = newtable.CheckNum2; table.CheckNum3 = newtable.CheckNum3; table.CheckNum4 = newtable.CheckNum4; table.CheckLimitDate = newtable.CheckLimitDate; table.ExistTrain = newtable.ExistTrain; table.TrainNum = newtable.TrainNum; table.ExistContribution = newtable.ExistContribution; table.ContributionNum1 = newtable.ContributionNum1; table.ContributionNum2 = newtable.ContributionNum2; table.NextWork = newtable.NextWork; table.Problem = newtable.Problem; table.Suggestion = newtable.Suggestion; table.CompileMan = newtable.CompileMan; table.CompileDate = newtable.CompileDate; Funs.DB.SubmitChanges(); } } /// /// 根据安全工作汇报告主键删除一个安全工作汇报告信息 /// /// 安全工作汇报告主键 public static void DeleteSafetyWorkReportySafetyWorkReportId(string safetyWorkReportId) { Model.SUBQHSEDB db = Funs.DB; Model.Manager_SafetyWorkReport safetyWorkReport = db.Manager_SafetyWorkReport.FirstOrDefault(e => e.SafetyWorkReportId == safetyWorkReportId); if (safetyWorkReport != null) { ///删除编码表记录 BLL.CodeRecordsService.DeleteCodeRecordsByDataId(safetyWorkReportId); BLL.CommonService.DeleteAttachFileById(safetyWorkReportId);//删除附件 db.Manager_SafetyWorkReport.DeleteOnSubmit(safetyWorkReport); db.SubmitChanges(); } } } }