Просмотр исходного кода

添加部门限制不可添加重复的部门名称

yuqian лет назад: 8
Родитель
Сommit
09efe6ec13

+ 8 - 0
CallCenterApi/CallCenterApi.BLL/T_Sys_Department.cs

@@ -66,6 +66,14 @@ namespace CallCenterApi.BLL
66 66
         }
67 67
 
68 68
         /// <summary>
69
+        /// 得到一个对象实体
70
+        /// </summary>
71
+        public Model.T_Sys_Department GetModel(string deptName)
72
+        {
73
+
74
+            return dal.GetModel(deptName);
75
+        }
76
+        /// <summary>
69 77
         /// 获得数据列表
70 78
         /// </summary>
71 79
         public DataSet GetList(string strWhere)

+ 26 - 1
CallCenterApi/CallCenterApi.DAL/T_Sys_Department.cs

@@ -224,6 +224,31 @@ namespace CallCenterApi.DAL
224 224
                 return null;
225 225
             }
226 226
         }
227
+        /// <summary>
228
+        /// 得到一个对象实体
229
+        /// </summary>
230
+        public Model.T_Sys_Department GetModel(string deptName)
231
+        {
232
+
233
+            StringBuilder strSql = new StringBuilder();
234
+            strSql.Append("select TOP 1 F_DeptId,F_DeptCode,(SELECT B.F_DeptName FROM T_Sys_Department B WHERE B.F_DeptId=A.F_ParentId) AS F_ParentName,F_ParentId,F_ParentCode,F_DeptName,F_State,F_Layer,F_Type,F_Sort,F_Remark,F_Telephone,F_Mobile,F_OtherPhone,F_Email,F_Header from T_Sys_Department  A");
235
+            strSql.Append(" where F_DeptName=@deptName");
236
+            SqlParameter[] parameters = {
237
+                    new SqlParameter("@deptName", deptName)
238
+            };
239
+
240
+            Model.T_Sys_Department model = new Model.T_Sys_Department();
241
+            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
242
+            if (ds.Tables[0].Rows.Count > 0)
243
+            {
244
+                return DataRowToModel(ds.Tables[0].Rows[0]);
245
+            }
246
+            else
247
+            {
248
+                return null;
249
+            }
250
+        }
251
+
227 252
 
228 253
 
229 254
         /// <summary>
@@ -392,7 +417,7 @@ namespace CallCenterApi.DAL
392 417
         /// <summary>
393 418
         /// 更新部门编号
394 419
         /// </summary>
395
-        public bool UpdateDeptCode(string deptcode,int deptid)
420
+        public bool UpdateDeptCode(string deptcode, int deptid)
396 421
         {
397 422
             StringBuilder strSql = new StringBuilder();
398 423
             strSql.Append("update T_Sys_Department set ");

+ 5 - 2
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/DepartmentController.cs

@@ -79,8 +79,11 @@ namespace CallCenterApi.Interface.Controllers
79 79
                         pcode = dModel.F_ParentCode = pdModel.F_DeptCode;
80 80
                     }
81 81
                 }
82
+                Model.T_Sys_Department model = departmentBLL.GetModel(input.DeptName.Trim());
83
+                if (model != null)
84
+                    return Error("不可以添加名称重复的部门");
82 85
                 dModel.F_Sort = input.Sort;
83
-                dModel.F_DeptName = input.DeptName;
86
+                dModel.F_DeptName = input.DeptName.Trim();
84 87
                 dModel.F_State = 1;
85 88
                 dModel.F_Remark = input.playivr;
86 89
                 int id = departmentBLL.Add(dModel);
@@ -176,7 +179,7 @@ namespace CallCenterApi.Interface.Controllers
176 179
             return NoToken("未知错误,请重新登录");
177 180
         }
178 181
 
179
-        public ActionResult GetDeptListRight(FilterDepartment filter )
182
+        public ActionResult GetDeptListRight(FilterDepartment filter)
180 183
         {
181 184
             if (Request.IsAuthenticated)
182 185
             {

+ 2 - 0
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/tel/SeatMonitoringController.cs

@@ -1,4 +1,5 @@
1 1
 using CallCenterApi.Common;
2
+using CallCenterApi.DB;
2 3
 using CallCenterApi.Interface.Controllers.Base;
3 4
 using System;
4 5
 using System.Collections.Generic;
@@ -59,5 +60,6 @@ namespace CallCenterApi.Interface.Controllers.tel
59 60
             }
60 61
             return res;
61 62
         }
63
+
62 64
     }
63 65
 }