0
1
00:00:05,256 --> 00:00:09,100
<v ->In Previous lecture we created our updates class and</v>
1

2
00:00:09,100 --> 00:00:11,060
also we created our window, right?
2

3
00:00:11,060 --> 00:00:13,120
What we need to do in this lesson?
3

4
00:00:13,120 --> 00:00:16,960
we need to create our design for this page, right?
4

5
00:00:16,960 --> 00:00:19,660
As you remember, it is totally empty.
5

6
00:00:19,660 --> 00:00:21,970
There is nothing for my window.
6

7
00:00:21,970 --> 00:00:25,170
My people, David, update. As you see,
7

8
00:00:25,170 --> 00:00:28,430
it's totally empty. So what I will do, actually now
8

9
00:00:28,430 --> 00:00:31,880
if I click this add button, you see it is...
9

10
00:00:33,303 --> 00:00:35,733
well my design is something like that, okay?
10

11
00:00:36,780 --> 00:00:41,400
I will copy this "add people" design codes, okay?
11

12
00:00:41,400 --> 00:00:43,530
And here I will go back here,
12

13
00:00:43,530 --> 00:00:44,610
add people...
13

14
00:00:45,853 --> 00:00:47,600
And frames
14

15
00:00:50,850 --> 00:00:55,050
I don't need this function because I will use update.
15

16
00:00:55,050 --> 00:00:57,030
This is insert method, right.
16

17
00:00:57,030 --> 00:01:01,023
Here, I will come to here and paste it somewhere here.
17

18
00:01:03,290 --> 00:01:07,283
So what I need to do, I need to remove this command, right,
18

19
00:01:08,210 --> 00:01:10,570
because I will create another function.
19

20
00:01:10,570 --> 00:01:12,980
Now if I run my application...
20

21
00:01:14,530 --> 00:01:18,430
my people and Adam. Update. As you see now it's here.
21

22
00:01:18,430 --> 00:01:21,530
So what I want to do here for example, for Adam I click it,
22

23
00:01:21,530 --> 00:01:26,530
right? I want to display the person information here
23

24
00:01:26,770 --> 00:01:30,880
at my entries and also here.
24

25
00:01:30,880 --> 00:01:32,290
Text editor. How can I do that?
25

26
00:01:32,290 --> 00:01:35,870
For example for a name, name will be here- Adam Black-
26

27
00:01:35,870 --> 00:01:39,730
his email, his phone, and also his address.
27

28
00:01:41,700 --> 00:01:46,510
And after that, you can update which information you
28

29
00:01:46,510 --> 00:01:49,343
want or use it anyway if you will like that.
29

30
00:01:51,170 --> 00:01:53,750
Here I will come and say...
30

31
00:01:54,690 --> 00:01:58,420
firstly, if you want, we can create our...
31

32
00:01:59,560 --> 00:02:03,803
actually lets go back here for our button is here.
32

33
00:02:06,450 --> 00:02:09,390
Not that one, sorry. It is somewhere here.
33

34
00:02:09,390 --> 00:02:11,530
Yes, we need to fill this area.
34

35
00:02:11,530 --> 00:02:13,310
For the name, what I need to do...
35

36
00:02:14,500 --> 00:02:18,840
I already got my information from my database by the way.
36

37
00:02:18,840 --> 00:02:23,720
It's here. So for the name, what I will say come here
37

38
00:02:23,720 --> 00:02:25,600
for the name and...
38

39
00:02:26,860 --> 00:02:28,830
instead of insert here
39

40
00:02:30,944 --> 00:02:35,020
I will say only here, "self dot person name".
40

41
00:02:38,380 --> 00:02:42,280
And now, if I run my application for example,
41

42
00:02:42,280 --> 00:02:46,970
Run, my people, Adam, and update,
42

43
00:02:46,970 --> 00:02:49,260
you see Adam is here.
43

44
00:02:49,260 --> 00:02:51,870
And for others also let's do that.
44

45
00:02:51,870 --> 00:02:56,580
For surname, what I will say here,
45

46
00:02:56,580 --> 00:02:59,237
I will say "self dot surname".
46

47
00:02:59,237 --> 00:03:00,587
"self dot surname".
47

48
00:03:02,820 --> 00:03:05,297
But it was "person surname" I think it was.
48

49
00:03:05,297 --> 00:03:07,253
"person surname"
49

50
00:03:07,253 --> 00:03:11,320
Yes, it's here by the way, values from my database.
50

51
00:03:11,320 --> 00:03:14,467
The second one is "self dot person email".
51

52
00:03:15,797 --> 00:03:17,430
"surname" "email"
52

53
00:03:17,430 --> 00:03:20,207
Instead of "please enter an email" I will say
53

54
00:03:20,207 --> 00:03:25,207
"self dot person email" and this one is will be
54

55
00:03:25,407 --> 00:03:29,080
"person phone" I think. "Self dot...
55

56
00:03:31,170 --> 00:03:33,610
person phone".
56

57
00:03:33,610 --> 00:03:36,800
And for the address, what I will do it is text editor.
57

58
00:03:36,800 --> 00:03:40,010
I need to do something else here  what I will say...
58

59
00:03:41,640 --> 00:03:46,640
And I will say "address" is here. Okay. So
59

60
00:03:47,040 --> 00:03:52,040
I will say, "self dot address dot insert".
60

61
00:03:52,810 --> 00:03:57,340
Here I will say, "one point zero", okay?
61

62
00:03:57,340 --> 00:03:59,267
And after that here I will say,
62

63
00:03:59,267 --> 00:04:04,267
"self dot person address". Okay?
63

64
00:04:04,400 --> 00:04:05,910
If I run my application now...
64

65
00:04:05,910 --> 00:04:08,190
By the way we need to go here for the button.
65

66
00:04:08,190 --> 00:04:11,917
It's "add person", I will say here "update person".
66

67
00:04:12,890 --> 00:04:15,853
And now let's run our application.
67

68
00:04:20,040 --> 00:04:24,083
For Adam, update. As you see, Adam's name is here,
68

69
00:04:24,083 --> 00:04:26,407
surname is here, email and phone number,
69

70
00:04:26,407 --> 00:04:30,980
and this is his address. And so what I need to do now,
70

71
00:04:30,980 --> 00:04:33,313
when I hit this button, that one right?
71

72
00:04:34,274 --> 00:04:36,060
When I hit this button,"update person"
72

73
00:04:36,060 --> 00:04:38,530
I need to update my database, right?
73

74
00:04:38,530 --> 00:04:42,240
And so how can I do that? To do that I need to create a new
74

75
00:04:42,240 --> 00:04:46,403
function for my button. My button is here.
75

76
00:04:48,200 --> 00:04:53,200
So I will say here, "command is equal to update person".
76

77
00:04:56,710 --> 00:04:58,987
But here must be self, by the way.
77

78
00:04:58,987 --> 00:05:02,123
"Self dot update person" and now what I need to do
78

79
00:05:02,123 --> 00:05:05,970
I need to create my function and here...
79

80
00:05:09,118 --> 00:05:11,583
I will come and say "def update...
80

81
00:05:15,227 --> 00:05:16,707
"update person".
81

82
00:05:20,270 --> 00:05:22,960
So what I will say here, right,
82

83
00:05:22,960 --> 00:05:27,960
I will say now, "person id is equal to
83

84
00:05:28,320 --> 00:05:31,427
self dot person id".
84

85
00:05:33,970 --> 00:05:37,920
And other one is "person name
85

86
00:05:39,650 --> 00:05:41,733
is equal to self dot"...
86

87
00:05:43,970 --> 00:05:47,230
Here is something wrong I am doing,
87

88
00:05:47,230 --> 00:05:49,230
let me explain, it's not like that,
88

89
00:05:49,230 --> 00:05:52,140
so let me explain something, sorry about it,
89

90
00:05:52,140 --> 00:05:57,140
now if I say here "pass", so I need to do something else here
90

91
00:05:58,240 --> 00:06:00,507
let me run my application.
91

92
00:06:00,507 --> 00:06:03,847
"My people", for example Adam, if I say "update",
92

93
00:06:04,970 --> 00:06:06,870
now what I'm doing for example here,
93

94
00:06:06,870 --> 00:06:09,513
you change name and you did , for example,
94

95
00:06:11,690 --> 00:06:14,390
let's say "Volkan", okay, my name.
95

96
00:06:14,390 --> 00:06:16,610
His name is something different, right?
96

97
00:06:16,610 --> 00:06:21,370
So I need to get these new values from my entries
97

98
00:06:21,370 --> 00:06:23,683
and also from the text editor.
98

99
00:06:26,613 --> 00:06:31,240
I have new entries, new information for my person.
99

100
00:06:31,240 --> 00:06:33,133
That's why I need to get these values.
100

101
00:06:35,020 --> 00:06:37,383
How can I do that? I need to use again here,
101

102
00:06:41,320 --> 00:06:44,380
values, right? Because for example for entry
102

103
00:06:44,380 --> 00:06:48,130
I need to say "self dot entry name dot get".
103

104
00:06:48,130 --> 00:06:52,643
For surname, "self dot entry surname dot get".
104

105
00:06:52,643 --> 00:06:55,890
I need to get these values. To do that, what I will do...
105

106
00:06:55,890 --> 00:06:58,730
new values... so I will go back here
106

107
00:06:58,730 --> 00:07:02,747
and my people is here and for new values I will say,
107

108
00:07:02,747 --> 00:07:06,920
"person id is equal to..."
108

109
00:07:06,920 --> 00:07:09,030
this is my "self dot person id"
109

110
00:07:09,030 --> 00:07:11,880
because I don't get "person id" from my
110

111
00:07:12,750 --> 00:07:17,750
fields, entries, or text editor.
111

112
00:07:17,760 --> 00:07:20,550
So that's why I need to use this person ID.
112

113
00:07:20,550 --> 00:07:22,320
I already know which person I will update,
113

114
00:07:22,320 --> 00:07:25,747
so I will use that one for the person ID only.
114

115
00:07:25,747 --> 00:07:30,620
"Self dot person id", but for name,
115

116
00:07:30,620 --> 00:07:33,757
name is a new value. can be a new value
116

117
00:07:33,757 --> 00:07:37,160
"person underscore name is equal
117

118
00:07:37,160 --> 00:07:38,810
to now self dot
118

119
00:07:40,570 --> 00:07:45,570
entry name dot get"
119

120
00:07:47,010 --> 00:07:48,350
This is important.
120

121
00:07:48,350 --> 00:07:50,240
For other one I will say "person...
121

122
00:07:50,240 --> 00:07:51,767
This is new values by the way.
122

123
00:07:51,767 --> 00:07:56,767
"person surname is equal to self dot entry...
123

124
00:07:59,960 --> 00:08:04,307
entry underscore surname dot get".
124

125
00:08:05,170 --> 00:08:10,170
I am going to get these values from ent_phone.
125

126
00:08:10,430 --> 00:08:14,810
This value, and this value, entry email value,
126

127
00:08:14,810 --> 00:08:17,793
phone value, surname value, and name value.
127

128
00:08:18,790 --> 00:08:20,647
And after that, what I will say, I will say,
128

129
00:08:20,647 --> 00:08:23,350
"person email...
129

130
00:08:26,030 --> 00:08:30,770
is equal to self dot entry email
130

131
00:08:32,230 --> 00:08:37,110
dot get". And the other one is "person...
131

132
00:08:38,970 --> 00:08:42,260
phone right? "person phone...
132

133
00:08:43,350 --> 00:08:47,463
is equal to self dot entry phone dot get".
133

134
00:08:49,810 --> 00:08:51,387
And the last one will be address
134

135
00:08:51,387 --> 00:08:52,950
"person address...
135

136
00:08:59,720 --> 00:09:03,670
is equal to self dot address".
136

137
00:09:03,670 --> 00:09:06,640
This is text editor so I will say "get" and after "get"
137

138
00:09:06,640 --> 00:09:10,190
I will say "one point zero" and here
138

139
00:09:12,010 --> 00:09:13,010
single quote 'end...
139

140
00:09:14,260 --> 00:09:19,260
dash one c'. For new values, I already have my new values
140

141
00:09:19,790 --> 00:09:23,550
it's here. So, how can I update my database?
141

142
00:09:23,550 --> 00:09:26,137
To do that here, I will use "try" and except again...
142

143
00:09:26,137 --> 00:09:31,137
"try" and after that here I say "except"
143

144
00:09:31,417 --> 00:09:35,040
for now I will say "pass". Okay?
144

145
00:09:35,040 --> 00:09:38,037
And now I need to create a query.
145

146
00:09:38,037 --> 00:09:43,030
"Query is equal to..." this will be a little bit long.
146

147
00:09:43,030 --> 00:09:45,519
Update query is actually very long,
147

148
00:09:45,519 --> 00:09:48,140
but don't worry, it's fine.
148

149
00:09:48,140 --> 00:09:51,080
And here I will say...
149

150
00:09:52,157 --> 00:09:55,260
"update persons"
150

151
00:09:55,260 --> 00:09:57,400
This is my table name, right?
151

152
00:09:57,400 --> 00:10:00,420
And "set person name...
152

153
00:10:03,310 --> 00:10:05,960
is equal to question mark".
153

154
00:10:05,960 --> 00:10:09,130
This is for person name. After here I will say...
154

155
00:10:11,710 --> 00:10:13,660
name, and after the other one, surname.
155

156
00:10:18,765 --> 00:10:23,447
"Person surname...
156

157
00:10:23,447 --> 00:10:26,320
is equal to question mark again
157

158
00:10:26,320 --> 00:10:30,097
and comma person underscore email
158

159
00:10:32,770 --> 00:10:35,020
is equal to question mark
159

160
00:10:36,100 --> 00:10:40,140
and person phone...
160

161
00:10:41,800 --> 00:10:43,530
phone number let's say...
161

162
00:10:50,190 --> 00:10:54,323
is equal to question mark" and last one is,
162

163
00:10:55,837 --> 00:10:56,830
"person...
163

164
00:11:01,950 --> 00:11:06,950
address is equal to... sorry...
164

165
00:11:08,790 --> 00:11:11,810
is equal to question mark". Right?
165

166
00:11:11,810 --> 00:11:14,430
What I need to do now, it's not enough,
166

167
00:11:14,430 --> 00:11:18,004
I need to say here and to use where statement.
167

168
00:11:18,004 --> 00:11:20,213
I will say "where" for which person.
168

169
00:11:21,864 --> 00:11:25,660
I will say which one person ID is,
169

170
00:11:25,660 --> 00:11:28,770
again, is equal to question mark.
170

171
00:11:28,770 --> 00:11:30,610
So I will use person ID...
171

172
00:11:32,301 --> 00:11:34,350
What I will say I will come here
172

173
00:11:34,350 --> 00:11:39,350
to my query and I will say "cursor dot
173

174
00:11:41,200 --> 00:11:45,010
execute" and my query is first parameter.
174

175
00:11:45,010 --> 00:11:48,320
And second one will be this question mark.
175

176
00:11:48,320 --> 00:11:51,820
Instead of this question marks I will use my variables
176

177
00:11:51,820 --> 00:11:56,820
And here I will say "parentheses person name"
177

178
00:11:58,320 --> 00:12:01,217
is the first one and the other one will be,
178

179
00:12:01,217 --> 00:12:03,393
"person surname"...
179

180
00:12:07,910 --> 00:12:09,830
person email...
180

181
00:12:11,760 --> 00:12:14,563
and person phone"
181

182
00:12:15,670 --> 00:12:18,513
and other one is "person address".
182

183
00:12:19,560 --> 00:12:22,803
But, not enough because I have also for "where,
183

184
00:12:24,170 --> 00:12:27,300
other one I have here, "where person ID".
184

185
00:12:27,300 --> 00:12:30,927
For the person ID also I will say "person ID".
185

186
00:12:31,970 --> 00:12:36,110
Here, "person address" and the other one will be "person ID
186

187
00:12:37,160 --> 00:12:42,160
Now, press enter here and what I need to say
187

188
00:12:42,277 --> 00:12:45,587
I need to say "connection dot commit".
188

189
00:12:47,430 --> 00:12:50,167
If everything is fine, I want to show a message.
189

190
00:12:50,167 --> 00:12:55,167
"Messagebox dot showinfo" and here I will say,
190

191
00:12:55,747 --> 00:12:56,903
"success"
191

192
00:12:58,650 --> 00:13:03,473
and here "person has been updated".
192

193
00:13:07,400 --> 00:13:10,617
By the way, also I want to destroy my window...
193

194
00:13:10,617 --> 00:13:14,020
"self dot destroy" that will close my window.
194

195
00:13:14,020 --> 00:13:16,763
If not, here I will show another message.
195

196
00:13:19,545 --> 00:13:22,830
And here it will be "showinfo" again,
196

197
00:13:22,830 --> 00:13:25,800
but this one title will be "warning".
197

198
00:13:25,800 --> 00:13:29,537
This is my question, sorry message box title right?
198

199
00:13:29,537 --> 00:13:32,687
"Person has not been updated".
199

200
00:13:33,750 --> 00:13:37,444
And here also we can use "icon", for "icon".
200

201
00:13:37,444 --> 00:13:39,530
For 'icon' I'll say...
201

202
00:13:42,870 --> 00:13:47,617
For "icon" I'll say "icon is equal to warning icon".
202

203
00:13:49,060 --> 00:13:53,280
That's all and now I hope everything is fine
203

204
00:13:53,280 --> 00:13:57,287
and if I run my application now, "Adam"
204

205
00:13:57,287 --> 00:13:59,657
"Update" as you see everything is here.
205

206
00:13:59,657 --> 00:14:02,983
I will say only for name, "Volkan" okay?
206

207
00:14:04,088 --> 00:14:06,150
Let's actually change everything,
207

208
00:14:06,150 --> 00:14:09,283
Surname, "Volkan"...
208

209
00:14:10,708 --> 00:14:11,763
Email... gmail.com...
209

210
00:14:17,100 --> 00:14:20,480
Plus one, something like that.
210

211
00:14:20,480 --> 00:14:21,733
So, what's wrong here?
211

212
00:14:25,380 --> 00:14:26,213
It's okay.
212

213
00:14:26,213 --> 00:14:29,360
And here, I will say now I am in Krasnodar
213

214
00:14:29,360 --> 00:14:31,873
so I will say Krasnodar, Russia.
214

215
00:14:38,340 --> 00:14:41,940
Okay, fine. Now if I hit update button.
215

216
00:14:41,940 --> 00:14:44,363
Person has not been updated, something wrong.
216

217
00:14:45,760 --> 00:14:48,643
Probably, it's about our query, okay?
217

218
00:14:51,610 --> 00:14:55,707
Let's check it, it's "my people" and "update persons".
218

219
00:14:58,900 --> 00:15:03,900
I need to check, "set person name". Okay. "question mark",
219

220
00:15:04,267 --> 00:15:08,647
"person surname", "person name".
220

221
00:15:08,647 --> 00:15:11,710
"person surname question mark", "person email
221

222
00:15:11,710 --> 00:15:16,710
question mark comma", "person phone number comma"
222

223
00:15:16,717 --> 00:15:20,720
"person address comma", "where person id equals two
223

224
00:15:21,930 --> 00:15:25,060
question mark". Okay this is also fine,
224

225
00:15:25,060 --> 00:15:28,063
something's wrong here, but what is it?
225

226
00:15:30,357 --> 00:15:34,120
"person phone number" is our database table name,
226

227
00:15:34,120 --> 00:15:39,050
let me check I think it is "person phone" not "phone number"
227

228
00:15:39,050 --> 00:15:44,033
show in explorer, okay? Database. And here,
228

229
00:15:45,030 --> 00:15:47,480
click it, we need to check our table,
229

230
00:15:47,480 --> 00:15:50,070
persons, right? "person phone",
230

231
00:15:50,070 --> 00:15:52,530
it's not "person phone number", okay?
231

232
00:15:52,530 --> 00:15:56,250
So I need to change here, this is my...
232

233
00:15:58,820 --> 00:16:01,070
table fields okay their name
233

234
00:16:01,070 --> 00:16:04,610
so I think that was the problem,
234

235
00:16:04,610 --> 00:16:07,970
now, again I want to check, "cursor", "execute",
235

236
00:16:07,970 --> 00:16:11,677
my query, "person name", "person surname" "person email",
236

237
00:16:11,677 --> 00:16:15,837
"person phone", "person address", "where person id",
237

238
00:16:16,727 --> 00:16:19,560
"person id". It is person... right.
238

239
00:16:19,560 --> 00:16:22,980
So "con dot commit", it's okay, I think it's fine now.
239

240
00:16:22,980 --> 00:16:27,980
If I run my application. Run. My people.
240

241
00:16:28,590 --> 00:16:33,590
Adam. Update. Instead of Adam I will say Volkan.
241

242
00:16:35,168 --> 00:16:38,357
"Volkan@gmail.com".
242

243
00:16:39,340 --> 00:16:41,580
Plus, something like that
243

244
00:16:41,580 --> 00:16:45,013
and here, I will say, Krasnodar,
244

245
00:16:47,780 --> 00:16:48,613
Russia.
245

246
00:16:49,660 --> 00:16:52,470
Let's hit "update person" button.
246

247
00:16:52,470 --> 00:16:56,000
As you see, person has been updated, everything works fine.
247

248
00:16:56,000 --> 00:16:59,840
And we are also done with our update page,
248

249
00:16:59,840 --> 00:17:01,983
for now that's all, see you in the next.
