Gitlab@Informatics
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
65160394
Project
Commits
0ec926f4
Commit
0ec926f4
authored
3 months ago
by
65160394
Browse files
Options
Downloads
Patches
Plain Diff
Project Round 10
parent
6fce0c93
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
models/tourModel.js
+4
-4
4 additions, 4 deletions
models/tourModel.js
views/edittour.ejs
+9
-0
9 additions, 0 deletions
views/edittour.ejs
with
13 additions
and
4 deletions
models/tourModel.js
+
4
−
4
View file @
0ec926f4
...
@@ -53,19 +53,19 @@ class Tour {
...
@@ -53,19 +53,19 @@ class Tour {
// อัปเดตทัวร์
// อัปเดตทัวร์
static
async
updateTour
(
tourId
,
tourData
)
{
static
async
updateTour
(
tourId
,
tourData
)
{
const
{
name
,
description
,
price
,
duration
}
=
tourData
;
const
{
name
,
description
,
price
,
duration
,
companyid
}
=
tourData
;
// ตรวจสอบข้อมูลให้ครบถ้วน
// ตรวจสอบข้อมูลให้ครบถ้วน
if
(
!
name
||
!
description
||
!
price
||
!
duration
)
{
if
(
!
name
||
!
description
||
!
price
||
!
duration
||
!
companyid
)
{
throw
new
Error
(
'
ข้อมูลไม่ครบถ้วน
'
);
throw
new
Error
(
'
ข้อมูลไม่ครบถ้วน
'
);
}
}
// สร้างคำสั่ง SQL สำหรับการอัปเดตข้อมูล
// สร้างคำสั่ง SQL สำหรับการอัปเดตข้อมูล
const
query
=
'
UPDATE tours SET name = ?, description = ?, price = ?, duration = ? WHERE id = ?
'
;
const
query
=
'
UPDATE tours SET name = ?, description = ?, price = ?, duration = ?
, companyid = ?
WHERE id = ?
'
;
try
{
try
{
// ใช้ tourId ที่รับมาในการอัปเดต
// ใช้ tourId ที่รับมาในการอัปเดต
const
[
results
]
=
await
pool
.
execute
(
query
,
[
name
,
description
,
price
,
duration
,
tourId
]);
const
[
results
]
=
await
pool
.
execute
(
query
,
[
name
,
description
,
price
,
duration
,
companyid
,
tourId
]);
console
.
log
(
'
✅ Update results:
'
,
results
);
console
.
log
(
'
✅ Update results:
'
,
results
);
return
results
;
return
results
;
}
catch
(
error
)
{
}
catch
(
error
)
{
...
...
This diff is collapsed.
Click to expand it.
views/edittour.ejs
+
9
−
0
View file @
0ec926f4
...
@@ -26,6 +26,15 @@
...
@@ -26,6 +26,15 @@
<label
for=
"tourDuration"
>
ระยะเวลา (วัน):
</label>
<label
for=
"tourDuration"
>
ระยะเวลา (วัน):
</label>
<input
type=
"number"
id=
"tourDuration"
name=
"duration"
value=
"<%= tour.duration %>"
required
>
<input
type=
"number"
id=
"tourDuration"
name=
"duration"
value=
"<%= tour.duration %>"
required
>
</div>
</div>
<div>
<label
for=
"tourCompany"
>
บริษัท:
</label>
<select
id=
"tourCompany"
name=
"companyid"
required
>
<option
value=
""
disabled
selected
>
เลือกบริษัท
</option>
<option
value=
"1"
>
Amazing Travel
</option>
<option
value=
"2"
>
Wonderful Tours
</option>
<option
value=
"3"
>
Explore Asia
</option>
</select>
</div>
<button
type=
"submit"
>
Update Tour
</button>
<button
type=
"submit"
>
Update Tour
</button>
</form>
</form>
</main>
</main>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment