CNCEC_SUBQHSE_WUHUAN/SGGL/BLL/Party/TwoOneGoodSelectionService.cs

126 lines
4.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BLL
{
/// <summary>
/// “两优一先”评选表
/// </summary>
public class TwoOneGoodSelectionService
{
/// <summary>
/// 根据主键获取“两优一先”评选表
/// </summary>
/// <param name="twoOneGoodSelectionId"></param>
/// <returns></returns>
public static Model.Party_TwoOneGoodSelection GetTwoOneGoodSelectionById(string twoOneGoodSelectionId)
{
return Funs.DB.Party_TwoOneGoodSelection.FirstOrDefault(e => e.TwoOneGoodSelectionId == twoOneGoodSelectionId);
}
/// <summary>
/// 根据类别获取字符串
/// </summary>
/// <param name="selectionType"></param>
/// <returns></returns>
public static string GetSelectionType(string selectionType)
{
string type = string.Empty;
if (selectionType == "1")
{
type = "优秀党员";
}
else if (selectionType == "2")
{
type = "优秀党务工作者";
}
else if (selectionType == "3")
{
type = "先进基层党支部";
}
return type;
}
/// <summary>
/// 根据主键获取当选人/党支部
/// </summary>
/// <param name="twoOneGoodSelectionId"></param>
/// <returns></returns>
public static string GetName(string twoOneGoodSelectionId)
{
string name = string.Empty;
Model.Party_TwoOneGoodSelection twoOneGoodSelection = Funs.DB.Party_TwoOneGoodSelection.FirstOrDefault(x=>x.TwoOneGoodSelectionId== twoOneGoodSelectionId);
if (twoOneGoodSelection != null)
{
if (twoOneGoodSelection.SelectionType == "3")
{
name = twoOneGoodSelection.PartyBranch;
}
else
{
Model.Party_Partyer partyer = Funs.DB.Party_Partyer.FirstOrDefault(x=>x.PartyerId==twoOneGoodSelection.PartyerId);
if (partyer != null)
{
name = partyer.Name;
}
}
}
return name;
}
/// <summary>
/// 添加“两优一先”评选表
/// </summary>
/// <param name="twoOneGoodSelection"></param>
public static void AddTwoOneGoodSelection(Model.Party_TwoOneGoodSelection twoOneGoodSelection)
{
Model.Party_TwoOneGoodSelection newTwoOneGoodSelection = new Model.Party_TwoOneGoodSelection
{
TwoOneGoodSelectionId = twoOneGoodSelection.TwoOneGoodSelectionId,
Year = twoOneGoodSelection.Year,
SelectionType = twoOneGoodSelection.SelectionType,
PartyerId = twoOneGoodSelection.PartyerId,
PartyBranch = twoOneGoodSelection.PartyBranch,
CompileMan = twoOneGoodSelection.CompileMan,
CompileDate = twoOneGoodSelection.CompileDate
};
Funs.DB.Party_TwoOneGoodSelection.InsertOnSubmit(newTwoOneGoodSelection);
Funs.DB.SubmitChanges();
}
/// <summary>
/// 修改“两优一先”评选表
/// </summary>
/// <param name="twoOneGoodSelection"></param>
public static void UpdateTwoOneGoodSelection(Model.Party_TwoOneGoodSelection twoOneGoodSelection)
{
Model.Party_TwoOneGoodSelection newTwoOneGoodSelection = Funs.DB.Party_TwoOneGoodSelection.FirstOrDefault(e => e.TwoOneGoodSelectionId == twoOneGoodSelection.TwoOneGoodSelectionId);
if (newTwoOneGoodSelection != null)
{
newTwoOneGoodSelection.SelectionType = twoOneGoodSelection.SelectionType;
newTwoOneGoodSelection.PartyerId = twoOneGoodSelection.PartyerId;
newTwoOneGoodSelection.PartyBranch = twoOneGoodSelection.PartyBranch;
Funs.DB.SubmitChanges();
}
}
/// <summary>
/// 根据主键删除“两优一先”评选表
/// </summary>
/// <param name="twoOneGoodSelectionId"></param>
public static void DeleteTwoOneGoodSelectionById(string twoOneGoodSelectionId)
{
Model.Party_TwoOneGoodSelection twoOneGoodSelection = Funs.DB.Party_TwoOneGoodSelection.FirstOrDefault(e => e.TwoOneGoodSelectionId == twoOneGoodSelectionId);
if (twoOneGoodSelection != null)
{
CommonService.DeleteAttachFileById(twoOneGoodSelectionId);
Funs.DB.Party_TwoOneGoodSelection.DeleteOnSubmit(twoOneGoodSelection);
Funs.DB.SubmitChanges();
}
}
}
}