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
{
///
/// 参数与人员组织接口
/// 创建者:郭佳伟
/// 创建日期:2013.2.7
///
public class ParaAuthorityPortManageDAL
{
#region 获取参数与人员组织信息列表
///
/// 获取参数与人员组织信息列表
///
/// 条件
/// 数据页
/// 数据页
public DataPage GetList(ParaAuthorityPort condition, DataPage page)
{
try
{
//StringBuilder sqlBuilder = new StringBuilder();
//StringBuilder whereBuilder = new StringBuilder();
//List parameters = new List();
//sqlBuilder.Append(" SELECT USERID,(SELECT USERNAME FROM T_QM_USER WHERE USERID = A.USERID) AS USERNAME");
//sqlBuilder.Append(" ,ORGAID,(SELECT ORGADESC FROM T_QM_ORGANIZATION WHERE ORGAID = A.ORGAID) AS ORGADESC ,PARAID ,PARADESC,PARATYPE, ");
//sqlBuilder.Append(" CREATEUSER,CREATETIME,UPDATEUSER,UPDATETIME ");
//sqlBuilder.Append(" ,DELFLAG ");
//sqlBuilder.Append(" FROM T_QM_PARAAUTHORITYPORT AS A WHERE DELFLAG = '0'");
////查询条件
//if (string.IsNullOrEmpty(condition.OrgaID) == false)
//{
// whereBuilder.Append(" AND ORGAID = @ORGAID");
// parameters.Add(new DataParameter { ParameterName = "ORGAID", DataType = DbType.String, Value = condition.OrgaID });
//}
////查询条件
//if (string.IsNullOrEmpty(condition.ParaID) == false)
//{
// whereBuilder.Append(" AND PARAID = @PARAID");
// parameters.Add(new DataParameter { ParameterName = "PARAID", DataType = DbType.String, Value = condition.ParaID });
//}
////查询条件
//if (string.IsNullOrEmpty(condition.UserID) == false)
//{
// whereBuilder.Append(" AND USERID = @USERID");
// parameters.Add(new DataParameter { ParameterName = "USERID", DataType = DbType.String, Value = condition.UserID });
//}
//if (whereBuilder.Length > 0)
//{
// sqlBuilder.Append(whereBuilder.ToString());
//}
////分页关键字段及排序
//page.KeyName = "PARAID";
//page.SortExpression = "UPDATETIME DESC";
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//page = session.GetDataPage(sqlBuilder.ToString(), parameters.ToArray(), page);
}
return page;
}
catch (Exception ex)
{
throw;
}
}
#endregion
#region 获取参数信息
///
/// 获取参数信息
///
/// 条件
/// 参数信息
public ParaAuthorityPort Get(ParaAuthorityPort user)
{
StringBuilder sqlBuilder = new StringBuilder();
StringBuilder whereBuilder = new StringBuilder();
List parameters = new List();
ParaAuthorityPort tmpPara = new ParaAuthorityPort();
try
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
////获取用户信息
//sqlBuilder.Append(" SELECT USERID,(SELECT USERNAME FROM T_QM_USER WHERE USERID = A.USERID) AS USERNAME");
//sqlBuilder.Append(" ,ORGAID,(SELECT ORGADESC FROM T_QM_ORGANIZATION WHERE ORGAID = A.ORGAID) AS ORGADESC ,PARAID ,PARADESC ,PARATYPE, ");
//sqlBuilder.Append(" CREATEUSER,CREATETIME,UPDATEUSER,UPDATETIME ");
//sqlBuilder.Append(" ,DELFLAG ");
//sqlBuilder.Append(" FROM T_QM_PARAAUTHORITYPORT AS A WHERE DELFLAG = '0' AND PARAID = @PARAID");
//parameters.Add(new DataParameter { ParameterName = "PARAID", DataType = DbType.String, Value = user.ParaID });
//tmpPara = session.Get(sqlBuilder.ToString(), parameters.ToArray());
}
return tmpPara;
}
catch (Exception ex)
{
throw;
}
}
#endregion
#region 插入参数信息
///
/// 插入参数信息
///
/// 参数基本信息
/// 插入数
public int Insert(ParaAuthorityPort pap)
{
int count = 0;
try
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
session.OpenTs();
//插入基本信息
session.Insert(pap);
session.CommitTs();
}
return count;
}
catch (Exception ex)
{
throw;
}
}
#endregion
#region 删除参数信息
///
/// 删除参数信息
///
/// 参数基本信息
/// 删除个数
public int Delete(ParaAuthorityPort pap)
{
int count = 0;
string sql = null;
try
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
session.OpenTs();
////删除参数信息
//sql = "UPDATE T_QM_PARAAUTHORITYPORT SET DELFLAG = '1' WHERE PARAID=@PARAID";
//count = session.ExecuteSql(sql, new DataParameter { ParameterName = "PARAID", DataType = DbType.String, Value = pap.ParaID });
session.CommitTs();
}
return count;
}
catch (Exception ex)
{
throw;
}
}
#endregion
#region 更新参数信息
///
/// 更新参数信息
///
/// 参数信息
/// 更新个数
public int Update(ParaAuthorityPort pap)
{
int count = 0;
try
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
session.OpenTs();
//更新基本信息
count = session.Update(pap);
session.CommitTs();
}
return count;
}
catch (Exception ex)
{
throw;
}
}
#endregion
}
}