146 lines
5.9 KiB
C#
146 lines
5.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace BLL.CQMS.Comprehensive
|
|
{
|
|
public class DataDistributionApproveService
|
|
{
|
|
|
|
/// <summary>
|
|
/// 增加施工方案审批信息
|
|
/// </summary>
|
|
/// <param name="managerRuleApprove">施工方案审批实体</param>
|
|
public static void EditApprove(Model.Comprehensive_DataDistributionApprove approve)
|
|
{
|
|
var db = Funs.DB;
|
|
Model.Comprehensive_DataDistributionApprove newApprove = new Model.Comprehensive_DataDistributionApprove();
|
|
|
|
if (string.IsNullOrWhiteSpace(approve.DataDistributionApproveId))
|
|
{ //新增
|
|
newApprove.DataDistributionApproveId = SQLHelper.GetNewID(typeof(Model.Comprehensive_DataDistributionApprove));
|
|
newApprove.DataDistributionId = approve.DataDistributionId;
|
|
newApprove.ApproveMan = approve.ApproveMan;
|
|
newApprove.ApproveDate = approve.ApproveDate;
|
|
newApprove.ApproveIdea = approve.ApproveIdea;
|
|
newApprove.IsAgree = approve.IsAgree;
|
|
newApprove.ApproveType = approve.ApproveType;
|
|
newApprove.Edition = approve.Edition;
|
|
db.Comprehensive_DataDistributionApprove.InsertOnSubmit(newApprove);
|
|
db.SubmitChanges();
|
|
}
|
|
else
|
|
{ //修改
|
|
Model.Comprehensive_DataDistributionApprove editApprove = db.Comprehensive_DataDistributionApprove.FirstOrDefault(e => e.DataDistributionApproveId == approve.DataDistributionApproveId);
|
|
if (editApprove != null)
|
|
{
|
|
editApprove.DataDistributionId = approve.DataDistributionId;
|
|
editApprove.ApproveMan = approve.ApproveMan;
|
|
editApprove.ApproveDate = approve.ApproveDate;
|
|
editApprove.ApproveIdea = approve.ApproveIdea;
|
|
editApprove.IsAgree = approve.IsAgree;
|
|
editApprove.ApproveType = approve.ApproveType;
|
|
editApprove.Edition = approve.Edition;
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public static Model.Comprehensive_DataDistributionApprove GetCurrentApprove(string DataDistributionId)
|
|
{
|
|
var q = from x in Funs.DB.Comprehensive_DataDistributionApprove
|
|
where x.DataDistributionId == DataDistributionId && x.ApproveType != "S" && x.ApproveDate == null
|
|
select x;
|
|
return q.FirstOrDefault();
|
|
|
|
}
|
|
|
|
public static Model.Comprehensive_DataDistributionApprove GetState(string DataDistributionId)
|
|
{
|
|
var q = from x in Funs.DB.Comprehensive_DataDistributionApprove
|
|
where x.DataDistributionId == DataDistributionId && x.ApproveType != "S"
|
|
orderby x.ApproveDate descending
|
|
select x;
|
|
var res = q.ToList();
|
|
if (res != null && res.Count > 0)
|
|
{
|
|
var q1 = res.Where(x => x.ApproveDate == null);
|
|
var res1 = q1.FirstOrDefault();
|
|
if (res1 != null)
|
|
{
|
|
return res1;
|
|
}
|
|
else
|
|
{
|
|
var q2 = res.Where(x => x.ApproveDate != null);
|
|
var res2 = q2.FirstOrDefault();
|
|
if (res2 != null)
|
|
{
|
|
return res2;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取当前用户的审核信息
|
|
/// </summary>
|
|
/// <param name="DataDistributionId"></param>
|
|
/// <param name="approveMan"></param>
|
|
/// <returns></returns>
|
|
public static Model.Comprehensive_DataDistributionApprove GetApproveByApproveMan(string DataDistributionId, string approveMan)
|
|
{
|
|
return Funs.DB.Comprehensive_DataDistributionApprove.FirstOrDefault(x => x.DataDistributionId == DataDistributionId && x.ApproveMan == approveMan && x.ApproveDate==null );
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据id 和当前用户获取审核列表
|
|
/// </summary>
|
|
/// <param name="DataDistributionId"></param>
|
|
/// <param name="approveMan"></param>
|
|
/// <returns></returns>
|
|
public static List<Model.Comprehensive_DataDistributionApprove> GetApproveByApproveManList(string DataDistributionId, string approveMan)
|
|
{
|
|
return Funs.DB.Comprehensive_DataDistributionApprove.Where(x => x.DataDistributionId == DataDistributionId && x.ApproveMan == approveMan).ToList();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 根据设备材料ID查询 审核记录
|
|
/// </summary>
|
|
/// <param name="DataDistributionId"></param>
|
|
/// <returns></returns>
|
|
public static DataTable GetProjectQualityList(string DataDistributionId)
|
|
{
|
|
string strSql = @"select i.* ,Sys_User.UserName from Comprehensive_DataDistributionApprove as i left join Sys_User on( i.ApproveMan = Sys_User.UserId)";
|
|
List<System.Data.SqlClient.SqlParameter> listStr = new List<SqlParameter>();
|
|
if (!string.IsNullOrEmpty(DataDistributionId))
|
|
{
|
|
strSql += "where i.DataDistributionId= @DataDistributionId ";
|
|
listStr.Add(new SqlParameter("@DataDistributionId", DataDistributionId));
|
|
}
|
|
|
|
strSql += " order by i.ApproveDate ";
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
return tb;
|
|
}
|
|
|
|
}
|
|
|
|
}
|