Hey guys welcome back.
In this video we're just going to review some of the changes that would have made since the last time
when we're creating our ad edit form for our cars.
Someone to start off with the money.
Vehicle listing window where you read that that I did what I labeled as our refresh button.
So this refresh button will just refresh the grid each time a change is made.
So let us take it for a spin firstly let's start with the ad new car.
So when adding a new car I added validation to the form to make sure that at least the make and the
model our presence when I click save changes then I'm going to get this please ensure that you provide
a make and a model.
So if I'm going to add a new one and let's say I had a Suzuki and swift and then I click save changes
I also put in try catch because then year is expecting a value so it can pass into integer.
So when I click save changes then my my arrow comes up from my exception right.
So then if I provide a change a year sorry and I say 2013 and while those are only three fields that
are absolutely necessary for it to work and click save changes it put in another message box that's
it.
Insert operation completed refresh grid to see changes.
Right.
So we did disclose that we wanted to manage the user's experience between adding or modifying data in
the car and getting back to the grid.
So if the display in this message box and I think we'll keep the window will close but then I can click
refresh and then it will display the new field.
Right.
And then if I try to edit without selecting so even though you may see it highlighted blue it's not
really selected.
So if I click edit car I get a nasty arrow.
But then once again this is just a try catch catching that arrow.
That would have been an exception showing me that you know the index was both offering and just basically
saying that I didn't select anything from the grid control right but then my program does not stop executing.
So I can always rectify that by just clicking.
And let's start with the record that we just added When I click Suzuki Swift click edit car then it
brings up edit vehicles so I made sure to modify the title that comes up.
So let me go back to ad car.
When I click a new car it's the same form but when the label changes and to the title in the window
changes.
So do any typical use it could have been two different windows.
That's not really our business to worry about.
So I'm just changing it so the user feels like it's the same window at all times although it is the
same with the book to feel like it's a different window sorry.
And then what happens is that a functionality slightly different also.
So we're getting the load the data preloaded I can change the VIN and the license plate number and just
put in some kind of number click save changes and then it is a bit operation completed.
So it's a similar message i click Okay.
Similar behavior.
And then I refresh and then I get the brand new data no deleting is kind of tricky because you can't
delete related data.
Meaning if I select see Subaru which I do believe I have our entire record to represents where already.
If I click delete that I'm going to get some arrows seeing that you know I have to see that exception
for details when I checked all that arrow.
It was really because I have our entire record on Subaru so enough to delete all the entire records
for the Subaru in order to delete the Subaru and that's just referential integrity coming over from
the database.
So that's not necessarily a bad thing.
So if you get that error that's really what's happening.
But I just created Suzuki Swift someone to delete it because I know I have no no records associated
with it.
So then I delete it will Oh well it's actually giving me an error.
I did not expect that.
So let us see exactly what that error is because I really didn't expect that one someone to go over
to my code Western in debug mode.
Go to my click event and then I'm just going to select the point where it's supposed to actually remove
the car and then we're going to try that operation again.
So I click it jumps the break point where it retrieve the car successfully so it knows that it's getting
this is looking Swift.
All right.
And then I can use if someone to step through singles to see if changes at which point to throw is the
exception.
And then if I look in the exception object it says look inside of the inner exception for more details
or I see an exception for more details so I can look at that and then it seeing that I have a constraint
that conflicts with my data base.
So I definitely have to check that out to see if there is an error into a record with that property
with a car.
Sir with that record in the database.
So there is no related record I just checked but what is happening is that it is enforcing some design
constraints.
So in the design of my car into a record or well in the design of this table four types of cars on the
I.D. or on the relationship.
Actually there would be this inserts an update deletion of data rule.
Right.
So basically I can set no action or cascade.
So it had to set cascade for it to just say OK I will delete the danger to this over is that if it deletes
the red card then it will delete all associated or all related records if it bleeds car with the I.D.
one can ever rent a record that is associated with car with I.D. one would also get deleted which you
may not necessarily want.
So you have to gauge that experience with your application.
However we do see that you know we can probably go by the delete form no and we fix it at a later date.
But I just wanted to get across the fact that we could modify our application to do some crud against
the vehicle listing we could create a single form that has multiple purposes and we can write some cool
code in our code file to handle the experience that our users have.
So after finishing up our money vehicle listing we'll probably want to turn our attention to finishing
up their entire record where we create a view similar to this where we can view all of the rental records
coming in from the database and be able to modify them when needed.