Typica is a free program for professional coffee roasters. https://typica.us
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

greeninventory.xml 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. units.addItem("kg");
  19. var items = findChildObject(this, 'item');
  20. var status = findChildObject(this, 'current');
  21. var q = "SELECT quantity FROM items WHERE id = ";
  22. q = q + items.currentData();
  23. query = new QSqlQuery();
  24. query.exec(q);
  25. query.next();
  26. var text = items.currentText;
  27. text = text + " Current inventory: ";
  28. text = text + query.value(0);
  29. text = text + " pounds ("
  30. text = text + Number(query.value(0)) / 2.2;
  31. text = text + " Kg (";
  32. q = "SELECT ";
  33. q = q + query.value(0);
  34. q = q + " / (SELECT conversion FROM lb_bag_conversion WHERE item = ";
  35. q = q + items.currentData();
  36. q = q + ")";
  37. query.exec(q);
  38. query.next();
  39. text = text + query.value(0);
  40. text = text + " bags)";
  41. query = query.invalidate();
  42. status.plainText = text;
  43. var button = findChildObject(this, 'update');
  44. var value = findChildObject(this, 'quantity');
  45. button.clicked.connect(function() {
  46. q = "INSERT INTO inventory (time, item, quantity) VALUES ('now', ";
  47. q = q + items.currentData();
  48. q = q + ", ";
  49. if(units.currentText == "lb") {
  50. q = q + value.text;
  51. } else if (units.currentText == "kg") {
  52. q = q + (value.text * 2.2);
  53. }
  54. else {
  55. q = q + value.text;
  56. q = q + " * (SELECT conversion FROM lb_bag_conversion WHERE item = ";
  57. q = q + items.currentData();
  58. q = q + ")";
  59. }
  60. q = q + ")";
  61. query = new QSqlQuery();
  62. query.exec(q);
  63. text = items.currentText;
  64. q = "SELECT quantity FROM items WHERE id = ";
  65. q = q + items.currentData();
  66. query.exec(q);
  67. query.next();
  68. text = text + " Current inventory: ";
  69. text = text + query.value(0);
  70. text = text + " pounds (";
  71. q = "SELECT ";
  72. q = q + query.value(0);
  73. q = q + " / (SELECT conversion FROM lb_bag_conversion WHERE item = ";
  74. q = q + items.currentData();
  75. q = q + ")";
  76. query.exec(q);
  77. query.next();
  78. text = text + query.value(0);
  79. text = text + " bags)";
  80. status.plainText = text;
  81. query = query.invalidate();
  82. });
  83. items['currentIndexChanged(int)'].connect(function() {
  84. q = "SELECT quantity FROM items WHERE id = ";
  85. q = q + items.currentData();
  86. query = new QSqlQuery();
  87. query.exec(q);
  88. query.next();
  89. var text = items.currentText;
  90. text = text + " Current inventory: ";
  91. text = text + query.value(0);
  92. text = text + " pounds ";
  93. text = text + Number(query.value(0)) / 2.2;
  94. text = text + " Kg (";
  95. q = "SELECT ";
  96. q = q + query.value(0);
  97. q = q + " / (SELECT conversion FROM lb_bag_conversion WHERE item = ";
  98. q = q + items.currentData();
  99. q = q + ")";
  100. query.exec(q);
  101. query.next();
  102. text = text + query.value(0);
  103. text = text + " bags)";
  104. status.plainText = text;
  105. query = query.invalidate();
  106. });
  107. ]]>
  108. </program>
  109. </window>