Typica is a free program for professional coffee roasters. https://typica.us
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

greeninventory.xml 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <window id="inventory">
  2. <layout type="vertical">
  3. <layout type="horizontal">
  4. <sqldrop data="0" display="1" showdata="true" id="item">
  5. <query><![CDATA[SELECT id, name FROM coffees WHERE quantity <> 0 ORDER BY name ASC]]></query>
  6. </sqldrop>
  7. <line id="quantity" />
  8. <sqldrop id="units" />
  9. <button type="push" name="Update" id="update" />
  10. </layout>
  11. <textarea id="current" />
  12. </layout>
  13. <program>
  14. <![CDATA[
  15. var units = findChildObject(this, 'units');
  16. units.addItem("bag");
  17. units.addItem("lb");
  18. var items = findChildObject(this, 'item');
  19. var status = findChildObject(this, 'current');
  20. var q = "SELECT quantity FROM items WHERE id = ";
  21. q = q + items.currentData();
  22. query = new QSqlQuery();
  23. query.exec(q);
  24. query.next();
  25. var text = items.currentText;
  26. text = text + " Current inventory: ";
  27. text = text + query.value(0);
  28. text = text + " pounds (";
  29. q = "SELECT ";
  30. q = q + query.value(0);
  31. q = q + " / (SELECT conversion FROM lb_bag_conversion WHERE item = ";
  32. q = q + items.currentData();
  33. q = q + ")";
  34. query.exec(q);
  35. query.next();
  36. text = text + query.value(0);
  37. text = text + " bags)";
  38. query = query.invalidate();
  39. status.plainText = text;
  40. var button = findChildObject(this, 'update');
  41. var value = findChildObject(this, 'quantity');
  42. button.clicked.connect(function() {
  43. q = "INSERT INTO inventory VALUES ('now', ";
  44. q = q + items.currentData();
  45. q = q + ", ";
  46. if(units.currentText == "lb") {
  47. q = q + value.text;
  48. } else {
  49. q = q + value.text;
  50. q = q + " * (SELECT conversion FROM lb_bag_conversion WHERE item = ";
  51. q = q + items.currentData();
  52. q = q + ")";
  53. }
  54. q = q + ")";
  55. query = new QSqlQuery();
  56. query.exec(q);
  57. text = items.currentText;
  58. q = "SELECT quantity FROM items WHERE id = ";
  59. q = q + items.currentData();
  60. query.exec(q);
  61. query.next();
  62. text = text + " Current inventory: ";
  63. text = text + query.value(0);
  64. text = text + " pounds (";
  65. q = "SELECT ";
  66. q = q + query.value(0);
  67. q = q + " / (SELECT conversion FROM lb_bag_conversion WHERE item = ";
  68. q = q + items.currentData();
  69. q = q + ")";
  70. query.exec(q);
  71. query.next();
  72. text = text + query.value(0);
  73. text = text + " bags)";
  74. status.plainText = text;
  75. query = query.invalidate();
  76. });
  77. items['currentIndexChanged(int)'].connect(function() {
  78. q = "SELECT quantity FROM items WHERE id = ";
  79. q = q + items.currentData();
  80. query = new QSqlQuery();
  81. query.exec(q);
  82. query.next();
  83. var text = items.currentText;
  84. text = text + " Current inventory: ";
  85. text = text + query.value(0);
  86. text = text + " pounds (";
  87. q = "SELECT ";
  88. q = q + query.value(0);
  89. q = q + " / (SELECT conversion FROM lb_bag_conversion WHERE item = ";
  90. q = q + items.currentData();
  91. q = q + ")";
  92. query.exec(q);
  93. query.next();
  94. text = text + query.value(0);
  95. text = text + " bags)";
  96. status.plainText = text;
  97. query = query.invalidate();
  98. });
  99. ]]>
  100. </program>
  101. </window>