160 lines
7.8 KiB
C#
160 lines
7.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
|
|
namespace BLL
|
|
{
|
|
public class RewardAndPunishApproveService
|
|
{
|
|
public static Model.SGGLDB db = Funs.DB;
|
|
/// <summary>
|
|
/// 获取质量奖罚模板列表
|
|
/// </summary>
|
|
/// <param name="satartRowIndex"></param>
|
|
/// <param name="maximumRows"></param>
|
|
/// <returns></returns>
|
|
public static DataTable getListData(string RewardAndPunishId)
|
|
{
|
|
var res = from x in db.RewardAndPunish_RewardAndPunishApprove
|
|
where x.RewardAndPunishId == RewardAndPunishId && x.ApproveDate != null && x.ApproveType != "S"
|
|
orderby x.ApproveDate
|
|
select new
|
|
{
|
|
x.RewardAndPunishApproveId,
|
|
x.RewardAndPunishId,
|
|
ApproveMan = (from y in db.Person_Persons where y.PersonId == x.ApproveMan select y.PersonName).First(),
|
|
x.ApproveDate,
|
|
x.IsAgree,
|
|
x.ApproveIdea,
|
|
x.ApproveType,
|
|
};
|
|
return Funs.LINQToDataTable(res);
|
|
}
|
|
/// <summary>
|
|
/// 根据质量奖罚编号删除对应的所有质量奖罚审批信息
|
|
/// </summary>
|
|
/// <param name="RewardAndPunishId">质量奖罚编号</param>
|
|
public static void DeleteRewardAndPunishApprovesByRewardAndPunishId(string RewardAndPunishId)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
var q = (from x in db.RewardAndPunish_RewardAndPunishApprove where x.RewardAndPunishId == RewardAndPunishId select x).ToList();
|
|
db.RewardAndPunish_RewardAndPunishApprove.DeleteAllOnSubmit(q);
|
|
db.SubmitChanges();
|
|
}
|
|
/// <summary>
|
|
/// 获取登录人的通知信息
|
|
/// </summary>
|
|
/// <param name="RewardAndPunishId"></param>
|
|
/// <param name="userId"></param>
|
|
/// <returns></returns>
|
|
public static IQueryable getList(string userId)
|
|
{
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
var res = from x in db.RewardAndPunish_RewardAndPunishApprove
|
|
join ca in db.RewardAndPunish_RewardAndPunish on x.RewardAndPunishId equals ca.RewardAndPunishId
|
|
where x.ApproveDate == null && x.ApproveType == "S" && x.ApproveMan == userId
|
|
orderby x.ApproveDate
|
|
select new
|
|
{
|
|
//x.RewardAndPunishApproveId,
|
|
x.RewardAndPunishId,
|
|
//x.ApproveDate,
|
|
//x.IsAgree,
|
|
//x.ApproveIdea,
|
|
//x.ApproveType,
|
|
ca.RewardAndPunishCode
|
|
};
|
|
return res.AsQueryable().Distinct();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 更新通知信息提醒
|
|
/// </summary>
|
|
/// <param name="RewardAndPunishId"></param>
|
|
/// <param name="userId"></param>
|
|
/// <returns></returns>
|
|
public static Model.RewardAndPunish_RewardAndPunishApprove GetSee(string RewardAndPunishId, string userId)
|
|
{
|
|
return db.RewardAndPunish_RewardAndPunishApprove.FirstOrDefault(x => x.RewardAndPunishId == RewardAndPunishId && x.ApproveType == "S" && x.ApproveMan == userId && x.ApproveDate == null);
|
|
}
|
|
public static void See(string RewardAndPunishId, string userId)
|
|
{
|
|
using (var db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
var res = db.RewardAndPunish_RewardAndPunishApprove.FirstOrDefault(x => x.RewardAndPunishId == RewardAndPunishId && x.ApproveType == "S" && x.ApproveMan == userId && x.ApproveDate == null);
|
|
if (res != null)
|
|
{
|
|
res.ApproveDate = DateTime.Now;
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 根据质量奖罚编号获取一个质量奖罚审批信息
|
|
/// </summary>
|
|
/// <param name="RewardAndPunishId">质量奖罚编号</param>
|
|
/// <returns>一个质量奖罚审批实体</returns>
|
|
public static Model.RewardAndPunish_RewardAndPunishApprove GetRewardAndPunishApproveByRewardAndPunishId(string RewardAndPunishId)
|
|
{
|
|
return db.RewardAndPunish_RewardAndPunishApprove.FirstOrDefault(x => x.RewardAndPunishId == RewardAndPunishId && x.ApproveType != "S" && x.ApproveDate == null);
|
|
}
|
|
public static Model.RewardAndPunish_RewardAndPunishApprove GetAuditMan(string RewardAndPunishId, string state)
|
|
{
|
|
return db.RewardAndPunish_RewardAndPunishApprove.OrderByDescending(x => x.ApproveDate).FirstOrDefault(x => x.RewardAndPunishId == RewardAndPunishId && x.ApproveType == state);
|
|
}
|
|
/// <summary>
|
|
/// 修改质量奖罚审批信息
|
|
/// </summary>
|
|
/// <param name="managerRuleApprove">质量奖罚审批实体</param>
|
|
public static void UpdateRewardAndPunishApprove(Model.RewardAndPunish_RewardAndPunishApprove approve)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.RewardAndPunish_RewardAndPunishApprove newApprove = db.RewardAndPunish_RewardAndPunishApprove.First(e => e.RewardAndPunishApproveId == approve.RewardAndPunishApproveId && e.ApproveDate == null);
|
|
newApprove.RewardAndPunishId = approve.RewardAndPunishId;
|
|
newApprove.ApproveMan = approve.ApproveMan;
|
|
newApprove.ApproveDate = approve.ApproveDate;
|
|
newApprove.ApproveIdea = approve.ApproveIdea;
|
|
newApprove.IsAgree = approve.IsAgree;
|
|
newApprove.ApproveType = approve.ApproveType;
|
|
|
|
db.SubmitChanges();
|
|
}
|
|
/// <summary>
|
|
/// 增加质量奖罚审批信息
|
|
/// </summary>
|
|
/// <param name="managerRuleApprove">质量奖罚审批实体</param>
|
|
public static void AddRewardAndPunishApprove(Model.RewardAndPunish_RewardAndPunishApprove approve)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
string newKeyID = SQLHelper.GetNewID(typeof(Model.RewardAndPunish_RewardAndPunishApprove));
|
|
Model.RewardAndPunish_RewardAndPunishApprove newApprove = new Model.RewardAndPunish_RewardAndPunishApprove();
|
|
newApprove.RewardAndPunishApproveId = newKeyID;
|
|
newApprove.RewardAndPunishId = approve.RewardAndPunishId;
|
|
newApprove.ApproveMan = approve.ApproveMan;
|
|
newApprove.ApproveDate = approve.ApproveDate;
|
|
newApprove.ApproveIdea = approve.ApproveIdea;
|
|
newApprove.IsAgree = approve.IsAgree;
|
|
newApprove.ApproveType = approve.ApproveType;
|
|
db.RewardAndPunish_RewardAndPunishApprove.InsertOnSubmit(newApprove);
|
|
db.SubmitChanges();
|
|
|
|
}
|
|
/// <summary>
|
|
/// 总包专业工程师审核信息
|
|
/// </summary>
|
|
/// <param name="RewardAndPunishId"></param>
|
|
/// <returns></returns>
|
|
public static Model.RewardAndPunish_RewardAndPunishApprove GetAudit1(string RewardAndPunishId)
|
|
{
|
|
return db.RewardAndPunish_RewardAndPunishApprove.OrderByDescending(x => x.ApproveDate).FirstOrDefault(x => x.RewardAndPunishId == RewardAndPunishId && x.ApproveType == BLL.Const.RewardAndPunish_Audit1);
|
|
}
|
|
|
|
public static Model.RewardAndPunish_RewardAndPunishApprove GetComplie(string RewardAndPunishId)
|
|
{
|
|
return db.RewardAndPunish_RewardAndPunishApprove.FirstOrDefault(x => x.RewardAndPunishId == RewardAndPunishId && x.ApproveType == BLL.Const.RewardAndPunish_Compile);
|
|
}
|
|
}
|
|
}
|