196 lines
6.7 KiB
C#
196 lines
6.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace BLL
|
|
{
|
|
/// <summary>
|
|
/// 基础信息
|
|
/// </summary>
|
|
public static class ConstService
|
|
{
|
|
/// <summary>
|
|
/// 根据主键获取基础信息
|
|
/// </summary>
|
|
/// <param name="constId"></param>
|
|
/// <returns></returns>
|
|
public static Model.Base_Const GetConstById(string constId)
|
|
{
|
|
return Funs.DB.Base_Const.FirstOrDefault(e => e.ConstId == constId);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据Id获取基础信息名称
|
|
/// </summary>
|
|
/// <param name="constId"></param>
|
|
/// <returns></returns>
|
|
public static string GetConstTextById(string constId)
|
|
{
|
|
return (from x in Funs.DB.Base_Const where x.ConstId == constId select x.ConstText).FirstOrDefault();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据分组ID获取基础信息列表
|
|
/// </summary>
|
|
/// <param name="groupId"></param>
|
|
/// <returns></returns>
|
|
public static List<Model.Base_Const> GetConstListByGroupId(string groupId)
|
|
{
|
|
return (from x in Funs.DB.Base_Const where x.GroupId == groupId orderby x.ConstValue select x).ToList();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 增加基础信息
|
|
/// </summary>
|
|
/// <param name="consts"></param>
|
|
public static void AddConst(Model.Base_Const consts)
|
|
{
|
|
Model.Base_Const newConst = new Model.Base_Const();
|
|
newConst.ConstId = consts.ConstId;
|
|
newConst.ConstValue = consts.ConstValue;
|
|
newConst.ConstText = consts.ConstText;
|
|
newConst.GroupType = consts.GroupType;
|
|
newConst.GroupId = consts.GroupId;
|
|
Funs.DB.Base_Const.InsertOnSubmit(newConst);
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改基础信息
|
|
/// </summary>
|
|
/// <param name="consts"></param>
|
|
public static void UpdateConst(Model.Base_Const consts)
|
|
{
|
|
Model.Base_Const newConst = Funs.DB.Base_Const.FirstOrDefault(e => e.ConstId == consts.ConstId);
|
|
if (newConst != null)
|
|
{
|
|
newConst.ConstValue = consts.ConstValue;
|
|
newConst.ConstText = consts.ConstText;
|
|
newConst.GroupType = consts.GroupType;
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据主键删除基础信息
|
|
/// </summary>
|
|
/// <param name="constId"></param>
|
|
public static void DeleteConstById(string constId)
|
|
{
|
|
Model.Base_Const consts = Funs.DB.Base_Const.FirstOrDefault(e => e.ConstId == constId);
|
|
if (consts != null)
|
|
{
|
|
Funs.DB.Base_Const.DeleteOnSubmit(consts);
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据名称和组Id获取基础信息
|
|
/// </summary>
|
|
/// <param name="constText"></param>
|
|
/// <param name="groupId"></param>
|
|
/// <returns></returns>
|
|
public static Model.Base_Const GetConstListByTextAndGroupId(string constText, string groupId)
|
|
{
|
|
return Funs.DB.Base_Const.FirstOrDefault(e => e.ConstText == constText && e.GroupId == groupId);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 验证是否存在相同的值
|
|
/// </summary>
|
|
/// <param name="constValue"></param>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public static bool IsExitConstValue(string constValue, string id)
|
|
{
|
|
var q = Funs.DB.Base_Const.FirstOrDefault(x => x.ConstValue == constValue && x.ConstId != id);
|
|
if (q != null)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 是否存在相同的名称
|
|
/// </summary>
|
|
/// <param name="constText"></param>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public static bool IsExitConstText(string constText, string id)
|
|
{
|
|
var q = Funs.DB.Base_Const.FirstOrDefault(x => x.ConstText == constText && x.ConstId != id);
|
|
if (q != null)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取下拉框
|
|
/// </summary>
|
|
/// <param name="dropName"></param>
|
|
/// <param name="isShowPlease"></param>
|
|
public static void InitConstValueDropDownList(FineUIPro.DropDownList dropName,string groupId, bool isShowPlease)
|
|
{
|
|
dropName.DataValueField = "ConstValue";
|
|
dropName.DataTextField = "ConstText";
|
|
dropName.DataSource = BLL.ConstService.GetConstListByGroupId(groupId);
|
|
dropName.DataBind();
|
|
if (isShowPlease)
|
|
{
|
|
Funs.FineUIPleaseSelect(dropName);
|
|
}
|
|
}
|
|
|
|
public static void InitConstIdDropDownList(FineUIPro.DropDownList dropName, string groupId, bool isShowPlease)
|
|
{
|
|
dropName.DataValueField = "ConstId";
|
|
dropName.DataTextField = "ConstText";
|
|
dropName.DataSource = BLL.ConstService.GetConstListByGroupId(groupId);
|
|
dropName.DataBind();
|
|
if (isShowPlease)
|
|
{
|
|
Funs.FineUIPleaseSelect(dropName);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 只对项目状态的查询
|
|
/// </summary>
|
|
/// <param name="dropName"></param>
|
|
/// <param name="groupId"></param>
|
|
/// <param name="projectStatus"></param>
|
|
/// <param name="isShowPlease"></param>
|
|
public static void InitConstValueProjectStatus(FineUIPro.DropDownList dropName, string groupId, string projectStatus, bool isShowPlease)
|
|
{
|
|
|
|
dropName.DataValueField = "ConstValue";
|
|
dropName.DataTextField = "ConstText";
|
|
if (projectStatus == "2") // 非Other类型
|
|
{
|
|
dropName.DataSource = (from x in Funs.DB.Base_Const where x.GroupId == groupId && (x.GroupType=="1" ||x.GroupType == "2") orderby x.ConstValue select x).ToList();
|
|
}
|
|
else if (projectStatus == "3") //Other类型
|
|
{
|
|
dropName.DataSource = (from x in Funs.DB.Base_Const where x.GroupId == groupId && (x.GroupType == "1" || x.GroupType == "3") orderby x.ConstValue select x).ToList();
|
|
}
|
|
|
|
dropName.DataBind();
|
|
if (isShowPlease)
|
|
{
|
|
Funs.FineUIPleaseSelect(dropName);
|
|
}
|
|
}
|
|
}
|
|
}
|