using System.Collections.Generic; using System.Linq; namespace BLL { public static class CQMSTrainObjectService { /// /// 根据主键获取培训对象 /// /// /// public static Model.Base_CQMSTrainObject GetTrainObjectById(string trainObjectId) { return Funs.DB.Base_CQMSTrainObject.FirstOrDefault(e => e.TrainObjectId == trainObjectId); } /// /// 根据主键获取培训对象 /// /// /// public static string GetTrainObjectNameById(string trainObjectId) { string name = string.Empty; var o = Funs.DB.Base_CQMSTrainObject.FirstOrDefault(e => e.TrainObjectId == trainObjectId); if (o != null) { name = o.TrainObjectName; } return name; } /// /// 添加培训对象 /// /// public static void AddTrainObject(Model.Base_CQMSTrainObject trainObject) { Model.SGGLDB db = Funs.DB; Model.Base_CQMSTrainObject newTrainObject = new Model.Base_CQMSTrainObject { TrainObjectId = trainObject.TrainObjectId, TrainObjectCode = trainObject.TrainObjectCode, TrainObjectName = trainObject.TrainObjectName, Remark = trainObject.Remark, }; db.Base_CQMSTrainObject.InsertOnSubmit(newTrainObject); db.SubmitChanges(); } /// /// 修改培训对象 /// /// public static void UpdateTrainObject(Model.Base_CQMSTrainObject trainObject) { Model.SGGLDB db = Funs.DB; Model.Base_CQMSTrainObject newTrainObject = db.Base_CQMSTrainObject.FirstOrDefault(e => e.TrainObjectId == trainObject.TrainObjectId); if (newTrainObject != null) { newTrainObject.TrainObjectCode = trainObject.TrainObjectCode; newTrainObject.TrainObjectName = trainObject.TrainObjectName; newTrainObject.Remark = trainObject.Remark; db.SubmitChanges(); } } /// /// 根据主键删除培训对象 /// /// public static void DeleteTrainObjectById(string trainObjectId) { Model.SGGLDB db = Funs.DB; Model.Base_CQMSTrainObject trainObject = db.Base_CQMSTrainObject.FirstOrDefault(e => e.TrainObjectId == trainObjectId); if (trainObject != null) { db.Base_CQMSTrainObject.DeleteOnSubmit(trainObject); db.SubmitChanges(); } } /// /// 获取培训对象列表 /// /// public static List GetTrainObjectList() { return (from x in Funs.DB.Base_CQMSTrainObject orderby x.TrainObjectCode select x).ToList(); } #region 培训对象下拉框 /// /// 培训对象下拉框 /// /// 下拉框名字 /// 是否显示请选择 public static void InitTrainObjectDropDownList(FineUIPro.DropDownList dropName, bool isShowPlease) { dropName.DataValueField = "TrainObjectId"; dropName.DataTextField = "TrainObjectName"; dropName.DataSource = GetTrainObjectList(); dropName.DataBind(); if (isShowPlease) { Funs.FineUIPleaseSelect(dropName); } } #endregion } }