Addition, deletion, modification and query can be implemented through TreeView. The database uses Access and the operation uses OleDbHelper.
Database description
classId
className
classDescrip
parentId, parent number, top level is 0
sortId, sort number,
When deleting, all the sortIds greater than this number will be reduced by one.
When increasing, add one to the maximum number.
When moving up, exchange the sortId with the front, and first determine whether it is already the front. That is, whether it is 0
When moving down, exchange the sortId with the next one, and first determine whether it is the last one. That is, whether it is childNum+1
depth, depth, 0 is the top level.
childNum, the number of children, 0 means none.
Add operations
1. If it is the top level, then parentId=0, depth=0
sortId, by maximum value
2. If there is a parent, operate the parent and increase childNum by 1
sortId, by childNum+1, depth is parent depth+1
Delete operation
1. Determine whether there is a subclass, that is, parentId = current classId. If there is, it cannot be deleted.
2. If none, determine whether it is the top level. If there is a parent, then the parent's childNum is reduced by 1.
Find the sortId and subtract 1 if the parent sortId is greater than this.
Expand