01.
$scope.MenuList = [];
02.
var
query =
"SELECT * FROM menu WHERE menu_name=(?) "
;
03.
$cordovaSQLite.execute(db,query,[$stateParams.menu_name]).then(
function
(result){
04.
console.log(
'Select DB Pass.'
);
05.
if
(result.rows.length > 0){
06.
console.log(
'Show DB.'
);
07.
console.log(
'End Select DB.'
);
08.
for
(
var
i = 0; i < result.rows.length; i++){
09.
$scope.MenuList.push({
10.
menu_name: result.rows.item(i).menu_name,
11.
menu_type: result.rows.item(i).menu_type,
12.
menu_id: result.rows.item(i).menu_id
13.
});
14.
}
15.
}
16.
else
{
17.
console.log(
'DB Null.'
);
18.
console.log(
'End Select DB.'
);
19.
$scope.resultAction =
"ไม่พบเมนู"
;
20.
$scope.MenuList = [];
21.
}
22.
},
function
(error){
23.
console.log(
'Select DB Error.'
);
24.
}
25.
);
26.
27.
28.
console.log(
'Start Select DB.'
);
29.
$scope.RmList = [];
30.
var
query =
"SELECT * FROM rm WHERE menu_id=(?) "
;
31.
$cordovaSQLite.execute(db,query,[***ตรงนี้ผมจะเอา menu_id ของการ SELECT TEBLE menu แต่ไม่รู้จะทำยังไง***]).then(
function
(result){
32.
console.log(
'Select DB Pass.'
);
33.
if
(result.rows.length > 0){
34.
console.log(
'Show DB.'
);
35.
console.log(
'End Select DB.'
);
36.
for
(
var
i = 0; i < result.rows.length; i++){
37.
$scope.RmList.push({
38.
rm_name: result.rows.item(i).rm_name,
39.
rm_unit: result.rows.item(i).rm_unit,
40.
rm_nameunit: result.rows.item(i).rm_nameunit,
41.
rm_price: result.rows.item(i).rm_price,
42.
rm_id: result.rows.item(i).rm_id,
43.
menu_id: result.rows.item(i).menu_id
44.
});
45.
}
46.
$scope.resultAction =
""
;
47.
}
48.
else
{
49.
console.log(
'DB Null.'
);
50.
console.log(
'End Select DB.'
);
51.
$scope.resultAction =
"ไม่พบวัตถุดิบ"
;
52.
$scope.RmList = [];
53.
}
54.
},
function
(error){
55.
console.log(
'Select DB Error.'
);
56.
}
57.
);