1
00:00:00,910 --> 00:00:02,230
Hey guys welcome back.

2
00:00:02,230 --> 00:00:07,150
In this video we're just going to review some of the changes that would have made since the last time

3
00:00:07,150 --> 00:00:12,280
when we're creating our ad edit form for our cars.

4
00:00:12,280 --> 00:00:14,140
Someone to start off with the money.

5
00:00:14,140 --> 00:00:20,050
Vehicle listing window where you read that that I did what I labeled as our refresh button.

6
00:00:20,290 --> 00:00:25,030
So this refresh button will just refresh the grid each time a change is made.

7
00:00:25,330 --> 00:00:29,550
So let us take it for a spin firstly let's start with the ad new car.

8
00:00:29,590 --> 00:00:35,140
So when adding a new car I added validation to the form to make sure that at least the make and the

9
00:00:35,140 --> 00:00:40,900
model our presence when I click save changes then I'm going to get this please ensure that you provide

10
00:00:40,900 --> 00:00:42,700
a make and a model.

11
00:00:42,700 --> 00:00:51,220
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

12
00:00:51,250 --> 00:00:58,360
I also put in try catch because then year is expecting a value so it can pass into integer.

13
00:00:58,390 --> 00:01:05,330
So when I click save changes then my my arrow comes up from my exception right.

14
00:01:05,770 --> 00:01:14,440
So then if I provide a change a year sorry and I say 2013 and while those are only three fields that

15
00:01:14,440 --> 00:01:21,130
are absolutely necessary for it to work and click save changes it put in another message box that's

16
00:01:21,130 --> 00:01:21,280
it.

17
00:01:21,280 --> 00:01:24,940
Insert operation completed refresh grid to see changes.

18
00:01:24,940 --> 00:01:25,180
Right.

19
00:01:25,180 --> 00:01:32,440
So we did disclose that we wanted to manage the user's experience between adding or modifying data in

20
00:01:32,440 --> 00:01:35,000
the car and getting back to the grid.

21
00:01:35,020 --> 00:01:40,540
So if the display in this message box and I think we'll keep the window will close but then I can click

22
00:01:40,540 --> 00:01:44,190
refresh and then it will display the new field.

23
00:01:44,200 --> 00:01:44,980
Right.

24
00:01:44,980 --> 00:01:51,070
And then if I try to edit without selecting so even though you may see it highlighted blue it's not

25
00:01:51,070 --> 00:01:52,150
really selected.

26
00:01:52,180 --> 00:01:55,100
So if I click edit car I get a nasty arrow.

27
00:01:55,120 --> 00:01:58,980
But then once again this is just a try catch catching that arrow.

28
00:01:58,990 --> 00:02:03,550
That would have been an exception showing me that you know the index was both offering and just basically

29
00:02:03,550 --> 00:02:11,140
saying that I didn't select anything from the grid control right but then my program does not stop executing.

30
00:02:11,320 --> 00:02:13,950
So I can always rectify that by just clicking.

31
00:02:13,990 --> 00:02:19,630
And let's start with the record that we just added When I click Suzuki Swift click edit car then it

32
00:02:19,630 --> 00:02:24,700
brings up edit vehicles so I made sure to modify the title that comes up.

33
00:02:24,700 --> 00:02:26,820
So let me go back to ad car.

34
00:02:27,100 --> 00:02:32,590
When I click a new car it's the same form but when the label changes and to the title in the window

35
00:02:32,590 --> 00:02:33,490
changes.

36
00:02:33,490 --> 00:02:36,510
So do any typical use it could have been two different windows.

37
00:02:36,520 --> 00:02:39,910
That's not really our business to worry about.

38
00:02:40,000 --> 00:02:45,580
So I'm just changing it so the user feels like it's the same window at all times although it is the

39
00:02:45,580 --> 00:02:49,000
same with the book to feel like it's a different window sorry.

40
00:02:49,150 --> 00:02:52,850
And then what happens is that a functionality slightly different also.

41
00:02:52,920 --> 00:03:03,200
So we're getting the load the data preloaded I can change the VIN and the license plate number and just

42
00:03:03,200 --> 00:03:07,910
put in some kind of number click save changes and then it is a bit operation completed.

43
00:03:07,910 --> 00:03:09,860
So it's a similar message i click Okay.

44
00:03:09,860 --> 00:03:11,070
Similar behavior.

45
00:03:11,130 --> 00:03:18,110
And then I refresh and then I get the brand new data no deleting is kind of tricky because you can't

46
00:03:18,110 --> 00:03:19,970
delete related data.

47
00:03:20,030 --> 00:03:27,630
Meaning if I select see Subaru which I do believe I have our entire record to represents where already.

48
00:03:27,770 --> 00:03:33,310
If I click delete that I'm going to get some arrows seeing that you know I have to see that exception

49
00:03:33,350 --> 00:03:35,890
for details when I checked all that arrow.

50
00:03:35,900 --> 00:03:42,110
It was really because I have our entire record on Subaru so enough to delete all the entire records

51
00:03:42,110 --> 00:03:47,450
for the Subaru in order to delete the Subaru and that's just referential integrity coming over from

52
00:03:47,450 --> 00:03:48,140
the database.

53
00:03:48,140 --> 00:03:50,570
So that's not necessarily a bad thing.

54
00:03:50,570 --> 00:03:53,770
So if you get that error that's really what's happening.

55
00:03:53,900 --> 00:04:02,900
But I just created Suzuki Swift someone to delete it because I know I have no no records associated

56
00:04:02,900 --> 00:04:03,440
with it.

57
00:04:03,500 --> 00:04:08,500
So then I delete it will Oh well it's actually giving me an error.

58
00:04:08,510 --> 00:04:09,970
I did not expect that.

59
00:04:09,970 --> 00:04:15,770
So let us see exactly what that error is because I really didn't expect that one someone to go over

60
00:04:15,770 --> 00:04:18,300
to my code Western in debug mode.

61
00:04:18,440 --> 00:04:23,900
Go to my click event and then I'm just going to select the point where it's supposed to actually remove

62
00:04:23,900 --> 00:04:27,290
the car and then we're going to try that operation again.

63
00:04:27,290 --> 00:04:33,890
So I click it jumps the break point where it retrieve the car successfully so it knows that it's getting

64
00:04:33,890 --> 00:04:35,020
this is looking Swift.

65
00:04:35,510 --> 00:04:36,410
All right.

66
00:04:36,410 --> 00:04:41,900
And then I can use if someone to step through singles to see if changes at which point to throw is the

67
00:04:41,900 --> 00:04:43,010
exception.

68
00:04:43,160 --> 00:04:52,700
And then if I look in the exception object it says look inside of the inner exception for more details

69
00:04:52,700 --> 00:05:01,910
or I see an exception for more details so I can look at that and then it seeing that I have a constraint

70
00:05:02,300 --> 00:05:06,200
that conflicts with my data base.

71
00:05:06,200 --> 00:05:13,400
So I definitely have to check that out to see if there is an error into a record with that property

72
00:05:14,000 --> 00:05:14,670
with a car.

73
00:05:14,660 --> 00:05:17,540
Sir with that record in the database.

74
00:05:17,690 --> 00:05:26,150
So there is no related record I just checked but what is happening is that it is enforcing some design

75
00:05:26,150 --> 00:05:27,320
constraints.

76
00:05:27,320 --> 00:05:37,010
So in the design of my car into a record or well in the design of this table four types of cars on the

77
00:05:37,100 --> 00:05:39,430
I.D. or on the relationship.

78
00:05:39,470 --> 00:05:46,010
Actually there would be this inserts an update deletion of data rule.

79
00:05:46,040 --> 00:05:46,520
Right.

80
00:05:46,790 --> 00:05:50,080
So basically I can set no action or cascade.

81
00:05:50,090 --> 00:05:57,230
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

82
00:05:57,500 --> 00:06:05,360
the red card then it will delete all associated or all related records if it bleeds car with the I.D.

83
00:06:05,360 --> 00:06:11,510
one can ever rent a record that is associated with car with I.D. one would also get deleted which you

84
00:06:11,510 --> 00:06:13,800
may not necessarily want.

85
00:06:13,820 --> 00:06:18,060
So you have to gauge that experience with your application.

86
00:06:18,080 --> 00:06:26,100
However we do see that you know we can probably go by the delete form no and we fix it at a later date.

87
00:06:26,210 --> 00:06:33,170
But I just wanted to get across the fact that we could modify our application to do some crud against

88
00:06:33,170 --> 00:06:41,690
the vehicle listing we could create a single form that has multiple purposes and we can write some cool

89
00:06:41,690 --> 00:06:47,120
code in our code file to handle the experience that our users have.

90
00:06:47,510 --> 00:06:54,770
So after finishing up our money vehicle listing we'll probably want to turn our attention to finishing

91
00:06:54,770 --> 00:07:00,830
up their entire record where we create a view similar to this where we can view all of the rental records

92
00:07:00,830 --> 00:07:06,320
coming in from the database and be able to modify them when needed.
