bklLiudl
2024-07-23 675b8bcc4a3630d95e3d0b97d933e63442075ecb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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();
            }
        }
    }
}