1
00:00:00,840 --> 00:00:02,340
Hey guys welcome back.

2
00:00:02,340 --> 00:00:08,550
In this video we'll continue putting in functionality into our wind farms application our most recent

3
00:00:08,610 --> 00:00:15,240
set of tasks had us do our manage vehicle listings where we could add a new car and just add one for

4
00:00:15,240 --> 00:00:21,810
sample sake and we know that when we click save changes it will get added to the database and there

5
00:00:21,810 --> 00:00:25,320
would have to refresh the grid to see or a new car.

6
00:00:25,320 --> 00:00:31,170
Of course when we select the roll and click edit car we could change this so if I if manual suppose

7
00:00:31,170 --> 00:00:33,690
I have two ends then I correct it.

8
00:00:33,690 --> 00:00:39,840
Click save changes and then once again refresh the grid so we can look into automating that grid refresh

9
00:00:39,870 --> 00:00:45,600
in a bit and I'll be doing that in the rental record and management.

10
00:00:45,600 --> 00:00:51,000
But just to finish up or recap the final thing that I would want to do with our vehicles would be to

11
00:00:51,000 --> 00:00:51,690
remove them.

12
00:00:51,690 --> 00:00:57,300
So if I select a roll and remember we discussed that if there is our entire record already associated

13
00:00:57,300 --> 00:01:04,910
with a vehicle that the database would make it a bit more difficult to actually delete the vehicle itself.

14
00:01:04,950 --> 00:01:13,070
But I can always select this vehicle click delete car and then it would OK and I refresh.

15
00:01:13,090 --> 00:01:14,260
And then I see.

16
00:01:14,260 --> 00:01:19,630
So you'd want to automate that refresh because just know the car was removed but the grid didn't show

17
00:01:19,630 --> 00:01:22,870
me it was removed and then I tried again and then I got an error.

18
00:01:22,870 --> 00:01:23,080
All right.

19
00:01:23,380 --> 00:01:31,480
So what we want to do is have grid like sitting in the view archive and then this will allow us to kind

20
00:01:31,480 --> 00:01:37,930
of do those CRUD operations and then I'll show you other things like automating that grid refresh so

21
00:01:37,930 --> 00:01:45,430
to get this party started the first thing I want to do is create a new form that will serve as my archive

22
00:01:45,850 --> 00:01:48,810
window for my rental record.

23
00:01:48,820 --> 00:01:56,680
So I go to my solution Explorer I right click in the solution go to add new item or I can just go down

24
00:01:56,680 --> 00:02:06,870
to form I want to call this form management records and then click Add and once our form is added We

25
00:02:06,870 --> 00:02:14,320
do our regular changes where we go to properties and we change the text in the header to be more you

26
00:02:14,320 --> 00:02:23,280
know more human readable we make it a little bigger and then I'm going to borrow the same elements that

27
00:02:23,280 --> 00:02:27,750
I had over on the managed vehicle listing on went to bar each and every one of them so I'm just going

28
00:02:27,750 --> 00:02:32,090
to bar the label and I'm holding down control while I click.

29
00:02:32,090 --> 00:02:35,190
So I'm holding don't control what I click the Refresh button.

30
00:02:35,200 --> 00:02:43,200
Agreed the three buttons that I want to control C to copy go back over to my design and then control

31
00:02:43,200 --> 00:02:52,740
V to paste after pasting I'm just going to change this label text so I click the label go to properties

32
00:02:53,280 --> 00:02:59,830
and I'm just going to change this to manage our entire records.

33
00:03:00,270 --> 00:03:01,700
It's all right.

34
00:03:01,870 --> 00:03:05,660
This week's my spelling errors.

35
00:03:05,820 --> 00:03:07,130
And then we're good to go.

36
00:03:07,130 --> 00:03:09,180
So manage very entire records.

37
00:03:09,180 --> 00:03:10,560
That's our new window.

38
00:03:10,560 --> 00:03:17,340
And then of course from the main window I need to set it up on the click events several scenes of close

39
00:03:17,370 --> 00:03:19,100
all the unnecessary windows right.

40
00:03:19,100 --> 00:03:26,110
No go back to my mean window yet the button and I'll save you archive.

41
00:03:26,190 --> 00:03:31,200
Set up a click event and Autumn went to do is launch this new windows.

42
00:03:31,210 --> 00:03:34,790
I'm just going to copy sorry I just wrecked it also.

43
00:03:34,950 --> 00:03:51,860
Var manage her and her cards is equal to a new manage or an auto records as my class then I will do

44
00:03:51,860 --> 00:03:52,430
that.

45
00:03:53,740 --> 00:03:55,390
MDI appearance

46
00:03:57,890 --> 00:04:05,760
is equal to this and the window should show all right.

47
00:04:08,550 --> 00:04:15,250
Now after copying over these things what you want to do of course after renaming or label we want to

48
00:04:15,250 --> 00:04:16,930
change out our buttons so right.

49
00:04:16,930 --> 00:04:17,410
No.

50
00:04:17,530 --> 00:04:20,630
They still have the same names from the previous form.

51
00:04:20,740 --> 00:04:26,220
And that's because well the same name can exist on two entirely different forms.

52
00:04:26,230 --> 00:04:28,570
So into entirely different classes.

53
00:04:28,570 --> 00:04:29,920
Sure you can have the same names.

54
00:04:29,920 --> 00:04:31,300
What's contextually.

55
00:04:31,360 --> 00:04:33,390
I don't want this to be beaten out of Cairo.

56
00:04:33,420 --> 00:04:35,120
I want it to be beaten.

57
00:04:35,140 --> 00:04:39,580
I'd maybe record all right.

58
00:04:39,700 --> 00:04:41,290
And just the same way.

59
00:04:41,290 --> 00:04:44,910
Anything that's his car for these buttons should see a record.

60
00:04:44,920 --> 00:04:50,780
So the text should be ad new or into entire record or a record.

61
00:04:50,910 --> 00:04:52,250
I just say a record.

62
00:04:52,480 --> 00:04:54,400
And then I'll do the same for the edit.

63
00:04:54,400 --> 00:04:58,150
So I'll just change those all you can do those on your own.

64
00:04:58,150 --> 00:05:02,600
All right so by the end of that exercise anything that's said car should not see a record.

65
00:05:02,650 --> 00:05:07,510
Also might want to change a name on this grid just to make sure everything is consistent because this

66
00:05:07,510 --> 00:05:09,030
is GV vehicle list.

67
00:05:09,190 --> 00:05:13,010
So I wanted to see GV a card list.

68
00:05:13,090 --> 00:05:13,910
All right.

69
00:05:13,990 --> 00:05:20,220
So now that we have you know Oh I think the refresh button may also need to be changed what it's been

70
00:05:20,230 --> 00:05:20,740
generally for.

71
00:05:20,770 --> 00:05:21,610
So that can see.

72
00:05:22,090 --> 00:05:23,370
All right.

73
00:05:23,370 --> 00:05:29,410
Now we know that we need to click events for each of these buttons someone to just set up those click

74
00:05:29,410 --> 00:05:34,550
events from low by just double clicking each button and generating the Click event.

75
00:05:34,550 --> 00:05:40,930
So of the click event to add click event for the record and clicking event for the delete.

76
00:05:40,960 --> 00:05:47,380
We already have a window that adds so I can actually just read that quote right now and we would kind

77
00:05:47,380 --> 00:05:52,420
of follow the same pattern as we did when we were doing the manage vehicle listings.

78
00:05:52,420 --> 00:05:57,880
So if I go back to that click event for a new car you see that what we did was just launched a window.

79
00:05:58,000 --> 00:06:03,390
Tell it's that the parent off the launching window is experience also.

80
00:06:03,400 --> 00:06:13,010
And then sure someone to follow that same pattern for the ad ad beaten at a record click.

81
00:06:13,200 --> 00:06:13,510
All right.

82
00:06:13,510 --> 00:06:14,110
There we go.

83
00:06:14,110 --> 00:06:20,920
So when we click the beaten ad record it will launch the same window as we would have launched if we

84
00:06:20,920 --> 00:06:23,480
clicked from the many ways so far.

85
00:06:23,500 --> 00:06:26,740
So we're giving the user two options of course it's your application.

86
00:06:26,860 --> 00:06:30,640
You can styled it all you would like but that's how I'm doing it.

87
00:06:30,640 --> 00:06:34,440
Now if you pay attention here I don't know if I would have gone through this before.

88
00:06:34,450 --> 00:06:39,790
But you see those three dots underneath the new if I hover over it and click on that light bulb that

89
00:06:39,790 --> 00:06:47,130
appears they showed me that I can actually simplify the initialization our declaration of this object

90
00:06:47,140 --> 00:06:47,470
right.

91
00:06:47,770 --> 00:06:53,760
So if I click on that then you're going to see a different way to initialize the object which would

92
00:06:53,770 --> 00:06:57,580
have seen when you were using the link code.

93
00:06:57,610 --> 00:06:57,940
Right.

94
00:06:57,940 --> 00:07:05,500
So it's universal one sailor class any are setting properties off the class after initializing the object

95
00:07:05,800 --> 00:07:11,820
you can actually do it like this or you can do it the way you're comfortable doing it and that visual

96
00:07:11,820 --> 00:07:18,690
studio rearrange it for you know for their entire records are going to have to write a lot of similar

97
00:07:18,690 --> 00:07:23,130
code to what we're doing when we're doing manage vehicle listing so I'm actually just going to be copying

98
00:07:23,130 --> 00:07:29,610
and pasting a lot of the code because would have written a lot of it already so I'm pasting my connection

99
00:07:29,610 --> 00:07:38,230
to the database or my entity's object and the object initialization which went inside of my constructor.

100
00:07:38,310 --> 00:07:46,760
Also I would have set up the Load event for the form so I need a load event on this form.

101
00:07:46,800 --> 00:07:53,280
So I just go and double click the form itself and that gives me a load event and then inside off this

102
00:07:53,280 --> 00:07:59,850
load event for the mileage vehicle listings I would have tried and I'm just going to copy all of this

103
00:07:59,850 --> 00:08:09,630
because I mean I'll be re typing very similar code anyway so I am I copied over populate grid but of

104
00:08:09,630 --> 00:08:15,380
course I don't have a method inside of this new form called populate grid.

105
00:08:15,600 --> 00:08:20,250
So I can hover over it and keep that light bulb.

106
00:08:20,250 --> 00:08:23,530
And then this is generate the method for me which.

107
00:08:23,530 --> 00:08:24,900
OK that's good.

108
00:08:24,900 --> 00:08:29,730
Get a move that generates a design and then forward the populates grid.

109
00:08:29,730 --> 00:08:32,270
I'll be doing a similar query.

110
00:08:32,430 --> 00:08:40,110
So let's just write the query for the populate grid for our manage rental records.

111
00:08:40,230 --> 00:08:47,090
So of course the first thing I want to do is declare some object or some variable I just say var or

112
00:08:47,110 --> 00:08:49,900
a cards is equal to.

113
00:08:50,220 --> 00:08:58,800
And then I call on my database object dot car into records which is my table and then I would say dot

114
00:08:58,890 --> 00:09:00,150
select.

115
00:09:00,720 --> 00:09:03,800
And I want to be very specific with what I'm selecting.

116
00:09:03,830 --> 00:09:10,790
So I would just say select open up my lambda expression using q as my object or my token.

117
00:09:11,350 --> 00:09:15,490
And but I'm bloating into a new blank object.

118
00:09:15,510 --> 00:09:16,780
All right.

119
00:09:16,930 --> 00:09:22,710
Let me just put a semicolon here so I don't forget later on and then I'm going to say what it is I want

120
00:09:22,710 --> 00:09:26,440
to select and what that column name is.

121
00:09:26,440 --> 00:09:31,870
All right so the columns that we intend to have would be a customer.

122
00:09:31,890 --> 00:09:42,510
So I'm just going to say customer is equal to huge dots and I are on customer name comma and then date

123
00:09:42,600 --> 00:09:43,060
in.

124
00:09:43,290 --> 00:09:49,290
So here I can actually use my own names for our property right.

125
00:09:49,290 --> 00:09:57,330
So date in is going to have the value of Q dots data into the sorry date out my bud is going to have

126
00:09:57,330 --> 00:09:59,960
the value of data printed.

127
00:10:00,060 --> 00:10:01,040
All right.

128
00:10:01,200 --> 00:10:11,610
And then I'm going to say comma date in of the value of Q Dot date returned.

129
00:10:11,610 --> 00:10:19,910
Of course I need the I.D. So I.D. is going to be equal to cue that I.D..

130
00:10:23,030 --> 00:10:24,320
All right.

131
00:10:24,420 --> 00:10:29,730
And then the last one that I would want is the cost.

132
00:10:29,880 --> 00:10:32,330
So cost is equal to.

133
00:10:32,680 --> 00:10:34,940
That costs.

134
00:10:35,220 --> 00:10:36,240
But then you noticed.

135
00:10:36,240 --> 00:10:36,530
No.

136
00:10:36,530 --> 00:10:40,860
That of course I need to see the type of car or what car was borrowed.

137
00:10:40,860 --> 00:10:42,620
So you see cost this kind of great.

138
00:10:42,690 --> 00:10:45,060
Everything else is you know strong and wide.

139
00:10:45,070 --> 00:10:50,100
What this is great all because the property name I'm giving it is the same as a property coming from

140
00:10:50,100 --> 00:10:56,580
the database so I can actually just remove that and just secured up costs give me the costs and I need

141
00:10:56,580 --> 00:10:57,180
the car.

142
00:10:57,510 --> 00:10:58,220
No.

143
00:10:58,260 --> 00:11:03,870
If you look back in our database and others go over to the database quickly you'll see that we have

144
00:11:04,170 --> 00:11:10,290
the type of car I.D. I have a table for the types of cars.

145
00:11:10,290 --> 00:11:11,150
Sure.

146
00:11:11,250 --> 00:11:15,990
But then I have the name and the I.D. over in that one.

147
00:11:15,990 --> 00:11:22,380
So then you just select top 1000 or let me just look at the design rather so that we can see the column

148
00:11:22,380 --> 00:11:23,520
names.

149
00:11:23,520 --> 00:11:30,800
So I have ideas make model Vin license plate number and we're no in showing the details of their entire

150
00:11:30,810 --> 00:11:31,770
record.

151
00:11:31,770 --> 00:11:37,200
I probably wouldn't want to just show that I.D. because I.D. car I.D. 1 means nothing to me.

152
00:11:37,200 --> 00:11:43,180
But that is the property that I have access to inside of my rental record.

153
00:11:43,260 --> 00:11:43,810
No.

154
00:11:43,860 --> 00:11:50,820
In a typical situation like in escrow syntax I would have to use an inner join statement to actually

155
00:11:50,820 --> 00:11:57,230
get the details of the car being a reference details meaning the make and model.

156
00:11:57,240 --> 00:11:57,600
Right.

157
00:11:57,960 --> 00:12:05,370
So if I wanted to see all of this information and then print the car details Kyra make and model inside

158
00:12:05,370 --> 00:12:12,750
of a query then I would have to use an inner join link allows me to actually access the property.

159
00:12:12,750 --> 00:12:20,340
So let's say I said car as my property and then I wanted to make and the model off the related car or

160
00:12:20,340 --> 00:12:22,440
the car related to this record.

161
00:12:22,530 --> 00:12:29,280
All we really have is the idea because if I say a Q Dot then you're going to see type of car I.D. once

162
00:12:29,280 --> 00:12:30,960
again that is not useful.

163
00:12:31,020 --> 00:12:38,190
So I can kind of simulate a situation where I would need an inner join in any details from the related

164
00:12:38,580 --> 00:12:45,800
entity or the related a record by saying I know we see the use of this types of car properties.

165
00:12:45,800 --> 00:12:53,340
So remember that we add the types of car I.D. and I was seeing that we have inside of the relationship

166
00:12:53,400 --> 00:12:58,490
what link does is give us access to all related objects off the bat.

167
00:12:58,620 --> 00:13:00,770
So I can actually say.

168
00:13:00,780 --> 00:13:08,690
Q What types of car and then they try to make it singular sometimes awkward because it's types of cars.

169
00:13:08,760 --> 00:13:09,860
That's the name of the table.

170
00:13:09,870 --> 00:13:11,700
And in this it's types of car.

171
00:13:11,940 --> 00:13:17,320
Because it's saying that I know only one car is associated with this rental record.

172
00:13:17,340 --> 00:13:18,770
So it's a car.

173
00:13:18,970 --> 00:13:19,770
All right.

174
00:13:19,830 --> 00:13:30,570
So they did try to you know modify the the ten not the tents the singularity and plurality of each property

175
00:13:30,630 --> 00:13:34,530
just to indicate whether it's a singular or multiple.

176
00:13:34,540 --> 00:13:35,060
Right.

177
00:13:35,100 --> 00:13:40,780
So if we're looking at the types of car table types of cars table then link would show us that we ever

178
00:13:40,790 --> 00:13:45,790
integrate cards because one car could be in multiple rental red cards.

179
00:13:46,170 --> 00:13:52,740
But then since you're looking at the entire card that we know one rental record is associated with one

180
00:13:52,980 --> 00:13:53,450
car.

181
00:13:53,450 --> 00:13:55,200
Are types of car.

182
00:13:55,380 --> 00:13:57,250
In this situation.

183
00:13:57,480 --> 00:14:02,840
Oh that's not too confusing but the more you use it those the more you realize how exactly it works.

184
00:14:02,850 --> 00:14:04,560
So I can say.

185
00:14:04,560 --> 00:14:12,390
Q What types of car which is a class the representing or the entity or the related correct card once

186
00:14:12,390 --> 00:14:15,250
again off the card details.

187
00:14:15,450 --> 00:14:21,850
So then I can see the types of car dot and then it gives me access to every single property that would

188
00:14:21,850 --> 00:14:25,040
have been in the types of cars table anyway.

189
00:14:25,080 --> 00:14:32,130
So I did say I wanted the make and the model cyclists a car is equal to Q What types of car make and

190
00:14:32,130 --> 00:14:35,140
then concatenate that onto.

191
00:14:35,400 --> 00:14:42,500
Q What types of car Dot's model.

192
00:14:42,580 --> 00:14:42,860
All right.

193
00:14:43,110 --> 00:14:49,170
So when this runs it will give me all of these properties basically from the database table they're

194
00:14:49,170 --> 00:14:54,570
all right there in the database table and then it will kind of do an inner join to say Okay give me

195
00:14:54,570 --> 00:15:03,060
the details of the related red card from the types of cars table and give me the make space model and

196
00:15:03,060 --> 00:15:07,620
store that inside my custom property called car.

197
00:15:07,620 --> 00:15:07,990
All right.

198
00:15:08,220 --> 00:15:13,500
So the expectation is that when this grid loads we're going to be seeing all of these details in addition

199
00:15:13,500 --> 00:15:16,100
to the details for the related car.

200
00:15:16,830 --> 00:15:22,910
And then while I was pretty much sure with a semicolon of course after all of this we always do a test

201
00:15:23,210 --> 00:15:25,440
just to make our lives easier.

202
00:15:25,700 --> 00:15:26,050
All right.

203
00:15:26,600 --> 00:15:33,560
So the next line which I'm just going to go back over to manage vehicle listing would have me set up

204
00:15:33,560 --> 00:15:41,480
the data source the header text for any one of them that I think is too cumbersome to display and then

205
00:15:41,480 --> 00:15:43,300
they hide the idea.

206
00:15:43,330 --> 00:15:50,030
So I'm just going to copy these lines and then I'm just going to meet them relative to this situation.

207
00:15:50,030 --> 00:15:52,250
So actually I don't think OK.

208
00:15:52,270 --> 00:15:53,270
Dating on dates.

209
00:15:53,320 --> 00:15:55,040
So I definitely want to change those.

210
00:15:55,130 --> 00:16:01,560
But before I do that I need to change older references so I need GV and that it's red card list.

211
00:16:01,730 --> 00:16:04,880
So it's no longer a vehicle this button on its record list.

212
00:16:04,910 --> 00:16:10,470
So in a sense it changes the result the data source is not cars but it's records.

213
00:16:10,550 --> 00:16:11,360
All right.

214
00:16:11,360 --> 00:16:20,480
And then the header text so no I can actually say which column header takes I want to change it so I

215
00:16:20,480 --> 00:16:27,950
can probably use the named columns here because I'm not so confident about the ordering read ordering

216
00:16:27,950 --> 00:16:31,010
my change at anytime I may introduce or remove.

217
00:16:31,010 --> 00:16:35,770
So if I don't see it for like I did in manage vehicle easily it worked here you know.

218
00:16:35,900 --> 00:16:43,920
But then if I modified the arrangement of these columns then for me not to be license plate number anymore.

219
00:16:43,940 --> 00:16:44,300
Right.

220
00:16:44,600 --> 00:16:50,600
So instead of referencing it by its subscript or its placement instead I'm went to reference it by its

221
00:16:50,600 --> 00:16:58,040
name someone to see that the column called it out or a date in it doesn't really matter.

222
00:16:58,040 --> 00:17:01,400
I just duplicate that's under one foot you're not on for oats.

223
00:17:01,420 --> 00:17:02,200
All right.

224
00:17:02,240 --> 00:17:09,650
And then the date in one I wanted to see a date space in and then the dates all one I wanted to see

225
00:17:10,010 --> 00:17:11,710
date space out.

226
00:17:12,140 --> 00:17:12,950
All right.

227
00:17:12,950 --> 00:17:20,540
And then I want to once again hide the column for the I.D..

228
00:17:20,630 --> 00:17:21,010
All right.

229
00:17:21,020 --> 00:17:26,510
So with all those changes made let's at least see if our grid load so I'm just going to start up this

230
00:17:26,510 --> 00:17:32,630
application that I went to manage rent records and click to view archive and voila.

231
00:17:32,630 --> 00:17:42,280
So our grid is loading and notice that we're seeing the car records Subaru and Honda space civic right.

232
00:17:42,290 --> 00:17:46,790
So just to verify I can actually have multiple windows open.

233
00:17:46,910 --> 00:17:53,330
So just expand the application so you can see both the vehicles listed to the left and their entire

234
00:17:53,330 --> 00:17:54,800
regards to the right.

235
00:17:54,800 --> 00:17:58,430
So we see that Subaru is really just the meek.

236
00:17:58,520 --> 00:18:07,040
So that's why we're only seeing the word Subaru whereas Honda Civic make and model are displaying the

237
00:18:07,040 --> 00:18:09,770
details accordingly.

238
00:18:09,790 --> 00:18:11,160
All right.

239
00:18:11,210 --> 00:18:20,240
Further so that if I click add new record then we see add new record coming up allowing us to put in

240
00:18:20,240 --> 00:18:31,010
a new record so I'm going to put in one test driver cost is fifteen hundred dollars and the date returned

241
00:18:31,010 --> 00:18:40,640
would be let's say the 1st of March the type of car is a Rolls Royce Phantom I submit and then everything

242
00:18:40,640 --> 00:18:46,280
goes through I can modify this window no that's it kills is afterwords.

243
00:18:46,280 --> 00:18:46,690
All right.

244
00:18:46,720 --> 00:18:52,410
So that we don't have somebody clicking submit twice but once we close and we click refresh Well there's

245
00:18:52,430 --> 00:18:53,510
no refresh here.

246
00:18:53,780 --> 00:18:59,540
So we need to wire that refresh button up what we did see we're going to try for an automatic refresh

247
00:18:59,840 --> 00:19:05,870
but by closing the window and reopening it it rear end that query that populate grid query and then

248
00:19:05,960 --> 00:19:07,850
we see that our greatest populated.

249
00:19:08,240 --> 00:19:16,980
So I'm just going to quickly wire up the edit and the delete record functionality so I'm going to go

250
00:19:16,980 --> 00:19:23,040
back to my core that we wrote for the edit car listing and I'm going to just take all of this school

251
00:19:23,070 --> 00:19:29,670
because literally it's going to be very similar and I'm going to place it inside of the function and

252
00:19:29,670 --> 00:19:36,220
then I'm just going to change all the relevant references so it's not GV vocalists anymore it's GV or

253
00:19:36,240 --> 00:19:44,930
chord list and I'm getting the same rule with the same so I'd be looking inside of current records.

254
00:19:44,940 --> 00:19:48,510
This time though not types of car car entire records is our table.

255
00:19:48,510 --> 00:19:53,340
So D.B. car entire records first are default.

256
00:19:53,340 --> 00:19:54,960
Give me where to.

257
00:19:55,010 --> 00:20:02,130
Come on I d so you may have some little cosmetic things that change out and the variable here is not

258
00:20:02,130 --> 00:20:07,980
car but it is no record.

259
00:20:08,100 --> 00:20:14,970
All right and then we're here launching an edit vehicle sermon that we did add a vehicle as our window

260
00:20:14,970 --> 00:20:18,060
to allow us to edit or add a vehicle.

261
00:20:18,060 --> 00:20:20,960
We started off with a car and tarot card.

262
00:20:21,030 --> 00:20:26,130
So we're going to have to make some major modifications to that to get it to work.

263
00:20:26,160 --> 00:20:31,020
So I'm just going to come into these lines for No.

264
00:20:31,050 --> 00:20:31,760
All right.

265
00:20:31,770 --> 00:20:33,370
And we'll get back to them.

266
00:20:33,510 --> 00:20:35,560
Gwen's off to do that's in part two.

267
00:20:35,580 --> 00:20:42,370
I'm just going to go back and get that delete code and get the try catch everything.

268
00:20:42,390 --> 00:20:43,820
Bring it over me.

269
00:20:43,830 --> 00:20:45,860
Those cosmetic changes once again.

270
00:20:45,870 --> 00:20:50,910
So it's GV record list and not GV vehicle list.

271
00:20:51,120 --> 00:20:58,320
So I'm getting the same call home different table once again car our cards.

272
00:20:58,350 --> 00:21:00,520
Come on I a B.

273
00:21:01,020 --> 00:21:07,820
And then I'm seeing remove the object and this is a record not car.

274
00:21:07,950 --> 00:21:17,280
So remove the object or a card from the table save changes and then I could just recall populate grid

275
00:21:17,280 --> 00:21:23,100
here instead of doing that a shred.

276
00:21:23,160 --> 00:21:31,970
Delete I just recall populate grid which should rear on the query I did allude to us doing it in part

277
00:21:31,970 --> 00:21:36,370
to what I'm just going to push ahead and finish this up in this video.

278
00:21:36,370 --> 00:21:43,530
So we need to make some modifications to our window that we were using to add or rent record.

279
00:21:43,550 --> 00:21:45,950
So we call it our entire record.

280
00:21:45,970 --> 00:21:53,560
I'm going to rename it's to add edit our entire record and by renaming it and saving it it's going to

281
00:21:53,560 --> 00:21:56,200
ask me if I want to rename all references so I click.

282
00:21:56,200 --> 00:21:56,400
Yes.

283
00:21:56,410 --> 00:22:02,580
So that everywhere that it was making reference to add her entire record it will no say add editor into

284
00:22:02,580 --> 00:22:03,630
our record.

285
00:22:03,640 --> 00:22:09,520
Of course I need to modify the code so I'm just going to write clicks a view code and that brings me

286
00:22:09,520 --> 00:22:16,900
directly to the view file but I'm also going to bring up our ad edit vehicle code file so that we can

287
00:22:16,900 --> 00:22:22,050
see them side by side once again I'm when to make some very similar modifications.

288
00:22:22,050 --> 00:22:28,830
I'm going to take most of the properties that I had in edit vehicle and place instead of ad edit rent

289
00:22:28,900 --> 00:22:35,490
record starting with the edit mode because then we need to track if it's a bit more or add mode you'll

290
00:22:35,500 --> 00:22:38,680
see that we had to construct here.

291
00:22:38,680 --> 00:22:47,290
So I'm going to take all of these properties are all of these lines of code that were inside of the

292
00:22:48,760 --> 00:22:50,660
windows remove what's not necessary.

293
00:22:50,890 --> 00:22:53,830
So I had a car into entities as the name here.

294
00:22:53,830 --> 00:22:59,050
So to keep everything consistent up as I've been saying before I'm just going to rename it to underscore

295
00:22:59,050 --> 00:22:59,730
D.B..

296
00:22:59,770 --> 00:23:00,370
All right.

297
00:23:00,430 --> 00:23:03,070
So it's better to just keep everything consistent.

298
00:23:03,070 --> 00:23:07,990
Use one variable name across the board so that everybody knows who they are.

299
00:23:07,990 --> 00:23:08,610
Right.

300
00:23:08,640 --> 00:23:17,970
So LBO title I didn't give the label inside of this window title but I just say add knew her intro and

301
00:23:18,490 --> 00:23:24,630
the text of the window should also see add new rental and is edit more these forms.

302
00:23:24,640 --> 00:23:25,420
All right.

303
00:23:25,420 --> 00:23:33,490
And then I will declare another constructor sic industry CTO R by step twice and then it generates another

304
00:23:33,490 --> 00:23:44,650
constructor and then I will put in the object off or entire record second a car rental or a card another

305
00:23:44,650 --> 00:23:46,290
Sarah card.

306
00:23:46,360 --> 00:23:47,260
All right.

307
00:23:47,380 --> 00:23:54,130
So remember that when we're doing the ad edit vehicle what we did was create a second constructor that's

308
00:23:54,130 --> 00:23:58,530
allowed us to pass in the the record that needed to be edited.

309
00:23:58,530 --> 00:24:00,320
In this case it was a car to edit.

310
00:24:00,340 --> 00:24:05,140
So to keep be consistent take and say or a card to edit.

311
00:24:05,260 --> 00:24:05,840
All right.

312
00:24:06,190 --> 00:24:14,370
And then once again I'm just going to copy most of this well all of this code since is very similar.

313
00:24:14,410 --> 00:24:15,550
Once again.

314
00:24:15,550 --> 00:24:17,200
And then I'll just change.

315
00:24:17,220 --> 00:24:17,770
Oh.

316
00:24:17,860 --> 00:24:23,870
So this is idiots Renato Ricard.

317
00:24:24,000 --> 00:24:27,450
Let me put the record so that my sentences are complete.

318
00:24:27,460 --> 00:24:28,600
Through and through.

319
00:24:28,600 --> 00:24:34,050
So her entire record it earned her a card.

320
00:24:34,720 --> 00:24:39,230
And then this is record to it it's not card to edit.

321
00:24:39,230 --> 00:24:40,020
All right.

322
00:24:40,030 --> 00:24:42,060
And then populate fields.

323
00:24:42,070 --> 00:24:48,030
That is a that is something that we need to load up so I'm just going to generate a method for that

324
00:24:48,790 --> 00:24:55,230
and then go back to ad vehicle and then we'll see all of the fields that were populated.

325
00:24:55,230 --> 00:25:00,220
So we're probably going to have to do that part manually since there are two entirely different forms.

326
00:25:00,220 --> 00:25:04,420
I'm not going to copy this code but I'm going to still follow that pattern.

327
00:25:04,420 --> 00:25:04,810
All right.

328
00:25:05,230 --> 00:25:13,300
So then what I'm going to do is scroll down to the beat button one click so you see even these things

329
00:25:13,300 --> 00:25:18,280
when we're starting off I was starting off simple so I didn't want to complicate everything but know

330
00:25:18,280 --> 00:25:24,490
that we're at more advanced so we're going back to our old code we realize that we have some gaps so

331
00:25:24,490 --> 00:25:30,760
like button 1 underscore click I don't like this button one on the score click we didn't name the button

332
00:25:30,760 --> 00:25:36,160
at a time but you know that we're naming buttons you can probably go back and give it a better name

333
00:25:36,430 --> 00:25:42,400
and change the name of the button click event that is associated with it so that your code is more readable.

334
00:25:42,440 --> 00:25:47,130
ANNIE HALL What I'm really here for is to get but these fields.

335
00:25:47,140 --> 00:25:53,940
So what I'm going to do is just copy all of this so that I have all of the fields that need to be populated.

336
00:25:55,620 --> 00:25:58,170
And then I'm going to remove.

337
00:25:58,170 --> 00:25:59,790
So I just wanted the field names.

338
00:25:59,790 --> 00:26:00,970
That's all I really wanted.

339
00:26:01,020 --> 00:26:07,840
I'm trying to work you know a bit smarter than I'm trying to work harder so I'm just getting the really

340
00:26:07,840 --> 00:26:10,230
fun parts because I have it's all over.

341
00:26:10,230 --> 00:26:16,080
So instead of sitting down and read typing and trying to remember all of these fields I know I had them

342
00:26:16,500 --> 00:26:17,630
somewhere else.

343
00:26:17,700 --> 00:26:19,670
So I just went and got them right.

344
00:26:19,740 --> 00:26:25,130
And you see here I have a few arrows because this is calling on the car into entities which we changed

345
00:26:25,130 --> 00:26:28,760
the DB So we just fix that same time.

346
00:26:28,800 --> 00:26:33,390
So I mean if you you may not have some other problems I I'm having what I'm going through them just

347
00:26:33,390 --> 00:26:38,360
so that when you see similar problems you know exactly what you need to do to fix them.

348
00:26:38,370 --> 00:26:39,160
Right.

349
00:26:39,210 --> 00:26:50,250
So here I see that I have my fields and I need to give them values so TB customer name not text is going

350
00:26:50,250 --> 00:26:55,730
to have the value of this is car to it it's I don't want it to say car to edit.

351
00:26:55,740 --> 00:27:03,090
So it's a scar to edit because I generated the property based on the function called the function based

352
00:27:03,090 --> 00:27:04,600
on the function called sorry.

353
00:27:04,860 --> 00:27:11,460
So it's required to edit changes that are required to edit and also changes direct or to edit and change

354
00:27:11,460 --> 00:27:11,970
the type.

355
00:27:11,970 --> 00:27:14,700
So you notice it's a generic Object type.

356
00:27:14,940 --> 00:27:21,600
So to make sure that it says car into record so strongly tied to language make sure that all of your

357
00:27:22,230 --> 00:27:24,240
your types are proper.

358
00:27:24,240 --> 00:27:30,980
So it's red card to edit dot and then I'll see costumer name.

359
00:27:31,160 --> 00:27:32,280
All right.

360
00:27:32,280 --> 00:27:38,010
And then just the same for the day it's rented DTA entered that value is going to be required to edit

361
00:27:38,130 --> 00:27:42,720
dot data printed and then the same here.

362
00:27:42,730 --> 00:27:51,230
Oh but I'm getting an arrow where it's seeing that it cannot convert he cannot implicitly convert knowledgeable.

363
00:27:51,240 --> 00:27:56,490
So once you see that question mark alongside a data type it means it's not a boom which means that I

364
00:27:56,490 --> 00:28:00,690
may or may not have a date time or a value inside of it.

365
00:28:00,720 --> 00:28:03,450
So it's in that to the to the right.

366
00:28:03,540 --> 00:28:06,990
This is knowledgeable but to the left it's not multiple.

367
00:28:07,050 --> 00:28:11,190
The value is not knowable so they're saying they can't just see it at.

368
00:28:11,220 --> 00:28:11,970
Okay.

369
00:28:12,090 --> 00:28:19,620
I have another data types so I'm just going to see date time to convert it.

370
00:28:22,790 --> 00:28:23,390
All right.

371
00:28:23,430 --> 00:28:27,730
So now we see that the date time is not knowable.

372
00:28:27,750 --> 00:28:28,290
All right.

373
00:28:28,320 --> 00:28:34,110
So I converted it from a notable date time to an actual date time.

374
00:28:34,110 --> 00:28:38,280
So once again if you look if you just hover over a data until to see the question mark.

375
00:28:38,280 --> 00:28:42,710
So the reason the question mark is there and it's notable is that this is coming from the database and

376
00:28:42,720 --> 00:28:49,730
remember that our database design or at least my database design says that the date time I Low's nodes.

377
00:28:49,740 --> 00:28:57,540
So if I load knows from the database design when the link was converting it into C sharp equivalent

378
00:28:58,050 --> 00:29:05,430
data types then it would have retained that low null property so that the data type would have had this

379
00:29:05,430 --> 00:29:10,590
question mark to say that the date time is a load to be known in C sharp just like oh it is a low to

380
00:29:10,590 --> 00:29:12,540
be no in the database.

381
00:29:12,540 --> 00:29:20,040
In reality however that that knowledgeable date time data type is actually different from our regular

382
00:29:20,040 --> 00:29:25,770
date time just to see him with string and in an almost every other data type you have a multiple version

383
00:29:26,070 --> 00:29:29,280
and you have a version that requires of value.

384
00:29:29,280 --> 00:29:29,880
All right.

385
00:29:29,880 --> 00:29:35,970
So I'll just do the same thing for the next line where I'll just go ahead and write the date time at

386
00:29:35,970 --> 00:29:48,100
the front and then I will call the object that date returned and then for the cost I'll see object not

387
00:29:48,400 --> 00:29:50,560
cost.

388
00:29:50,560 --> 00:29:59,730
All right I don't believe I need any of this but then I see here where they're saying that they I have

389
00:30:00,220 --> 00:30:01,450
what is the problem.

390
00:30:01,470 --> 00:30:02,820
So this is a decimal.

391
00:30:02,850 --> 00:30:06,060
So of course I need to do this to string.

392
00:30:06,330 --> 00:30:09,360
So the database from the database it's a decimal.

393
00:30:09,360 --> 00:30:14,520
I need to convert it to a string so that it can go inside of the text box.

394
00:30:14,520 --> 00:30:17,630
All right so I slow a few errors the fixed gluing back to the top.

395
00:30:17,640 --> 00:30:25,830
We see where there is no there is no object on my form called be a title so I'm just going to make sure

396
00:30:25,830 --> 00:30:27,750
I go or to my design.

397
00:30:27,750 --> 00:30:35,080
So solution expert add ed into a record and this would be the set title right.

398
00:30:35,100 --> 00:30:40,540
So I'm just are said label or other so I'm just going to go to the properties and give it a name so

399
00:30:40,540 --> 00:30:40,790
right.

400
00:30:40,800 --> 00:30:40,950
No.

401
00:30:40,950 --> 00:30:47,520
By default this label one I just rename it to build title and once I do that that should solve that

402
00:30:47,610 --> 00:30:48,900
error.

403
00:30:48,900 --> 00:30:50,200
And there goes.

404
00:30:50,250 --> 00:30:55,260
And see if there are any other errors so you can always see if they're arrows in your code by just looking

405
00:30:55,260 --> 00:31:02,250
over here you see that that's a red line that has an error it was showing red square on that line has

406
00:31:02,250 --> 00:31:08,730
a visual cue and the next error here is that it's still looking for the old entities reference so does

407
00:31:08,730 --> 00:31:13,620
change that's all to my new object name which is on the score sheet.

408
00:31:13,740 --> 00:31:14,220
All right.

409
00:31:14,640 --> 00:31:23,850
So the next thing I would probably want to do is to enforce that edit mode so I have edit mode declared

410
00:31:24,030 --> 00:31:31,640
I have it being set to True or false based on which constructor is being called or so.

411
00:31:31,680 --> 00:31:33,360
All right I'll do that later.

412
00:31:33,570 --> 00:31:42,840
And then what I do is modify the Click event to get all of the data and then do the validations and

413
00:31:42,840 --> 00:31:48,980
then after checking if it is valid we check if we're in edit mode or not.

414
00:31:48,990 --> 00:31:50,250
So we just do that quickly.

415
00:31:50,250 --> 00:32:01,860
So if if is it its mode and ls all right.

416
00:32:02,150 --> 00:32:09,540
So I put else so put all of this in the LS because this is what happens if it's not an idiot mode it

417
00:32:09,670 --> 00:32:16,680
adds it so if it's not an edit more than we're adding I already have the add code splits it into else

418
00:32:16,970 --> 00:32:25,760
but then if it is edit mode then I need to get the record by ideas and then he added so then I'm sorry

419
00:32:25,760 --> 00:32:31,850
if I've seen back unfair to what we're just going through this together from scratch anyway so to get

420
00:32:31,850 --> 00:32:32,480
the idea.

421
00:32:32,480 --> 00:32:41,210
Remember that what we did in the ad edit vehicle was that we created a property or we created control

422
00:32:41,900 --> 00:32:48,080
which was hidden a label which was hidden to which we had assigned the idea off the record that came

423
00:32:48,080 --> 00:32:49,640
over in the of course.

424
00:32:49,660 --> 00:32:54,700
So we failed to do that this time let's just do that to make sure that we have all the bases covered.

425
00:32:54,710 --> 00:32:59,240
Once again it's good that we already rode this good because when we do a side by side comparison we

426
00:32:59,240 --> 00:32:59,670
can.

427
00:32:59,690 --> 00:33:02,570
It can help to inform what we need to do right.

428
00:33:02,630 --> 00:33:07,690
So I'll go back to my design for the ad edit or into record.

429
00:33:07,880 --> 00:33:19,350
I will bring over from the tool box label all right so come on controls get to a label place it somewhere

430
00:33:19,350 --> 00:33:24,510
it doesn't really matter at this point I can just change the properties to see that.

431
00:33:24,540 --> 00:33:31,340
Okay I want this one to be red card or LBO or a card I.D..

432
00:33:32,550 --> 00:33:33,110
Sorry.

433
00:33:33,540 --> 00:33:37,860
Let's text how long it takes to be blank don't want to type in a text.

434
00:33:37,860 --> 00:33:47,550
What I do want it to have the name it'll be a record idea and then I want its visibility to be falls

435
00:33:48,200 --> 00:33:49,530
so it will be hidden.

436
00:33:49,530 --> 00:33:53,640
All right so we have that hidden label somewhere.

437
00:33:53,640 --> 00:33:57,810
It doesn't really matter where if he concedes or not it doesn't really matter unless you need to delete

438
00:33:57,810 --> 00:33:58,160
it.

439
00:33:58,290 --> 00:34:05,820
Then I guess again paint over that area to help selected more moving along what we want to do is to

440
00:34:05,820 --> 00:34:15,850
make sure that we are also populating that LBO record I.D. up text with the idea coming from or a card

441
00:34:16,210 --> 00:34:16,660
so.

442
00:34:16,680 --> 00:34:20,480
Edit all rights are a card to edit that I.D..

443
00:34:22,100 --> 00:34:23,920
All right.

444
00:34:24,120 --> 00:34:26,660
And of course off to see it's a string.

445
00:34:26,940 --> 00:34:29,820
Sorry good.

446
00:34:29,900 --> 00:34:34,020
So we have or I.D. somewhere on the farm.

447
00:34:34,050 --> 00:34:34,860
Right.

448
00:34:34,910 --> 00:34:41,500
So when I move along and I'm about to do editing no the first thing I do is retrieve that.

449
00:34:41,500 --> 00:34:48,120
So var ideas equal to and then I can just implicitly convert this one.

450
00:34:48,200 --> 00:34:59,830
I can't I can go on in that pious rather in that pass and then I'm passing the record i.e. that text

451
00:35:01,160 --> 00:35:08,020
all right so whatever gets stored in that in the text value for that label I'm passing it on.

452
00:35:08,410 --> 00:35:17,260
And I'm retrieving that idea and then I can say via a card is equal to gets it from the database.

453
00:35:17,270 --> 00:35:30,510
D.B. dot and now on car entire records not first are defaults that and then queuing up my lambda expression

454
00:35:30,900 --> 00:35:40,680
Q that I.D. property is equivalent to whatever I.D. value I just got and stored inside of my variable

455
00:35:40,680 --> 00:35:41,760
called I.D..

456
00:35:41,790 --> 00:35:52,080
All right now that I have the record I need to go about changing all the actual values so I can actually

457
00:35:52,590 --> 00:35:54,480
just well.

458
00:35:54,520 --> 00:35:58,480
So what I already did was I scraped the values from the form.

459
00:35:58,480 --> 00:36:01,170
That's what we're doing from day one right.

460
00:36:01,180 --> 00:36:08,440
When we submit the form we have local variables that gets all of these values from the farm.

461
00:36:08,440 --> 00:36:08,960
All right.

462
00:36:09,280 --> 00:36:12,900
So what I'm going to do is not to have the red card.

463
00:36:13,060 --> 00:36:16,310
I'm just going to borrow this code down here.

464
00:36:16,320 --> 00:36:25,960
Actually they can just bought all of this code here base it's up here and then what I will say is instead

465
00:36:25,960 --> 00:36:31,990
of seeing or entire card because our entire record is relative to the object we created from the start

466
00:36:32,210 --> 00:36:37,240
when we set our entire record is blank and then start assigning all the values accordingly.

467
00:36:37,300 --> 00:36:44,440
This time I got retrieved our EBT card that existed and by variables record on well I could actually

468
00:36:44,440 --> 00:36:50,920
just call the variable or entire a just a same because within the scope this rental record exists within

469
00:36:50,920 --> 00:37:00,350
the if scope and then this rent a record object exists instead of the S scope.

470
00:37:00,400 --> 00:37:01,240
All right.

471
00:37:01,240 --> 00:37:07,810
So then based on whatever and I mean this code could probably be refracted I'm seeing how it can be

472
00:37:07,810 --> 00:37:08,640
refracted right.

473
00:37:08,650 --> 00:37:14,320
No to be no more you know much cleaner but I'm not going to complicate it.

474
00:37:14,480 --> 00:37:18,280
I'm just going to leave it like that so I'm declaring an object.

475
00:37:18,310 --> 00:37:25,540
Well I'm retrieving our record here and then using this record I'm going to reset all of the values

476
00:37:25,540 --> 00:37:30,970
based on what we just stored in our local variables coming from the the farm.

477
00:37:30,970 --> 00:37:32,380
All right.

478
00:37:32,380 --> 00:37:42,940
And then in this situation I mean the El situation I'm creating a brand new record and then I'm still

479
00:37:42,940 --> 00:37:46,120
populating this brand new record with but it's coming from the farm.

480
00:37:46,120 --> 00:37:50,370
So even populating with values coming from the farm all of that.

481
00:37:50,410 --> 00:37:51,840
That's his repeated code.

482
00:37:51,850 --> 00:37:55,870
This code could have been done one time really.

483
00:37:55,870 --> 00:37:56,590
All right.

484
00:37:56,590 --> 00:38:02,860
So anytime you see repeated code like this you can look for an opportunity to do refractory it's someone

485
00:38:02,860 --> 00:38:08,140
to leave you to do that outer factor it later and explain it to you but then you can try it on your

486
00:38:08,140 --> 00:38:13,930
own and see how basic entry into the code that your you know you don't repeat all of these lines of

487
00:38:13,930 --> 00:38:16,900
code but you could do it one time and get away.

488
00:38:16,900 --> 00:38:18,340
All right.

489
00:38:18,550 --> 00:38:26,820
So moving on the next thing that we want to do having repopulated all of the records with the potential

490
00:38:26,850 --> 00:38:32,740
new value is even if they're old buddies what a potential new voters from the database is to save the

491
00:38:32,740 --> 00:38:33,300
changes.

492
00:38:33,310 --> 00:38:35,580
I can just once again Copy that.

493
00:38:35,580 --> 00:38:36,870
See if changes.

494
00:38:37,000 --> 00:38:40,460
And then once we're done we want to close.

495
00:38:40,480 --> 00:38:45,390
So much change is going to right close after the message box comes up.

496
00:38:45,490 --> 00:38:51,850
If you're adding We disclose or rather I can just the one close I don't have to close if it's close

497
00:38:51,850 --> 00:38:59,650
if you delete but if is valid and you do all of these things then you just close at the end of that.

498
00:38:59,680 --> 00:39:00,240
Right.

499
00:39:00,310 --> 00:39:11,880
So I'm going to set a message box after saving change is often at its operation and I'll just duplicate

500
00:39:11,880 --> 00:39:12,140
this.

501
00:39:12,140 --> 00:39:14,610
So that's another duplication here again.

502
00:39:14,610 --> 00:39:15,190
Right.

503
00:39:15,210 --> 00:39:20,850
So the problem with duplication is that if I have to make a change to something then I have to do it

504
00:39:20,850 --> 00:39:25,850
here and have to remember to do it here and then in this case with a message box I have to do it here.

505
00:39:25,920 --> 00:39:27,360
And then after remember to do it here.

506
00:39:27,390 --> 00:39:33,570
So on the way four up to code would be to just show you know like call a method that does something

507
00:39:33,570 --> 00:39:34,890
one time.

508
00:39:34,910 --> 00:39:35,810
All right.

509
00:39:36,000 --> 00:39:38,210
So I have multiple ways to do it.

510
00:39:38,550 --> 00:39:44,340
As I said you can find a way I'll do it on my own and then explain it later on but I want to challenge

511
00:39:44,340 --> 00:39:49,440
you guys to start thinking about refactoring code and reducing repetition.

512
00:39:49,440 --> 00:39:49,770
All right.

513
00:39:49,770 --> 00:39:55,530
So before I moved on are fractured the code so I hope you pause the video and try to do yourself.

514
00:39:55,530 --> 00:39:58,800
But either way I did it and explain to you what I did.

515
00:39:59,250 --> 00:40:07,070
So I said after checking if it is valid then I declared an object off car into a red card.

516
00:40:07,080 --> 00:40:08,360
All right.

517
00:40:08,610 --> 00:40:13,740
This is what we would have done if it was create what we need an object of that type either way whether

518
00:40:13,740 --> 00:40:15,750
it is create mode or not.

519
00:40:15,780 --> 00:40:25,040
So within the context then it's okay to just do this step next I think if it is it mode then I want

520
00:40:25,040 --> 00:40:32,720
to retrieve the idea and I want to then retrieve the record from the database and then set that as the

521
00:40:32,720 --> 00:40:34,170
value offerings are required.

522
00:40:34,190 --> 00:40:42,710
So if it is not and if it does not edit mode then this is still just a blank object off car to record

523
00:40:42,770 --> 00:40:49,040
it has no value yet except the fact that it is an initialized object if it is edit mode then we give

524
00:40:49,040 --> 00:40:54,420
it the value based on the record that we're retrieving from the database.

525
00:40:54,650 --> 00:41:02,810
Either way whether it is edit mode or not we want to be populating all off the properties with stuff

526
00:41:02,870 --> 00:41:03,860
from the farm.

527
00:41:03,860 --> 00:41:09,800
So if if it is edit mode then we know the farm is going to have values and if the person is just creating

528
00:41:09,800 --> 00:41:11,600
Eric or the A student of value.

529
00:41:11,600 --> 00:41:17,780
So we're just getting all of those values and placing inside of the object whether or not it was retrieved

530
00:41:17,810 --> 00:41:19,710
or it is still empty.

531
00:41:20,030 --> 00:41:25,680
After doing all of that I'm just saying if it is not edit mode which means that I about to add a red

532
00:41:25,680 --> 00:41:33,140
card then I want to do this step to add the record to the database right to the database table.

533
00:41:33,350 --> 00:41:40,100
And then if it does skip all that then well either way it's going to see the changes the saving the

534
00:41:40,100 --> 00:41:48,130
changes I call the message box so the same message box and then I close the window and that's it that's

535
00:41:48,130 --> 00:41:54,350
all I refracted that whole section to have you know one instance of everything instead of having two

536
00:41:54,350 --> 00:42:00,710
instances of the same operations you know you can look for things that have to hop regardless of the

537
00:42:00,710 --> 00:42:06,730
situation and how you can rearrange your code into fewer lines just to make it easier.

538
00:42:06,760 --> 00:42:14,380
So you can actually go ahead and pause at the different parts just to see add comments.

539
00:42:14,700 --> 00:42:21,130
All rights of added some some comments and the fix a spelling error here.

540
00:42:21,350 --> 00:42:30,080
And so you can actually just go ahead and pause the video you know look at the the comments look at

541
00:42:30,080 --> 00:42:36,710
the code that's written rewrite your code that way or whatever it is you need to do to get acquainted

542
00:42:36,710 --> 00:42:39,460
with what was done here.

543
00:42:39,470 --> 00:42:40,940
All right.

544
00:42:40,940 --> 00:42:46,400
So notice that the statement here I don't know if I pointed it out if you have one line often operationally

545
00:42:46,510 --> 00:42:47,750
you don't need a curly braces.

546
00:42:47,750 --> 00:42:53,300
So here you have to have created braces because I have two lines within here I just said if it's not

547
00:42:53,310 --> 00:42:59,810
adding more than just indented into the next line and indented it will only operate on that one line.

548
00:43:00,110 --> 00:43:07,280
So nothing else will be seen as parts of that if statement now that I'm finished wiring up the edit

549
00:43:07,340 --> 00:43:15,590
her entire record I need to go back to my manage and manage print our cards and that edit click event

550
00:43:15,920 --> 00:43:21,890
and then I will be able to launch the window like I need to.

551
00:43:21,890 --> 00:43:22,610
Right.

552
00:43:22,670 --> 00:43:35,370
So let's say add edit or or a car that's any of my object and that's equal to a new instance of ad edit

553
00:43:35,810 --> 00:43:41,290
or in or card and then the object we're passing in is red card not car.

554
00:43:41,850 --> 00:43:49,170
And then it's the same lines of code just changing the object references there and then we should be

555
00:43:49,170 --> 00:43:55,030
able to properly test the functionality of what we've just done.

556
00:43:55,050 --> 00:43:55,380
All right.

557
00:43:55,380 --> 00:44:00,540
So I clicked on view archive and then let's see what happens if I click a new record.

558
00:44:00,540 --> 00:44:03,660
So we see add new or entire record comes up.

559
00:44:03,750 --> 00:44:05,510
We get our blank form.

560
00:44:05,610 --> 00:44:12,520
Let me just make sure that it works properly.

561
00:44:12,550 --> 00:44:22,990
So he's renting or Volkswagen Beetle for that many days submit all right and then okay.

562
00:44:23,010 --> 00:44:26,480
And the window closes it doesn't refresh.

563
00:44:26,850 --> 00:44:27,840
But then let's try it.

564
00:44:27,840 --> 00:44:30,780
Edit So edit is going to give us that error.

565
00:44:30,780 --> 00:44:38,010
If I had to record and click edit then I see that I'm getting my edit to screen up just as I expected.

566
00:44:38,010 --> 00:44:45,090
So now we know that our ad an edit for the entire record works just that it worked for a managed vehicle

567
00:44:45,090 --> 00:44:50,520
listing and once again we copied and pasted a lot of code made some minor changes but the functionality

568
00:44:50,520 --> 00:44:56,310
was so similar that we really did enough to sit and retype everything right so we can reuse code and

569
00:44:56,310 --> 00:45:01,710
then by refactoring code we're reducing the number of steps in between.

570
00:45:01,730 --> 00:45:06,190
Finally I think we've done quite a bit of work on this form.

571
00:45:06,330 --> 00:45:09,500
So what we will do is end here.

572
00:45:09,540 --> 00:45:15,750
You can go through and you can review revise everything that was done if you have any problems any difficulties

573
00:45:15,750 --> 00:45:17,770
with anything feel free to let me know.

574
00:45:17,820 --> 00:45:19,800
I'd now be more than happy to help.
