using System; using System.Collections.Generic; using System.Data; using System.Linq; namespace BLL { public class RewardAndPunishApproveService { public static Model.SGGLDB db = Funs.DB; /// /// 获取质量奖罚模板列表 /// /// /// /// 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); } /// /// 根据质量奖罚编号删除对应的所有质量奖罚审批信息 /// /// 质量奖罚编号 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(); } /// /// 获取登录人的通知信息 /// /// /// /// 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(); } } /// /// 更新通知信息提醒 /// /// /// /// 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(); } } } /// /// 根据质量奖罚编号获取一个质量奖罚审批信息 /// /// 质量奖罚编号 /// 一个质量奖罚审批实体 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); } /// /// 修改质量奖罚审批信息 /// /// 质量奖罚审批实体 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(); } /// /// 增加质量奖罚审批信息 /// /// 质量奖罚审批实体 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(); } /// /// 总包专业工程师审核信息 /// /// /// 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); } } }