137 lines
4.7 KiB
C#
137 lines
4.7 KiB
C#
|
|
namespace BLL;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using System.Linq;
|
||
|
|
public class MaterialUnitService
|
||
|
|
{
|
||
|
|
/// <summary>
|
||
|
|
/// 根据主键获取信息
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="groupId"></param>
|
||
|
|
/// <returns></returns>
|
||
|
|
public static Model.Base_MaterialUnit GetMaterialUnitById(string materialUnitId)
|
||
|
|
{
|
||
|
|
return Funs.DB.Base_MaterialUnit.FirstOrDefault(e => e.MaterialUnitId == materialUnitId);
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 根据名称获取信息
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="groupId"></param>
|
||
|
|
/// <returns></returns>
|
||
|
|
public static Model.Base_MaterialUnit GetMaterialUnitByName(string materialUnitName)
|
||
|
|
{
|
||
|
|
return Funs.DB.Base_MaterialUnit.FirstOrDefault(e => e.MaterialUnitName == materialUnitName);
|
||
|
|
}
|
||
|
|
|
||
|
|
#region 根据职称ID得到职称名称
|
||
|
|
/// <summary>
|
||
|
|
/// 根据职称ID得到职称名称
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="MaterialUnitId"></param>
|
||
|
|
/// <returns></returns>
|
||
|
|
public static string GetMaterialUnitNameById(string MaterialUnitId)
|
||
|
|
{
|
||
|
|
string MaterialUnitName = string.Empty;
|
||
|
|
if (!string.IsNullOrEmpty(MaterialUnitId))
|
||
|
|
{
|
||
|
|
var q = GetMaterialUnitById(MaterialUnitId);
|
||
|
|
if (q != null)
|
||
|
|
{
|
||
|
|
MaterialUnitName = q.MaterialUnitName;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return MaterialUnitName;
|
||
|
|
}
|
||
|
|
#endregion
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 添加职称信息
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="?"></param>
|
||
|
|
public static void AddMaterialUnit(Model.Base_MaterialUnit postTitle)
|
||
|
|
{
|
||
|
|
Model.SGGLDB db = Funs.DB;
|
||
|
|
Model.Base_MaterialUnit newMaterialUnit = new Model.Base_MaterialUnit
|
||
|
|
{
|
||
|
|
MaterialUnitId = postTitle.MaterialUnitId,
|
||
|
|
MaterialUnitCode = postTitle.MaterialUnitCode,
|
||
|
|
MaterialUnitName = postTitle.MaterialUnitName,
|
||
|
|
Remark = postTitle.Remark
|
||
|
|
};
|
||
|
|
|
||
|
|
db.Base_MaterialUnit.InsertOnSubmit(newMaterialUnit);
|
||
|
|
db.SubmitChanges();
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 修改职称信息
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="teamGroup"></param>
|
||
|
|
public static void UpdateMaterialUnit(Model.Base_MaterialUnit postTitle)
|
||
|
|
{
|
||
|
|
Model.SGGLDB db = Funs.DB;
|
||
|
|
Model.Base_MaterialUnit newMaterialUnit = db.Base_MaterialUnit.FirstOrDefault(e => e.MaterialUnitId == postTitle.MaterialUnitId);
|
||
|
|
if (newMaterialUnit != null)
|
||
|
|
{
|
||
|
|
newMaterialUnit.MaterialUnitCode = postTitle.MaterialUnitCode;
|
||
|
|
newMaterialUnit.MaterialUnitName = postTitle.MaterialUnitName;
|
||
|
|
newMaterialUnit.Remark = postTitle.Remark;
|
||
|
|
db.SubmitChanges();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 根据职称主键删除对应职称信息
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="materialUnitId"></param>
|
||
|
|
public static void DeleteMaterialUnitById(string materialUnitId)
|
||
|
|
{
|
||
|
|
Model.SGGLDB db = Funs.DB;
|
||
|
|
Model.Base_MaterialUnit postTitle = db.Base_MaterialUnit.FirstOrDefault(e => e.MaterialUnitId == materialUnitId);
|
||
|
|
{
|
||
|
|
db.Base_MaterialUnit.DeleteOnSubmit(postTitle);
|
||
|
|
db.SubmitChanges();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 获取类别下拉项
|
||
|
|
/// </summary>
|
||
|
|
/// <returns></returns>
|
||
|
|
public static List<Model.Base_MaterialUnit> GetMaterialUnitList()
|
||
|
|
{
|
||
|
|
var list = (from x in Funs.DB.Base_MaterialUnit orderby x.MaterialUnitCode select x).ToList();
|
||
|
|
return list;
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 获取职称下拉选项
|
||
|
|
/// </summary>
|
||
|
|
/// <returns></returns>
|
||
|
|
public static List<Model.Base_MaterialUnit> GetMaterialUnitDropDownList()
|
||
|
|
{
|
||
|
|
var list = (from x in Funs.DB.Base_MaterialUnit orderby x.MaterialUnitCode select x).ToList();
|
||
|
|
return list;
|
||
|
|
}
|
||
|
|
|
||
|
|
#region 表下拉框
|
||
|
|
/// <summary>
|
||
|
|
/// 表下拉框
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="dropName">下拉框名字</param>
|
||
|
|
/// <param name="isShowPlease">是否显示请选择</param>
|
||
|
|
public static void InitMaterialUnitDropDownList(FineUIPro.DropDownList dropName, bool isShowPlease)
|
||
|
|
{
|
||
|
|
dropName.DataValueField = "MaterialUnitId";
|
||
|
|
dropName.DataTextField = "MaterialUnitName";
|
||
|
|
dropName.DataSource = BLL.MaterialUnitService.GetMaterialUnitList();
|
||
|
|
dropName.DataBind();
|
||
|
|
if (isShowPlease)
|
||
|
|
{
|
||
|
|
Funs.FineUIPleaseSelect(dropName);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
#endregion
|
||
|
|
|
||
|
|
}
|