ソースを参照

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

yuqian 8 年 前
コミット
09efe6ec13

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

66
         }
66
         }
67
 
67
 
68
         /// <summary>
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
         /// </summary>
78
         /// </summary>
71
         public DataSet GetList(string strWhere)
79
         public DataSet GetList(string strWhere)

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

224
                 return null;
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
         /// <summary>
254
         /// <summary>
392
         /// <summary>
417
         /// <summary>
393
         /// 更新部门编号
418
         /// 更新部门编号
394
         /// </summary>
419
         /// </summary>
395
-        public bool UpdateDeptCode(string deptcode,int deptid)
420
+        public bool UpdateDeptCode(string deptcode, int deptid)
396
         {
421
         {
397
             StringBuilder strSql = new StringBuilder();
422
             StringBuilder strSql = new StringBuilder();
398
             strSql.Append("update T_Sys_Department set ");
423
             strSql.Append("update T_Sys_Department set ");

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

79
                         pcode = dModel.F_ParentCode = pdModel.F_DeptCode;
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
                 dModel.F_Sort = input.Sort;
85
                 dModel.F_Sort = input.Sort;
83
-                dModel.F_DeptName = input.DeptName;
86
+                dModel.F_DeptName = input.DeptName.Trim();
84
                 dModel.F_State = 1;
87
                 dModel.F_State = 1;
85
                 dModel.F_Remark = input.playivr;
88
                 dModel.F_Remark = input.playivr;
86
                 int id = departmentBLL.Add(dModel);
89
                 int id = departmentBLL.Add(dModel);
176
             return NoToken("未知错误,请重新登录");
179
             return NoToken("未知错误,请重新登录");
177
         }
180
         }
178
 
181
 
179
-        public ActionResult GetDeptListRight(FilterDepartment filter )
182
+        public ActionResult GetDeptListRight(FilterDepartment filter)
180
         {
183
         {
181
             if (Request.IsAuthenticated)
184
             if (Request.IsAuthenticated)
182
             {
185
             {

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

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