using Model; using System.Collections.Generic; using System.Linq; namespace BLL { /// /// 岗位培训方式 /// public static class PostTrainingMethodService { /// /// 根据主键获取岗位培训方式信息 /// /// /// public static Model.PostTraining_Method GetMethodById(string Id) { return Funs.DB.PostTraining_Method.FirstOrDefault(e => e.Id == Id); } /// /// 根据名称获取岗位培训方式信息 /// /// /// public static Model.PostTraining_Method GetMethodByName(string Name) { return Funs.DB.PostTraining_Method.FirstOrDefault(e => e.Name == Name); } /// /// 添加岗位培训方式 /// /// public static void AddMethod(Model.PostTraining_Method model) { Model.PostTraining_Method newModel = new Model.PostTraining_Method { Id = model.Id, Code = model.Code, Name = model.Name, CompileDate = model.CompileDate, CompileMan = model.CompileMan, Remark = model.Remark }; Funs.DB.PostTraining_Method.InsertOnSubmit(newModel); Funs.DB.SubmitChanges(); } /// /// 修改 /// /// public static void UpdateMethod(Model.PostTraining_Method model) { Model.PostTraining_Method newModel = Funs.DB.PostTraining_Method.FirstOrDefault(e => e.Id == model.Id); if (newModel != null) { newModel.Code = model.Code; newModel.Name = model.Name; newModel.Remark = model.Remark; newModel.CompileDate = model.CompileDate; newModel.CompileMan = model.CompileMan; Funs.DB.SubmitChanges(); } } /// /// 删除 /// /// public static void DeleteMethodById(string Id) { Model.PostTraining_Method model = Funs.DB.PostTraining_Method.FirstOrDefault(e => e.Id == Id); if (model != null) { CommonService.DeleteAttachFileById(Id); Funs.DB.PostTraining_Method.DeleteOnSubmit(model); Funs.DB.SubmitChanges(); } } /// /// 获取所有培训方式List /// /// public static List GetMethodList() { return (from x in Funs.DB.PostTraining_Method orderby x.Code select x).ToList(); } /// /// 获取培训方式下拉框 /// /// /// /// public static void InitPostTrainingMethodDropDownList(FineUIPro.DropDownList dropName, string excludeName, bool isShowPlease) { dropName.DataValueField = "Name"; dropName.DataTextField = "Name"; dropName.DataSource = GetPostTrainingMethodList(excludeName); dropName.DataBind(); if (isShowPlease) { Funs.FineUIPleaseSelect(dropName); } } /// /// 获取培训方式下拉项 /// /// /// public static List GetPostTrainingMethodList(string excludeName) { var lst = (from x in Funs.DB.PostTraining_Method orderby x.Code select x).ToList(); if (!string.IsNullOrWhiteSpace(excludeName)) { lst = lst.Where(x => x.Name != excludeName).ToList(); } return lst; } } }