using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Text;
|
using Common;
|
using Model;
|
|
namespace BLL
|
{
|
public class DALRelation : IDALRelation
|
{
|
public IList<Relation> GetList(string RoleNum)
|
{
|
|
try
|
{
|
|
IList<Relation> list = new List<Relation>();
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("Select RoleNum,ReNum from Relation where ");
|
strSql.Append("RoleNum = @RoleNum ");
|
|
SqlParam[] para = new SqlParam[]
|
{
|
new SqlParam("@RoleNum", RoleNum),
|
};
|
DataTable dt = DataFactory.SqlDataBase().GetDataTableBySQL(strSql, para, "");
|
list = ModelConvertHelper<Relation>.DataTableToModel(dt);
|
|
return list;
|
}
|
catch
|
{
|
throw new NotImplementedException();
|
}
|
}
|
|
public bool SetPermission(AjaxRelation model)
|
{
|
try
|
{
|
bool result =false;
|
int _ret = -1;
|
string[] RoleN = new string[] { model.RoleNum };
|
int dt = DataFactory.SqlDataBase().IsExist("Relation", nameof(model.RoleNum), RoleN);
|
if (dt >= RoleN.Length)
|
{
|
_ret = DataFactory.SqlDataBase().BatchDeleteData("Relation", "RoleNum", RoleN);
|
}
|
|
if (_ret >= 0 || dt == 0)
|
{
|
IList<Relation> list = new List<Relation>();
|
StringBuilder strSql = new StringBuilder();
|
string[] ReNum = model.ResNum.Split(',');
|
List<SqlParam> para = new List<SqlParam>();
|
|
if (ReNum.Length > 0)
|
{
|
strSql.Append("insert into Relation ( RoleNum,ReNum,CreateUser,CreatTime ) values ");
|
for (int k = 0; k < ReNum.Length; k++)
|
{
|
strSql.Append("(");
|
strSql.Append("@RoleNum" + k + ",");
|
strSql.Append("@ReNum" + k + ",");
|
strSql.Append("'"+ model.CreateUser+"',");
|
strSql.Append("GETDATE()");
|
strSql.Append("),");
|
|
para.Add(new SqlParam("@RoleNum" + k, model.RoleNum));
|
para.Add(new SqlParam("@ReNum" + k, DESEncrypt.Decrypt(ReNum[k])));
|
}
|
|
StringBuilder sb = new StringBuilder();
|
sb.Append(strSql.ToString().Substring(0, strSql.ToString().Length - 1));
|
|
SqlParam[] param = null;
|
if (para != null)
|
param = para.ToArray();
|
if (DataFactory.SqlDataBase().ExecuteBySql(sb, param) >= ReNum.Length)
|
result = true;
|
}
|
|
}
|
return result;
|
}
|
catch
|
{
|
throw new NotImplementedException();
|
}
|
}
|
}
|
}
|