CNCEC_SUBQHSE_WUHUAN/SGGL/BLL/CQMS/Check/RewardAndPunishService.cs

152 lines
6.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI.WebControls;
namespace BLL
{
public class RewardAndPunishService
{
/// <summary>
/// 获取施工图纸信息
/// </summary>
/// <param name="UnitWorkId"></param>
/// <returns></returns>
public static Model.Check_RewardAndPunish GetRewardAndPunishById(string RewardAndPunishID)
{
return Funs.DB.Check_RewardAndPunish.FirstOrDefault(e => e.RewardAndPunishID == RewardAndPunishID);
}
/// <summary>
/// 添加施工图纸信息
/// </summary>
/// <param name="WPQ"></param>
public static void AddRewardAndPunish(Model.Check_RewardAndPunish RewardAndPunish)
{
Model.SGGLDB db = Funs.DB;
Model.Check_RewardAndPunish newRewardAndPunish = new Model.Check_RewardAndPunish();
newRewardAndPunish.RewardAndPunishID = RewardAndPunish.RewardAndPunishID;
newRewardAndPunish.ProjectId = RewardAndPunish.ProjectId;
newRewardAndPunish.CreateMan = RewardAndPunish.CreateMan;
newRewardAndPunish.Date = RewardAndPunish.Date;
newRewardAndPunish.Description = RewardAndPunish.Description;
newRewardAndPunish.Money = RewardAndPunish.Money;
newRewardAndPunish.Type = RewardAndPunish.Type;
newRewardAndPunish.ResponseUnit = RewardAndPunish.ResponseUnit;
newRewardAndPunish.NoticeUnit = RewardAndPunish.NoticeUnit;
newRewardAndPunish.RewardAndPunishType = RewardAndPunish.RewardAndPunishType;
newRewardAndPunish.RewardAndPunishCode = RewardAndPunish.RewardAndPunishCode;
newRewardAndPunish.RewardAndPunishMan = RewardAndPunish.RewardAndPunishMan;
newRewardAndPunish.TeamGroupId = RewardAndPunish.TeamGroupId;
newRewardAndPunish.Remark = RewardAndPunish.Remark;
newRewardAndPunish.DataSource = RewardAndPunish.DataSource;
newRewardAndPunish.HazardRegisterId = RewardAndPunish.HazardRegisterId;
newRewardAndPunish.SysTemType = RewardAndPunish.SysTemType;
db.Check_RewardAndPunish.InsertOnSubmit(newRewardAndPunish);
db.SubmitChanges();
}
/// <summary>
/// 修改施工图纸信息
/// </summary>
/// <param name="WPQ"></param>
public static void UpdateRewardAndPunish(Model.Check_RewardAndPunish RewardAndPunish)
{
Model.SGGLDB db = Funs.DB;
Model.Check_RewardAndPunish newRewardAndPunish = db.Check_RewardAndPunish.FirstOrDefault(e => e.RewardAndPunishID == RewardAndPunish.RewardAndPunishID);
if (newRewardAndPunish != null)
{
newRewardAndPunish.RewardAndPunishID = RewardAndPunish.RewardAndPunishID;
newRewardAndPunish.ProjectId = RewardAndPunish.ProjectId;
newRewardAndPunish.CreateMan = RewardAndPunish.CreateMan;
newRewardAndPunish.Date = RewardAndPunish.Date;
newRewardAndPunish.Description = RewardAndPunish.Description;
newRewardAndPunish.Money = RewardAndPunish.Money;
newRewardAndPunish.Type = RewardAndPunish.Type;
newRewardAndPunish.ResponseUnit = RewardAndPunish.ResponseUnit;
newRewardAndPunish.NoticeUnit = RewardAndPunish.NoticeUnit;
newRewardAndPunish.RewardAndPunishType = RewardAndPunish.RewardAndPunishType;
newRewardAndPunish.RewardAndPunishCode = RewardAndPunish.RewardAndPunishCode;
newRewardAndPunish.RewardAndPunishMan = RewardAndPunish.RewardAndPunishMan;
newRewardAndPunish.TeamGroupId = RewardAndPunish.TeamGroupId;
newRewardAndPunish.Remark = RewardAndPunish.Remark;
newRewardAndPunish.DataSource = RewardAndPunish.DataSource;
newRewardAndPunish.HazardRegisterId = RewardAndPunish.HazardRegisterId;
newRewardAndPunish.SysTemType = RewardAndPunish.SysTemType;
db.SubmitChanges();
}
}
/// <summary>
/// 根据主键删除施工图纸信息
/// </summary>
/// <param name="checkerId"></param>
public static void DeleteRewardAndPunishById(string RewardAndPunishID)
{
Model.SGGLDB db = Funs.DB;
Model.Check_RewardAndPunish RewardAndPunish = db.Check_RewardAndPunish.FirstOrDefault(e => e.RewardAndPunishID == RewardAndPunishID);
if (RewardAndPunish != null)
{
db.Check_RewardAndPunish.DeleteOnSubmit(RewardAndPunish);
db.SubmitChanges();
}
}
public static void InitTypeDropDownList(FineUIPro.DropDownList dropName)
{
ListItem[] list = new ListItem[2];
list[0] = new ListItem("奖励通知单", "0");
list[1] = new ListItem("处罚通知单", "1");
dropName.DataValueField = "Value";
dropName.DataTextField = "Text";
dropName.DataSource = list;
dropName.DataBind();
Funs.FineUIPleaseSelect(dropName);
}
/// <summary>
/// 根据巡检主键删除
/// </summary>
/// <param name="checkerId"></param>
public static void DeleteRewardAndPunishByHazardRegisterId(string HazardRegisterId)
{
Model.SGGLDB db = Funs.DB;
Model.Check_RewardAndPunish RewardAndPunish = db.Check_RewardAndPunish.FirstOrDefault(e => e.HazardRegisterId == HazardRegisterId);
if (RewardAndPunish != null)
{
db.Check_RewardAndPunish.DeleteOnSubmit(RewardAndPunish);
db.SubmitChanges();
}
}
/// <summary>
/// 获取最大编号
/// </summary>
/// <param name="SysTemType"></param>
/// <param name="type"></param>
/// <returns></returns>
public static string getCode(string SysTemType, string type)
{
var maxCode = Funs.DB.Check_RewardAndPunish
.Where(x => x.SysTemType == SysTemType && x.RewardAndPunishCode.Contains(type))
.Max(x => x.RewardAndPunishCode);
if (maxCode != null)
{
//取最后5 位
var code = maxCode.Substring(maxCode.Length - 5);
var codeNum = int.Parse(code);
codeNum++;
return $"{type}{codeNum:D5}";
}
else
{
return $"{type}00001";
}
}
}
}