169 lines
7.7 KiB
C#
169 lines
7.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Collections;
|
|
|
|
namespace BLL
|
|
{
|
|
/// <summary>
|
|
/// 一般方案审批
|
|
/// </summary>
|
|
public static class GeneralPlanApprovalService
|
|
{
|
|
public static Model.SGGLDB db = Funs.DB;
|
|
|
|
/// <summary>
|
|
/// 记录数
|
|
/// </summary>
|
|
private static int count
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取分页列表
|
|
/// </summary>
|
|
/// <param name="projectId"></param>
|
|
/// <param name="unitId"></param>
|
|
/// <param name="cNProfessionalId"></param>
|
|
/// <param name="startRowIndex"></param>
|
|
/// <param name="maximumRows"></param>
|
|
/// <returns></returns>
|
|
public static IEnumerable GetListData(string projectId, string unitId, string cNProfessionalId,string UnitWorkId, int startRowIndex, int maximumRows)
|
|
{
|
|
IQueryable<Model.Comprehensive_GeneralPlanApproval> q = from x in db.Comprehensive_GeneralPlanApproval
|
|
where x.ProjectId == projectId
|
|
orderby x.ApprovalDate descending
|
|
select x;
|
|
if (unitId != "0")
|
|
{
|
|
q = q.Where(e => e.UnitId == unitId);
|
|
}
|
|
if (cNProfessionalId != "0")
|
|
{
|
|
q = q.Where(e => e.CNProfessionalId == cNProfessionalId);
|
|
}
|
|
if (UnitWorkId != "0")
|
|
{
|
|
q = q.Where(e => e.UnitWorkId.Contains(UnitWorkId));
|
|
}
|
|
count = q.Count();
|
|
if (count == 0)
|
|
{
|
|
return new object[] { "" };
|
|
}
|
|
return from x in q.Skip(startRowIndex).Take(maximumRows)
|
|
select new
|
|
{
|
|
x.GeneralPlanApprovalId,
|
|
x.ProjectId,
|
|
UnitName = (from y in db.Base_Unit where y.UnitId == x.UnitId select y.UnitName).FirstOrDefault(),
|
|
ProfessionalName = (from y in db.Base_CNProfessional where y.CNProfessionalId == x.CNProfessionalId select y.ProfessionalName).FirstOrDefault(),
|
|
x.PlanCode,
|
|
x.PlanName,
|
|
x.ApprovalDate,
|
|
x.AuditMan,
|
|
x.ApprovalMan,
|
|
UnitWorkName = x.UnitWorkId != null ? BLL.UnitWorkService.GetUnitWorkName(x.UnitWorkId) : null,
|
|
x.UnitWorkId,
|
|
x.ImplementationDeviation,
|
|
x.AttachUrl
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取分页列表数
|
|
/// </summary>
|
|
/// <param name="projectId"></param>
|
|
/// <param name="unitId"></param>
|
|
/// <param name="cNProfessionalId"></param>
|
|
/// <returns></returns>
|
|
public static int GetListCount(string projectId, string unitId, string cNProfessionalId, string UnitWorkId)
|
|
{
|
|
return count;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据主键获取一般方案审批
|
|
/// </summary>
|
|
/// <param name="generalPlanApprovalId"></param>
|
|
/// <returns></returns>
|
|
public static Model.Comprehensive_GeneralPlanApproval GetGeneralPlanApprovalById(string generalPlanApprovalId)
|
|
{
|
|
return Funs.DB.Comprehensive_GeneralPlanApproval.FirstOrDefault(e => e.GeneralPlanApprovalId == generalPlanApprovalId);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加一般方案审批
|
|
/// </summary>
|
|
/// <param name="generalPlanApproval"></param>
|
|
public static void AddGeneralPlanApproval(Model.Comprehensive_GeneralPlanApproval generalPlanApproval)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.Comprehensive_GeneralPlanApproval newGeneralPlanApproval = new Model.Comprehensive_GeneralPlanApproval();
|
|
newGeneralPlanApproval.GeneralPlanApprovalId = generalPlanApproval.GeneralPlanApprovalId;
|
|
newGeneralPlanApproval.ProjectId = generalPlanApproval.ProjectId;
|
|
newGeneralPlanApproval.UnitId = generalPlanApproval.UnitId;
|
|
newGeneralPlanApproval.CNProfessionalId = generalPlanApproval.CNProfessionalId;
|
|
newGeneralPlanApproval.PlanCode = generalPlanApproval.PlanCode;
|
|
newGeneralPlanApproval.PlanName = generalPlanApproval.PlanName;
|
|
newGeneralPlanApproval.ApprovalDate = generalPlanApproval.ApprovalDate;
|
|
newGeneralPlanApproval.ApprovalMan = generalPlanApproval.ApprovalMan;
|
|
newGeneralPlanApproval.AuditMan = generalPlanApproval.AuditMan;
|
|
newGeneralPlanApproval.ImplementationDeviation = generalPlanApproval.ImplementationDeviation;
|
|
newGeneralPlanApproval.AttachUrl = generalPlanApproval.AttachUrl;
|
|
newGeneralPlanApproval.CompileMan = generalPlanApproval.CompileMan;
|
|
newGeneralPlanApproval.CompileDate = generalPlanApproval.CompileDate;
|
|
newGeneralPlanApproval.UnitWorkId = generalPlanApproval.UnitWorkId;
|
|
db.Comprehensive_GeneralPlanApproval.InsertOnSubmit(newGeneralPlanApproval);
|
|
db.SubmitChanges();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改一般方案审批
|
|
/// </summary>
|
|
/// <param name="generalPlanApproval"></param>
|
|
public static void UpdateGeneralPlanApproval(Model.Comprehensive_GeneralPlanApproval generalPlanApproval)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.Comprehensive_GeneralPlanApproval newGeneralPlanApproval = db.Comprehensive_GeneralPlanApproval.FirstOrDefault(e => e.GeneralPlanApprovalId == generalPlanApproval.GeneralPlanApprovalId);
|
|
if (newGeneralPlanApproval != null)
|
|
{
|
|
newGeneralPlanApproval.ProjectId = generalPlanApproval.ProjectId;
|
|
newGeneralPlanApproval.UnitId = generalPlanApproval.UnitId;
|
|
newGeneralPlanApproval.CNProfessionalId = generalPlanApproval.CNProfessionalId;
|
|
newGeneralPlanApproval.PlanCode = generalPlanApproval.PlanCode;
|
|
newGeneralPlanApproval.PlanName = generalPlanApproval.PlanName;
|
|
newGeneralPlanApproval.ApprovalDate = generalPlanApproval.ApprovalDate;
|
|
newGeneralPlanApproval.ApprovalMan = generalPlanApproval.ApprovalMan;
|
|
newGeneralPlanApproval.AuditMan = generalPlanApproval.AuditMan;
|
|
newGeneralPlanApproval.ImplementationDeviation = generalPlanApproval.ImplementationDeviation;
|
|
newGeneralPlanApproval.AttachUrl = generalPlanApproval.AttachUrl;
|
|
newGeneralPlanApproval.UnitWorkId = generalPlanApproval.UnitWorkId;
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据主键删除一般方案审批
|
|
/// </summary>
|
|
/// <param name="generalPlanApprovalId"></param>
|
|
public static void DeleteGeneralPlanApproval(string generalPlanApprovalId)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.Comprehensive_GeneralPlanApproval generalPlanApproval = db.Comprehensive_GeneralPlanApproval.FirstOrDefault(e => e.GeneralPlanApprovalId == generalPlanApprovalId);
|
|
if (generalPlanApproval != null)
|
|
{
|
|
if (!string.IsNullOrEmpty(generalPlanApproval.AttachUrl))
|
|
{
|
|
BLL.UploadAttachmentService.DeleteFile(Funs.RootPath, generalPlanApproval.AttachUrl);//删除附件
|
|
}
|
|
db.Comprehensive_GeneralPlanApproval.DeleteOnSubmit(generalPlanApproval);
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
}
|
|
}
|