using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; namespace BLL { public class ManhoursSortBService { public static Model.SGGLDB db = Funs.DB; /// /// 获取分页列表 /// /// public static IEnumerable getListData(string monthReportId) { return from x in db.Manager_ManhoursSortB where x.MonthReportId == monthReportId orderby x.UnitId select new { UnitName = (from y in db.Base_Unit where y.UnitId == x.UnitId select y.UnitName).First(), x.PersonTotal, x.ManhoursTotal, x.TotalManhoursTotal, }; } /// /// 根据月报告主键获取所有月报告人工时分类信息 /// /// 月报告主键 /// public static List GetManhoursSortsByMonthReportId(string monthReportId) { return (from x in Funs.DB.Manager_ManhoursSortB where x.MonthReportId == monthReportId orderby x.UnitId select x).ToList(); } /// /// 根据月报告主键获取总完成人工时 /// /// 单位主键 /// 月报告主键 /// public static decimal? GetSumManhoursTotalByMonthReportId(string monthReportId, string unitId) { return (from x in Funs.DB.Manager_ManhoursSortB where x.MonthReportId == monthReportId && x.UnitId == unitId select x.ManhoursTotal).Sum(); } /// /// 根据月报告主键和单位主键获取一条记录 /// /// 单位主键 /// 月报告主键 /// public static Model.Manager_ManhoursSortB GetSumManhoursTotalByMonthReportIdAndUnitId(string monthReportId, string unitId) { return (from x in Funs.DB.Manager_ManhoursSortB where x.MonthReportId == monthReportId && x.UnitId == unitId select x).FirstOrDefault(); } /// /// 增加月报告人工时分类信息 /// /// 月报告人工时分类实体 public static void AddManhoursSort(Model.Manager_ManhoursSortB manhoursSort) { Model.SGGLDB db = Funs.DB; string newKeyID = SQLHelper.GetNewID(typeof(Model.Manager_ManhoursSortB)); Model.Manager_ManhoursSortB newManhoursSort = new Model.Manager_ManhoursSortB { ManhoursSortId = newKeyID, MonthReportId = manhoursSort.MonthReportId, UnitId = manhoursSort.UnitId, PersonTotal = manhoursSort.PersonTotal, ManhoursTotal = manhoursSort.ManhoursTotal, TotalManhoursTotal = manhoursSort.TotalManhoursTotal }; db.Manager_ManhoursSortB.InsertOnSubmit(newManhoursSort); db.SubmitChanges(); } /// /// 根据月报告主键删除对应的所有月报告人工时分类信息 /// /// 月报告主键 public static void DeleteManhoursSortsByMonthReportId(string monthReportId) { var q = (from x in Funs.DB.Manager_ManhoursSortB where x.MonthReportId == monthReportId select x).ToList(); Funs.DB.Manager_ManhoursSortB.DeleteAllOnSubmit(q); Funs.DB.SubmitChanges(); } } }