获取最大值,从新编号,编号,编码,新编码

        /// 获取调整xxxx信息新编号
        /// </summary>
        /// <param name="Year"></param>
        /// <returns></returns>
        public string GetNewModifyNo(int Year,string Stro)
        {
            string NewModifyNo="";
            string Prefix = "TZ";
            string CommandText = "SELECT count(*) FROM OverSystems_TosModifyInfo where ModifyNo like ‘" + Stro + "%‘";
           if (Convert.ToInt32(sqlAccess.ExecuteScalar(CommandText)) > 0)
            {
               string LastModifyNo;
                CommandText = "SELECT ModifyNo FROM OverSystems_TosModifyInfo where ModifyNo like ‘"+ Stro + "%‘";
                DataTable ModifyNo = new DataTable();
                ModifyNo = sqlAccess.ExecuteTable(CommandText);
               
                //编号‘-ZT‘后的最大值
                int[] num = new int[1000];
                for (int i=0;i< ModifyNo.Rows.Count;i++) {
                    string Str = Convert.ToString(ModifyNo.Rows[i].ItemArray[0]);
                   
                    if (Str.Contains("-"))
                    {
                        string SerialNum = Str.Remove(0, Str.Length - 3);
                        num[i] = Convert.ToInt32(SerialNum);
                    }
                   
                }
                int max = num.Max();
                NewModifyNo = Stro+"-"+ Prefix + (max + 1).ToString("000");
            }
            else
           {
                NewModifyNo = Stro+"-"+ Prefix + "001";
            }
            return NewModifyNo;
        }

  

获取最大值,从新编号,编号,编码,新编码

上一篇:Egress TLS Origination


下一篇:Codeforces Round #742 (Div. 2)题解