Files
SGGL_SHJ/SGGL/BLL/CQMS/RewardAndPunish/RewardAndPunishService.cs
T
2023-03-16 14:35:01 +08:00

188 lines
8.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.UI.WebControls;
namespace BLL
{
/// <summary>
/// 质量奖罚
/// </summary>
public static class RewardAndPunishService
{
public static Model.SGGLDB db = Funs.DB;
/// <summary>
/// 根据主键获取质量奖罚
/// </summary>
/// <param name="RewardAndPunishId"></param>
/// <returns></returns>
public static Model.RewardAndPunish_RewardAndPunish GetRewardAndPunishById(string RewardAndPunishId)
{
return Funs.DB.RewardAndPunish_RewardAndPunish.FirstOrDefault(e => e.RewardAndPunishId == RewardAndPunishId);
}
/// <summary>
/// 添加质量奖罚
/// </summary>
/// <param name="RewardAndPunish"></param>
public static void AddRewardAndPunish(Model.RewardAndPunish_RewardAndPunish RewardAndPunish)
{
Model.SGGLDB db = Funs.DB;
Model.RewardAndPunish_RewardAndPunish newRewardAndPunish = new Model.RewardAndPunish_RewardAndPunish
{
RewardAndPunishId = RewardAndPunish.RewardAndPunishId,
ProjectId = RewardAndPunish.ProjectId,
RewardAndPunishCode = RewardAndPunish.RewardAndPunishCode,
UnitId = RewardAndPunish.UnitId,
Type = RewardAndPunish.Type,
RewardAndPunishTypeId = RewardAndPunish.RewardAndPunishTypeId,
RewardAndPunishBasis = RewardAndPunish.RewardAndPunishBasis,
RewardAndPunishDecision = RewardAndPunish.RewardAndPunishDecision,
State = RewardAndPunish.State,
CompileMan = RewardAndPunish.CompileMan,
CompileDate = RewardAndPunish.CompileDate,
};
db.RewardAndPunish_RewardAndPunish.InsertOnSubmit(newRewardAndPunish);
db.SubmitChanges();
}
/// <summary>
/// 修改质量奖罚
/// </summary>
/// <param name="RewardAndPunish"></param>
public static void UpdateRewardAndPunish(Model.RewardAndPunish_RewardAndPunish RewardAndPunish)
{
Model.SGGLDB db = Funs.DB;
Model.RewardAndPunish_RewardAndPunish newRewardAndPunish = db.RewardAndPunish_RewardAndPunish.FirstOrDefault(e => e.RewardAndPunishId == RewardAndPunish.RewardAndPunishId);
if (newRewardAndPunish != null)
{
newRewardAndPunish.RewardAndPunishCode = RewardAndPunish.RewardAndPunishCode;
newRewardAndPunish.UnitId = RewardAndPunish.UnitId;
newRewardAndPunish.Type = RewardAndPunish.Type;
newRewardAndPunish.RewardAndPunishTypeId = RewardAndPunish.RewardAndPunishTypeId;
newRewardAndPunish.RewardAndPunishBasis = RewardAndPunish.RewardAndPunishBasis;
newRewardAndPunish.RewardAndPunishDecision = RewardAndPunish.RewardAndPunishDecision;
newRewardAndPunish.State = RewardAndPunish.State;
db.SubmitChanges();
}
}
/// <summary>
/// 根据主键删除质量奖罚
/// </summary>
/// <param name="RewardAndPunishId"></param>
public static void DeleteRewardAndPunishById(string RewardAndPunishId)
{
Model.SGGLDB db = Funs.DB;
Model.RewardAndPunish_RewardAndPunish RewardAndPunish = db.RewardAndPunish_RewardAndPunish.FirstOrDefault(e => e.RewardAndPunishId == RewardAndPunishId);
if (RewardAndPunish != null)
{
BLL.CommonService.DeleteAttachFileById(RewardAndPunishId);
db.RewardAndPunish_RewardAndPunish.DeleteOnSubmit(RewardAndPunish);
db.SubmitChanges();
}
}
/// <summary>
/// 根据状态选择下一步办理类型
/// </summary>
/// <param name="state"></param>
/// <returns></returns>
public static ListItem[] GetDHandleTypeByState(string state)
{
if (state == Const.RewardAndPunish_Compile || state == Const.RewardAndPunish_ReCompile)
{
ListItem[] lis = new ListItem[1];
lis[0] = new ListItem("质量经理审核", Const.RewardAndPunish_Audit1);
return lis;
}
else if (state == Const.RewardAndPunish_Audit1)
{
ListItem[] lis = new ListItem[2];
lis[0] = new ListItem("项目经理批准", Const.RewardAndPunish_Audit2);
lis[1] = new ListItem("重新编制", Const.RewardAndPunish_ReCompile);
return lis;
}
else if (state == Const.RewardAndPunish_Audit2)
{
ListItem[] lis = new ListItem[2];
lis[0] = new ListItem("审批完成", Const.RewardAndPunish_Complete);
lis[1] = new ListItem("重新编制", Const.RewardAndPunish_ReCompile);
return lis;
}
else
return null;
}
//public static List<Model.Meeting_CQMSMeeting> getListDataForApi(string projectId, int startRowIndex, int maximumRows, string type)
//{
// using (var db = new Model.SGGLDB(Funs.ConnString))
// {
// IQueryable<Model.RewardAndPunish_RewardAndPunish> q = db.RewardAndPunish_RewardAndPunish;
// if (!string.IsNullOrEmpty(projectId))
// {
// q = q.Where(e => e.ProjectId == projectId);
// }
// if (type!="0")
// {
// q = q.Where(e => e.Type == type);
// }
// var qres = from x in q
// orderby x.CompileDate descending
// select new
// {
// x.MeetingId,
// x.ProjectId,
// x.UnitId,
// UnitName = (from y in db.Base_Unit where y.UnitId == x.UnitId select y.UnitName).First(),
// x.MeetingType,
// MeetingTypeStr = x.MeetingType == "M" ? "质量月例会" : "质量专题会",
// x.MeetingCode,
// x.MeetingDate,
// x.Place,
// x.HostMan,
// HostManName = BLL.Person_PersonsService.getPersonsNamesPersonIds(x.HostMan),
// x.AttentPerson,
// AttentPersonName = BLL.Person_PersonsService.getPersonsNamesPersonIds(x.AttentPerson),
// x.AttentPersonNum,
// x.MeetingTheme,
// x.MeetingContents,
// x.CompileDate,
// x.CompileMan,
// x.State,
// StateStr = ConvertState(x.State),
// CompileManName = (from y in db.Person_Persons where y.PersonId == x.CompileMan select y.PersonName).First(),
// HandleManName = BLL.CQMS_MeetingApproveService.GetHandleManName(x.MeetingId),
// x.AttachUrl,
// };
// List<Model.Meeting_CQMSMeeting> res = new List<Model.Meeting_CQMSMeeting>();
// var list = qres.Skip(startRowIndex).Take(maximumRows).ToList();
// foreach (var item in list)
// {
// Model.Meeting_CQMSMeeting cd = new Model.Meeting_CQMSMeeting();
// cd.MeetingId = item.MeetingId;
// cd.ProjectId = item.ProjectId;
// cd.UnitId = item.UnitId + "$" + item.UnitName;
// cd.MeetingType = item.MeetingType + "$" + item.MeetingTypeStr;
// cd.MeetingCode = item.MeetingCode;
// cd.MeetingDate = item.MeetingDate;
// cd.Place = item.Place;
// cd.HostMan = item.HostMan + "$" + item.HostManName;
// cd.AttentPerson = item.AttentPerson + "$" + item.AttentPersonName;
// cd.AttentPersonNum = item.AttentPersonNum;
// cd.MeetingTheme = item.MeetingTheme;
// cd.MeetingContents = item.MeetingContents;
// cd.CompileDate = item.CompileDate;
// cd.CompileMan = item.CompileMan + "$" + item.CompileManName;
// cd.State = item.State + "$" + item.StateStr + "$" + item.HandleManName;
// cd.AttachUrl = AttachFileService.getFileUrl(item.MeetingId);
// res.Add(cd);
// }
// return res;
// }
//}
}
}