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

添加修改员工信息时,工号不能重复

machenyang лет назад: 8
Родитель
Сommit
55e0bfb26d

+ 26 - 6
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/UserAccountController.cs

173
             {
173
             {
174
 
174
 
175
                 Model.T_Sys_UserAccount userAccountModel = new Model.T_Sys_UserAccount();
175
                 Model.T_Sys_UserAccount userAccountModel = new Model.T_Sys_UserAccount();
176
-                if (input.Usercode != null)
176
+                //员工工号不能重复
177
+                string ucode = input.Usercode.Trim();
178
+                if (!string.IsNullOrEmpty(ucode))
177
                 {
179
                 {
178
-                    userAccountModel.F_UserCode = input.Usercode.Trim();
179
-                    userAccountModel.F_WorkNumber = input.Usercode.Trim();
180
+                    Model.T_Sys_UserAccount uModel = new BLL.T_Sys_UserAccount().GetModel(ucode);
181
+                    if (uModel != null)
182
+                    {
183
+                        res = Error("不能重复添加工号");
184
+                    }
185
+                    else
186
+                    {
187
+                        userAccountModel.F_UserCode = ucode;
188
+                        userAccountModel.F_WorkNumber = ucode;
189
+                    }
180
                 }
190
                 }
181
                 if (input.Username != null)
191
                 if (input.Username != null)
182
                     userAccountModel.F_UserName = input.Username.Trim();
192
                     userAccountModel.F_UserName = input.Username.Trim();
261
                 Model.T_Sys_UserAccount userAccountModel = sysUserAccountBll.GetModelList("  F_UserId = " + input.UserId).FirstOrDefault();
271
                 Model.T_Sys_UserAccount userAccountModel = sysUserAccountBll.GetModelList("  F_UserId = " + input.UserId).FirstOrDefault();
262
                 if (userAccountModel == null)
272
                 if (userAccountModel == null)
263
                     return Error("获取用户失败");
273
                     return Error("获取用户失败");
264
-                if (input.Usercode != null)
274
+                //员工工号不能重复
275
+                string ucode = input.Usercode.Trim();
276
+                if (!string.IsNullOrEmpty(ucode))
265
                 {
277
                 {
266
-                    userAccountModel.F_UserCode = input.Usercode.Trim();
267
-                    userAccountModel.F_WorkNumber = input.Usercode;
278
+                    Model.T_Sys_UserAccount uModel = new BLL.T_Sys_UserAccount().GetModel(ucode);
279
+                    if (uModel != null)
280
+                    {
281
+                        res = Error("不能重复添加工号");
282
+                    }
283
+                    else
284
+                    {
285
+                        userAccountModel.F_UserCode = ucode;
286
+                        userAccountModel.F_WorkNumber = ucode;
287
+                    }
268
                 }
288
                 }
269
                 if (input.Username != null)
289
                 if (input.Username != null)
270
                     userAccountModel.F_UserName = input.Username.Trim();
290
                     userAccountModel.F_UserName = input.Username.Trim();