yantian yue
2023-12-29 fdda48e034b2da82fb100ec04f5b51351477e2bb
提交 | 用户 | 时间
e46d3b 1 using System;
2 using System.Collections.Generic;
3 using System.Data;
4 using System.Data.SqlClient;
5 using System.Linq;
6 using System.Text;
7 using YX.Entity;
8
9 namespace YX.DAL
10 {
11     public class SystemAppendProperty_Dal
12     {
13         //static string _connectionString = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"].ToString();
14         /// 业务附加属性列表
15         /// </summary>
16         /// <param name="Function">业务功能</param>
17         /// <returns></returns>
18 //        public DataTable AppendProperty_List(string Function)
19 //        {
20
21 //            try
22 //            {
23 //                string sql = @"SELECT  [Property_ID] as '编号'
24 //              ,[Property_Function]                   as '业务分类'
25 //              ,[Property_Control_ID]                 as '控件ID'
26 //              ,[Property_Name]                       as '控件名称'
27 //              ,[Property_Control_DataSource]         as '数据源'
28 //              ,[Property_Control_Length]             as '控件长度'
29 //              ,case [Property_Control_Style]
30 //              when 'txt' then '文本框' 
31 //              when 'select' then '下拉框' 
32 //              when 'richText' then '大文本框'
33 //              when 'label' then '标签框'
34 //              when 'date' then '日期框' end       as '控件类型'
35 //              ,[SortCode]                           as '排序' 
36 //                FROM Base_AppendProperty 
37 //                WHERE DeleteMark = 1         
38 //                AND Property_Function=@Property_Function 
39 //                ORDER BY SortCode ASC";
40 //                SqlParameter[] par = new SqlParameter[]
41 //                {
42 //                   new SqlParameter("@Property_Function", Function)
43 //                };
44
45 //                return SqlHelper.ExecuteDataset(_connectionString, CommandType.Text, sql,par).Tables[0];
46 //            }
47 //            catch (Exception ex)
48 //            {
49
50 //                throw ex;
51 //            }
52 //        }
53              //业务功能列表
54         public List<string> GetAppendPropertys()
55         {
56             try
57             {
58                 using (Sam_DBEntities db = new Sam_DBEntities())
59                 {
60                     return db.Base_AppendProperty.Select(o => o.Property_Function).Distinct().ToList();
61                 }
62             }
63             catch (Exception ex)
64             {
65                 
66                 throw ex;
67             }
68   
69
70         }
71         //具体业务功能属性列表
72         public List<Base_AppendProperty> AppendProperty_List(string Property_Function)
73         {
74             try
75             {
76                 using (Sam_DBEntities db = new Sam_DBEntities())
77                 {
78                   return   db.Base_AppendProperty.Where(o=>o.DeleteMark==1 && o.Property_Function== Property_Function).OrderBy(o=>o.SortCode).ToList();
79                 }
80             }
81             catch (Exception ex)
82             {
83                 
84                 throw ex;
85             }
86         }
87
88         /// <summary>
89         /// 根据业务名称获取附加属性值
90         /// </summary>
91         /// <param name="Property_Function">所属功能</param>
92         /// <param name="Obj_ID">业务主键</param>
93         /// <returns></returns>
94         public List<Base_AppendPropertyInstance> GetPropertyInstancepk(string Property_Function, string Obj_ID)
95         {
96             try
97             {
98                 StringBuilder item_value = new StringBuilder();
99                 using (Sam_DBEntities db = new Sam_DBEntities())
100                 {
101                     var query = from I in db.Base_AppendPropertyInstance
102                                 join A in db.Base_AppendProperty
103                                 on I.Property_Control_ID equals A.Property_Control_ID
104                                 where I.Base_UserInfo.User_ID == Obj_ID && A.Property_Function == Property_Function
105                                 select I;
106                     return query.ToList();
107                 }
108             }
109             catch (Exception)
110             {
111                 
112                 throw;
113             }
114
115         }
116         /// <summary>
117         /// 添加属性
118         /// </summary>
119         /// <returns></returns>
120         public int AddAppendProperty(Base_AppendProperty info)
121         {
122             try
123             {
124                 using (Sam_DBEntities db = new Sam_DBEntities())
125                 {
126                     db.Base_AppendProperty.Add(info);
127                     return db.SaveChanges();
128                 }
129             }
130             catch (Exception ex)
131             {
132                 
133                 throw ex;
134             }
135         }
136         /// <summary>
137         /// 修改属性
138         /// </summary>
139         /// <param name="info"></param>
140         /// <returns></returns>
141         public int UpdateAppendProertty(Base_AppendProperty info)
142         {
143             try
144             {
145                 using (Sam_DBEntities db = new Sam_DBEntities())
146                 {
147                     db.Base_AppendProperty.Attach(info);
148                     db.Entry(info).State = System.Data.Entity.EntityState.Modified;
149                     return db.SaveChanges();
150                 }
151             }
152             catch (Exception ex)
153             {
154                 
155                 throw ex;
156             }
157         }
158         /// <summary>
159         /// 删除属性
160         /// </summary>
161         /// <param name="Property_ID"></param>
162         /// <returns></returns>
163         public int DeleteAppendProettty(string Property_ID)
164         {
165             try
166             {
167                 using (Sam_DBEntities db=new Sam_DBEntities())
168                 {
169                     var obj = new Base_AppendProperty { Property_ID= Property_ID };
170                     db.Base_AppendProperty.Attach(obj);
171                     db.Base_AppendProperty.Remove(obj);
172                     return db.SaveChanges();
173                 }
174             }
175             catch (Exception ex)
176             {
177
178                 throw ex;
179             }
180         }
181     }
182     
183 }