23. januar 2005 - 10:19Der er
9 kommentarer og 2 løsninger
validering / kontrol
I forbindelse med en databse til kørepenge har jeg brug for at kunne krontolerer at km aften ikke er højre en km morgen dagen efter.
_________________________________________________ dato km morgen km aften ------------------------------------------------- 1-1-05 10 20 2-1-05 35 45 osv
ps hvordan beregner man "private" km ((km aften (1-1-05))- (km morgen (2-1-05))
Not as easy as it may seem, it all depend on HOW the data is entered! If I entered data for 2-1-05 AFTER I entered data for 1-1 then I could check that the previous data was LESS. But if I enter the information in a different order then I cant!
I think your going to need a function which does the following
If you enter "km morgen" then you find the previous "km aften" and make sure that it is <=
If you enter "km aften" check if a record exists newer (higher date) if there is one then you need to make sure that the km you entered is <= "km morgen" for the newer date, OR inform the user that the newer date information is incorrect!
Jeg er optaget andet sted, og har ikke lige min koncentration på dette spørgsmål. Men kan man ikke lave en funktion, der finder den post, hvor datoen er:
I would make a general function which you call EVERY time you enter/alter a km field.
It has to check information for the same day (is km aften > km morgen ?)
It also needs to check that the information is valid against the highest date previous to the date your are entering.
and it also needs to validate the data which if you have entered against data for records with dates NEWER than the date yuo are entering for.
What you decide to do is really up to you. But you have to inform the user if you find a problem.
I would suggest that you cancel the CURRENT changes and inform the user that they MUST alter other records BEFORE they can continue. Otherwise you can not be sure that they remember to alter other data.
I would suggest that you write down on paper the different possibilities you have for entering the information. Then your function must take these into account.
In my oppinion it should be allowed to enter information in any date order and your program should validate the information against the existing infromation (dates)
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.