首页 > 代码库 > 或得最新的采购单号并改变为定长

或得最新的采购单号并改变为定长

服务器端实现:

 //或得最新采购单号
        protected void GetNewNumber()
        {
            int NewNumber = PurchaseplanBll.GetPurchaseplanNewNumber();
            int NewNumber1 = NewNumber + 1;
            string PurchaserplanNumber = NewNumber1.ToString().PadLeft(8, ‘0‘);
            hfPurchaseplanNumber.Value = http://www.mamicode.com/PurchaserplanNumber;
        }

 

在数据库中实现:

 SELECT @NewPurchaseplanNumber=(SELECT Top 1 PurchaseplanNumber from tblPurchaseplan Order by ID Desc)+1    
    SELECT @NewPurchaseNumber=RIGHT(REPLICATE(‘0‘,8)+CAST(@NewPurchaseplanNumber AS varchar(10)),8)

或得最新的采购单号并改变为定长