Need help with this GUI
I keep getting error when I try to remove students , etc.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Jan 19, 2012, 4:44 PM
I've done the best I can with it but notice that if you try to expand the membership to more than 10 the program will error out because of an error in the RetreiveStudents() method.
Another problem is that there's only 5 students in the initial database but the aforementioned method returns an array of 10 student objects, the last 5 being null. The nulls need to be removed to avoid various problems arising:
Prime bPosted Jan 22, 2012, 1:54 PM
VulpesPosted Jan 22, 2012, 1:30 PM
The easiest way to do this is to right click on the name of the eventhandler in the code window, select Refactor -> Rename, enter the new name of the handler in the textbox and OK it. This should change it everywhere it's used including the InitializeComponent method.
Prime bPosted Jan 22, 2012, 12:45 PM
Prime bPosted Jan 22, 2012, 12:26 PM
Thank you Vulpes, for all that trouble you had to go through.
VulpesPosted Jan 22, 2012, 6:04 AM
It will then build OK but won't run properly as some code in form1.cs hasn't yet been updated in line with my previous post - button2_Click for instance.
So, I'd go through each method in turn, in the light of the changed names, to make sure you've picked up all the changes as it's quite intricate.
Incidentally, the lines I originally had - checking that there were actually some students remaining in the database before doing anything - are no longer needed as all the navigation buttons will be disabled in this event.
Prime bPosted Jan 21, 2012, 8:56 PM
I re-uploaded the file so its easier for you to see , i changed all the names
http://www.4shared.com/rar/dUztIHti/Student_Viewer.html
Once you open it , you will the error.
Prime bPosted Jan 21, 2012, 7:13 PM
VulpesPosted Jan 21, 2012, 6:54 PM
Prime bPosted Jan 21, 2012, 1:05 PM
Prime bPosted Jan 21, 2012, 12:16 PM
For example( you have to have GUI running) if you click View Students tab you will see First Name label, the textbox next to it named textbox1, well I renamed that textbox1 to viewStudFName. viewStud stands for the tab name and FName is first name, is it good ? or should i rename to to something different?
Prime bPosted Jan 19, 2012, 5:44 PM
VulpesPosted Jan 19, 2012, 5:11 PM
public Student[] RetreiveStudents()
{
Student[] list = new Student[10];
students.Clear(); // clear list
FileStream inFile = new FileStream(FILE_NAME, FileMode.Open, FileAccess.Read);
BinaryFormatter binFormatter = new BinaryFormatter();
int index = 0;
while (inFile.Position < inFile.Length)
{
if (index >= list.Length)
{
list = Expand(list); // need to assign result back to list
}
list[index++] = (Student)binFormatter.Deserialize(inFile);
students.Add(list[index - 1]);
}
inFile.Close();
return list;
}
It's a bit rich asking you to begin method names with a lower case letter when they all begin with capital letters in the PersistantData class. That's the recommended practice for .NET anyway - how many methods have you seen in the framework that begin with lower case letters?. What they're asking you to do is the Java naming standard.
Prime bPosted Jan 19, 2012, 4:53 PM
I'll have to go through all of them and rename it, also I have to rename all the objects in the form it self, since they are default names if i wont change it then my teacher will give me bad grade(maybe C). And this is my last semester in this college so I need to get all A's in all four classes that I am currently taking otherwise I wont be accepted to a four college due to my GPA being below the limit....
I had fun during few semesters in community college and it killed my GPA so now I am trying to fix all the mistakes I did..... Also the reason I am telling you all this is so you wont think I am stupid or something.. I am good student , just met wrong people at college and it cost me a lot.
Prime bPosted Jan 19, 2012, 4:09 PM