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

修改客户信息编号和公司名提醒bug

mengjie лет назад: 5
Родитель
Сommit
a54e2470df

+ 50 - 10
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/customer/CustomerNewController.cs

@@ -260,8 +260,18 @@ namespace CallCenterApi.Interface.Controllers.customer
260 260
             #region 添加验证判断
261 261
             if (string.IsNullOrEmpty(input.F_CustomerCode))
262 262
                 return Error("编号不能为空!");
263
-            if (getunique(0, input.F_CustomerCode, input.F_CompanyName))
264
-                return Error("编号已被占用,请重新输入!");
263
+            int b = 0;
264
+            if (getunique(0, input.F_CustomerCode, input.F_CompanyName, out b))
265
+            {
266
+                if (b > 0)
267
+                {
268
+                    return Error("公司名称已被占用,请重新输入!");
269
+                }
270
+                else
271
+                {
272
+                    return Error("编号已被占用,请重新输入!");
273
+                }
274
+            }
265 275
             #endregion
266 276
             var model = new Model.T_Cus_CustomerBaseNew();
267 277
             #region 保存客户基本信息
@@ -324,8 +334,18 @@ namespace CallCenterApi.Interface.Controllers.customer
324 334
             #region 添加验证判断
325 335
             if (input.F_CustomerId <= 0)
326 336
                 return Error("参数错误!");
327
-            if (getunique(input.F_CustomerId, input.F_CustomerCode, input.F_CompanyName))
328
-                return Error("编号已被占用,请重新输入!");
337
+            int b = 0;
338
+            if (getunique(0, input.F_CustomerCode, input.F_CompanyName, out b))
339
+            {
340
+                if (b > 0)
341
+                {
342
+                    return Error("公司名称已被占用,请重新输入!");
343
+                }
344
+                else
345
+                {
346
+                    return Error("编号已被占用,请重新输入!");
347
+                }
348
+            }
329 349
             #endregion
330 350
             var model = cusbll.GetModel(input.F_CustomerId);
331 351
             #region 保存客户基本信息
@@ -451,15 +471,34 @@ namespace CallCenterApi.Interface.Controllers.customer
451 471
         /// <summary>
452 472
         /// 验证客户编号是否唯一
453 473
         /// </summary>
454
-        private bool getunique(int id, string code,string name)
474
+        private bool getunique(int id, string code,string name,out int b)//是否公司名称重复
455 475
         {
456 476
             var sql = " F_DeleteFlag=0 ";
457
-            sql += "and (F_CustomerCode='" + code + "' or F_CompanyName='"+ name + "')";
477
+            var sql1 = " F_DeleteFlag=0 ";
478
+            sql += "and (F_CustomerCode='" + code + "')";
479
+            sql1 += "and ( F_CompanyName='" + name + "')";
458 480
             if (id > 0)
459
-                sql += " and F_CustomerId<>"+id;
481
+            {
482
+                sql += " and F_CustomerId<>" + id;
483
+                sql1 += " and F_CustomerId<>" + id;
484
+            }
460 485
             var count=cusbll.GetModelList(sql).Count();
461
-            
462
-            return count > 0;
486
+            var count1 = cusbll.GetModelList(sql1).Count();
487
+            if (count > 0)
488
+            {
489
+                b = 0;
490
+                return true;
491
+            }
492
+            else if (count1 > 0)
493
+            {
494
+                b = 1;
495
+                return true;
496
+            }
497
+            else
498
+            {
499
+                b = 0;
500
+                return count1 + count > 0;
501
+            }
463 502
         }
464 503
         /// <summary>
465 504
         /// 删除客户
@@ -867,7 +906,8 @@ namespace CallCenterApi.Interface.Controllers.customer
867 906
                         cusmodel.F_CustomerCode = dataRow["编号"].ToString();
868 907
                         cusmodel.F_CompanyName = dataRow["公司名称"].ToString();
869 908
                         //判断编号唯一
870
-                        if (getunique(0, cusmodel.F_CustomerCode, cusmodel.F_CompanyName))
909
+                        int b = 0;
910
+                        if (getunique(0, cusmodel.F_CustomerCode, cusmodel.F_CompanyName,out b))
871 911
                             continue;
872 912
                         #region 处理关键字
873 913
                         var keyword = cusmodel.F_CompanyName;