You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
156 lines
5.3 KiB
156 lines
5.3 KiB
4 years ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Text;
|
||
|
using QMFrameWork.Data;
|
||
|
using QMAPP.Entity.Sys;
|
||
|
using System.Data;
|
||
|
|
||
|
namespace QMAPP.DAL.Sys
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 流程设置数据层对象
|
||
|
/// 创建者:
|
||
|
/// 创建日期:
|
||
|
/// </summary>
|
||
|
public class FlowSetDAL : BaseDAL
|
||
|
{
|
||
|
|
||
|
#region 获取列表
|
||
|
/// <summary>
|
||
|
/// 获取列表
|
||
|
/// </summary>
|
||
|
/// <param name="condition">条件</param>
|
||
|
/// <param name="page">数据页</param>
|
||
|
/// <returns>数据页</returns>
|
||
|
public List<ZPFlow> GetList()
|
||
|
{
|
||
|
string sql = null;
|
||
|
List<DataParameter> parameters = new List<DataParameter>();
|
||
|
List<ZPFlow> resultList = null;
|
||
|
try
|
||
|
{
|
||
|
sql = this.GetQuerySql(new ZPFlow(), ref parameters);
|
||
|
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
sql = this.ChangeSqlByDB(sql, session);
|
||
|
resultList = session.GetList<ZPFlow>(sql, parameters.ToArray()).ToList<ZPFlow>();
|
||
|
}
|
||
|
return resultList;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
#region 获取查询语句
|
||
|
/// <summary>
|
||
|
/// 获取查询语句
|
||
|
/// </summary>
|
||
|
/// <param name="user">查询条件</param>
|
||
|
/// <param name="parameters">参数</param>
|
||
|
/// <returns>查询语句</returns>
|
||
|
private string GetQuerySql(ZPFlow zpFlow, ref List<DataParameter> parameters)
|
||
|
{
|
||
|
StringBuilder sqlBuilder = new StringBuilder();
|
||
|
try
|
||
|
{
|
||
|
//构成查询语句
|
||
|
sqlBuilder.Append(@" SELECT FLOWLEVEL,SDEPT,
|
||
|
(SELECT ORGA.ORGADESC FROM T_QM_ORGANIZATION ORGA WHERE ORGA.ORGAID = FLOW.SDEPT) AS SOrgaDesc
|
||
|
FROM T_QM_ZPFLOW FLOW ");
|
||
|
|
||
|
if (zpFlow.FlowLevel != 0)
|
||
|
{
|
||
|
sqlBuilder.Append(" WHERE FLOW.FLOWLEVEL = @FLOWLEVEL ");
|
||
|
parameters.Add(new DataParameter { ParameterName = "FLOWLEVEL", DataType = DbType.Int32, Value = zpFlow.FlowLevel });
|
||
|
}
|
||
|
|
||
|
sqlBuilder.Append(" ORDER BY FLOWLEVEL ASC ");
|
||
|
|
||
|
return sqlBuilder.ToString();
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 获取结点下的人员信息
|
||
|
/// <summary>
|
||
|
/// 获取结点下的人员信息
|
||
|
/// </summary>
|
||
|
/// <returns>数据页</returns>
|
||
|
public List<ZPFlow> GetUserByFlowLevel(ZPFlow zpFlow)
|
||
|
{
|
||
|
string sql = null;
|
||
|
List<DataParameter> parameters = new List<DataParameter>();
|
||
|
List<ZPFlow> resultList = null;
|
||
|
try
|
||
|
{
|
||
|
sql = this.GetQuerySql(zpFlow, ref parameters);
|
||
|
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
sql = this.ChangeSqlByDB(sql, session);
|
||
|
resultList = session.GetList<ZPFlow>(sql, parameters.ToArray()).ToList<ZPFlow>();
|
||
|
}
|
||
|
return resultList;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 保存结点下的人员信息
|
||
|
/// <summary>
|
||
|
/// 保存结点下的人员信息
|
||
|
/// </summary>
|
||
|
/// <returns>数据页</returns>
|
||
|
public int SaveUser(string FlowLevel ,List<ZPFlow> zpFlowList)
|
||
|
{
|
||
|
int count = 0;
|
||
|
List<DataParameter> parameters = null;
|
||
|
try
|
||
|
{
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
session.OpenTs();
|
||
|
parameters = new List<DataParameter>();
|
||
|
//删除原有的流程设置信息
|
||
|
string sql = " DELETE FROM T_QM_ZPFLOW WHERE FLOWLEVEL = @FLOWLEVEL ";
|
||
|
parameters.Add(new DataParameter { ParameterName = "FLOWLEVEL", DataType = DbType.Int32, Value = FlowLevel });
|
||
|
sql = this.ChangeSqlByDB(sql, session);
|
||
|
session.ExecuteSql(sql, parameters.ToArray());
|
||
|
|
||
|
//插入新的流程设置记录
|
||
|
foreach (ZPFlow zp in zpFlowList)
|
||
|
{
|
||
|
sql = " INSERT INTO T_QM_ZPFLOW(PID,FLOWLEVEL,SDEPT)VALUES(@PID,@FLOWLEVEL,@SDEPT)";
|
||
|
parameters.Add(new DataParameter { ParameterName = "PID", DataType = DbType.String, Value = zp.PID });
|
||
|
|
||
|
parameters.Add(new DataParameter { ParameterName = "SDEPT", DataType = DbType.String, Value = zp.SDept });
|
||
|
sql = this.ChangeSqlByDB(sql, session);
|
||
|
count += session.ExecuteSql(sql, parameters.ToArray());
|
||
|
}
|
||
|
session.CommitTs();
|
||
|
}
|
||
|
return count;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
}
|
||
|
}
|