using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace BLL { public class Sys_ActualManHourMonthSetService { /// /// 根据主键获取每月实际人工设置信息 /// /// /// public static Model.Sys_ActualManHourMonthSet GetActualManHourMonthSetById(string actualManHourMonthSetId) { return Funs.DB.Sys_ActualManHourMonthSet.FirstOrDefault(e => e.ActualManHourMonthId == actualManHourMonthSetId); } /// /// 根据部门和年份获取信息 /// /// /// /// public static Model.Sys_ActualManHourMonthSet GetActualManHourMonthSetByDepAndYear(string departId, string years) { return Funs.DB.Sys_ActualManHourMonthSet.FirstOrDefault(e => e.DepartId == departId && e.Years == years); } /// /// 根据人员和年份获取信息 /// /// /// public static Model.Sys_ActualManHourMonthSet GetActualManHourMonthSetByYear(string years) { return Funs.DB.Sys_ActualManHourMonthSet.FirstOrDefault(e => e.DepartId==null && e.Years == years); } public static List GetListByYear(string types, string year) { var list = new List(); if (types == "1") { list = (from x in Funs.DB.Sys_ActualManHourMonthSet join y in Funs.DB.Base_Depart on x.DepartId equals y.DepartId orderby y.DepartCode where x.DepartId != null && x.Years == year select x).ToList(); } else { list = (from x in Funs.DB.Sys_ActualManHourMonthSet join y in Funs.DB.Base_Depart on x.DepartId equals y.DepartId orderby y.DepartCode where x.DepartId==null && x.Years == year select x).ToList(); } return list; } /// /// 批量增加 /// /// public static void AddActualManHourMonthSet(List set) { Funs.DB.Sys_ActualManHourMonthSet.InsertAllOnSubmit(set); Funs.DB.SubmitChanges(); } /// /// 批量删除 /// public static void DeleteActualManHourMonthSetList(string types, string years) { var q = new List(); if (types == "1") { q = (from x in Funs.DB.Sys_ActualManHourMonthSet where x.DepartId != null && x.Years == years select x).ToList(); } else { q = (from x in Funs.DB.Sys_ActualManHourMonthSet where x.DepartId==null && x.Years == years select x).ToList(); } Funs.DB.Sys_ActualManHourMonthSet.DeleteAllOnSubmit(q); Funs.DB.SubmitChanges(); } /// /// 根据时间获取每个月的人工时 /// /// /// public static decimal GetHoursByMonth(DateTime d) { decimal? m = 0; var q = (from x in Funs.DB.Sys_ActualManHourMonthSet where x.DepartId==null && x.Years == d.Year.ToString() select x).FirstOrDefault(); if (q != null) { if (d.Month == 1) { m = q.Month1; } else if (d.Month == 2) { m = q.Month2; } else if (d.Month == 3) { m = q.Month3; } else if (d.Month == 4) { m = q.Month4; } else if (d.Month == 5) { m = q.Month5; } else if (d.Month == 6) { m = q.Month6; } else if (d.Month == 7) { m = q.Month7; } else if (d.Month == 8) { m = q.Month8; } else if (d.Month == 9) { m = q.Month9; } else if (d.Month == 10) { m = q.Month10; } else if (d.Month == 11) { m = q.Month11; } else if (d.Month == 12) { m = q.Month12; } } if (m != null) { return m.Value; } else { return 0; } } } }