From 461a7bfc0a2250ec5ff4b7a85cb6ce3c2f0bf06e Mon Sep 17 00:00:00 2001 From: zrg <z18737863051@163.com> Date: 星期二, 13 八月 2024 11:20:44 +0800 Subject: [PATCH] 1 --- WebAPI/Controllers/BaseSet/Gy_SupplierController.cs | 78 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 78 insertions(+), 0 deletions(-) diff --git a/WebAPI/Controllers/BaseSet/Gy_SupplierController.cs b/WebAPI/Controllers/BaseSet/Gy_SupplierController.cs index 348db1d..6bf08f4 100644 --- a/WebAPI/Controllers/BaseSet/Gy_SupplierController.cs +++ b/WebAPI/Controllers/BaseSet/Gy_SupplierController.cs @@ -8,6 +8,7 @@ using System.Data.SqlClient; using System.Web.Http; using WebAPI.Models; +using System.Text.RegularExpressions; namespace WebAPI.Controllers { public class Gy_SupplierController : ApiController @@ -110,6 +111,83 @@ } } + #region 瀹㈡埛鏍规嵁鍒嗙被鑾峰彇鏈�澶у鎴风紪鐮� + [Route("Gy_Supplier/getMaxNum")] + [HttpGet] + public object getMaxNum(int HSupTypeID, string user, string Organization) + { + try + { + List<object> columnNameList = new List<object>(); + //缂栬緫鏉冮檺 + if (!DBUtility.ClsPub.Security_Log_second("Gy_Supplier", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + if (HSupTypeID == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "娌℃湁閫夋嫨鍏蜂綋鍒嗙被锛�"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + ds = oCN.RunProcReturn(@"select * from h_v_Gy_SupplierList where 缁勭粐鍚嶇О='" + Organization + "'" + "and HSupTypeID = '" + HSupTypeID + "'" + " order by 渚涘簲鍟嗕唬鐮� desc", "h_v_Gy_SupplierList"); + if (ds == null || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "娌℃湁鎵惧埌璇ュ垎绫荤殑瀹㈡埛缂栫爜璇蜂娇鐢ㄦ櫘閫氭柊澧�"; + objJsonResult.data = null; + return objJsonResult; + } + string HNumber = ds.Tables[0].Rows[0]["渚涘簲鍟嗕唬鐮�"].ToString(); + // 浣跨敤姝e垯琛ㄨ揪寮忔壘鍒版暟瀛楅儴鍒� (?<=\D)鏄竴涓浂瀹芥柇瑷�锛岃〃绀哄墠闈㈢殑瀛楃涓嶆槸鏁板瓧 (\d+)$琛ㄧず鍚庨潰璺熺潃涓�杩炰覆瀛楃涓茬煡閬撴湯灏� + Match match = Regex.Match(HNumber, @"(?<=\D)(\d+)$"); + if (match.Success) + { + string prefix = HNumber.Substring(0, HNumber.Length - match.Length); // 鎻愬彇鍓嶇紑 + int number = int.Parse(match.Value); // 瑙f瀽鏁板瓧 + // 鏁板瓧+1 + number++; + // 鏍煎紡鍖栨暟瀛楋紝淇濇寔鍘熼暱搴� + string formattedNumber = number.ToString().PadLeft(match.Length, '0'); + // 閲嶆柊缁勫悎瀛楃涓� + string result = prefix + formattedNumber; + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "success"; + objJsonResult.data = result; + return objJsonResult; + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "姝ゅ垎绫讳緵搴斿晢缂栫爜鏍煎紡鏈夎"; + objJsonResult.data = null; + return objJsonResult; + } + } + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + /// <summary> /// 渚涘簲鍟嗗垪琛ㄤ慨鏀规寜閽柟娉� ///鍙傛暟锛歴tring sql銆� -- Gitblit v1.9.1