SGGL_SHJ/SGGL/BLL/BaseInfo/CQMSTrainObjectService.cs

117 lines
4.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BLL
{
public static class CQMSTrainObjectService
{
/// <summary>
/// 根据主键获取培训对象
/// </summary>
/// <param name="trainObjectId"></param>
/// <returns></returns>
public static Model.Base_CQMSTrainObject GetTrainObjectById(string trainObjectId)
{
return Funs.DB.Base_CQMSTrainObject.FirstOrDefault(e => e.TrainObjectId == trainObjectId);
}
/// <summary>
/// 根据主键获取培训对象
/// </summary>
/// <param name="trainObjectId"></param>
/// <returns></returns>
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;
}
/// <summary>
/// 添加培训对象
/// </summary>
/// <param name="trainObject"></param>
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();
}
/// <summary>
/// 修改培训对象
/// </summary>
/// <param name="trainObject"></param>
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();
}
}
/// <summary>
/// 根据主键删除培训对象
/// </summary>
/// <param name="trainObjectId"></param>
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();
}
}
/// <summary>
/// 获取培训对象列表
/// </summary>
/// <returns></returns>
public static List<Model.Base_CQMSTrainObject> GetTrainObjectList()
{
return (from x in Funs.DB.Base_CQMSTrainObject orderby x.TrainObjectCode select x).ToList();
}
#region
/// <summary>
/// 培训对象下拉框
/// </summary>
/// <param name="dropName">下拉框名字</param>
/// <param name="isShowPlease">是否显示请选择</param>
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
}
}