Typica is a free program for professional coffee roasters. https://typica.us
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

renamedepartment.xml 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <window id="renamedepartment">
  2. <layout type="vertical">
  3. <layout type="horizontal">
  4. <label>Department Name:</label>
  5. <line id="namefield" />
  6. </layout>
  7. <layout type="horizontal">
  8. <button name="Save" type="push" id="save" />
  9. </layout>
  10. </layout>
  11. <program>
  12. <![CDATA[
  13. var window = this;
  14. this.windowTitle = "Typica - Set Department Name";
  15. var namefield = findChildObject(this, "namefield");
  16. if(this.arguments.newDepartment) {
  17. namefield.text = "New Department";
  18. } else {
  19. namefield.text = this.arguments.currentName;
  20. }
  21. var save = findChildObject(this, "save");
  22. save.clicked.connect(function() {
  23. var query = new QSqlQuery();
  24. if(window.arguments.newDepartment) {
  25. query.prepare("INSERT INTO depts(id, name) VALUES (default, :name)");
  26. } else {
  27. query.prepare("UPDATE depts SET name = :name WHERE id = :id");
  28. query.bind(":id", window.arguments.departmentId);
  29. }
  30. query.bind(":name", namefield.text);
  31. query.exec();
  32. query.invalidate();
  33. window.arguments.updateCallback();
  34. window.close();
  35. });
  36. ]]>
  37. </program>
  38. </window>