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.
186 lines
5.5 KiB
186 lines
5.5 KiB
using System;
|
|
using System.Data;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using QMFrameWork.Data;
|
|
using QMAPP.Entity.Sys;
|
|
|
|
namespace QMAPP.DAL.Sys
|
|
{
|
|
/// <summary>
|
|
/// 桌面快捷方式数据层对象
|
|
/// 创建者:李炳海
|
|
/// 创建日期:2015.2.25
|
|
/// </summary>
|
|
public class DeskTopItemDAL:BaseDAL
|
|
{
|
|
#region 根据桌面布局信息
|
|
|
|
/// <summary>
|
|
/// 根据桌面布局信息
|
|
/// </summary>
|
|
/// <param name="userID">用户ID</param>
|
|
/// <returns>桌面布局信息集合</returns>
|
|
public List<DeskTopItem> GetList(string userID)
|
|
{
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
string sql = @"SELECT PID,USERID,MENUID,SORT
|
|
FROM T_QM_DESKTOPITEM WHERE USERID = @USERID ORDER BY SORT ASC";
|
|
parameters.Add(new DataParameter
|
|
{
|
|
ParameterName = "USERID",
|
|
DataType = DbType.String,
|
|
Value = userID
|
|
});
|
|
try
|
|
{
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
sql = base.ChangeSqlByDB(sql, session);
|
|
return session.GetList<DeskTopItem>(sql, parameters.ToArray()).ToList<DeskTopItem>();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 获取最大值序号
|
|
|
|
/// <summary>
|
|
/// 获取最大值序号
|
|
/// </summary>
|
|
/// <param name="userID">用户主键</param>
|
|
/// <returns>最大值序号</returns>
|
|
public int GetMaxSort(string userID)
|
|
{
|
|
string sql = "SELECT MAX(SORT) FROM T_QM_DESKTOPITEM WHERE USERID = @USERID";
|
|
|
|
int count = 0;
|
|
object value;
|
|
try
|
|
{
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
sql = base.ChangeSqlByDB(sql, session);
|
|
value=session.ExecuteSqlScalar(sql,new DataParameter("USERID",userID));
|
|
if (value!=System.DBNull.Value)
|
|
{
|
|
count=int.Parse(value.ToString());
|
|
}
|
|
}
|
|
return count;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 添加
|
|
|
|
/// <summary>
|
|
/// 添加
|
|
/// </summary>
|
|
/// <param name="info">信息</param>
|
|
/// <returns>插入行数</returns>
|
|
public int Insert(DeskTopItem info)
|
|
{
|
|
int count = 0;
|
|
|
|
try
|
|
{
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
count = session.Insert<DeskTopItem>(info);
|
|
}
|
|
return count;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 交换序号
|
|
|
|
/// <summary>
|
|
/// 交换序号
|
|
/// </summary>
|
|
/// <param name="userID">用户主键</param>
|
|
/// <param name="id1">主键1</param>
|
|
/// <param name="id2">主键2</param>
|
|
public void ExchangeSort(string userID, string id1, string id2)
|
|
{
|
|
DeskTopItem item1 = new DeskTopItem();
|
|
DeskTopItem item2 = new DeskTopItem();
|
|
int sort = 0;
|
|
string sql = "";
|
|
|
|
item1.PID = id1;
|
|
item2.PID = id2;
|
|
try
|
|
{
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
//获取基本信息
|
|
sql = "SELECT * FROM T_QM_DESKTOPITEM WHERE USERID = @USERID AND MENUID = @MENUID";
|
|
sql = this.ChangeSqlByDB(sql, session);
|
|
item1 = session.Get<DeskTopItem>(sql, new DataParameter("USERID", userID), new DataParameter("MENUID",id1));
|
|
item2 = session.Get<DeskTopItem>(sql, new DataParameter("USERID", userID), new DataParameter("MENUID", id2));
|
|
|
|
//交换序号
|
|
sort = item1.SORT;
|
|
item1.SORT = item2.SORT;
|
|
item2.SORT = sort;
|
|
|
|
//更新
|
|
session.Update<DeskTopItem>(item1);
|
|
session.Update<DeskTopItem>(item2);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 删除
|
|
|
|
/// <summary>
|
|
/// 删除
|
|
/// </summary>
|
|
/// <param name="guid">主键</param>
|
|
/// <returns>删除个数</returns>
|
|
public int Delete(string userID,string id)
|
|
{
|
|
int count = 0;
|
|
string sql = "";
|
|
try
|
|
{
|
|
sql = "DELETE FROM T_QM_DESKTOPITEM WHERE USERID = @USERID AND MENUID = @MENUID";
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
sql = this.ChangeSqlByDB(sql, session);
|
|
count = session.ExecuteSql(sql, new DataParameter("USERID", userID), new DataParameter("MENUID", id));
|
|
}
|
|
return count;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
}
|
|
}
|
|
|