Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
alexproust committed Nov 29, 2024
2 parents cbfc29f + d03dfc6 commit 0a25b95
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
14 changes: 13 additions & 1 deletion Database.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function dbGetHandle()
return db
}

function dbInsert(Id, Type, Description)
function dbInsert()
{
let db = dbGetHandle()
let rowid = 0;
Expand Down Expand Up @@ -69,6 +69,18 @@ function dbReadAll()
})
}


function dbSet(id, costume)
{
let db = dbGetHandle()
console.log("Change in db the id " + id + " type : " + costume.type)
db.transaction(function (tx) {
tx.executeSql(
'update costume set id=?, type=?, description=?, genre=?, mode=?, epoque=?, couleur=?, taille=?, etat=?, emplacement=?, emprunteur=?, date_emprunt=?, date_versement_caution=?, date_retour=?, date_remoursement_caution=?, commentaires=? where rowid = ?',
[id, costume.type, costume.description, costume.genre, costume.mode, costume.epoque, costume.couleur, costume.taille, "", "", "", "", "", "", "", "", id])
})
}

function dbUpdate(costume)
{
let db = dbGetHandle()
Expand Down
12 changes: 12 additions & 0 deletions DemoDetail.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Rectangle {
color: Colors.bluegrey25
signal recordModification()
signal deleteCostume()
signal duplicateCostume()

MouseArea {
width: parent.width + 100
Expand Down Expand Up @@ -58,6 +59,17 @@ Rectangle {
}
}

Button {
id: duplicateButton
text: "Dupliquer"
anchors.left: suppressionButton.right
anchors.top: parent.top
anchors.margins: 16
onClicked: {
demoDetail.duplicateCostume()
}
}

Button {
text: demoDetail.editMode ? "Sauvegarder" : "Fermer"
anchors.right: parent.right
Expand Down
11 changes: 9 additions & 2 deletions main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ AppliQuantum {

onAddSelect: {
let rowid = JS.dbInsert()
JS.dbUpdate(({}));
visualModel.listModel.update()
demoDetail.costumeSelected = visualModel.listModel.get(0)
demoDetail.visible = true
Expand Down Expand Up @@ -93,7 +92,15 @@ AppliQuantum {
onDeleteCostume: {
JS.dbDeleteRow(costumeSelected.id)
demoDetail.visible = false
listModel.update()
visualModel.listModel.update()
}
onDuplicateCostume: {
let rowid = JS.dbInsert();
JS.dbSet(rowid, demoDetail.costumeSelected);
visualModel.listModel.update()
demoDetail.costumeSelected = visualModel.listModel.get(0)
demoDetail.visible = true
demoDetail.editMode = true
}
}

Expand Down

0 comments on commit 0a25b95

Please sign in to comment.