130 lines
4.2 KiB
C#
130 lines
4.2 KiB
C#
using Model;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace BLL
|
|
{
|
|
/// <summary>
|
|
/// 岗位培训师资
|
|
/// </summary>
|
|
public static class PostTrainingTeachersService
|
|
{
|
|
/// <summary>
|
|
/// 根据主键获取岗位培训师资信息
|
|
/// </summary>
|
|
/// <param name="Id"></param>
|
|
/// <returns></returns>
|
|
public static Model.PostTraining_Teachers GetTeachersById(string Id)
|
|
{
|
|
return Funs.DB.PostTraining_Teachers.FirstOrDefault(e => e.Id == Id);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据名称获取岗位培训师资信息
|
|
/// </summary>
|
|
/// <param name="Name"></param>
|
|
/// <returns></returns>
|
|
public static Model.PostTraining_Teachers GetTeachersByName(string Name)
|
|
{
|
|
return Funs.DB.PostTraining_Teachers.FirstOrDefault(e => e.Name == Name);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加岗位培训师资
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
public static void AddTeachers(Model.PostTraining_Teachers model)
|
|
{
|
|
Model.PostTraining_Teachers newModel = new Model.PostTraining_Teachers
|
|
{
|
|
Id = model.Id,
|
|
Code = model.Code,
|
|
Name = model.Name,
|
|
CompileDate = model.CompileDate,
|
|
CompileMan = model.CompileMan,
|
|
Remark = model.Remark
|
|
};
|
|
Funs.DB.PostTraining_Teachers.InsertOnSubmit(newModel);
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
public static void UpdateTeachers(Model.PostTraining_Teachers model)
|
|
{
|
|
Model.PostTraining_Teachers newModel = Funs.DB.PostTraining_Teachers.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();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除
|
|
/// </summary>
|
|
/// <param name="Id"></param>
|
|
public static void DeleteTeachersById(string Id)
|
|
{
|
|
Model.PostTraining_Teachers model = Funs.DB.PostTraining_Teachers.FirstOrDefault(e => e.Id == Id);
|
|
if (model != null)
|
|
{
|
|
CommonService.DeleteAttachFileById(Id);
|
|
Funs.DB.PostTraining_Teachers.DeleteOnSubmit(model);
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取所有培训师资List
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static List<PostTraining_Teachers> GetTeachersList()
|
|
{
|
|
return (from x in Funs.DB.PostTraining_Teachers orderby x.Code select x).ToList();
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 获取培训师资下拉框
|
|
/// </summary>
|
|
/// <param name="dropName"></param>
|
|
/// <param name="excludeName"></param>
|
|
/// <param name="isShowPlease"></param>
|
|
public static void InitPostTrainingTeachersDropDownList(FineUIPro.DropDownList dropName, string excludeName, bool isShowPlease)
|
|
{
|
|
dropName.DataValueField = "Name";
|
|
dropName.DataTextField = "Name";
|
|
dropName.DataSource = GetPostTrainingTeachersList(excludeName);
|
|
dropName.DataBind();
|
|
if (isShowPlease)
|
|
{
|
|
Funs.FineUIPleaseSelect(dropName);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取培训师资下拉项
|
|
/// </summary>
|
|
/// <param name="excludeName"></param>
|
|
/// <returns></returns>
|
|
public static List<Model.PostTraining_Teachers> GetPostTrainingTeachersList(string excludeName)
|
|
{
|
|
var lst = (from x in Funs.DB.PostTraining_Teachers orderby x.Code select x).ToList();
|
|
if (!string.IsNullOrWhiteSpace(excludeName))
|
|
{
|
|
lst = lst.Where(x => x.Name != excludeName).ToList();
|
|
}
|
|
return lst;
|
|
}
|
|
|
|
}
|
|
}
|