New data from increasing numbers backfill

Development tools and key technologies: Visual Studio and Session

Author: Huang Can

Write Time: 2019.5.14

New data, numbers have many custom data, not the data in our primary key ID. In the database, each new piece of data, the data will be the primary key ID from +1. I want to achieve a custom look numbered from +1 and automatically fill in the new modal box number input label (ie the number of input box).

The first step in the new data from increasing numbers of backfill: check out the number of the last data results in a common method query.

Just add a piece of data, and delete this data, add data and then re-added again to the number of the last data acquisition and data from +1 to get to this number is not correct, because in the end get a and since the number +1, and the resulting number is just deleted piece of data will be the number of duplicate data. I want to increment the number is no duplication of data, which is used Even if you delete a number on that data will not get deleted from +1, you want to get even deleted data you can also get to delete the number from this data and +1. Not get to number +1 data from the last piece of data, but to get all the data that the largest number, regardless of the existence of the database data or data is deleted can also get to the number of data. So I get data from a Session ID, so the acquired data number will not be the last number of database data.
Here Insert Picture Description

After obtaining the number, write a public method, convenient method in javascript function here in order to get access controller check out the numbers. In the public method, declare an empty string, determine what the query whether the Session ID is empty, if not executed, then empty it, get to the Session if the number is not empty, then get put in Session to the number assigned to a string which has just stated. The data is then returned as the string of the form Json
Here Insert Picture Description
Javascript in the function, the reset form, bound each drop-down box, etc. do not described in detail, since the post number +1 backfilling method of access control using jquery 's method, and to a callback, the callback function named in a method of receiving data in the controller over the data return transmission parameters, i.e. the number of receiving a query, there is a method in the controller, but only to obtain the largest number, and no way to make the numbers from +1, the callback function written in javascript method on the callback number acquired from +1, although the controller to get the number has been assigned to a string of them, but control returned json data is returned in the form of data, so self +1, or should json data in the form of a string to become self +1, or +1 if only the direct increase in the numbers get back to a 1, +1 is not a form of mathematics. No self +1 want to, is the number of formal mathematical +1; instead of adding one digit behind the numbers, if a word is incremented by one in the back number, then increment the number will be a large number and I use the numbers, there are regular expressions allow only specified number is five digits, more than 5 digits, then is new unsuccessful.

Here I get to the numbers, with the stupid way, the json data format is converted to a Number of data from +1. Since this is indeed a digital +1 +1 on mathematics, but in front of the number 0 which is lost, it is determined if else with a number greater than 9 from +1 stitching three zero zero two splicing greater than 99, greater than 999 a zero splicing, the splicing is not greater than 9999, less than 10 in the otherwise less than four zeros stitching 10, in the form of stitching up a string concatenation, and the backfill spliced ​​to a corresponding number ipnut label (i.e. fill in the input box number)

Here Insert Picture Description

I put in html tag on input from read to write numbers properties, prevent users from manually modified when new auto-incremented number

Here Insert Picture Description

Please correct me if wrong or there are other ways to thank guidance, small farmers are just a rookie, still in school age, acquiring data number is still thinking Session of the teacher.

Guess you like

Origin blog.csdn.net/weixin_44542088/article/details/90268129