I am trying to write this program that stores the employee database in a random access file, it should have functions for adding employees and deleting employees (by writing all the spaces in the record). This is what I have so far, but it does not work perfectly right. When reading an employee, he reads the salary of the correct record, but the name of the next record. In addition, when I delete the last record and add an employee to this record, I cannot view the information about the employee, I get an exception error.
I'm not looking for a solution here, just a push in the right direction. Thanks.
Ok, here is a new and improved (well, I think so) code. The only problem I am facing is adding an employee, I can make the program add it to the first open record just fine, but if there are no open records, I cannot force it to add to the end of the file without messing up the addition to the first empty record. I mean, if there is an empty record, it will add an employee to the record, but if there is no empty record, it will not add an employee to the end of the file. If I add the code to be added to the end of the file, one of two things will happen: either it will add to the empty record, then it will request another employee and add it to the end, or it will simply skip the empty record and add the end of the file.
Not sure what I'm doing wrong here, but any tips would be appreciated.
source share