167 lines
6.6 KiB
C#
167 lines
6.6 KiB
C#
using System;
|
|
using Model;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace BLL
|
|
{
|
|
/// <summary>
|
|
/// 公司培训明细表——教材库
|
|
/// </summary>
|
|
public class CompanyTrainingItemService
|
|
{
|
|
|
|
/// <summary>
|
|
/// 根据主键获取公司培训明细信息
|
|
/// </summary>
|
|
/// <param name="companyTrainingItemId"></param>
|
|
/// <returns></returns>
|
|
public static Model.Training_CompanyTrainingItem GetCompanyTrainingItemById(string companyTrainingItemId)
|
|
{
|
|
Model.CNPCDB db = Funs.DB;
|
|
return db.Training_CompanyTrainingItem.FirstOrDefault(e => e.CompanyTrainingItemId == companyTrainingItemId);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加公司培训明细
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
public static void AddCompanyTrainingItem(Model.Training_CompanyTrainingItem model)
|
|
{
|
|
Model.CNPCDB db = Funs.DB;
|
|
Model.Training_CompanyTrainingItem newModel = new Model.Training_CompanyTrainingItem();
|
|
newModel.CompanyTrainingItemId = model.CompanyTrainingItemId;
|
|
newModel.CompanyTrainingId = model.CompanyTrainingId;
|
|
newModel.CompanyTrainingItemCode = model.CompanyTrainingItemCode;
|
|
newModel.CompanyTrainingItemName = model.CompanyTrainingItemName;
|
|
newModel.AttachUrl = model.AttachUrl;
|
|
newModel.CompileMan = model.CompileMan;
|
|
newModel.CompileDate = model.CompileDate;
|
|
newModel.WorkPostIds = model.WorkPostIds;
|
|
newModel.WorkPostNames = model.WorkPostNames;
|
|
newModel.Outcome = model.Outcome;
|
|
newModel.LearningTime = model.LearningTime;
|
|
newModel.TestTrainingIds = model.TestTrainingIds;
|
|
db.Training_CompanyTrainingItem.InsertOnSubmit(newModel);
|
|
db.SubmitChanges();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改公司培训明细
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
public static void UpdateCompanyTrainingItem(Model.Training_CompanyTrainingItem model)
|
|
{
|
|
Model.CNPCDB db = Funs.DB;
|
|
Model.Training_CompanyTrainingItem newModel = db.Training_CompanyTrainingItem.FirstOrDefault(e => e.CompanyTrainingItemId == model.CompanyTrainingItemId);
|
|
if (newModel != null)
|
|
{
|
|
newModel.CompanyTrainingItemCode = model.CompanyTrainingItemCode;
|
|
newModel.CompanyTrainingItemName = model.CompanyTrainingItemName;
|
|
newModel.AttachUrl = model.AttachUrl;
|
|
newModel.CompileMan = model.CompileMan;
|
|
newModel.CompileDate = model.CompileDate;
|
|
newModel.WorkPostIds = model.WorkPostIds;
|
|
newModel.WorkPostNames = model.WorkPostNames;
|
|
newModel.Outcome = model.Outcome;
|
|
newModel.LearningTime = model.LearningTime;
|
|
newModel.TestTrainingIds = model.TestTrainingIds;
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据主键删除明细信息
|
|
/// </summary>
|
|
/// <param name="companyTrainItemId"></param>
|
|
public static void DeleteCompanyTrainingItemById(string companyTrainItemId)
|
|
{
|
|
Model.CNPCDB db = Funs.DB;
|
|
Model.Training_CompanyTrainingItem model = db.Training_CompanyTrainingItem.FirstOrDefault(e => e.CompanyTrainingItemId == companyTrainItemId);
|
|
if (model != null)
|
|
{
|
|
db.Training_CompanyTrainingItem.DeleteOnSubmit(model);
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 教材库下拉框
|
|
/// </summary>
|
|
/// <param name="dropName">下拉框名字</param>
|
|
/// <param name="workPostId">职务Id</param>
|
|
/// <param name="isShowPlease">是否显示请选择</param>
|
|
public static void InitCompanyTrainingItemDownList(FineUIPro.DropDownList dropName, string workPostId, bool isShowPlease)
|
|
{
|
|
dropName.DataValueField = "CompanyTrainingItemId";
|
|
dropName.DataTextField = "CompanyTrainingItemName";
|
|
dropName.DataSource = GetCompanyTrainingItemList(workPostId);
|
|
dropName.DataBind();
|
|
if (isShowPlease)
|
|
{
|
|
Funs.FineUIPleaseSelect(dropName);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取教材库下拉项
|
|
/// </summary>
|
|
/// <param name="workPostId"></param>
|
|
/// <returns></returns>
|
|
public static List<Model.Training_CompanyTrainingItem> GetCompanyTrainingItemList(string workPostId)
|
|
{
|
|
var lst = (from x in Funs.DB.Training_CompanyTrainingItem orderby x.CompanyTrainingItemCode select x).ToList();
|
|
if (!string.IsNullOrWhiteSpace(workPostId))
|
|
{
|
|
lst = lst.Where(x => x.WorkPostIds == null || x.WorkPostIds.Contains(workPostId)).ToList();
|
|
}
|
|
return lst;
|
|
}
|
|
|
|
|
|
#region BoundTree
|
|
|
|
/// <summary>
|
|
/// 加载培训教材
|
|
/// </summary>
|
|
/// <param name="myList"></param>
|
|
/// <param name="menuId"></param>
|
|
/// <param name="depth"></param>
|
|
public static void BoundTree(List<JQueryFeature> myList, string menuId, int depth)
|
|
{
|
|
var dt = GetNewTraining(menuId);
|
|
if (dt.Count() > 0)
|
|
{
|
|
foreach (var dr in dt)
|
|
{
|
|
myList.Add(new JQueryFeature(dr.CompanyTrainingId, dr.CompanyTrainingName, depth, false));
|
|
BoundTree(myList, dr.CompanyTrainingId, depth + 1);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
var item = Funs.DB.Training_CompanyTrainingItem.Where(x => x.CompanyTrainingId == menuId).OrderBy(x => x.CompanyTrainingItemCode);
|
|
if (item.Count() > 0)
|
|
{
|
|
foreach (var dr in item)
|
|
{
|
|
myList.Add(new JQueryFeature(dr.CompanyTrainingItemId, dr.CompanyTrainingItemName, depth, true));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 得到菜单方法
|
|
/// </summary>
|
|
/// <param name="parentId"></param>
|
|
/// <returns></returns>
|
|
public static List<Model.Training_CompanyTraining> GetNewTraining(string parentId)
|
|
{
|
|
return (from x in Funs.DB.Training_CompanyTraining where x.SupCompanyTrainingId == parentId orderby x.CompanyTrainingCode select x).ToList(); ;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |