SGGL_HBAZ/SGGL/BLL/HSSE/Technique/AwardStandardsService.cs

183 lines
6.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BLL
{
public class AwardStandardsService
{
public static Model.SGGLDB db = Funs.DB;
/// <summary>
/// 根据主键获取
/// </summary>
/// <param name="AwardStandardsId"></param>
/// <returns></returns>
public static Model.Technique_AwardStandards GetAwardStandardsListById(string AwardStandardsId)
{
return Funs.DB.Technique_AwardStandards.FirstOrDefault(e =>
e.AwardStandardsId == AwardStandardsId);
}
/// <summary>
/// 获取集合
/// </summary>
/// <param name="AwardStandardsId"></param>
/// <returns></returns>
public static List<AwardStandardsItem> GetAwardStandardsList(int PageNumber, int PageSize)
{
List<AwardStandardsItem> getDataLists = (from x in Funs.DB.Technique_AwardStandards
select new AwardStandardsItem
{
AwardStandardsId = x.AwardStandardsId,
AwardStandardsCode = x.AwardStandardsCode,
AwardStandardsName = x.AwardStandardsName,
AttachUrl = x.AttachUrl,
CompileMan = x.CompileMan,
CompileDate = x.CompileDate,
IsPass = x.IsPass,
UpState = x.UpState,
Remark = x.Remark
}).ToList();
if (PageNumber > 0 && PageSize > 0)
{
getDataLists = getDataLists.Skip((PageNumber - 1) * PageSize).Take(PageSize).ToList();
}
return getDataLists;
}
/// <summary>
/// 添加
/// </summary>
/// <param name="AwardStandardsList"></param>
public static void AddAwardStandardsList(Model.Technique_AwardStandards AwardStandardsList)
{
Model.SGGLDB db = Funs.DB;
Model.Technique_AwardStandards newAwardStandardsList = new Model.Technique_AwardStandards
{
AwardStandardsId = AwardStandardsList.AwardStandardsId,
AwardStandardsCode = AwardStandardsList.AwardStandardsCode,
AwardStandardsName = AwardStandardsList.AwardStandardsName,
AttachUrl = AwardStandardsList.AttachUrl,
CompileMan = AwardStandardsList.CompileMan,
CompileDate = AwardStandardsList.CompileDate,
};
newAwardStandardsList.CompileMan = AwardStandardsList.CompileMan;
newAwardStandardsList.CompileDate = AwardStandardsList.CompileDate;
newAwardStandardsList.IsPass = AwardStandardsList.IsPass;
newAwardStandardsList.UpState = AwardStandardsList.UpState;
newAwardStandardsList.Remark = AwardStandardsList.Remark;
db.Technique_AwardStandards.InsertOnSubmit(newAwardStandardsList);
db.SubmitChanges();
}
/// <summary>
/// 修改
/// </summary>
/// <param name="AwardStandardsList"></param>
public static void UpdateAwardStandardsList(Model.Technique_AwardStandards AwardStandardsList)
{
Model.SGGLDB db = Funs.DB;
Model.Technique_AwardStandards newAwardStandardsList =
db.Technique_AwardStandards.FirstOrDefault(e =>
e.AwardStandardsId == AwardStandardsList.AwardStandardsId);
if (newAwardStandardsList != null)
{
newAwardStandardsList.AwardStandardsCode = AwardStandardsList.AwardStandardsCode;
newAwardStandardsList.AwardStandardsName = AwardStandardsList.AwardStandardsName;
newAwardStandardsList.AttachUrl = AwardStandardsList.AttachUrl;
newAwardStandardsList.CompileMan = AwardStandardsList.CompileMan;
newAwardStandardsList.CompileDate = AwardStandardsList.CompileDate;
newAwardStandardsList.UpState = AwardStandardsList.UpState;
newAwardStandardsList.Remark = AwardStandardsList.Remark;
db.SubmitChanges();
}
}
/// <summary>
///根据主键删除
/// </summary>
/// <param name="AwardStandardsId"></param>
public static void DeleteAwardStandardsListById(string AwardStandardsId)
{
Model.SGGLDB db = Funs.DB;
Model.Technique_AwardStandards AwardStandardsList =
db.Technique_AwardStandards.FirstOrDefault(e => e.AwardStandardsId == AwardStandardsId);
if (AwardStandardsList != null)
{
if (!string.IsNullOrEmpty(AwardStandardsList.AttachUrl))
{
BLL.UploadFileService.DeleteFile(Funs.RootPath, AwardStandardsList.AttachUrl);
}
////删除附件表
BLL.CommonService.DeleteAttachFileById(AwardStandardsList.AwardStandardsId);
db.Technique_AwardStandards.DeleteOnSubmit(AwardStandardsList);
db.SubmitChanges();
}
}
public class AwardStandardsItem
{
public string AwardStandardsId
{
get;
set;
}
public string AwardStandardsCode
{
get;
set;
}
public string AwardStandardsName
{
get;
set;
}
public string AttachUrl
{
get;
set;
}
public string CompileMan
{
get;
set;
}
public System.Nullable<System.DateTime> CompileDate
{
get;
set;
}
public System.Nullable<bool> IsPass
{
get;
set;
}
public string UpState
{
get;
set;
}
public string Remark
{
get;
set;
}
}
}
}